board.c 18 KB

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