Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 1 | /* |
| 2 | * U-boot - board.c First C file to be called contains init routines |
| 3 | * |
Aubrey Li | 314d22f | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 4 | * Copyright (c) 2005-2007 Analog Devices Inc. |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [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 |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <command.h> |
| 30 | #include <malloc.h> |
| 31 | #include <devices.h> |
| 32 | #include <version.h> |
| 33 | #include <net.h> |
| 34 | #include <environment.h> |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 35 | #include <i2c.h> |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 36 | #include "blackfin_board.h" |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 37 | #include <asm/cplb.h> |
Jean-Christophe PLAGNIOL-VILLARD | ed0ea1f | 2007-11-21 21:19:24 +0100 | [diff] [blame] | 38 | #include "../drivers/net/smc91111.h" |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 39 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 40 | #if defined(CONFIG_BF537)&&defined(CONFIG_POST) |
| 41 | #include <post.h> |
| 42 | int post_flag; |
| 43 | #endif |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 44 | |
Wolfgang Denk | d112a2c | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 45 | DECLARE_GLOBAL_DATA_PTR; |
| 46 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 47 | #ifndef CFG_NO_FLASH |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 48 | extern flash_info_t flash_info[]; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 49 | #endif |
| 50 | |
| 51 | static inline u_long get_vco(void) |
| 52 | { |
| 53 | u_long msel; |
| 54 | u_long vco; |
| 55 | |
| 56 | msel = (*pPLL_CTL >> 9) & 0x3F; |
| 57 | if (0 == msel) |
| 58 | msel = 64; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 59 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 60 | vco = CONFIG_CLKIN_HZ; |
| 61 | vco >>= (1 & *pPLL_CTL); /* DF bit */ |
| 62 | vco = msel * vco; |
| 63 | return vco; |
| 64 | } |
| 65 | |
| 66 | /*Get the Core clock*/ |
| 67 | u_long get_cclk(void) |
| 68 | { |
| 69 | u_long csel, ssel; |
| 70 | if (*pPLL_STAT & 0x1) |
| 71 | return CONFIG_CLKIN_HZ; |
| 72 | |
| 73 | ssel = *pPLL_DIV; |
| 74 | csel = ((ssel >> 4) & 0x03); |
| 75 | ssel &= 0xf; |
| 76 | if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */ |
| 77 | return get_vco() / ssel; |
| 78 | return get_vco() >> csel; |
| 79 | } |
| 80 | |
| 81 | /* Get the System clock */ |
| 82 | u_long get_sclk(void) |
| 83 | { |
| 84 | u_long ssel; |
| 85 | |
| 86 | if (*pPLL_STAT & 0x1) |
| 87 | return CONFIG_CLKIN_HZ; |
| 88 | |
| 89 | ssel = (*pPLL_DIV & 0xf); |
| 90 | |
| 91 | return get_vco() / ssel; |
| 92 | } |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 93 | |
| 94 | static void mem_malloc_init(void) |
| 95 | { |
| 96 | mem_malloc_start = CFG_MALLOC_BASE; |
| 97 | mem_malloc_end = (CFG_MALLOC_BASE + CFG_MALLOC_LEN); |
| 98 | mem_malloc_brk = mem_malloc_start; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 99 | memset((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void *sbrk(ptrdiff_t increment) |
| 103 | { |
| 104 | ulong old = mem_malloc_brk; |
| 105 | ulong new = old + increment; |
| 106 | |
| 107 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { |
| 108 | return (NULL); |
| 109 | } |
| 110 | mem_malloc_brk = new; |
| 111 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 112 | return ((void *)old); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | static int display_banner(void) |
| 116 | { |
| 117 | sprintf(version_string, VERSION_STRING_FORMAT, VERSION_STRING); |
| 118 | printf("%s\n", version_string); |
| 119 | return (0); |
| 120 | } |
| 121 | |
| 122 | static void display_flash_config(ulong size) |
| 123 | { |
| 124 | puts("FLASH: "); |
| 125 | print_size(size, "\n"); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | static int init_baudrate(void) |
| 130 | { |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 131 | char tmp[64]; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 132 | int i = getenv_r("baudrate", tmp, sizeof(tmp)); |
| 133 | gd->bd->bi_baudrate = gd->baudrate = (i > 0) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 134 | ? (int)simple_strtoul(tmp, NULL, 10) |
| 135 | : CONFIG_BAUDRATE; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 136 | return (0); |
| 137 | } |
| 138 | |
| 139 | #ifdef DEBUG |
| 140 | static void display_global_data(void) |
| 141 | { |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 142 | bd_t *bd; |
| 143 | bd = gd->bd; |
| 144 | printf("--flags:%x\n", gd->flags); |
| 145 | printf("--board_type:%x\n", gd->board_type); |
| 146 | printf("--baudrate:%x\n", gd->baudrate); |
| 147 | printf("--have_console:%x\n", gd->have_console); |
| 148 | printf("--ram_size:%x\n", gd->ram_size); |
| 149 | printf("--reloc_off:%x\n", gd->reloc_off); |
| 150 | printf("--env_addr:%x\n", gd->env_addr); |
| 151 | printf("--env_valid:%x\n", gd->env_valid); |
| 152 | printf("--bd:%x %x\n", gd->bd, bd); |
| 153 | printf("---bi_baudrate:%x\n", bd->bi_baudrate); |
| 154 | printf("---bi_ip_addr:%x\n", bd->bi_ip_addr); |
| 155 | printf("---bi_enetaddr:%x %x %x %x %x %x\n", |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 156 | bd->bi_enetaddr[0], |
| 157 | bd->bi_enetaddr[1], |
| 158 | bd->bi_enetaddr[2], |
| 159 | bd->bi_enetaddr[3], bd->bi_enetaddr[4], bd->bi_enetaddr[5]); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 160 | printf("---bi_arch_number:%x\n", bd->bi_arch_number); |
| 161 | printf("---bi_boot_params:%x\n", bd->bi_boot_params); |
| 162 | printf("---bi_memstart:%x\n", bd->bi_memstart); |
| 163 | printf("---bi_memsize:%x\n", bd->bi_memsize); |
| 164 | printf("---bi_flashstart:%x\n", bd->bi_flashstart); |
| 165 | printf("---bi_flashsize:%x\n", bd->bi_flashsize); |
| 166 | printf("---bi_flashoffset:%x\n", bd->bi_flashoffset); |
| 167 | printf("--jt:%x *:%x\n", gd->jt, *(gd->jt)); |
| 168 | } |
| 169 | #endif |
| 170 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 171 | /* we cover everything with 4 meg pages, and need an extra for L1 */ |
| 172 | unsigned int icplb_table[page_descriptor_table_size][2]; |
| 173 | unsigned int dcplb_table[page_descriptor_table_size][2]; |
| 174 | |
| 175 | void init_cplbtables(void) |
| 176 | { |
| 177 | int i, j; |
| 178 | |
| 179 | j = 0; |
| 180 | icplb_table[j][0] = 0xFFA00000; |
| 181 | icplb_table[j][1] = L1_IMEMORY; |
| 182 | j++; |
| 183 | |
Aubrey Li | e8c47f4 | 2007-04-05 18:33:04 +0800 | [diff] [blame] | 184 | for (i = 0; i < CONFIG_MEM_SIZE / 4; i++) { |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 185 | icplb_table[j][0] = (i * 4 * 1024 * 1024); |
| 186 | if (i * 4 * 1024 * 1024 <= CFG_MONITOR_BASE |
| 187 | && (i + 1) * 4 * 1024 * 1024 >= CFG_MONITOR_BASE) { |
| 188 | icplb_table[j][1] = SDRAM_IKERNEL; |
| 189 | } else { |
| 190 | icplb_table[j][1] = SDRAM_IGENERIC; |
| 191 | } |
| 192 | j++; |
| 193 | } |
| 194 | #if defined(CONFIG_BF561) |
Aubrey Li | e8c47f4 | 2007-04-05 18:33:04 +0800 | [diff] [blame] | 195 | /* MAC space */ |
| 196 | icplb_table[j][0] = 0x2C000000; |
| 197 | icplb_table[j][1] = SDRAM_INON_CHBL; |
| 198 | j++; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 199 | /* Async Memory space */ |
| 200 | for (i = 0; i < 3; i++) { |
Aubrey Li | e8c47f4 | 2007-04-05 18:33:04 +0800 | [diff] [blame] | 201 | icplb_table[j][0] = 0x20000000 + i * 4 * 1024 * 1024; |
| 202 | icplb_table[j][1] = SDRAM_INON_CHBL; |
| 203 | j++; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 204 | } |
| 205 | #else |
| 206 | icplb_table[j][0] = 0x20000000; |
Aubrey Li | e8c47f4 | 2007-04-05 18:33:04 +0800 | [diff] [blame] | 207 | icplb_table[j][1] = SDRAM_INON_CHBL; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 208 | #endif |
| 209 | j = 0; |
| 210 | dcplb_table[j][0] = 0xFF800000; |
| 211 | dcplb_table[j][1] = L1_DMEMORY; |
| 212 | j++; |
| 213 | |
| 214 | for (i = 0; i < CONFIG_MEM_SIZE / 4; i++) { |
| 215 | dcplb_table[j][0] = (i * 4 * 1024 * 1024); |
| 216 | if (i * 4 * 1024 * 1024 <= CFG_MONITOR_BASE |
| 217 | && (i + 1) * 4 * 1024 * 1024 >= CFG_MONITOR_BASE) { |
| 218 | dcplb_table[j][1] = SDRAM_DKERNEL; |
| 219 | } else { |
| 220 | dcplb_table[j][1] = SDRAM_DGENERIC; |
| 221 | } |
| 222 | j++; |
| 223 | } |
| 224 | |
| 225 | #if defined(CONFIG_BF561) |
| 226 | /* MAC space */ |
Aubrey Li | e8c47f4 | 2007-04-05 18:33:04 +0800 | [diff] [blame] | 227 | dcplb_table[j][0] = 0x2C000000; |
| 228 | dcplb_table[j][1] = SDRAM_EBIU; |
| 229 | j++; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 230 | |
| 231 | /* Flash space */ |
Aubrey Li | e8c47f4 | 2007-04-05 18:33:04 +0800 | [diff] [blame] | 232 | for (i = 0; i < 3; i++) { |
| 233 | dcplb_table[j][0] = 0x20000000 + i * 4 * 1024 * 1024; |
| 234 | dcplb_table[j][1] = SDRAM_EBIU; |
| 235 | j++; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 236 | } |
| 237 | #else |
| 238 | dcplb_table[j][0] = 0x20000000; |
| 239 | dcplb_table[j][1] = SDRAM_EBIU; |
| 240 | #endif |
| 241 | } |
| 242 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 243 | /* |
| 244 | * All attempts to come up with a "common" initialization sequence |
| 245 | * that works for all boards and architectures failed: some of the |
| 246 | * requirements are just _too_ different. To get rid of the resulting |
| 247 | * mess of board dependend #ifdef'ed code we now make the whole |
| 248 | * initialization sequence configurable to the user. |
| 249 | * |
| 250 | * The requirements for any new initalization function is simple: it |
| 251 | * receives a pointer to the "global data" structure as it's only |
| 252 | * argument, and returns an integer return code, where 0 means |
| 253 | * "continue" and != 0 means "fatal error, hang the system". |
| 254 | */ |
| 255 | |
| 256 | void board_init_f(ulong bootflag) |
| 257 | { |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 258 | ulong addr; |
| 259 | bd_t *bd; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 260 | int i; |
| 261 | |
| 262 | init_cplbtables(); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 263 | |
| 264 | gd = (gd_t *) (CFG_GBL_DATA_ADDR); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 265 | memset((void *)gd, 0, sizeof(gd_t)); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 266 | |
| 267 | /* Board data initialization */ |
| 268 | addr = (CFG_GBL_DATA_ADDR + sizeof(gd_t)); |
| 269 | |
| 270 | /* Align to 4 byte boundary */ |
Wolfgang Denk | 2bad868 | 2006-03-12 02:55:22 +0100 | [diff] [blame] | 271 | addr &= ~(4 - 1); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 272 | bd = (bd_t *) addr; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 273 | gd->bd = bd; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 274 | memset((void *)bd, 0, sizeof(bd_t)); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 275 | |
| 276 | /* Initialize */ |
| 277 | init_IRQ(); |
| 278 | env_init(); /* initialize environment */ |
| 279 | init_baudrate(); /* initialze baudrate settings */ |
| 280 | serial_init(); /* serial communications setup */ |
| 281 | console_init_f(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 282 | #ifdef CONFIG_ICACHE_ON |
| 283 | icache_enable(); |
| 284 | #endif |
| 285 | #ifdef CONFIG_DCACHE_ON |
| 286 | dcache_enable(); |
| 287 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 288 | display_banner(); /* say that we are here */ |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 289 | |
| 290 | for (i = 0; i < page_descriptor_table_size; i++) { |
Aubrey Li | 3c56995 | 2007-03-12 00:25:14 +0800 | [diff] [blame] | 291 | debug |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 292 | ("data (%02i)= 0x%08x : 0x%08x intr = 0x%08x : 0x%08x\n", |
| 293 | i, dcplb_table[i][0], dcplb_table[i][1], icplb_table[i][0], |
| 294 | icplb_table[i][1]); |
| 295 | } |
| 296 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 297 | checkboard(); |
Jon Loeliger | 1207797 | 2007-07-09 18:05:38 -0500 | [diff] [blame] | 298 | #if defined(CONFIG_RTC_BF533) && defined(CONFIG_CMD_DATE) |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 299 | rtc_init(); |
| 300 | #endif |
| 301 | timer_init(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 302 | printf("Clock: VCO: %lu MHz, Core: %lu MHz, System: %lu MHz\n", |
| 303 | get_vco() / 1000000, get_cclk() / 1000000, get_sclk() / 1000000); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 304 | printf("SDRAM: "); |
| 305 | print_size(initdram(0), "\n"); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 306 | #if defined(CONFIG_BF537)&&defined(CONFIG_POST) |
| 307 | post_init_f(); |
| 308 | post_bootmode_init(); |
| 309 | post_run(NULL, POST_ROM | post_bootmode_get(0)); |
| 310 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 311 | board_init_r((gd_t *) gd, 0x20000010); |
| 312 | } |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 313 | |
| 314 | #if defined(CONFIG_SOFT_I2C) || defined(CONFIG_HARD_I2C) |
| 315 | static int init_func_i2c(void) |
| 316 | { |
| 317 | puts("I2C: "); |
| 318 | i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE); |
| 319 | puts("ready\n"); |
| 320 | return (0); |
| 321 | } |
| 322 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 323 | |
| 324 | void board_init_r(gd_t * id, ulong dest_addr) |
| 325 | { |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 326 | ulong size; |
| 327 | extern void malloc_bin_reloc(void); |
| 328 | char *s, *e; |
| 329 | bd_t *bd; |
| 330 | int i; |
| 331 | gd = id; |
| 332 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
| 333 | bd = gd->bd; |
| 334 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 335 | #if defined(CONFIG_BF537) && defined(CONFIG_POST) |
| 336 | post_output_backlog(); |
| 337 | post_reloc(); |
| 338 | #endif |
| 339 | |
| 340 | #if (CONFIG_STAMP || CONFIG_BF537 || CONFIG_EZKIT561) && !defined(CFG_NO_FLASH) |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 341 | /* There are some other pointer constants we must deal with */ |
| 342 | /* configure available FLASH banks */ |
| 343 | size = flash_init(); |
| 344 | display_flash_config(size); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 345 | flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE, |
| 346 | CFG_FLASH_BASE + 0x1ffff, &flash_info[0]); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 347 | bd->bi_flashstart = CFG_FLASH_BASE; |
| 348 | bd->bi_flashsize = size; |
| 349 | bd->bi_flashoffset = 0; |
| 350 | #else |
| 351 | bd->bi_flashstart = 0; |
| 352 | bd->bi_flashsize = 0; |
| 353 | bd->bi_flashoffset = 0; |
| 354 | #endif |
| 355 | /* initialize malloc() area */ |
| 356 | mem_malloc_init(); |
| 357 | malloc_bin_reloc(); |
| 358 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 359 | #ifdef CONFIG_SPI |
| 360 | # if ! defined(CFG_ENV_IS_IN_EEPROM) |
| 361 | spi_init_f(); |
| 362 | # endif |
| 363 | spi_init_r(); |
| 364 | #endif |
| 365 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 366 | /* relocate environment function pointers etc. */ |
| 367 | env_relocate(); |
| 368 | |
| 369 | /* board MAC address */ |
| 370 | s = getenv("ethaddr"); |
| 371 | for (i = 0; i < 6; ++i) { |
| 372 | bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0; |
| 373 | if (s) |
| 374 | s = (*e) ? e + 1 : e; |
| 375 | } |
| 376 | |
| 377 | /* IP Address */ |
| 378 | bd->bi_ip_addr = getenv_IPaddr("ipaddr"); |
| 379 | |
| 380 | /* Initialize devices */ |
| 381 | devices_init(); |
| 382 | jumptable_init(); |
| 383 | |
| 384 | /* Initialize the console (after the relocation and devices init) */ |
| 385 | console_init_r(); |
| 386 | |
| 387 | /* Initialize from environment */ |
| 388 | if ((s = getenv("loadaddr")) != NULL) { |
| 389 | load_addr = simple_strtoul(s, NULL, 16); |
| 390 | } |
Jon Loeliger | 1207797 | 2007-07-09 18:05:38 -0500 | [diff] [blame] | 391 | #if defined(CONFIG_CMD_NET) |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 392 | if ((s = getenv("bootfile")) != NULL) { |
| 393 | copy_filename(BootFile, s, sizeof(BootFile)); |
| 394 | } |
| 395 | #endif |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 396 | |
Jon Loeliger | 1207797 | 2007-07-09 18:05:38 -0500 | [diff] [blame] | 397 | #if defined(CONFIG_CMD_NAND) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 398 | puts("NAND: "); |
| 399 | nand_init(); /* go init the NAND */ |
| 400 | #endif |
| 401 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 402 | #if defined(CONFIG_MISC_INIT_R) |
| 403 | /* miscellaneous platform dependent initialisations */ |
| 404 | misc_init_r(); |
| 405 | #endif |
| 406 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 407 | #if ((BFIN_CPU == ADSP_BF537) || (BFIN_CPU == ADSP_BF536)) |
| 408 | printf("Net: "); |
| 409 | eth_initialize(bd); |
| 410 | #endif |
| 411 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 412 | #ifdef CONFIG_DRIVER_SMC91111 |
| 413 | #ifdef SHARED_RESOURCES |
| 414 | /* Switch to Ethernet */ |
| 415 | swap_to(ETHERNET); |
| 416 | #endif |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 417 | if ((SMC_inw(BANK_SELECT) & UPPER_BYTE_MASK) != SMC_IDENT) { |
| 418 | printf("ERROR: Can't find SMC91111 at address %x\n", |
| 419 | SMC_BASE_ADDRESS); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 420 | } else { |
| 421 | printf("Net: SMC91111 at 0x%08X\n", SMC_BASE_ADDRESS); |
| 422 | } |
| 423 | |
| 424 | #ifdef SHARED_RESOURCES |
| 425 | swap_to(FLASH); |
| 426 | #endif |
| 427 | #endif |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 428 | #if defined(CONFIG_SOFT_I2C) || defined(CONFIG_HARD_I2C) |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 429 | init_func_i2c(); |
| 430 | #endif |
| 431 | |
| 432 | #ifdef DEBUG |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 433 | display_global_data(); |
| 434 | #endif |
| 435 | |
| 436 | #if defined(CONFIG_BF537) && defined(CONFIG_POST) |
| 437 | if (post_flag) |
| 438 | post_run(NULL, POST_RAM | post_bootmode_get(0)); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 439 | #endif |
| 440 | |
| 441 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
| 442 | for (;;) { |
| 443 | main_loop(); |
| 444 | } |
| 445 | } |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 446 | |
| 447 | void hang(void) |
| 448 | { |
| 449 | puts("### ERROR ### Please RESET the board ###\n"); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 450 | for (;;) ; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 451 | } |