board_r.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * (C) Copyright 2002-2006
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2002
  7. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  8. * Marius Groeger <mgroeger@sysgo.de>
  9. *
  10. * SPDX-License-Identifier: GPL-2.0+
  11. */
  12. #include <common.h>
  13. /* TODO: can we just include all these headers whether needed or not? */
  14. #if defined(CONFIG_CMD_BEDBUG)
  15. #include <bedbug/type.h>
  16. #endif
  17. #ifdef CONFIG_HAS_DATAFLASH
  18. #include <dataflash.h>
  19. #endif
  20. #include <environment.h>
  21. #include <fdtdec.h>
  22. #if defined(CONFIG_CMD_IDE)
  23. #include <ide.h>
  24. #endif
  25. #include <initcall.h>
  26. #ifdef CONFIG_PS2KBD
  27. #include <keyboard.h>
  28. #endif
  29. #if defined(CONFIG_CMD_KGDB)
  30. #include <kgdb.h>
  31. #endif
  32. #include <logbuff.h>
  33. #include <malloc.h>
  34. #ifdef CONFIG_BITBANGMII
  35. #include <miiphy.h>
  36. #endif
  37. #include <mmc.h>
  38. #include <nand.h>
  39. #include <onenand_uboot.h>
  40. #include <scsi.h>
  41. #include <serial.h>
  42. #include <spi.h>
  43. #include <stdio_dev.h>
  44. #include <trace.h>
  45. #include <watchdog.h>
  46. #ifdef CONFIG_ADDR_MAP
  47. #include <asm/mmu.h>
  48. #endif
  49. #include <asm/sections.h>
  50. #ifdef CONFIG_X86
  51. #include <asm/init_helpers.h>
  52. #endif
  53. #include <linux/compiler.h>
  54. DECLARE_GLOBAL_DATA_PTR;
  55. ulong monitor_flash_len;
  56. int __board_flash_wp_on(void)
  57. {
  58. /*
  59. * Most flashes can't be detected when write protection is enabled,
  60. * so provide a way to let U-Boot gracefully ignore write protected
  61. * devices.
  62. */
  63. return 0;
  64. }
  65. int board_flash_wp_on(void)
  66. __attribute__ ((weak, alias("__board_flash_wp_on")));
  67. void __cpu_secondary_init_r(void)
  68. {
  69. }
  70. void cpu_secondary_init_r(void)
  71. __attribute__ ((weak, alias("__cpu_secondary_init_r")));
  72. static int initr_secondary_cpu(void)
  73. {
  74. /*
  75. * after non-volatile devices & environment is setup and cpu code have
  76. * another round to deal with any initialization that might require
  77. * full access to the environment or loading of some image (firmware)
  78. * from a non-volatile device
  79. */
  80. /* TODO: maybe define this for all archs? */
  81. cpu_secondary_init_r();
  82. return 0;
  83. }
  84. static int initr_trace(void)
  85. {
  86. #ifdef CONFIG_TRACE
  87. trace_init(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE);
  88. #endif
  89. return 0;
  90. }
  91. static int initr_reloc(void)
  92. {
  93. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  94. bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
  95. return 0;
  96. }
  97. #ifdef CONFIG_ARM
  98. /*
  99. * Some of these functions are needed purely because the functions they
  100. * call return void. If we change them to return 0, these stubs can go away.
  101. */
  102. static int initr_caches(void)
  103. {
  104. /* Enable caches */
  105. enable_caches();
  106. return 0;
  107. }
  108. #endif
  109. __weak int fixup_cpu(void)
  110. {
  111. return 0;
  112. }
  113. static int initr_reloc_global_data(void)
  114. {
  115. #ifdef __ARM__
  116. monitor_flash_len = _end - __image_copy_start;
  117. #elif !defined(CONFIG_SANDBOX)
  118. monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
  119. #endif
  120. #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
  121. /*
  122. * The gd->cpu pointer is set to an address in flash before relocation.
  123. * We need to update it to point to the same CPU entry in RAM.
  124. * TODO: why not just add gd->reloc_ofs?
  125. */
  126. gd->arch.cpu += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
  127. /*
  128. * If we didn't know the cpu mask & # cores, we can save them of
  129. * now rather than 'computing' them constantly
  130. */
  131. fixup_cpu();
  132. #endif
  133. #ifdef CONFIG_SYS_EXTRA_ENV_RELOC
  134. /*
  135. * Some systems need to relocate the env_addr pointer early because the
  136. * location it points to will get invalidated before env_relocate is
  137. * called. One example is on systems that might use a L2 or L3 cache
  138. * in SRAM mode and initialize that cache from SRAM mode back to being
  139. * a cache in cpu_init_r.
  140. */
  141. gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
  142. #endif
  143. return 0;
  144. }
  145. static int initr_serial(void)
  146. {
  147. serial_initialize();
  148. return 0;
  149. }
  150. #ifdef CONFIG_PPC
  151. static int initr_trap(void)
  152. {
  153. /*
  154. * Setup trap handlers
  155. */
  156. trap_init(gd->relocaddr);
  157. return 0;
  158. }
  159. #endif
  160. #ifdef CONFIG_ADDR_MAP
  161. static int initr_addr_map(void)
  162. {
  163. init_addr_map();
  164. return 0;
  165. }
  166. #endif
  167. #ifdef CONFIG_LOGBUFFER
  168. unsigned long logbuffer_base(void)
  169. {
  170. return gd->ram_top - LOGBUFF_LEN;
  171. }
  172. static int initr_logbuffer(void)
  173. {
  174. logbuff_init_ptrs();
  175. return 0;
  176. }
  177. #endif
  178. #ifdef CONFIG_POST
  179. static int initr_post_backlog(void)
  180. {
  181. post_output_backlog();
  182. return 0;
  183. }
  184. #endif
  185. #ifdef CONFIG_SYS_DELAYED_ICACHE
  186. static int initr_icache_enable(void)
  187. {
  188. return 0;
  189. }
  190. #endif
  191. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  192. static int initr_unlock_ram_in_cache(void)
  193. {
  194. unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
  195. return 0;
  196. }
  197. #endif
  198. #ifdef CONFIG_PCI
  199. static int initr_pci(void)
  200. {
  201. pci_init();
  202. return 0;
  203. }
  204. #endif
  205. #ifdef CONFIG_WINBOND_83C553
  206. static int initr_w83c553f(void)
  207. {
  208. /*
  209. * Initialise the ISA bridge
  210. */
  211. initialise_w83c553f();
  212. return 0;
  213. }
  214. #endif
  215. static int initr_barrier(void)
  216. {
  217. #ifdef CONFIG_PPC
  218. /* TODO: Can we not use dmb() macros for this? */
  219. asm("sync ; isync");
  220. #endif
  221. return 0;
  222. }
  223. static int initr_malloc(void)
  224. {
  225. ulong malloc_start;
  226. /* The malloc area is immediately below the monitor copy in DRAM */
  227. malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
  228. mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
  229. TOTAL_MALLOC_LEN);
  230. return 0;
  231. }
  232. __weak int power_init_board(void)
  233. {
  234. return 0;
  235. }
  236. static int initr_announce(void)
  237. {
  238. debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr);
  239. return 0;
  240. }
  241. #if !defined(CONFIG_SYS_NO_FLASH)
  242. static int initr_flash(void)
  243. {
  244. ulong flash_size = 0;
  245. bd_t *bd = gd->bd;
  246. int ok;
  247. puts("Flash: ");
  248. if (board_flash_wp_on()) {
  249. printf("Uninitialized - Write Protect On\n");
  250. /* Since WP is on, we can't find real size. Set to 0 */
  251. ok = 1;
  252. } else {
  253. flash_size = flash_init();
  254. ok = flash_size > 0;
  255. }
  256. if (!ok) {
  257. puts("*** failed ***\n");
  258. #ifdef CONFIG_PPC
  259. /* Why does PPC do this? */
  260. hang();
  261. #endif
  262. return -1;
  263. }
  264. print_size(flash_size, "");
  265. #ifdef CONFIG_SYS_FLASH_CHECKSUM
  266. /*
  267. * Compute and print flash CRC if flashchecksum is set to 'y'
  268. *
  269. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  270. */
  271. if (getenv_yesno("flashchecksum") == 1) {
  272. printf(" CRC: %08X", crc32(0,
  273. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  274. flash_size));
  275. }
  276. #endif /* CONFIG_SYS_FLASH_CHECKSUM */
  277. putc('\n');
  278. /* update start of FLASH memory */
  279. #ifdef CONFIG_SYS_FLASH_BASE
  280. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
  281. #endif
  282. /* size of FLASH memory (final value) */
  283. bd->bi_flashsize = flash_size;
  284. #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
  285. /* Make a update of the Memctrl. */
  286. update_flash_size(flash_size);
  287. #endif
  288. #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
  289. /* flash mapped at end of memory map */
  290. bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
  291. #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
  292. bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
  293. #endif
  294. return 0;
  295. }
  296. #endif
  297. #ifdef CONFIG_PPC
  298. static int initr_spi(void)
  299. {
  300. /* PPC does this here */
  301. #ifdef CONFIG_SPI
  302. #if !defined(CONFIG_ENV_IS_IN_EEPROM)
  303. spi_init_f();
  304. #endif
  305. spi_init_r();
  306. #endif
  307. return 0;
  308. }
  309. #endif
  310. #ifdef CONFIG_CMD_NAND
  311. /* go init the NAND */
  312. int initr_nand(void)
  313. {
  314. puts("NAND: ");
  315. nand_init();
  316. return 0;
  317. }
  318. #endif
  319. #if defined(CONFIG_CMD_ONENAND)
  320. /* go init the NAND */
  321. int initr_onenand(void)
  322. {
  323. puts("NAND: ");
  324. onenand_init();
  325. return 0;
  326. }
  327. #endif
  328. #ifdef CONFIG_GENERIC_MMC
  329. int initr_mmc(void)
  330. {
  331. puts("MMC: ");
  332. mmc_initialize(gd->bd);
  333. return 0;
  334. }
  335. #endif
  336. #ifdef CONFIG_HAS_DATAFLASH
  337. int initr_dataflash(void)
  338. {
  339. AT91F_DataflashInit();
  340. dataflash_print_info();
  341. return 0;
  342. }
  343. #endif
  344. /*
  345. * Tell if it's OK to load the environment early in boot.
  346. *
  347. * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
  348. * if this is OK (defaulting to saying it's OK).
  349. *
  350. * NOTE: Loading the environment early can be a bad idea if security is
  351. * important, since no verification is done on the environment.
  352. *
  353. * @return 0 if environment should not be loaded, !=0 if it is ok to load
  354. */
  355. static int should_load_env(void)
  356. {
  357. #ifdef CONFIG_OF_CONTROL
  358. return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
  359. #elif defined CONFIG_DELAY_ENVIRONMENT
  360. return 0;
  361. #else
  362. return 1;
  363. #endif
  364. }
  365. static int initr_env(void)
  366. {
  367. /* initialize environment */
  368. if (should_load_env())
  369. env_relocate();
  370. else
  371. set_default_env(NULL);
  372. /* Initialize from environment */
  373. load_addr = getenv_ulong("loadaddr", 16, load_addr);
  374. #if defined(CONFIG_SYS_EXTBDINFO)
  375. #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
  376. #if defined(CONFIG_I2CFAST)
  377. /*
  378. * set bi_iic_fast for linux taking environment variable
  379. * "i2cfast" into account
  380. */
  381. {
  382. char *s = getenv("i2cfast");
  383. if (s && ((*s == 'y') || (*s == 'Y'))) {
  384. gd->bd->bi_iic_fast[0] = 1;
  385. gd->bd->bi_iic_fast[1] = 1;
  386. }
  387. }
  388. #endif /* CONFIG_I2CFAST */
  389. #endif /* CONFIG_405GP, CONFIG_405EP */
  390. #endif /* CONFIG_SYS_EXTBDINFO */
  391. return 0;
  392. }
  393. #ifdef CONFIG_HERMES
  394. static int initr_hermes(void)
  395. {
  396. if ((gd->board_type >> 16) == 2)
  397. gd->bd->bi_ethspeed = gd->board_type & 0xFFFF;
  398. else
  399. gd->bd->bi_ethspeed = 0xFFFF;
  400. return 0;
  401. }
  402. static int initr_hermes_start(void)
  403. {
  404. if (gd->bd->bi_ethspeed != 0xFFFF)
  405. hermes_start_lxt980((int) gd->bd->bi_ethspeed);
  406. return 0;
  407. }
  408. #endif
  409. #ifdef CONFIG_SC3
  410. /* TODO: with new initcalls, move this into the driver */
  411. extern void sc3_read_eeprom(void);
  412. static int initr_sc3_read_eeprom(void)
  413. {
  414. sc3_read_eeprom();
  415. return 0;
  416. }
  417. #endif
  418. static int initr_jumptable(void)
  419. {
  420. jumptable_init();
  421. return 0;
  422. }
  423. #if defined(CONFIG_API)
  424. static int initr_api(void)
  425. {
  426. /* Initialize API */
  427. api_init();
  428. return 0;
  429. }
  430. #endif
  431. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  432. static int show_model_r(void)
  433. {
  434. /* Put this here so it appears on the LCD, now it is ready */
  435. # ifdef CONFIG_OF_CONTROL
  436. const char *model;
  437. model = (char *)fdt_getprop(gd->fdt_blob, 0, "model", NULL);
  438. printf("Model: %s\n", model ? model : "<unknown>");
  439. # else
  440. checkboard();
  441. # endif
  442. }
  443. #endif
  444. /* enable exceptions */
  445. #ifdef CONFIG_ARM
  446. static int initr_enable_interrupts(void)
  447. {
  448. enable_interrupts();
  449. return 0;
  450. }
  451. #endif
  452. #ifdef CONFIG_CMD_NET
  453. static int initr_ethaddr(void)
  454. {
  455. bd_t *bd = gd->bd;
  456. /* kept around for legacy kernels only ... ignore the next section */
  457. eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
  458. #ifdef CONFIG_HAS_ETH1
  459. eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
  460. #endif
  461. #ifdef CONFIG_HAS_ETH2
  462. eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
  463. #endif
  464. #ifdef CONFIG_HAS_ETH3
  465. eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
  466. #endif
  467. #ifdef CONFIG_HAS_ETH4
  468. eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
  469. #endif
  470. #ifdef CONFIG_HAS_ETH5
  471. eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
  472. #endif
  473. return 0;
  474. }
  475. #endif /* CONFIG_CMD_NET */
  476. #ifdef CONFIG_CMD_KGDB
  477. static int initr_kgdb(void)
  478. {
  479. puts("KGDB: ");
  480. kgdb_init();
  481. return 0;
  482. }
  483. #endif
  484. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  485. static int initr_status_led(void)
  486. {
  487. status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
  488. return 0;
  489. }
  490. #endif
  491. #if defined(CONFIG_CMD_SCSI)
  492. static int initr_scsi(void)
  493. {
  494. /* Not supported properly on ARM yet */
  495. #ifndef CONFIG_ARM
  496. puts("SCSI: ");
  497. scsi_init();
  498. #endif
  499. return 0;
  500. }
  501. #endif /* CONFIG_CMD_NET */
  502. #if defined(CONFIG_CMD_DOC)
  503. static int initr_doc(void)
  504. {
  505. puts("DOC: ");
  506. doc_init();
  507. }
  508. #endif
  509. #ifdef CONFIG_BITBANGMII
  510. static int initr_bbmii(void)
  511. {
  512. bb_miiphy_init();
  513. return 0;
  514. }
  515. #endif
  516. #ifdef CONFIG_CMD_NET
  517. static int initr_net(void)
  518. {
  519. puts("Net: ");
  520. eth_initialize(gd->bd);
  521. #if defined(CONFIG_RESET_PHY_R)
  522. debug("Reset Ethernet PHY\n");
  523. reset_phy();
  524. #endif
  525. return 0;
  526. }
  527. #endif
  528. #ifdef CONFIG_POST
  529. static int initr_post(void)
  530. {
  531. post_run(NULL, POST_RAM | post_bootmode_get(0));
  532. return 0;
  533. }
  534. #endif
  535. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
  536. static int initr_pcmcia(void)
  537. {
  538. puts("PCMCIA:");
  539. pcmcia_init();
  540. return 0;
  541. }
  542. #endif
  543. #if defined(CONFIG_CMD_IDE)
  544. static int initr_ide(void)
  545. {
  546. #ifdef CONFIG_IDE_8xx_PCCARD
  547. puts("PCMCIA:");
  548. #else
  549. puts("IDE: ");
  550. #endif
  551. #if defined(CONFIG_START_IDE)
  552. if (board_start_ide())
  553. ide_init();
  554. #else
  555. ide_init();
  556. #endif
  557. return 0;
  558. }
  559. #endif
  560. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  561. /*
  562. * Export available size of memory for Linux, taking into account the
  563. * protected RAM at top of memory
  564. */
  565. int initr_mem(void)
  566. {
  567. ulong pram = 0;
  568. char memsz[32];
  569. # ifdef CONFIG_PRAM
  570. pram = getenv_ulong("pram", 10, CONFIG_PRAM);
  571. # endif
  572. # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
  573. /* Also take the logbuffer into account (pram is in kB) */
  574. pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
  575. # endif
  576. sprintf(memsz, "%ldk", (gd->ram_size / 1024) - pram);
  577. setenv("mem", memsz);
  578. return 0;
  579. }
  580. #endif
  581. #ifdef CONFIG_CMD_BEDBUG
  582. static int initr_bedbug(void)
  583. {
  584. bedbug_init();
  585. return 0;
  586. }
  587. #endif
  588. #ifdef CONFIG_PS2KBD
  589. static int initr_kbd(void)
  590. {
  591. puts("PS/2: ");
  592. kbd_init();
  593. return 0;
  594. }
  595. #endif
  596. #ifdef CONFIG_MODEM_SUPPORT
  597. static int initr_modem(void)
  598. {
  599. /* TODO: with new initcalls, move this into the driver */
  600. extern int do_mdm_init;
  601. do_mdm_init = gd->do_mdm_init;
  602. return 0;
  603. }
  604. #endif
  605. static int run_main_loop(void)
  606. {
  607. #ifdef CONFIG_SANDBOX
  608. sandbox_main_loop_init();
  609. #endif
  610. /* main_loop() can return to retry autoboot, if so just run it again */
  611. for (;;)
  612. main_loop();
  613. return 0;
  614. }
  615. /*
  616. * Over time we hope to remove these functions with code fragments and
  617. * stub funtcions, and instead call the relevant function directly.
  618. *
  619. * We also hope to remove most of the driver-related init and do it if/when
  620. * the driver is later used.
  621. *
  622. * TODO: perhaps reset the watchdog in the initcall function after each call?
  623. */
  624. init_fnc_t init_sequence_r[] = {
  625. initr_trace,
  626. initr_reloc,
  627. /* TODO: could x86/PPC have this also perhaps? */
  628. #ifdef CONFIG_ARM
  629. initr_caches,
  630. board_init, /* Setup chipselects */
  631. #endif
  632. /*
  633. * TODO: printing of the clock inforamtion of the board is now
  634. * implemented as part of bdinfo command. Currently only support for
  635. * davinci SOC's is added. Remove this check once all the board
  636. * implement this.
  637. */
  638. #ifdef CONFIG_CLOCKS
  639. set_cpu_clk_info, /* Setup clock information */
  640. #endif
  641. initr_reloc_global_data,
  642. initr_serial,
  643. initr_announce,
  644. INIT_FUNC_WATCHDOG_RESET
  645. #ifdef CONFIG_PPC
  646. initr_trap,
  647. #endif
  648. #ifdef CONFIG_ADDR_MAP
  649. initr_addr_map,
  650. #endif
  651. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  652. board_early_init_r,
  653. #endif
  654. INIT_FUNC_WATCHDOG_RESET
  655. #ifdef CONFIG_LOGBUFFER
  656. initr_logbuffer,
  657. #endif
  658. #ifdef CONFIG_POST
  659. initr_post_backlog,
  660. #endif
  661. INIT_FUNC_WATCHDOG_RESET
  662. #ifdef CONFIG_SYS_DELAYED_ICACHE
  663. initr_icache_enable,
  664. #endif
  665. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  666. initr_unlock_ram_in_cache,
  667. #endif
  668. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
  669. /*
  670. * Do early PCI configuration _before_ the flash gets initialised,
  671. * because PCU ressources are crucial for flash access on some boards.
  672. */
  673. initr_pci,
  674. #endif
  675. #ifdef CONFIG_WINBOND_83C553
  676. initr_w83c553f,
  677. #endif
  678. initr_barrier,
  679. initr_malloc,
  680. bootstage_relocate,
  681. #ifdef CONFIG_ARCH_EARLY_INIT_R
  682. arch_early_init_r,
  683. #endif
  684. power_init_board,
  685. #ifndef CONFIG_SYS_NO_FLASH
  686. initr_flash,
  687. #endif
  688. INIT_FUNC_WATCHDOG_RESET
  689. #if defined(CONFIG_PPC) || defined(CONFIG_X86)
  690. /* initialize higher level parts of CPU like time base and timers */
  691. cpu_init_r,
  692. #endif
  693. #ifdef CONFIG_PPC
  694. initr_spi,
  695. #endif
  696. #if defined(CONFIG_X86) && defined(CONFIG_SPI)
  697. init_func_spi,
  698. #endif
  699. #ifdef CONFIG_CMD_NAND
  700. initr_nand,
  701. #endif
  702. #ifdef CONFIG_CMD_ONENAND
  703. initr_onenand,
  704. #endif
  705. #ifdef CONFIG_GENERIC_MMC
  706. initr_mmc,
  707. #endif
  708. #ifdef CONFIG_HAS_DATAFLASH
  709. initr_dataflash,
  710. #endif
  711. initr_env,
  712. INIT_FUNC_WATCHDOG_RESET
  713. initr_secondary_cpu,
  714. #ifdef CONFIG_SC3
  715. initr_sc3_read_eeprom,
  716. #endif
  717. #ifdef CONFIG_HERMES
  718. initr_hermes,
  719. #endif
  720. #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
  721. mac_read_from_eeprom,
  722. #endif
  723. INIT_FUNC_WATCHDOG_RESET
  724. #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
  725. /*
  726. * Do pci configuration
  727. */
  728. initr_pci,
  729. #endif
  730. stdio_init,
  731. initr_jumptable,
  732. #ifdef CONFIG_API
  733. initr_api,
  734. #endif
  735. console_init_r, /* fully init console as a device */
  736. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  737. show_model_r,
  738. #endif
  739. #ifdef CONFIG_ARCH_MISC_INIT
  740. arch_misc_init, /* miscellaneous arch-dependent init */
  741. #endif
  742. #ifdef CONFIG_MISC_INIT_R
  743. misc_init_r, /* miscellaneous platform-dependent init */
  744. #endif
  745. #ifdef CONFIG_HERMES
  746. initr_hermes_start,
  747. #endif
  748. INIT_FUNC_WATCHDOG_RESET
  749. #ifdef CONFIG_CMD_KGDB
  750. initr_kgdb,
  751. #endif
  752. #ifdef CONFIG_X86
  753. board_early_init_r,
  754. #endif
  755. interrupt_init,
  756. #if defined(CONFIG_ARM) || defined(CONFIG_x86)
  757. initr_enable_interrupts,
  758. #endif
  759. #ifdef CONFIG_X86
  760. timer_init, /* initialize timer */
  761. #endif
  762. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  763. initr_status_led,
  764. #endif
  765. /* PPC has a udelay(20) here dating from 2002. Why? */
  766. #ifdef CONFIG_CMD_NET
  767. initr_ethaddr,
  768. #endif
  769. #ifdef CONFIG_BOARD_LATE_INIT
  770. board_late_init,
  771. #endif
  772. #ifdef CONFIG_CMD_SCSI
  773. INIT_FUNC_WATCHDOG_RESET
  774. initr_scsi,
  775. #endif
  776. #ifdef CONFIG_CMD_DOC
  777. INIT_FUNC_WATCHDOG_RESET
  778. initr_doc,
  779. #endif
  780. #ifdef CONFIG_BITBANGMII
  781. initr_bbmii,
  782. #endif
  783. #ifdef CONFIG_CMD_NET
  784. INIT_FUNC_WATCHDOG_RESET
  785. initr_net,
  786. #endif
  787. #ifdef CONFIG_POST
  788. initr_post,
  789. #endif
  790. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
  791. initr_pcmcia,
  792. #endif
  793. #if defined(CONFIG_CMD_IDE)
  794. initr_ide,
  795. #endif
  796. #ifdef CONFIG_LAST_STAGE_INIT
  797. INIT_FUNC_WATCHDOG_RESET
  798. /*
  799. * Some parts can be only initialized if all others (like
  800. * Interrupts) are up and running (i.e. the PC-style ISA
  801. * keyboard).
  802. */
  803. last_stage_init,
  804. #endif
  805. #ifdef CONFIG_CMD_BEDBUG
  806. INIT_FUNC_WATCHDOG_RESET
  807. initr_bedbug,
  808. #endif
  809. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  810. initr_mem,
  811. #endif
  812. #ifdef CONFIG_PS2KBD
  813. initr_kbd,
  814. #endif
  815. #ifdef CONFIG_MODEM_SUPPORT
  816. initr_modem,
  817. #endif
  818. run_main_loop,
  819. };
  820. void board_init_r(gd_t *new_gd, ulong dest_addr)
  821. {
  822. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  823. int i;
  824. #endif
  825. #ifndef CONFIG_X86
  826. gd = new_gd;
  827. #endif
  828. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  829. for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
  830. init_sequence_r[i] += gd->reloc_off;
  831. #endif
  832. if (initcall_run_list(init_sequence_r))
  833. hang();
  834. /* NOTREACHED - run_main_loop() does not return */
  835. hang();
  836. }