board.c 18 KB

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