board.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /*
  2. * (C) Copyright 2003
  3. * Josef Baumgartner <josef.baumgartner@telex.de>
  4. *
  5. * (C) Copyright 2000-2002
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <command.h>
  29. #include <malloc.h>
  30. #include <stdio_dev.h>
  31. #include <asm/immap.h>
  32. #if defined(CONFIG_CMD_IDE)
  33. #include <ide.h>
  34. #endif
  35. #if defined(CONFIG_CMD_SCSI)
  36. #include <scsi.h>
  37. #endif
  38. #if defined(CONFIG_CMD_KGDB)
  39. #include <kgdb.h>
  40. #endif
  41. #ifdef CONFIG_STATUS_LED
  42. #include <status_led.h>
  43. #endif
  44. #include <net.h>
  45. #include <serial.h>
  46. #if defined(CONFIG_CMD_BEDBUG)
  47. #include <cmd_bedbug.h>
  48. #endif
  49. #ifdef CONFIG_SYS_ALLOC_DPRAM
  50. #include <commproc.h>
  51. #endif
  52. #include <version.h>
  53. #if defined(CONFIG_HARD_I2C) || \
  54. defined(CONFIG_SOFT_I2C)
  55. #include <i2c.h>
  56. #endif
  57. #ifdef CONFIG_CMD_SPI
  58. #include <spi.h>
  59. #endif
  60. #include <nand.h>
  61. DECLARE_GLOBAL_DATA_PTR;
  62. static char *failed = "*** failed ***\n";
  63. #ifdef CONFIG_PCU_E
  64. extern flash_info_t flash_info[];
  65. #endif
  66. #include <environment.h>
  67. #if ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
  68. (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
  69. defined(CONFIG_ENV_IS_IN_NVRAM)
  70. #define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
  71. #else
  72. #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
  73. #endif
  74. extern ulong __init_end;
  75. extern ulong _end;
  76. extern void timer_init(void);
  77. #if defined(CONFIG_WATCHDOG)
  78. # define INIT_FUNC_WATCHDOG_INIT watchdog_init,
  79. # define WATCHDOG_DISABLE watchdog_disable
  80. extern int watchdog_init(void);
  81. extern int watchdog_disable(void);
  82. #else
  83. # define INIT_FUNC_WATCHDOG_INIT /* undef */
  84. # define WATCHDOG_DISABLE /* undef */
  85. #endif /* CONFIG_WATCHDOG */
  86. ulong monitor_flash_len;
  87. /************************************************************************
  88. * Utilities *
  89. ************************************************************************
  90. */
  91. /*
  92. * The Malloc area is immediately below the monitor copy in DRAM
  93. */
  94. static void mem_malloc_init(ulong start, ulong size)
  95. {
  96. mem_malloc_start = start;
  97. mem_malloc_end = start + size;
  98. mem_malloc_brk = start;
  99. memset ((void *)mem_malloc_start, 0, size);
  100. }
  101. /*
  102. * All attempts to come up with a "common" initialization sequence
  103. * that works for all boards and architectures failed: some of the
  104. * requirements are just _too_ different. To get rid of the resulting
  105. * mess of board dependend #ifdef'ed code we now make the whole
  106. * initialization sequence configurable to the user.
  107. *
  108. * The requirements for any new initalization function is simple: it
  109. * receives a pointer to the "global data" structure as it's only
  110. * argument, and returns an integer return code, where 0 means
  111. * "continue" and != 0 means "fatal error, hang the system".
  112. */
  113. typedef int (init_fnc_t) (void);
  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. static int init_baudrate (void)
  121. {
  122. char tmp[64]; /* long enough for environment variables */
  123. int i = getenv_r ("baudrate", tmp, sizeof (tmp));
  124. gd->baudrate = (i > 0)
  125. ? (int) simple_strtoul (tmp, NULL, 10)
  126. : CONFIG_BAUDRATE;
  127. return (0);
  128. }
  129. /***********************************************************************/
  130. static int init_func_ram (void)
  131. {
  132. int board_type = 0; /* use dummy arg */
  133. puts ("DRAM: ");
  134. if ((gd->ram_size = initdram (board_type)) > 0) {
  135. print_size (gd->ram_size, "\n");
  136. return (0);
  137. }
  138. puts (failed);
  139. return (1);
  140. }
  141. /***********************************************************************/
  142. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  143. static int init_func_i2c (void)
  144. {
  145. puts ("I2C: ");
  146. i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  147. puts ("ready\n");
  148. return (0);
  149. }
  150. #endif
  151. #if defined(CONFIG_HARD_SPI)
  152. static int init_func_spi (void)
  153. {
  154. puts ("SPI: ");
  155. spi_init ();
  156. puts ("ready\n");
  157. return (0);
  158. }
  159. #endif
  160. /***********************************************************************/
  161. /************************************************************************
  162. * Initialization sequence *
  163. ************************************************************************
  164. */
  165. init_fnc_t *init_sequence[] = {
  166. get_clocks,
  167. env_init,
  168. init_baudrate,
  169. serial_init,
  170. console_init_f,
  171. display_options,
  172. checkcpu,
  173. checkboard,
  174. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  175. init_func_i2c,
  176. #endif
  177. #if defined(CONFIG_HARD_SPI)
  178. init_func_spi,
  179. #endif
  180. init_func_ram,
  181. #if defined(CONFIG_SYS_DRAM_TEST)
  182. testdram,
  183. #endif /* CONFIG_SYS_DRAM_TEST */
  184. INIT_FUNC_WATCHDOG_INIT
  185. NULL, /* Terminate this list */
  186. };
  187. /************************************************************************
  188. *
  189. * This is the first part of the initialization sequence that is
  190. * implemented in C, but still running from ROM.
  191. *
  192. * The main purpose is to provide a (serial) console interface as
  193. * soon as possible (so we can see any error messages), and to
  194. * initialize the RAM so that we can relocate the monitor code to
  195. * RAM.
  196. *
  197. * Be aware of the restrictions: global data is read-only, BSS is not
  198. * initialized, and stack space is limited to a few kB.
  199. *
  200. ************************************************************************
  201. */
  202. void
  203. board_init_f (ulong bootflag)
  204. {
  205. bd_t *bd;
  206. ulong len, addr, addr_sp;
  207. ulong *paddr;
  208. gd_t *id;
  209. init_fnc_t **init_fnc_ptr;
  210. #ifdef CONFIG_PRAM
  211. int i;
  212. ulong reg;
  213. char tmp[64]; /* long enough for environment variables */
  214. #endif
  215. /* Pointer is writable since we allocated a register for it */
  216. gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
  217. /* compiler optimization barrier needed for GCC >= 3.4 */
  218. __asm__ __volatile__("": : :"memory");
  219. /* Clear initial global data */
  220. memset ((void *) gd, 0, sizeof (gd_t));
  221. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  222. if ((*init_fnc_ptr)() != 0) {
  223. hang ();
  224. }
  225. }
  226. /*
  227. * Now that we have DRAM mapped and working, we can
  228. * relocate the code and continue running from DRAM.
  229. *
  230. * Reserve memory at end of RAM for (top down in that order):
  231. * - protected RAM
  232. * - LCD framebuffer
  233. * - monitor code
  234. * - board info struct
  235. */
  236. len = (ulong)&_end - CONFIG_SYS_MONITOR_BASE;
  237. addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
  238. #ifdef CONFIG_LOGBUFFER
  239. /* reserve kernel log buffer */
  240. addr -= (LOGBUFF_RESERVE);
  241. debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
  242. #endif
  243. #ifdef CONFIG_PRAM
  244. /*
  245. * reserve protected RAM
  246. */
  247. i = getenv_r ("pram", tmp, sizeof (tmp));
  248. reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM;
  249. addr -= (reg << 10); /* size is in kB */
  250. debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  251. #endif /* CONFIG_PRAM */
  252. /* round down to next 4 kB limit */
  253. addr &= ~(4096 - 1);
  254. debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
  255. #ifdef CONFIG_LCD
  256. /* reserve memory for LCD display (always full pages) */
  257. addr = lcd_setmem (addr);
  258. gd->fb_base = addr;
  259. #endif /* CONFIG_LCD */
  260. /*
  261. * reserve memory for U-Boot code, data & bss
  262. * round down to next 4 kB limit
  263. */
  264. addr -= len;
  265. addr &= ~(4096 - 1);
  266. debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
  267. /*
  268. * reserve memory for malloc() arena
  269. */
  270. addr_sp = addr - TOTAL_MALLOC_LEN;
  271. debug ("Reserving %dk for malloc() at: %08lx\n",
  272. TOTAL_MALLOC_LEN >> 10, addr_sp);
  273. /*
  274. * (permanently) allocate a Board Info struct
  275. * and a permanent copy of the "global" data
  276. */
  277. addr_sp -= sizeof (bd_t);
  278. bd = (bd_t *) addr_sp;
  279. gd->bd = bd;
  280. debug ("Reserving %zu Bytes for Board Info at: %08lx\n",
  281. sizeof (bd_t), addr_sp);
  282. addr_sp -= sizeof (gd_t);
  283. id = (gd_t *) addr_sp;
  284. debug ("Reserving %zu Bytes for Global Data at: %08lx\n",
  285. sizeof (gd_t), addr_sp);
  286. /* Reserve memory for boot params. */
  287. addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN;
  288. bd->bi_boot_params = addr_sp;
  289. debug ("Reserving %dk for boot parameters at: %08lx\n",
  290. CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp);
  291. /*
  292. * Finally, we set up a new (bigger) stack.
  293. *
  294. * Leave some safety gap for SP, force alignment on 16 byte boundary
  295. * Clear initial stack frame
  296. */
  297. addr_sp -= 16;
  298. addr_sp &= ~0xF;
  299. paddr = (ulong *)addr_sp;
  300. *paddr-- = 0;
  301. *paddr-- = 0;
  302. addr_sp = (ulong)paddr;
  303. debug ("Stack Pointer at: %08lx\n", addr_sp);
  304. /*
  305. * Save local variables to board info struct
  306. */
  307. bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */
  308. bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
  309. #ifdef CONFIG_SYS_INIT_RAM_ADDR
  310. bd->bi_sramstart = CONFIG_SYS_INIT_RAM_ADDR; /* start of SRAM memory */
  311. bd->bi_sramsize = CONFIG_SYS_INIT_RAM_END; /* size of SRAM memory */
  312. #endif
  313. bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
  314. bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
  315. WATCHDOG_RESET ();
  316. bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
  317. bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
  318. #ifdef CONFIG_PCI
  319. bd->bi_pcifreq = gd->pci_clk; /* PCI Freq in Hz */
  320. #endif
  321. #ifdef CONFIG_EXTRA_CLOCK
  322. bd->bi_inpfreq = gd->inp_clk; /* input Freq in Hz */
  323. bd->bi_vcofreq = gd->vco_clk; /* vco Freq in Hz */
  324. bd->bi_flbfreq = gd->flb_clk; /* flexbus Freq in Hz */
  325. #endif
  326. bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
  327. #ifdef CONFIG_SYS_EXTBDINFO
  328. strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
  329. strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
  330. #endif
  331. WATCHDOG_RESET ();
  332. #ifdef CONFIG_POST
  333. post_bootmode_init();
  334. post_run (NULL, POST_ROM | post_bootmode_get(0));
  335. #endif
  336. WATCHDOG_RESET();
  337. memcpy (id, (void *)gd, sizeof (gd_t));
  338. debug ("Start relocate of code from %08x to %08lx\n", CONFIG_SYS_MONITOR_BASE, addr);
  339. relocate_code (addr_sp, id, addr);
  340. /* NOTREACHED - jump_to_ram() does not return */
  341. }
  342. /************************************************************************
  343. *
  344. * This is the next part if the initialization sequence: we are now
  345. * running from RAM and have a "normal" C environment, i. e. global
  346. * data can be written, BSS has been cleared, the stack size in not
  347. * that critical any more, etc.
  348. *
  349. ************************************************************************
  350. */
  351. void board_init_r (gd_t *id, ulong dest_addr)
  352. {
  353. cmd_tbl_t *cmdtp;
  354. char *s;
  355. bd_t *bd;
  356. extern void malloc_bin_reloc (void);
  357. #ifndef CONFIG_ENV_IS_NOWHERE
  358. extern char * env_name_spec;
  359. #endif
  360. #ifndef CONFIG_SYS_NO_FLASH
  361. ulong flash_size;
  362. #endif
  363. gd = id; /* initialize RAM version of global data */
  364. bd = gd->bd;
  365. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  366. #ifdef CONFIG_SERIAL_MULTI
  367. serial_initialize();
  368. #endif
  369. debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  370. WATCHDOG_RESET ();
  371. gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
  372. monitor_flash_len = (ulong)&__init_end - dest_addr;
  373. /*
  374. * We have to relocate the command table manually
  375. */
  376. for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
  377. ulong addr;
  378. addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
  379. #if 0
  380. printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
  381. cmdtp->name, (ulong) (cmdtp->cmd), addr);
  382. #endif
  383. cmdtp->cmd =
  384. (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
  385. addr = (ulong)(cmdtp->name) + gd->reloc_off;
  386. cmdtp->name = (char *)addr;
  387. if (cmdtp->usage) {
  388. addr = (ulong)(cmdtp->usage) + gd->reloc_off;
  389. cmdtp->usage = (char *)addr;
  390. }
  391. #ifdef CONFIG_SYS_LONGHELP
  392. if (cmdtp->help) {
  393. addr = (ulong)(cmdtp->help) + gd->reloc_off;
  394. cmdtp->help = (char *)addr;
  395. }
  396. #endif
  397. }
  398. /* there are some other pointer constants we must deal with */
  399. #ifndef CONFIG_ENV_IS_NOWHERE
  400. env_name_spec += gd->reloc_off;
  401. #endif
  402. WATCHDOG_RESET ();
  403. #ifdef CONFIG_LOGBUFFER
  404. logbuff_init_ptrs ();
  405. #endif
  406. #ifdef CONFIG_POST
  407. post_output_backlog ();
  408. post_reloc ();
  409. #endif
  410. WATCHDOG_RESET();
  411. #if 0
  412. /* instruction cache enabled in cpu_init_f() for faster relocation */
  413. icache_enable (); /* it's time to enable the instruction cache */
  414. #endif
  415. /*
  416. * Setup trap handlers
  417. */
  418. trap_init (CONFIG_SYS_SDRAM_BASE);
  419. /* initialize malloc() area */
  420. mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
  421. TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
  422. malloc_bin_reloc ();
  423. #if !defined(CONFIG_SYS_NO_FLASH)
  424. puts ("FLASH: ");
  425. if ((flash_size = flash_init ()) > 0) {
  426. # ifdef CONFIG_SYS_FLASH_CHECKSUM
  427. print_size (flash_size, "");
  428. /*
  429. * Compute and print flash CRC if flashchecksum is set to 'y'
  430. *
  431. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  432. */
  433. s = getenv ("flashchecksum");
  434. if (s && (*s == 'y')) {
  435. printf (" CRC: %08X",
  436. crc32 (0,
  437. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  438. flash_size)
  439. );
  440. }
  441. putc ('\n');
  442. # else /* !CONFIG_SYS_FLASH_CHECKSUM */
  443. print_size (flash_size, "\n");
  444. # endif /* CONFIG_SYS_FLASH_CHECKSUM */
  445. } else {
  446. puts (failed);
  447. hang ();
  448. }
  449. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */
  450. bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
  451. bd->bi_flashoffset = 0;
  452. #else /* CONFIG_SYS_NO_FLASH */
  453. bd->bi_flashsize = 0;
  454. bd->bi_flashstart = 0;
  455. bd->bi_flashoffset = 0;
  456. #endif /* !CONFIG_SYS_NO_FLASH */
  457. WATCHDOG_RESET ();
  458. /* initialize higher level parts of CPU like time base and timers */
  459. cpu_init_r ();
  460. WATCHDOG_RESET ();
  461. #ifdef CONFIG_SPI
  462. # if !defined(CONFIG_ENV_IS_IN_EEPROM)
  463. spi_init_f ();
  464. # endif
  465. spi_init_r ();
  466. #endif
  467. /* relocate environment function pointers etc. */
  468. env_relocate ();
  469. /*
  470. * Fill in missing fields of bd_info.
  471. * We do this here, where we have "normal" access to the
  472. * environment; we used to do this still running from ROM,
  473. * where had to use getenv_r(), which can be pretty slow when
  474. * the environment is in EEPROM.
  475. */
  476. bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
  477. WATCHDOG_RESET ();
  478. #if defined(CONFIG_PCI)
  479. /*
  480. * Do pci configuration
  481. */
  482. pci_init ();
  483. #endif
  484. /** leave this here (after malloc(), environment and PCI are working) **/
  485. /* Initialize stdio devices */
  486. stdio_init ();
  487. /* Initialize the jump table for applications */
  488. jumptable_init ();
  489. /* Initialize the console (after the relocation and devices init) */
  490. console_init_r ();
  491. #if defined(CONFIG_MISC_INIT_R)
  492. /* miscellaneous platform dependent initialisations */
  493. misc_init_r ();
  494. #endif
  495. #if defined(CONFIG_CMD_KGDB)
  496. WATCHDOG_RESET ();
  497. puts ("KGDB: ");
  498. kgdb_init ();
  499. #endif
  500. debug ("U-Boot relocated to %08lx\n", dest_addr);
  501. /*
  502. * Enable Interrupts
  503. */
  504. interrupt_init ();
  505. /* Must happen after interrupts are initialized since
  506. * an irq handler gets installed
  507. */
  508. timer_init();
  509. #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
  510. serial_buffered_init();
  511. #endif
  512. #ifdef CONFIG_STATUS_LED
  513. status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
  514. #endif
  515. udelay (20);
  516. set_timer (0);
  517. /* Insert function pointers now that we have relocated the code */
  518. /* Initialize from environment */
  519. if ((s = getenv ("loadaddr")) != NULL) {
  520. load_addr = simple_strtoul (s, NULL, 16);
  521. }
  522. #if defined(CONFIG_CMD_NET)
  523. if ((s = getenv ("bootfile")) != NULL) {
  524. copy_filename (BootFile, s, sizeof (BootFile));
  525. }
  526. #endif
  527. WATCHDOG_RESET ();
  528. #if defined(CONFIG_CMD_DOC)
  529. WATCHDOG_RESET ();
  530. puts ("DOC: ");
  531. doc_init ();
  532. #endif
  533. #if defined(CONFIG_CMD_NAND)
  534. WATCHDOG_RESET ();
  535. puts ("NAND: ");
  536. nand_init(); /* go init the NAND */
  537. #endif
  538. #if defined(CONFIG_CMD_NET)
  539. WATCHDOG_RESET();
  540. #if defined(FEC_ENET)
  541. eth_init(bd);
  542. #endif
  543. #if defined(CONFIG_NET_MULTI)
  544. puts ("Net: ");
  545. eth_initialize (bd);
  546. #endif
  547. #endif
  548. #ifdef CONFIG_POST
  549. post_run (NULL, POST_RAM | post_bootmode_get(0));
  550. #endif
  551. #if defined(CONFIG_CMD_PCMCIA) \
  552. && !defined(CONFIG_CMD_IDE)
  553. WATCHDOG_RESET ();
  554. puts ("PCMCIA:");
  555. pcmcia_init ();
  556. #endif
  557. #if defined(CONFIG_CMD_IDE)
  558. WATCHDOG_RESET ();
  559. puts ("IDE: ");
  560. ide_init ();
  561. #endif
  562. #ifdef CONFIG_LAST_STAGE_INIT
  563. WATCHDOG_RESET ();
  564. /*
  565. * Some parts can be only initialized if all others (like
  566. * Interrupts) are up and running (i.e. the PC-style ISA
  567. * keyboard).
  568. */
  569. last_stage_init ();
  570. #endif
  571. #if defined(CONFIG_CMD_BEDBUG)
  572. WATCHDOG_RESET ();
  573. bedbug_init ();
  574. #endif
  575. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  576. /*
  577. * Export available size of memory for Linux,
  578. * taking into account the protected RAM at top of memory
  579. */
  580. {
  581. ulong pram;
  582. char memsz[32];
  583. #ifdef CONFIG_PRAM
  584. char *s;
  585. if ((s = getenv ("pram")) != NULL) {
  586. pram = simple_strtoul (s, NULL, 10);
  587. } else {
  588. pram = CONFIG_PRAM;
  589. }
  590. #else
  591. pram=0;
  592. #endif
  593. #ifdef CONFIG_LOGBUFFER
  594. /* Also take the logbuffer into account (pram is in kB) */
  595. pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
  596. #endif
  597. sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
  598. setenv ("mem", memsz);
  599. }
  600. #endif
  601. #ifdef CONFIG_MODEM_SUPPORT
  602. {
  603. extern int do_mdm_init;
  604. do_mdm_init = gd->do_mdm_init;
  605. }
  606. #endif
  607. #ifdef CONFIG_WATCHDOG
  608. /* disable watchdog if environment is set */
  609. if ((s = getenv ("watchdog")) != NULL) {
  610. if (strncmp (s, "off", 3) == 0) {
  611. WATCHDOG_DISABLE ();
  612. }
  613. }
  614. #endif /* CONFIG_WATCHDOG*/
  615. /* Initialization complete - start the monitor */
  616. /* main_loop() can return to retry autoboot, if so just run it again. */
  617. for (;;) {
  618. WATCHDOG_RESET ();
  619. main_loop ();
  620. }
  621. /* NOTREACHED - no way out of command loop except booting */
  622. }
  623. void hang(void)
  624. {
  625. puts ("### ERROR ### Please RESET the board ###\n");
  626. for (;;);
  627. }