board.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /*
  2. * (C) Copyright 2002-2006
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2002
  6. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Marius Groeger <mgroeger@sysgo.de>
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. /*
  12. * To match the U-Boot user interface on ARM platforms to the U-Boot
  13. * standard (as on PPC platforms), some messages with debug character
  14. * are removed from the default U-Boot build.
  15. *
  16. * Define DEBUG here if you want additional info as shown below
  17. * printed upon startup:
  18. *
  19. * U-Boot code: 00F00000 -> 00F3C774 BSS: -> 00FC3274
  20. * IRQ Stack: 00ebff7c
  21. * FIQ Stack: 00ebef7c
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <environment.h>
  26. #include <malloc.h>
  27. #include <stdio_dev.h>
  28. #include <version.h>
  29. #include <net.h>
  30. #include <serial.h>
  31. #include <nand.h>
  32. #include <onenand_uboot.h>
  33. #include <mmc.h>
  34. #include <scsi.h>
  35. #include <status_led.h>
  36. #include <libfdt.h>
  37. #include <fdtdec.h>
  38. #include <post.h>
  39. #include <logbuff.h>
  40. #include <asm/sections.h>
  41. #ifdef CONFIG_BITBANGMII
  42. #include <miiphy.h>
  43. #endif
  44. DECLARE_GLOBAL_DATA_PTR;
  45. ulong monitor_flash_len;
  46. #ifdef CONFIG_HAS_DATAFLASH
  47. extern int AT91F_DataflashInit(void);
  48. extern void dataflash_print_info(void);
  49. #endif
  50. #if defined(CONFIG_HARD_I2C) || \
  51. defined(CONFIG_SYS_I2C)
  52. #include <i2c.h>
  53. #endif
  54. /************************************************************************
  55. * Coloured LED functionality
  56. ************************************************************************
  57. * May be supplied by boards if desired
  58. */
  59. __weak void coloured_LED_init(void) {}
  60. __weak void red_led_on(void) {}
  61. __weak void red_led_off(void) {}
  62. __weak void green_led_on(void) {}
  63. __weak void green_led_off(void) {}
  64. __weak void yellow_led_on(void) {}
  65. __weak void yellow_led_off(void) {}
  66. __weak void blue_led_on(void) {}
  67. __weak void blue_led_off(void) {}
  68. /*
  69. ************************************************************************
  70. * Init Utilities *
  71. ************************************************************************
  72. * Some of this code should be moved into the core functions,
  73. * or dropped completely,
  74. * but let's get it working (again) first...
  75. */
  76. #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE)
  77. #define CONFIG_BAUDRATE 115200
  78. #endif
  79. static int init_baudrate(void)
  80. {
  81. gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
  82. return 0;
  83. }
  84. static int display_banner(void)
  85. {
  86. printf("\n\n%s\n\n", version_string);
  87. debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
  88. (ulong)&_start,
  89. (ulong)&__bss_start, (ulong)&__bss_end);
  90. #ifdef CONFIG_MODEM_SUPPORT
  91. debug("Modem Support enabled\n");
  92. #endif
  93. #ifdef CONFIG_USE_IRQ
  94. debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
  95. debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
  96. #endif
  97. return (0);
  98. }
  99. /*
  100. * WARNING: this code looks "cleaner" than the PowerPC version, but
  101. * has the disadvantage that you either get nothing, or everything.
  102. * On PowerPC, you might see "DRAM: " before the system hangs - which
  103. * gives a simple yet clear indication which part of the
  104. * initialization if failing.
  105. */
  106. static int display_dram_config(void)
  107. {
  108. int i;
  109. #ifdef DEBUG
  110. puts("RAM Configuration:\n");
  111. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  112. printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
  113. print_size(gd->bd->bi_dram[i].size, "\n");
  114. }
  115. #else
  116. ulong size = 0;
  117. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
  118. size += gd->bd->bi_dram[i].size;
  119. puts("DRAM: ");
  120. print_size(size, "\n");
  121. #endif
  122. return (0);
  123. }
  124. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
  125. static int init_func_i2c(void)
  126. {
  127. puts("I2C: ");
  128. #ifdef CONFIG_SYS_I2C
  129. i2c_init_all();
  130. #else
  131. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  132. #endif
  133. puts("ready\n");
  134. return (0);
  135. }
  136. #endif
  137. #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
  138. #include <pci.h>
  139. static int arm_pci_init(void)
  140. {
  141. pci_init();
  142. return 0;
  143. }
  144. #endif /* CONFIG_CMD_PCI || CONFIG_PCI */
  145. /*
  146. * Breathe some life into the board...
  147. *
  148. * Initialize a serial port as console, and carry out some hardware
  149. * tests.
  150. *
  151. * The first part of initialization is running from Flash memory;
  152. * its main purpose is to initialize the RAM so that we
  153. * can relocate the monitor code to RAM.
  154. */
  155. /*
  156. * All attempts to come up with a "common" initialization sequence
  157. * that works for all boards and architectures failed: some of the
  158. * requirements are just _too_ different. To get rid of the resulting
  159. * mess of board dependent #ifdef'ed code we now make the whole
  160. * initialization sequence configurable to the user.
  161. *
  162. * The requirements for any new initalization function is simple: it
  163. * receives a pointer to the "global data" structure as it's only
  164. * argument, and returns an integer return code, where 0 means
  165. * "continue" and != 0 means "fatal error, hang the system".
  166. */
  167. typedef int (init_fnc_t) (void);
  168. __weak void dram_init_banksize(void)
  169. {
  170. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  171. gd->bd->bi_dram[0].size = gd->ram_size;
  172. }
  173. __weak int arch_cpu_init(void)
  174. {
  175. return 0;
  176. }
  177. __weak int power_init_board(void)
  178. {
  179. return 0;
  180. }
  181. /* Record the board_init_f() bootstage (after arch_cpu_init()) */
  182. static int mark_bootstage(void)
  183. {
  184. bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
  185. return 0;
  186. }
  187. init_fnc_t *init_sequence[] = {
  188. arch_cpu_init, /* basic arch cpu dependent setup */
  189. mark_bootstage,
  190. #ifdef CONFIG_OF_CONTROL
  191. fdtdec_check_fdt,
  192. #endif
  193. #if defined(CONFIG_BOARD_EARLY_INIT_F)
  194. board_early_init_f,
  195. #endif
  196. timer_init, /* initialize timer */
  197. #ifdef CONFIG_BOARD_POSTCLK_INIT
  198. board_postclk_init,
  199. #endif
  200. #ifdef CONFIG_FSL_ESDHC
  201. get_clocks,
  202. #endif
  203. env_init, /* initialize environment */
  204. init_baudrate, /* initialze baudrate settings */
  205. serial_init, /* serial communications setup */
  206. console_init_f, /* stage 1 init of console */
  207. display_banner, /* say that we are here */
  208. print_cpuinfo, /* display cpu info (and speed) */
  209. #if defined(CONFIG_DISPLAY_BOARDINFO)
  210. checkboard, /* display board info */
  211. #endif
  212. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
  213. init_func_i2c,
  214. #endif
  215. dram_init, /* configure available RAM banks */
  216. NULL,
  217. };
  218. void board_init_f(ulong bootflag)
  219. {
  220. bd_t *bd;
  221. init_fnc_t **init_fnc_ptr;
  222. gd_t *id;
  223. ulong addr, addr_sp;
  224. #ifdef CONFIG_PRAM
  225. ulong reg;
  226. #endif
  227. void *new_fdt = NULL;
  228. size_t fdt_size = 0;
  229. memset((void *)gd, 0, sizeof(gd_t));
  230. gd->mon_len = (ulong)&__bss_end - (ulong)_start;
  231. #ifdef CONFIG_OF_EMBED
  232. /* Get a pointer to the FDT */
  233. gd->fdt_blob = __dtb_dt_begin;
  234. #elif defined CONFIG_OF_SEPARATE
  235. /* FDT is at end of image */
  236. gd->fdt_blob = &_end;
  237. #endif
  238. /* Allow the early environment to override the fdt address */
  239. gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
  240. (uintptr_t)gd->fdt_blob);
  241. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  242. if ((*init_fnc_ptr)() != 0) {
  243. hang ();
  244. }
  245. }
  246. #ifdef CONFIG_OF_CONTROL
  247. /* For now, put this check after the console is ready */
  248. if (fdtdec_prepare_fdt()) {
  249. panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
  250. "doc/README.fdt-control");
  251. }
  252. #endif
  253. debug("monitor len: %08lX\n", gd->mon_len);
  254. /*
  255. * Ram is setup, size stored in gd !!
  256. */
  257. debug("ramsize: %08lX\n", gd->ram_size);
  258. #if defined(CONFIG_SYS_MEM_TOP_HIDE)
  259. /*
  260. * Subtract specified amount of memory to hide so that it won't
  261. * get "touched" at all by U-Boot. By fixing up gd->ram_size
  262. * the Linux kernel should now get passed the now "corrected"
  263. * memory size and won't touch it either. This should work
  264. * for arch/ppc and arch/powerpc. Only Linux board ports in
  265. * arch/powerpc with bootwrapper support, that recalculate the
  266. * memory size from the SDRAM controller setup will have to
  267. * get fixed.
  268. */
  269. gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
  270. #endif
  271. addr = CONFIG_SYS_SDRAM_BASE + get_effective_memsize();
  272. #ifdef CONFIG_LOGBUFFER
  273. #ifndef CONFIG_ALT_LB_ADDR
  274. /* reserve kernel log buffer */
  275. addr -= (LOGBUFF_RESERVE);
  276. debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
  277. addr);
  278. #endif
  279. #endif
  280. #ifdef CONFIG_PRAM
  281. /*
  282. * reserve protected RAM
  283. */
  284. reg = getenv_ulong("pram", 10, CONFIG_PRAM);
  285. addr -= (reg << 10); /* size is in kB */
  286. debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  287. #endif /* CONFIG_PRAM */
  288. #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
  289. /* reserve TLB table */
  290. gd->arch.tlb_size = PGTABLE_SIZE;
  291. addr -= gd->arch.tlb_size;
  292. /* round down to next 64 kB limit */
  293. addr &= ~(0x10000 - 1);
  294. gd->arch.tlb_addr = addr;
  295. debug("TLB table from %08lx to %08lx\n", addr, addr + gd->arch.tlb_size);
  296. #endif
  297. /* round down to next 4 kB limit */
  298. addr &= ~(4096 - 1);
  299. debug("Top of RAM usable for U-Boot at: %08lx\n", addr);
  300. #ifdef CONFIG_LCD
  301. #ifdef CONFIG_FB_ADDR
  302. gd->fb_base = CONFIG_FB_ADDR;
  303. #else
  304. /* reserve memory for LCD display (always full pages) */
  305. addr = lcd_setmem(addr);
  306. gd->fb_base = addr;
  307. #endif /* CONFIG_FB_ADDR */
  308. #endif /* CONFIG_LCD */
  309. /*
  310. * reserve memory for U-Boot code, data & bss
  311. * round down to next 4 kB limit
  312. */
  313. addr -= gd->mon_len;
  314. addr &= ~(4096 - 1);
  315. debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);
  316. #ifndef CONFIG_SPL_BUILD
  317. /*
  318. * reserve memory for malloc() arena
  319. */
  320. addr_sp = addr - TOTAL_MALLOC_LEN;
  321. debug("Reserving %dk for malloc() at: %08lx\n",
  322. TOTAL_MALLOC_LEN >> 10, addr_sp);
  323. /*
  324. * (permanently) allocate a Board Info struct
  325. * and a permanent copy of the "global" data
  326. */
  327. addr_sp -= sizeof (bd_t);
  328. bd = (bd_t *) addr_sp;
  329. gd->bd = bd;
  330. debug("Reserving %zu Bytes for Board Info at: %08lx\n",
  331. sizeof (bd_t), addr_sp);
  332. #ifdef CONFIG_MACH_TYPE
  333. gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
  334. #endif
  335. addr_sp -= sizeof (gd_t);
  336. id = (gd_t *) addr_sp;
  337. debug("Reserving %zu Bytes for Global Data at: %08lx\n",
  338. sizeof (gd_t), addr_sp);
  339. #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
  340. /*
  341. * If the device tree is sitting immediate above our image then we
  342. * must relocate it. If it is embedded in the data section, then it
  343. * will be relocated with other data.
  344. */
  345. if (gd->fdt_blob) {
  346. fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
  347. addr_sp -= fdt_size;
  348. new_fdt = (void *)addr_sp;
  349. debug("Reserving %zu Bytes for FDT at: %08lx\n",
  350. fdt_size, addr_sp);
  351. }
  352. #endif
  353. #ifndef CONFIG_ARM64
  354. /* setup stackpointer for exeptions */
  355. gd->irq_sp = addr_sp;
  356. #ifdef CONFIG_USE_IRQ
  357. addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);
  358. debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
  359. CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);
  360. #endif
  361. /* leave 3 words for abort-stack */
  362. addr_sp -= 12;
  363. /* 8-byte alignment for ABI compliance */
  364. addr_sp &= ~0x07;
  365. #else /* CONFIG_ARM64 */
  366. /* 16-byte alignment for ABI compliance */
  367. addr_sp &= ~0x0f;
  368. #endif /* CONFIG_ARM64 */
  369. #else
  370. addr_sp += 128; /* leave 32 words for abort-stack */
  371. gd->irq_sp = addr_sp;
  372. #endif
  373. debug("New Stack Pointer is: %08lx\n", addr_sp);
  374. #ifdef CONFIG_POST
  375. post_bootmode_init();
  376. post_run(NULL, POST_ROM | post_bootmode_get(0));
  377. #endif
  378. /* Ram ist board specific, so move it to board code ... */
  379. dram_init_banksize();
  380. display_dram_config(); /* and display it */
  381. gd->relocaddr = addr;
  382. gd->start_addr_sp = addr_sp;
  383. gd->reloc_off = addr - (ulong)&_start;
  384. debug("relocation Offset is: %08lx\n", gd->reloc_off);
  385. if (new_fdt) {
  386. memcpy(new_fdt, gd->fdt_blob, fdt_size);
  387. gd->fdt_blob = new_fdt;
  388. }
  389. memcpy(id, (void *)gd, sizeof(gd_t));
  390. }
  391. #if !defined(CONFIG_SYS_NO_FLASH)
  392. static char *failed = "*** failed ***\n";
  393. #endif
  394. /*
  395. * Tell if it's OK to load the environment early in boot.
  396. *
  397. * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
  398. * if this is OK (defaulting to saying it's not OK).
  399. *
  400. * NOTE: Loading the environment early can be a bad idea if security is
  401. * important, since no verification is done on the environment.
  402. *
  403. * @return 0 if environment should not be loaded, !=0 if it is ok to load
  404. */
  405. static int should_load_env(void)
  406. {
  407. #ifdef CONFIG_OF_CONTROL
  408. return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
  409. #elif defined CONFIG_DELAY_ENVIRONMENT
  410. return 0;
  411. #else
  412. return 1;
  413. #endif
  414. }
  415. #if defined(CONFIG_DISPLAY_BOARDINFO_LATE) && defined(CONFIG_OF_CONTROL)
  416. static void display_fdt_model(const void *blob)
  417. {
  418. const char *model;
  419. model = (char *)fdt_getprop(blob, 0, "model", NULL);
  420. printf("Model: %s\n", model ? model : "<unknown>");
  421. }
  422. #endif
  423. /************************************************************************
  424. *
  425. * This is the next part if the initialization sequence: we are now
  426. * running from RAM and have a "normal" C environment, i. e. global
  427. * data can be written, BSS has been cleared, the stack size in not
  428. * that critical any more, etc.
  429. *
  430. ************************************************************************
  431. */
  432. void board_init_r(gd_t *id, ulong dest_addr)
  433. {
  434. ulong malloc_start;
  435. #if !defined(CONFIG_SYS_NO_FLASH)
  436. ulong flash_size;
  437. #endif
  438. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  439. bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
  440. monitor_flash_len = (ulong)&__rel_dyn_end - (ulong)_start;
  441. /* Enable caches */
  442. enable_caches();
  443. debug("monitor flash len: %08lX\n", monitor_flash_len);
  444. board_init(); /* Setup chipselects */
  445. /*
  446. * TODO: printing of the clock inforamtion of the board is now
  447. * implemented as part of bdinfo command. Currently only support for
  448. * davinci SOC's is added. Remove this check once all the board
  449. * implement this.
  450. */
  451. #ifdef CONFIG_CLOCKS
  452. set_cpu_clk_info(); /* Setup clock information */
  453. #endif
  454. serial_initialize();
  455. debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  456. #ifdef CONFIG_LOGBUFFER
  457. logbuff_init_ptrs();
  458. #endif
  459. #ifdef CONFIG_POST
  460. post_output_backlog();
  461. #endif
  462. /* The Malloc area is immediately below the monitor copy in DRAM */
  463. malloc_start = dest_addr - TOTAL_MALLOC_LEN;
  464. mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
  465. #ifdef CONFIG_ARCH_EARLY_INIT_R
  466. arch_early_init_r();
  467. #endif
  468. power_init_board();
  469. #if !defined(CONFIG_SYS_NO_FLASH)
  470. puts("Flash: ");
  471. flash_size = flash_init();
  472. if (flash_size > 0) {
  473. # ifdef CONFIG_SYS_FLASH_CHECKSUM
  474. print_size(flash_size, "");
  475. /*
  476. * Compute and print flash CRC if flashchecksum is set to 'y'
  477. *
  478. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  479. */
  480. if (getenv_yesno("flashchecksum") == 1) {
  481. printf(" CRC: %08X", crc32(0,
  482. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  483. flash_size));
  484. }
  485. putc('\n');
  486. # else /* !CONFIG_SYS_FLASH_CHECKSUM */
  487. print_size(flash_size, "\n");
  488. # endif /* CONFIG_SYS_FLASH_CHECKSUM */
  489. } else {
  490. puts(failed);
  491. hang();
  492. }
  493. #endif
  494. #if defined(CONFIG_CMD_NAND)
  495. puts("NAND: ");
  496. nand_init(); /* go init the NAND */
  497. #endif
  498. #if defined(CONFIG_CMD_ONENAND)
  499. onenand_init();
  500. #endif
  501. #ifdef CONFIG_GENERIC_MMC
  502. puts("MMC: ");
  503. mmc_initialize(gd->bd);
  504. #endif
  505. #ifdef CONFIG_CMD_SCSI
  506. puts("SCSI: ");
  507. scsi_init();
  508. #endif
  509. #ifdef CONFIG_HAS_DATAFLASH
  510. AT91F_DataflashInit();
  511. dataflash_print_info();
  512. #endif
  513. /* initialize environment */
  514. if (should_load_env())
  515. env_relocate();
  516. else
  517. set_default_env(NULL);
  518. #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
  519. arm_pci_init();
  520. #endif
  521. stdio_init(); /* get the devices list going. */
  522. jumptable_init();
  523. #if defined(CONFIG_API)
  524. /* Initialize API */
  525. api_init();
  526. #endif
  527. console_init_r(); /* fully init console as a device */
  528. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  529. # ifdef CONFIG_OF_CONTROL
  530. /* Put this here so it appears on the LCD, now it is ready */
  531. display_fdt_model(gd->fdt_blob);
  532. # else
  533. checkboard();
  534. # endif
  535. #endif
  536. #if defined(CONFIG_ARCH_MISC_INIT)
  537. /* miscellaneous arch dependent initialisations */
  538. arch_misc_init();
  539. #endif
  540. #if defined(CONFIG_MISC_INIT_R)
  541. /* miscellaneous platform dependent initialisations */
  542. misc_init_r();
  543. #endif
  544. /* set up exceptions */
  545. interrupt_init();
  546. /* enable exceptions */
  547. enable_interrupts();
  548. /* Initialize from environment */
  549. load_addr = getenv_ulong("loadaddr", 16, load_addr);
  550. #ifdef CONFIG_BOARD_LATE_INIT
  551. board_late_init();
  552. #endif
  553. #ifdef CONFIG_BITBANGMII
  554. bb_miiphy_init();
  555. #endif
  556. #if defined(CONFIG_CMD_NET)
  557. puts("Net: ");
  558. eth_initialize();
  559. #if defined(CONFIG_RESET_PHY_R)
  560. debug("Reset Ethernet PHY\n");
  561. reset_phy();
  562. #endif
  563. #endif
  564. #ifdef CONFIG_POST
  565. post_run(NULL, POST_RAM | post_bootmode_get(0));
  566. #endif
  567. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  568. /*
  569. * Export available size of memory for Linux,
  570. * taking into account the protected RAM at top of memory
  571. */
  572. {
  573. ulong pram = 0;
  574. uchar memsz[32];
  575. #ifdef CONFIG_PRAM
  576. pram = getenv_ulong("pram", 10, CONFIG_PRAM);
  577. #endif
  578. #ifdef CONFIG_LOGBUFFER
  579. #ifndef CONFIG_ALT_LB_ADDR
  580. /* Also take the logbuffer into account (pram is in kB) */
  581. pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
  582. #endif
  583. #endif
  584. sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram);
  585. setenv("mem", (char *)memsz);
  586. }
  587. #endif
  588. /* main_loop() can return to retry autoboot, if so just run it again. */
  589. for (;;) {
  590. main_loop();
  591. }
  592. /* NOTREACHED - no way out of command loop except booting */
  593. }