Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 1 | /* SPARC Board initialization |
| 2 | * |
| 3 | * (C) Copyright 2000-2006 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
| 6 | * (C) Copyright 2007 |
| 7 | * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com. |
| 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 |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <command.h> |
| 30 | #include <malloc.h> |
| 31 | #include <devices.h> |
| 32 | #include <config.h> |
| 33 | #if defined(CONFIG_CMD_IDE) |
| 34 | #include <ide.h> |
| 35 | #endif |
| 36 | #ifdef CONFIG_STATUS_LED |
| 37 | #include <status_led.h> |
| 38 | #endif |
| 39 | #include <net.h> |
| 40 | #include <serial.h> |
| 41 | #include <version.h> |
| 42 | #if defined(CONFIG_POST) |
| 43 | #include <post.h> |
| 44 | #endif |
| 45 | #ifdef CONFIG_PS2KBD |
| 46 | #include <keyboard.h> |
| 47 | #endif |
| 48 | #ifdef CONFIG_CMD_AMBAPP |
| 49 | #include <ambapp.h> |
| 50 | #endif |
| 51 | |
| 52 | DECLARE_GLOBAL_DATA_PTR; |
| 53 | |
| 54 | /* Debug options |
| 55 | #define DEBUG_INIT_SEQUENCE |
| 56 | #define DEBUG_MEM_LAYOUT |
| 57 | #define DEBUG_COMMANDS |
| 58 | */ |
| 59 | |
| 60 | extern void timer_interrupt_init(void); |
| 61 | extern void malloc_bin_reloc(void); |
| 62 | extern int do_ambapp_print(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]); |
| 63 | extern int prom_init(void); |
| 64 | |
| 65 | #if defined(CONFIG__CMD_DOC) |
| 66 | void doc_init(void); |
| 67 | #endif |
| 68 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 69 | #if !defined(CONFIG_SYS_NO_FLASH) |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 70 | static char *failed = "*** failed ***\n"; |
| 71 | #endif |
| 72 | |
| 73 | #include <environment.h> |
| 74 | |
| 75 | ulong monitor_flash_len; |
| 76 | |
| 77 | /* |
| 78 | * Begin and End of memory area for malloc(), and current "brk" |
| 79 | */ |
| 80 | static ulong mem_malloc_start = 0; |
| 81 | static ulong mem_malloc_end = 0; |
| 82 | static ulong mem_malloc_brk = 0; |
| 83 | |
| 84 | /************************************************************************ |
| 85 | * Utilities * |
| 86 | ************************************************************************ |
| 87 | */ |
| 88 | |
| 89 | /* |
| 90 | * The Malloc area is immediately below the monitor copy in RAM |
| 91 | */ |
| 92 | static void mem_malloc_init(void) |
| 93 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 94 | mem_malloc_start = CONFIG_SYS_MALLOC_BASE; |
| 95 | mem_malloc_end = CONFIG_SYS_MALLOC_END; |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 96 | mem_malloc_brk = mem_malloc_start; |
| 97 | memset((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); |
| 98 | } |
| 99 | |
| 100 | void *sbrk(ptrdiff_t increment) |
| 101 | { |
| 102 | ulong old = mem_malloc_brk; |
| 103 | ulong new = old + increment; |
| 104 | |
| 105 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { |
| 106 | return (NULL); |
| 107 | } |
| 108 | mem_malloc_brk = new; |
| 109 | return ((void *)old); |
| 110 | } |
| 111 | |
| 112 | /***********************************************************************/ |
| 113 | |
| 114 | /************************************************************************ |
| 115 | * Init Utilities * |
| 116 | ************************************************************************ |
| 117 | * Some of this code should be moved into the core functions, |
| 118 | * but let's get it working (again) first... |
| 119 | */ |
| 120 | |
| 121 | static int init_baudrate(void) |
| 122 | { |
| 123 | char tmp[64]; /* long enough for environment variables */ |
| 124 | int i = getenv_r("baudrate", tmp, sizeof(tmp)); |
| 125 | |
| 126 | gd->baudrate = (i > 0) |
| 127 | ? (int)simple_strtoul(tmp, NULL, 10) |
| 128 | : CONFIG_BAUDRATE; |
| 129 | return (0); |
| 130 | } |
| 131 | |
| 132 | /***********************************************************************/ |
| 133 | |
| 134 | /* |
| 135 | * All attempts to come up with a "common" initialization sequence |
| 136 | * that works for all boards and architectures failed: some of the |
| 137 | * requirements are just _too_ different. To get rid of the resulting |
| 138 | * mess of board dependend #ifdef'ed code we now make the whole |
| 139 | * initialization sequence configurable to the user. |
| 140 | * |
| 141 | * The requirements for any new initalization function is simple: it |
| 142 | * receives a pointer to the "global data" structure as it's only |
| 143 | * argument, and returns an integer return code, where 0 means |
| 144 | * "continue" and != 0 means "fatal error, hang the system". |
| 145 | */ |
| 146 | typedef int (init_fnc_t) (void); |
| 147 | |
| 148 | #define WATCHDOG_RESET(x) |
| 149 | |
| 150 | /************************************************************************ |
| 151 | * Initialization sequence * |
| 152 | ************************************************************************ |
| 153 | */ |
| 154 | |
| 155 | init_fnc_t *init_sequence[] = { |
| 156 | |
| 157 | #if defined(CONFIG_BOARD_EARLY_INIT_F) |
| 158 | board_early_init_f, |
| 159 | #endif |
| 160 | serial_init, |
| 161 | |
| 162 | init_timebase, |
| 163 | |
| 164 | #if defined(CONFIG_CMD_AMBAPP) |
| 165 | ambapp_init_reloc, |
| 166 | #endif |
| 167 | |
| 168 | env_init, |
| 169 | |
| 170 | init_baudrate, |
| 171 | |
| 172 | console_init_f, |
| 173 | display_options, |
| 174 | |
| 175 | checkcpu, |
| 176 | checkboard, |
| 177 | #if defined(CONFIG_MISC_INIT_F) |
| 178 | misc_init_f, |
| 179 | #endif |
| 180 | |
| 181 | #ifdef CONFIG_POST |
| 182 | post_init_f, |
| 183 | #endif |
| 184 | |
| 185 | NULL, /* Terminate this list, |
| 186 | * beware: this list will be relocated |
| 187 | * which means that NULL will become |
| 188 | * NULL+RELOC_OFFSET. We simply make |
| 189 | * NULL be -RELOC_OFFSET instead. |
| 190 | */ |
| 191 | }; |
| 192 | |
| 193 | /************************************************************************ |
| 194 | * |
| 195 | * This is the SPARC board initialization routine, running from RAM. |
| 196 | * |
| 197 | ************************************************************************ |
| 198 | */ |
| 199 | #ifdef DEBUG_INIT_SEQUENCE |
| 200 | char *str_init_seq = "INIT_SEQ 00\n"; |
| 201 | char *str_init_seq_done = "\n\rInit sequence done...\r\n\r\n"; |
| 202 | #endif |
| 203 | |
| 204 | void board_init_f(ulong bootflag) |
| 205 | { |
| 206 | cmd_tbl_t *cmdtp; |
| 207 | bd_t *bd; |
| 208 | unsigned char *s; |
| 209 | init_fnc_t **init_fnc_ptr; |
| 210 | int j; |
| 211 | int i; |
| 212 | char *e; |
| 213 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 214 | #ifndef CONFIG_SYS_NO_FLASH |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 215 | ulong flash_size; |
| 216 | #endif |
| 217 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 218 | gd = (gd_t *) (CONFIG_SYS_GBL_DATA_OFFSET); |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 219 | |
| 220 | /* Clear initial global data */ |
| 221 | memset((void *)gd, 0, sizeof(gd_t)); |
| 222 | |
| 223 | gd->bd = (bd_t *) (gd + 1); /* At end of global data */ |
| 224 | gd->baudrate = CONFIG_BAUDRATE; |
| 225 | gd->cpu_clk = CONFIG_SYS_CLK_FREQ; |
| 226 | |
| 227 | bd = gd->bd; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 228 | bd->bi_memstart = CONFIG_SYS_RAM_BASE; |
| 229 | bd->bi_memsize = CONFIG_SYS_RAM_SIZE; |
| 230 | bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; |
| 231 | #if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE) |
| 232 | bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; |
| 233 | bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 234 | #endif |
| 235 | bd->bi_baudrate = CONFIG_BAUDRATE; |
| 236 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ |
| 237 | |
| 238 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 239 | gd->reloc_off = CONFIG_SYS_RELOC_MONITOR_BASE - CONFIG_SYS_MONITOR_BASE; |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 240 | |
| 241 | for (init_fnc_ptr = init_sequence, j = 0; *init_fnc_ptr; |
| 242 | ++init_fnc_ptr, j++) { |
| 243 | #ifdef DEBUG_INIT_SEQUENCE |
| 244 | if (j > 9) |
| 245 | str_init_seq[9] = '0' + (j / 10); |
| 246 | str_init_seq[10] = '0' + (j - (j / 10) * 10); |
| 247 | serial_puts(str_init_seq); |
| 248 | #endif |
| 249 | if ((*init_fnc_ptr + gd->reloc_off) () != 0) { |
| 250 | hang(); |
| 251 | } |
| 252 | } |
| 253 | #ifdef DEBUG_INIT_SEQUENCE |
| 254 | serial_puts(str_init_seq_done); |
| 255 | #endif |
| 256 | |
| 257 | /* |
| 258 | * Now that we have DRAM mapped and working, we can |
| 259 | * relocate the code and continue running from DRAM. |
| 260 | * |
| 261 | * Reserve memory at end of RAM for (top down in that order): |
| 262 | * - kernel log buffer |
| 263 | * - protected RAM |
| 264 | * - LCD framebuffer |
| 265 | * - monitor code |
| 266 | * - board info struct |
| 267 | */ |
| 268 | #ifdef DEBUG_MEM_LAYOUT |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 269 | printf("CONFIG_SYS_MONITOR_BASE: 0x%lx\n", CONFIG_SYS_MONITOR_BASE); |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 270 | printf("CONFIG_ENV_ADDR: 0x%lx\n", CONFIG_ENV_ADDR); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 271 | printf("CONFIG_SYS_RELOC_MONITOR_BASE: 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE, |
| 272 | CONFIG_SYS_MONITOR_LEN); |
| 273 | printf("CONFIG_SYS_MALLOC_BASE: 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE, |
| 274 | CONFIG_SYS_MALLOC_LEN); |
| 275 | printf("CONFIG_SYS_INIT_SP_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET, |
| 276 | CONFIG_SYS_STACK_SIZE); |
| 277 | printf("CONFIG_SYS_PROM_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET, |
| 278 | CONFIG_SYS_PROM_SIZE); |
| 279 | printf("CONFIG_SYS_GBL_DATA_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET, |
| 280 | CONFIG_SYS_GBL_DATA_SIZE); |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 281 | #endif |
| 282 | |
| 283 | #ifdef CONFIG_POST |
| 284 | post_bootmode_init(); |
| 285 | post_run(NULL, POST_ROM | post_bootmode_get(0)); |
| 286 | #endif |
| 287 | |
| 288 | /* |
| 289 | * We have to relocate the command table manually |
| 290 | */ |
| 291 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { |
| 292 | ulong addr; |
| 293 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; |
| 294 | #if DEBUG_COMMANDS |
| 295 | printf("Command \"%s\": 0x%08lx => 0x%08lx\n", |
| 296 | cmdtp->name, (ulong) (cmdtp->cmd), addr); |
| 297 | #endif |
| 298 | cmdtp->cmd = |
| 299 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; |
| 300 | |
| 301 | addr = (ulong) (cmdtp->name) + gd->reloc_off; |
| 302 | cmdtp->name = (char *)addr; |
| 303 | |
| 304 | if (cmdtp->usage) { |
| 305 | addr = (ulong) (cmdtp->usage) + gd->reloc_off; |
| 306 | cmdtp->usage = (char *)addr; |
| 307 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 308 | #ifdef CONFIG_SYS_LONGHELP |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 309 | if (cmdtp->help) { |
| 310 | addr = (ulong) (cmdtp->help) + gd->reloc_off; |
| 311 | cmdtp->help = (char *)addr; |
| 312 | } |
| 313 | #endif |
| 314 | } |
| 315 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 316 | #if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP) |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 317 | puts("AMBA:\n"); |
| 318 | do_ambapp_print(NULL, 0, 0, NULL); |
| 319 | #endif |
| 320 | |
| 321 | /* initialize higher level parts of CPU like time base and timers */ |
| 322 | cpu_init_r(); |
| 323 | |
| 324 | /* start timer */ |
| 325 | timer_interrupt_init(); |
| 326 | |
| 327 | /* |
| 328 | * Enable Interrupts before any calls to udelay, |
| 329 | * the flash driver may use udelay resulting in |
| 330 | * a hang if not timer0 IRQ is enabled. |
| 331 | */ |
| 332 | interrupt_init(); |
| 333 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 334 | #if !defined(CONFIG_SYS_NO_FLASH) |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 335 | puts("FLASH: "); |
| 336 | |
| 337 | if ((flash_size = flash_init()) > 0) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 338 | # ifdef CONFIG_SYS_FLASH_CHECKSUM |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 339 | print_size(flash_size, ""); |
| 340 | /* |
| 341 | * Compute and print flash CRC if flashchecksum is set to 'y' |
| 342 | * |
| 343 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX |
| 344 | */ |
| 345 | s = getenv("flashchecksum"); |
| 346 | if (s && (*s == 'y')) { |
| 347 | printf(" CRC: %08lX", |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 348 | crc32(0, (const unsigned char *)CONFIG_SYS_FLASH_BASE, |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 349 | flash_size) |
| 350 | ); |
| 351 | } |
| 352 | putc('\n'); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 353 | # else /* !CONFIG_SYS_FLASH_CHECKSUM */ |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 354 | print_size(flash_size, "\n"); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 355 | # endif /* CONFIG_SYS_FLASH_CHECKSUM */ |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 356 | } else { |
| 357 | puts(failed); |
| 358 | hang(); |
| 359 | } |
| 360 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 361 | bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */ |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 362 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 363 | #if CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 364 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */ |
| 365 | #else |
| 366 | bd->bi_flashoffset = 0; |
| 367 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 368 | #else /* CONFIG_SYS_NO_FLASH */ |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 369 | bd->bi_flashsize = 0; |
| 370 | bd->bi_flashstart = 0; |
| 371 | bd->bi_flashoffset = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 372 | #endif /* !CONFIG_SYS_NO_FLASH */ |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 373 | |
| 374 | /* initialize malloc() area */ |
| 375 | mem_malloc_init(); |
| 376 | |
| 377 | malloc_bin_reloc(); |
| 378 | |
| 379 | #ifdef CONFIG_SPI |
Jean-Christophe PLAGNIOL-VILLARD | e46af64 | 2008-09-05 09:19:30 +0200 | [diff] [blame] | 380 | # if !defined(CONFIG_ENV_IS_IN_EEPROM) |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 381 | spi_init_f(); |
| 382 | # endif |
| 383 | spi_init_r(); |
| 384 | #endif |
| 385 | |
| 386 | /* relocate environment function pointers etc. */ |
| 387 | env_relocate(); |
| 388 | |
| 389 | #if defined(CONFIG_BOARD_LATE_INIT) |
| 390 | board_late_init(); |
| 391 | #endif |
| 392 | |
| 393 | s = getenv("ethaddr"); |
| 394 | for (i = 0; i < 6; ++i) { |
| 395 | bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0; |
| 396 | if (s) |
| 397 | s = (*e) ? e + 1 : e; |
| 398 | } |
| 399 | |
| 400 | #ifdef CONFIG_HAS_ETH1 |
| 401 | /* handle the 2nd ethernet address */ |
| 402 | |
| 403 | s = getenv("eth1addr"); |
| 404 | |
| 405 | for (i = 0; i < 6; ++i) { |
| 406 | bd->bi_enet1addr[i] = s ? simple_strtoul(s, &e, 16) : 0; |
| 407 | if (s) |
| 408 | s = (*e) ? e + 1 : e; |
| 409 | } |
| 410 | #endif |
| 411 | |
Jean-Christophe PLAGNIOL-VILLARD | 8349c72 | 2008-08-30 23:54:58 +0200 | [diff] [blame] | 412 | #ifdef CONFIG_ID_EEPROM |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 413 | mac_read_from_eeprom(); |
| 414 | #endif |
| 415 | |
| 416 | /* IP Address */ |
| 417 | bd->bi_ip_addr = getenv_IPaddr("ipaddr"); |
| 418 | #if defined(CONFIG_PCI) |
| 419 | /* |
| 420 | * Do pci configuration |
| 421 | */ |
| 422 | pci_init(); |
| 423 | #endif |
| 424 | |
| 425 | /* Initialize devices */ |
| 426 | devices_init(); |
| 427 | |
| 428 | /* Initialize the jump table for applications */ |
| 429 | jumptable_init(); |
| 430 | |
| 431 | /* Initialize the console (after the relocation and devices init) */ |
| 432 | console_init_r(); |
| 433 | |
| 434 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO |
| 435 | serial_buffered_init(); |
| 436 | #endif |
| 437 | |
| 438 | #ifdef CONFIG_STATUS_LED |
| 439 | status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); |
| 440 | #endif |
| 441 | |
| 442 | udelay(20); |
| 443 | |
| 444 | set_timer(0); |
| 445 | |
| 446 | /* Initialize from environment */ |
| 447 | if ((s = getenv("loadaddr")) != NULL) { |
| 448 | load_addr = simple_strtoul(s, NULL, 16); |
| 449 | } |
| 450 | #if defined(CONFIG_CMD_NET) |
| 451 | if ((s = getenv("bootfile")) != NULL) { |
| 452 | copy_filename(BootFile, s, sizeof(BootFile)); |
| 453 | } |
Stefan Roese | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 454 | #endif /* CONFIG_CMD_NET */ |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 455 | |
| 456 | WATCHDOG_RESET(); |
| 457 | |
| 458 | #if defined(CONFIG_CMD_DOC) |
| 459 | WATCHDOG_RESET(); |
| 460 | puts("DOC: "); |
| 461 | doc_init(); |
| 462 | #endif |
| 463 | |
| 464 | #if defined(CONFIG_CMD_NET) |
| 465 | #if defined(CONFIG_NET_MULTI) |
| 466 | WATCHDOG_RESET(); |
| 467 | puts("Net: "); |
| 468 | #endif |
| 469 | eth_initialize(bd); |
| 470 | #endif |
| 471 | |
| 472 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) |
| 473 | WATCHDOG_RESET(); |
| 474 | debug("Reset Ethernet PHY\n"); |
| 475 | reset_phy(); |
| 476 | #endif |
| 477 | |
| 478 | #ifdef CONFIG_POST |
| 479 | post_run(NULL, POST_RAM | post_bootmode_get(0)); |
| 480 | #endif |
| 481 | |
| 482 | #if defined(CONFIG_CMD_IDE) |
| 483 | WATCHDOG_RESET(); |
| 484 | puts("IDE: "); |
| 485 | ide_init(); |
Stefan Roese | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 486 | #endif /* CONFIG_CMD_IDE */ |
Daniel Hellstrom | 9d7c6b2 | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 487 | |
| 488 | #ifdef CONFIG_LAST_STAGE_INIT |
| 489 | WATCHDOG_RESET(); |
| 490 | /* |
| 491 | * Some parts can be only initialized if all others (like |
| 492 | * Interrupts) are up and running (i.e. the PC-style ISA |
| 493 | * keyboard). |
| 494 | */ |
| 495 | last_stage_init(); |
| 496 | #endif |
| 497 | |
| 498 | #ifdef CONFIG_PS2KBD |
| 499 | puts("PS/2: "); |
| 500 | kbd_init(); |
| 501 | #endif |
| 502 | prom_init(); |
| 503 | |
| 504 | /* main_loop */ |
| 505 | for (;;) { |
| 506 | WATCHDOG_RESET(); |
| 507 | main_loop(); |
| 508 | } |
| 509 | |
| 510 | } |
| 511 | |
| 512 | void hang(void) |
| 513 | { |
| 514 | puts("### ERROR ### Please RESET the board ###\n"); |
| 515 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 516 | show_boot_progress(-30); |
| 517 | #endif |
| 518 | for (;;) ; |
| 519 | } |
| 520 | |
| 521 | /************************************************************************/ |