Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 1 | /* |
Mike Frysinger | 9427ef8 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 2 | * U-boot - main board file |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 3 | * |
Mike Frysinger | 9427ef8 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 4 | * Copyright (c) 2005-2008 Analog Devices Inc. |
Aubrey.Li | 9da597f | 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 | 314d22f | 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 | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include <common.h> |
Ben Warren | 0fd6aae | 2009-10-04 22:37:03 -0700 | [diff] [blame^] | 29 | #include <netdev.h> |
Aubrey Li | 3c56995 | 2007-03-12 00:25:14 +0800 | [diff] [blame] | 30 | #include <asm/io.h> |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 31 | #include "bf533-stamp.h" |
| 32 | |
Wolfgang Denk | d112a2c | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 35 | int checkboard(void) |
| 36 | { |
Aubrey.Li | 9da597f | 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 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 42 | phys_size_t initdram(int board_type) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 43 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 44 | gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; |
| 45 | gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE; |
Mike Frysinger | 9036bf9 | 2008-10-11 20:31:17 -0400 | [diff] [blame] | 46 | return gd->bd->bi_memsize; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 47 | } |
| 48 | |
Mike Frysinger | 942f0f59 | 2008-10-11 22:38:37 -0400 | [diff] [blame] | 49 | /* PF0 and PF1 are used to switch between the ethernet and flash: |
| 50 | * PF0 PF1 |
| 51 | * flash: 0 0 |
| 52 | * ether: 1 0 |
| 53 | */ |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 54 | void swap_to(int device_id) |
| 55 | { |
Mike Frysinger | 942f0f59 | 2008-10-11 22:38:37 -0400 | [diff] [blame] | 56 | bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0); |
| 57 | SSYNC(); |
| 58 | bfin_write_FIO_FLAG_C(PF1); |
| 59 | if (device_id == ETHERNET) |
| 60 | bfin_write_FIO_FLAG_S(PF0); |
| 61 | else if (device_id == FLASH) |
| 62 | bfin_write_FIO_FLAG_C(PF0); |
| 63 | else |
| 64 | printf("Unknown device to switch\n"); |
| 65 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | #if defined(CONFIG_MISC_INIT_R) |
| 69 | /* miscellaneous platform dependent initialisations */ |
| 70 | int misc_init_r(void) |
| 71 | { |
| 72 | int i; |
| 73 | int cf_stat = 0; |
| 74 | |
| 75 | /* Check whether CF card is inserted */ |
| 76 | *pFIO_EDGE = FIO_EDGE_CF_BITS; |
| 77 | *pFIO_POLAR = FIO_POLAR_CF_BITS; |
| 78 | for (i = 0; i < 0x300; i++) |
| 79 | asm("nop;"); |
| 80 | |
| 81 | if ((*pFIO_FLAG_S) & CF_STAT_BITS) { |
| 82 | cf_stat = 0; |
| 83 | } else { |
| 84 | cf_stat = 1; |
| 85 | } |
| 86 | |
| 87 | *pFIO_EDGE = FIO_EDGE_BITS; |
| 88 | *pFIO_POLAR = FIO_POLAR_BITS; |
| 89 | |
| 90 | if (cf_stat) { |
| 91 | printf("Booting from COMPACT flash\n"); |
| 92 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 93 | for (i = 0; i < 0x1000; i++) |
| 94 | asm("nop;"); |
| 95 | for (i = 0; i < 0x1000; i++) |
| 96 | asm("nop;"); |
| 97 | for (i = 0; i < 0x1000; i++) |
| 98 | asm("nop;"); |
| 99 | |
| 100 | serial_setbrg(); |
| 101 | ide_init(); |
| 102 | |
| 103 | setenv("bootargs", ""); |
| 104 | setenv("bootcmd", |
| 105 | "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000"); |
| 106 | } else { |
| 107 | printf("Booting from FLASH\n"); |
| 108 | } |
| 109 | |
| 110 | return 0; |
| 111 | } |
| 112 | #endif |
| 113 | |
| 114 | #ifdef CONFIG_STAMP_CF |
| 115 | |
| 116 | void cf_outb(unsigned char val, volatile unsigned char *addr) |
| 117 | { |
| 118 | /* |
| 119 | * Set PF1 PF0 respectively to 0 1 to divert address |
| 120 | * to the expansion memory banks |
| 121 | */ |
| 122 | *pFIO_FLAG_S = CF_PF0; |
| 123 | *pFIO_FLAG_C = CF_PF1; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 124 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 125 | |
| 126 | *(addr) = val; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 127 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 128 | |
| 129 | /* Setback PF1 PF0 to 0 0 to address external |
| 130 | * memory banks */ |
| 131 | *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 132 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | unsigned char cf_inb(volatile unsigned char *addr) |
| 136 | { |
| 137 | volatile unsigned char c; |
| 138 | |
| 139 | *pFIO_FLAG_S = CF_PF0; |
| 140 | *pFIO_FLAG_C = CF_PF1; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 141 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 142 | |
| 143 | c = *(addr); |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 144 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 145 | |
| 146 | *pFIO_FLAG_C = CF_PF1_PF0; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 147 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 148 | |
| 149 | return c; |
| 150 | } |
| 151 | |
| 152 | void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words) |
| 153 | { |
| 154 | int i; |
| 155 | |
| 156 | *pFIO_FLAG_S = CF_PF0; |
| 157 | *pFIO_FLAG_C = CF_PF1; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 158 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 159 | |
| 160 | for (i = 0; i < words; i++) { |
| 161 | *(sect_buf + i) = *(addr); |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 162 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | *pFIO_FLAG_C = CF_PF1_PF0; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 166 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words) |
| 170 | { |
| 171 | int i; |
| 172 | |
| 173 | *pFIO_FLAG_S = CF_PF0; |
| 174 | *pFIO_FLAG_C = CF_PF1; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 175 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 176 | |
| 177 | for (i = 0; i < words; i++) { |
| 178 | *(addr) = *(sect_buf + i); |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 179 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | *pFIO_FLAG_C = CF_PF1_PF0; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 183 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 184 | } |
| 185 | #endif |
| 186 | |
Mike Frysinger | 9427ef8 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 187 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 188 | |
| 189 | #define STATUS_LED_OFF 0 |
| 190 | #define STATUS_LED_ON 1 |
| 191 | |
| 192 | static void stamp_led_set(int LED1, int LED2, int LED3) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 193 | { |
Mike Frysinger | 9427ef8 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 194 | bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4)); |
| 195 | bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4)); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 196 | |
| 197 | if (LED1 == STATUS_LED_OFF) |
| 198 | *pFIO_FLAG_S = PF2; |
| 199 | else |
| 200 | *pFIO_FLAG_C = PF2; |
| 201 | if (LED2 == STATUS_LED_OFF) |
| 202 | *pFIO_FLAG_S = PF3; |
| 203 | else |
| 204 | *pFIO_FLAG_C = PF3; |
| 205 | if (LED3 == STATUS_LED_OFF) |
| 206 | *pFIO_FLAG_S = PF4; |
| 207 | else |
| 208 | *pFIO_FLAG_C = PF4; |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 209 | SSYNC(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | void show_boot_progress(int status) |
| 213 | { |
| 214 | switch (status) { |
| 215 | case 1: |
| 216 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON); |
| 217 | break; |
| 218 | case 2: |
| 219 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF); |
| 220 | break; |
| 221 | case 3: |
| 222 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON); |
| 223 | break; |
| 224 | case 4: |
| 225 | stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF); |
| 226 | break; |
| 227 | case 5: |
| 228 | case 6: |
| 229 | stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON); |
| 230 | break; |
| 231 | case 7: |
| 232 | case 8: |
| 233 | stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF); |
| 234 | break; |
| 235 | case 9: |
| 236 | case 10: |
| 237 | case 11: |
| 238 | case 12: |
| 239 | case 13: |
| 240 | case 14: |
| 241 | case 15: |
| 242 | stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF); |
| 243 | break; |
| 244 | default: |
| 245 | stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON); |
| 246 | break; |
| 247 | } |
| 248 | } |
Mike Frysinger | 9427ef8 | 2008-10-11 22:40:22 -0400 | [diff] [blame] | 249 | #endif |
| 250 | |
| 251 | #ifdef CONFIG_STATUS_LED |
| 252 | #include <status_led.h> |
| 253 | |
| 254 | static void set_led(int pf, int state) |
| 255 | { |
| 256 | switch (state) { |
| 257 | case STATUS_LED_OFF: bfin_write_FIO_FLAG_S(pf); break; |
| 258 | case STATUS_LED_BLINKING: bfin_write_FIO_FLAG_T(pf); break; |
| 259 | case STATUS_LED_ON: bfin_write_FIO_FLAG_C(pf); break; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | static void set_leds(led_id_t mask, int state) |
| 264 | { |
| 265 | if (mask & 0x1) set_led(PF2, state); |
| 266 | if (mask & 0x2) set_led(PF3, state); |
| 267 | if (mask & 0x4) set_led(PF4, state); |
| 268 | } |
| 269 | |
| 270 | void __led_init(led_id_t mask, int state) |
| 271 | { |
| 272 | bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4)); |
| 273 | bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4)); |
| 274 | } |
| 275 | |
| 276 | void __led_set(led_id_t mask, int state) |
| 277 | { |
| 278 | set_leds(mask, state); |
| 279 | } |
| 280 | |
| 281 | void __led_toggle(led_id_t mask) |
| 282 | { |
| 283 | set_leds(mask, STATUS_LED_BLINKING); |
| 284 | } |
| 285 | |
| 286 | #endif |
Ben Warren | 0fd6aae | 2009-10-04 22:37:03 -0700 | [diff] [blame^] | 287 | |
| 288 | #ifdef CONFIG_SMC91111 |
| 289 | int board_eth_init(bd_t *bis) |
| 290 | { |
| 291 | return smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 292 | } |
| 293 | #endif |