Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 1 | /* |
Mike Frysinger | 23fd959 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 2 | * U-boot - main board file |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 3 | * |
Mike Frysinger | 23fd959 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 4 | * Copyright (c) 2005-2008 Analog Devices Inc. |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 5 | * |
| 6 | * (C) Copyright 2000-2004 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
Aubrey Li | 155fd76 | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 25 | * MA 02110-1301 USA |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include <common.h> |
Ben Warren | 7194ab8 | 2009-10-04 22:37:03 -0700 | [diff] [blame] | 29 | #include <netdev.h> |
Aubrey Li | 8440bb1 | 2007-03-12 00:25:14 +0800 | [diff] [blame] | 30 | #include <asm/io.h> |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 31 | #include "bf533-stamp.h" |
| 32 | |
Wolfgang Denk | 1218abf | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 35 | int checkboard(void) |
| 36 | { |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 37 | printf("Board: ADI BF533 Stamp board\n"); |
| 38 | printf(" Support: http://blackfin.uclinux.org/\n"); |
| 39 | return 0; |
| 40 | } |
| 41 | |
Mike Frysinger | 1f75d6f | 2008-10-11 22:38:37 -0400 | [diff] [blame] | 42 | /* PF0 and PF1 are used to switch between the ethernet and flash: |
| 43 | * PF0 PF1 |
| 44 | * flash: 0 0 |
| 45 | * ether: 1 0 |
| 46 | */ |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 47 | void swap_to(int device_id) |
| 48 | { |
Mike Frysinger | 1f75d6f | 2008-10-11 22:38:37 -0400 | [diff] [blame] | 49 | bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0); |
| 50 | SSYNC(); |
| 51 | bfin_write_FIO_FLAG_C(PF1); |
| 52 | if (device_id == ETHERNET) |
| 53 | bfin_write_FIO_FLAG_S(PF0); |
| 54 | else if (device_id == FLASH) |
| 55 | bfin_write_FIO_FLAG_C(PF0); |
| 56 | else |
| 57 | printf("Unknown device to switch\n"); |
| 58 | SSYNC(); |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | #if defined(CONFIG_MISC_INIT_R) |
| 62 | /* miscellaneous platform dependent initialisations */ |
| 63 | int misc_init_r(void) |
| 64 | { |
Mike Frysinger | 5f79644 | 2009-11-30 13:08:39 -0500 | [diff] [blame] | 65 | #ifdef CONFIG_STAMP_CF |
| 66 | cf_ide_init(); |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 67 | #endif |
| 68 | |
Mike Frysinger | 5f79644 | 2009-11-30 13:08:39 -0500 | [diff] [blame] | 69 | return 0; |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 70 | } |
| 71 | #endif |
| 72 | |
Mike Frysinger | 23fd959 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 73 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 74 | |
| 75 | #define STATUS_LED_OFF 0 |
| 76 | #define STATUS_LED_ON 1 |
| 77 | |
| 78 | static void stamp_led_set(int LED1, int LED2, int LED3) |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 79 | { |
Mike Frysinger | 23fd959 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 80 | bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4)); |
| 81 | bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4)); |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 82 | |
| 83 | if (LED1 == STATUS_LED_OFF) |
| 84 | *pFIO_FLAG_S = PF2; |
| 85 | else |
| 86 | *pFIO_FLAG_C = PF2; |
| 87 | if (LED2 == STATUS_LED_OFF) |
| 88 | *pFIO_FLAG_S = PF3; |
| 89 | else |
| 90 | *pFIO_FLAG_C = PF3; |
| 91 | if (LED3 == STATUS_LED_OFF) |
| 92 | *pFIO_FLAG_S = PF4; |
| 93 | else |
| 94 | *pFIO_FLAG_C = PF4; |
Mike Frysinger | d4d7730 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 95 | SSYNC(); |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | void show_boot_progress(int status) |
| 99 | { |
| 100 | switch (status) { |
| 101 | case 1: |
| 102 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON); |
| 103 | break; |
| 104 | case 2: |
| 105 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF); |
| 106 | break; |
| 107 | case 3: |
| 108 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON); |
| 109 | break; |
| 110 | case 4: |
| 111 | stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF); |
| 112 | break; |
| 113 | case 5: |
| 114 | case 6: |
| 115 | stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON); |
| 116 | break; |
| 117 | case 7: |
| 118 | case 8: |
| 119 | stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF); |
| 120 | break; |
| 121 | case 9: |
| 122 | case 10: |
| 123 | case 11: |
| 124 | case 12: |
| 125 | case 13: |
| 126 | case 14: |
| 127 | case 15: |
| 128 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF); |
| 129 | break; |
| 130 | default: |
| 131 | stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON); |
| 132 | break; |
| 133 | } |
| 134 | } |
Mike Frysinger | 23fd959 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 135 | #endif |
| 136 | |
| 137 | #ifdef CONFIG_STATUS_LED |
| 138 | #include <status_led.h> |
| 139 | |
| 140 | static void set_led(int pf, int state) |
| 141 | { |
| 142 | switch (state) { |
| 143 | case STATUS_LED_OFF: bfin_write_FIO_FLAG_S(pf); break; |
| 144 | case STATUS_LED_BLINKING: bfin_write_FIO_FLAG_T(pf); break; |
| 145 | case STATUS_LED_ON: bfin_write_FIO_FLAG_C(pf); break; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | static void set_leds(led_id_t mask, int state) |
| 150 | { |
| 151 | if (mask & 0x1) set_led(PF2, state); |
| 152 | if (mask & 0x2) set_led(PF3, state); |
| 153 | if (mask & 0x4) set_led(PF4, state); |
| 154 | } |
| 155 | |
| 156 | void __led_init(led_id_t mask, int state) |
| 157 | { |
| 158 | bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4)); |
| 159 | bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4)); |
| 160 | } |
| 161 | |
| 162 | void __led_set(led_id_t mask, int state) |
| 163 | { |
| 164 | set_leds(mask, state); |
| 165 | } |
| 166 | |
| 167 | void __led_toggle(led_id_t mask) |
| 168 | { |
| 169 | set_leds(mask, STATUS_LED_BLINKING); |
| 170 | } |
| 171 | |
| 172 | #endif |
Ben Warren | 7194ab8 | 2009-10-04 22:37:03 -0700 | [diff] [blame] | 173 | |
| 174 | #ifdef CONFIG_SMC91111 |
| 175 | int board_eth_init(bd_t *bis) |
| 176 | { |
| 177 | return smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 178 | } |
| 179 | #endif |