board.c 16 KB

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