board_r.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2011 The Chromium OS Authors.
  4. * (C) Copyright 2002-2006
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * (C) Copyright 2002
  8. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  9. * Marius Groeger <mgroeger@sysgo.de>
  10. */
  11. #include <common.h>
  12. #include <api.h>
  13. #include <bootstage.h>
  14. #include <cpu_func.h>
  15. #include <exports.h>
  16. #include <flash.h>
  17. #include <hang.h>
  18. #include <image.h>
  19. #include <irq_func.h>
  20. #include <log.h>
  21. #include <net.h>
  22. #include <asm/cache.h>
  23. #include <asm/global_data.h>
  24. #include <u-boot/crc.h>
  25. #include <binman.h>
  26. #include <command.h>
  27. #include <console.h>
  28. #include <dm.h>
  29. #include <env.h>
  30. #include <env_internal.h>
  31. #include <fdtdec.h>
  32. #include <ide.h>
  33. #include <init.h>
  34. #include <initcall.h>
  35. #include <kgdb.h>
  36. #include <irq_func.h>
  37. #include <malloc.h>
  38. #include <mapmem.h>
  39. #include <miiphy.h>
  40. #include <mmc.h>
  41. #include <mux.h>
  42. #include <nand.h>
  43. #include <of_live.h>
  44. #include <onenand_uboot.h>
  45. #include <pvblock.h>
  46. #include <scsi.h>
  47. #include <serial.h>
  48. #include <status_led.h>
  49. #include <stdio_dev.h>
  50. #include <timer.h>
  51. #include <trace.h>
  52. #include <watchdog.h>
  53. #include <xen.h>
  54. #include <asm/sections.h>
  55. #include <dm/root.h>
  56. #include <dm/ofnode.h>
  57. #include <linux/compiler.h>
  58. #include <linux/err.h>
  59. #include <efi_loader.h>
  60. #include <wdt.h>
  61. #include <asm-generic/gpio.h>
  62. #include <efi_loader.h>
  63. DECLARE_GLOBAL_DATA_PTR;
  64. ulong monitor_flash_len;
  65. __weak int board_flash_wp_on(void)
  66. {
  67. /*
  68. * Most flashes can't be detected when write protection is enabled,
  69. * so provide a way to let U-Boot gracefully ignore write protected
  70. * devices.
  71. */
  72. return 0;
  73. }
  74. __weak int cpu_secondary_init_r(void)
  75. {
  76. return 0;
  77. }
  78. static int initr_trace(void)
  79. {
  80. #ifdef CONFIG_TRACE
  81. trace_init(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE);
  82. #endif
  83. return 0;
  84. }
  85. static int initr_reloc(void)
  86. {
  87. /* tell others: relocation done */
  88. gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT;
  89. return 0;
  90. }
  91. #if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
  92. /*
  93. * Some of these functions are needed purely because the functions they
  94. * call return void. If we change them to return 0, these stubs can go away.
  95. */
  96. static int initr_caches(void)
  97. {
  98. /* Enable caches */
  99. enable_caches();
  100. return 0;
  101. }
  102. #endif
  103. __weak int fixup_cpu(void)
  104. {
  105. return 0;
  106. }
  107. static int initr_reloc_global_data(void)
  108. {
  109. #ifdef __ARM__
  110. monitor_flash_len = _end - __image_copy_start;
  111. #elif defined(CONFIG_NDS32) || defined(CONFIG_RISCV)
  112. monitor_flash_len = (ulong)&_end - (ulong)&_start;
  113. #elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
  114. monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
  115. #endif
  116. #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
  117. /*
  118. * The gd->cpu pointer is set to an address in flash before relocation.
  119. * We need to update it to point to the same CPU entry in RAM.
  120. * TODO: why not just add gd->reloc_ofs?
  121. */
  122. gd->arch.cpu += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
  123. /*
  124. * If we didn't know the cpu mask & # cores, we can save them of
  125. * now rather than 'computing' them constantly
  126. */
  127. fixup_cpu();
  128. #endif
  129. #ifdef CONFIG_SYS_RELOC_GD_ENV_ADDR
  130. /*
  131. * Relocate the early env_addr pointer unless we know it is not inside
  132. * the binary. Some systems need this and for the rest, it doesn't hurt.
  133. */
  134. gd->env_addr += gd->reloc_off;
  135. #endif
  136. #ifdef CONFIG_OF_EMBED
  137. /*
  138. * The fdt_blob needs to be moved to new relocation address
  139. * incase of FDT blob is embedded with in image
  140. */
  141. gd->fdt_blob += gd->reloc_off;
  142. #endif
  143. #ifdef CONFIG_EFI_LOADER
  144. /*
  145. * On the ARM architecture gd is mapped to a fixed register (r9 or x18).
  146. * As this register may be overwritten by an EFI payload we save it here
  147. * and restore it on every callback entered.
  148. */
  149. efi_save_gd();
  150. efi_runtime_relocate(gd->relocaddr, NULL);
  151. #endif
  152. return 0;
  153. }
  154. __weak int arch_initr_trap(void)
  155. {
  156. return 0;
  157. }
  158. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  159. static int initr_unlock_ram_in_cache(void)
  160. {
  161. unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
  162. return 0;
  163. }
  164. #endif
  165. static int initr_barrier(void)
  166. {
  167. #ifdef CONFIG_PPC
  168. /* TODO: Can we not use dmb() macros for this? */
  169. asm("sync ; isync");
  170. #endif
  171. return 0;
  172. }
  173. static int initr_malloc(void)
  174. {
  175. ulong malloc_start;
  176. #if CONFIG_VAL(SYS_MALLOC_F_LEN)
  177. debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
  178. gd->malloc_ptr / 1024);
  179. #endif
  180. /* The malloc area is immediately below the monitor copy in DRAM */
  181. /*
  182. * This value MUST match the value of gd->start_addr_sp in board_f.c:
  183. * reserve_noncached().
  184. */
  185. malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
  186. mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
  187. TOTAL_MALLOC_LEN);
  188. return 0;
  189. }
  190. static int initr_of_live(void)
  191. {
  192. if (CONFIG_IS_ENABLED(OF_LIVE)) {
  193. int ret;
  194. bootstage_start(BOOTSTAGE_ID_ACCUM_OF_LIVE, "of_live");
  195. ret = of_live_build(gd->fdt_blob,
  196. (struct device_node **)gd_of_root_ptr());
  197. bootstage_accum(BOOTSTAGE_ID_ACCUM_OF_LIVE);
  198. if (ret)
  199. return ret;
  200. }
  201. return 0;
  202. }
  203. #ifdef CONFIG_DM
  204. static int initr_dm(void)
  205. {
  206. int ret;
  207. /* Save the pre-reloc driver model and start a new one */
  208. gd->dm_root_f = gd->dm_root;
  209. gd->dm_root = NULL;
  210. #ifdef CONFIG_TIMER
  211. gd->timer = NULL;
  212. #endif
  213. bootstage_start(BOOTSTAGE_ID_ACCUM_DM_R, "dm_r");
  214. ret = dm_init_and_scan(false);
  215. bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_R);
  216. if (ret)
  217. return ret;
  218. return 0;
  219. }
  220. #endif
  221. static int initr_dm_devices(void)
  222. {
  223. int ret;
  224. if (IS_ENABLED(CONFIG_TIMER_EARLY)) {
  225. ret = dm_timer_init();
  226. if (ret)
  227. return ret;
  228. }
  229. if (IS_ENABLED(CONFIG_MULTIPLEXER)) {
  230. /*
  231. * Initialize the multiplexer controls to their default state.
  232. * This must be done early as other drivers may unknowingly
  233. * rely on it.
  234. */
  235. ret = dm_mux_init();
  236. if (ret)
  237. return ret;
  238. }
  239. return 0;
  240. }
  241. static int initr_bootstage(void)
  242. {
  243. bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
  244. return 0;
  245. }
  246. __weak int power_init_board(void)
  247. {
  248. return 0;
  249. }
  250. static int initr_announce(void)
  251. {
  252. debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr);
  253. return 0;
  254. }
  255. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  256. static int initr_manual_reloc_cmdtable(void)
  257. {
  258. fixup_cmdtable(ll_entry_start(struct cmd_tbl, cmd),
  259. ll_entry_count(struct cmd_tbl, cmd));
  260. return 0;
  261. }
  262. #endif
  263. static int initr_binman(void)
  264. {
  265. int ret;
  266. if (!CONFIG_IS_ENABLED(BINMAN_FDT))
  267. return 0;
  268. ret = binman_init();
  269. if (ret)
  270. printf("binman_init failed:%d\n", ret);
  271. return ret;
  272. }
  273. #if defined(CONFIG_MTD_NOR_FLASH)
  274. __weak int is_flash_available(void)
  275. {
  276. return 1;
  277. }
  278. static int initr_flash(void)
  279. {
  280. ulong flash_size = 0;
  281. struct bd_info *bd = gd->bd;
  282. if (!is_flash_available())
  283. return 0;
  284. puts("Flash: ");
  285. if (board_flash_wp_on())
  286. printf("Uninitialized - Write Protect On\n");
  287. else
  288. flash_size = flash_init();
  289. print_size(flash_size, "");
  290. #ifdef CONFIG_SYS_FLASH_CHECKSUM
  291. /*
  292. * Compute and print flash CRC if flashchecksum is set to 'y'
  293. *
  294. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  295. */
  296. if (env_get_yesno("flashchecksum") == 1) {
  297. const uchar *flash_base = (const uchar *)CONFIG_SYS_FLASH_BASE;
  298. printf(" CRC: %08X", crc32(0,
  299. flash_base,
  300. flash_size));
  301. }
  302. #endif /* CONFIG_SYS_FLASH_CHECKSUM */
  303. putc('\n');
  304. /* update start of FLASH memory */
  305. #ifdef CONFIG_SYS_FLASH_BASE
  306. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
  307. #endif
  308. /* size of FLASH memory (final value) */
  309. bd->bi_flashsize = flash_size;
  310. #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
  311. /* Make a update of the Memctrl. */
  312. update_flash_size(flash_size);
  313. #endif
  314. #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
  315. /* flash mapped at end of memory map */
  316. bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
  317. #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
  318. bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
  319. #endif
  320. return 0;
  321. }
  322. #endif
  323. #ifdef CONFIG_CMD_NAND
  324. /* go init the NAND */
  325. static int initr_nand(void)
  326. {
  327. puts("NAND: ");
  328. nand_init();
  329. printf("%lu MiB\n", nand_size() / 1024);
  330. return 0;
  331. }
  332. #endif
  333. #if defined(CONFIG_CMD_ONENAND)
  334. /* go init the NAND */
  335. static int initr_onenand(void)
  336. {
  337. puts("NAND: ");
  338. onenand_init();
  339. return 0;
  340. }
  341. #endif
  342. #ifdef CONFIG_MMC
  343. static int initr_mmc(void)
  344. {
  345. puts("MMC: ");
  346. mmc_initialize(gd->bd);
  347. return 0;
  348. }
  349. #endif
  350. #ifdef CONFIG_PVBLOCK
  351. static int initr_pvblock(void)
  352. {
  353. puts("PVBLOCK: ");
  354. pvblock_init();
  355. return 0;
  356. }
  357. #endif
  358. /*
  359. * Tell if it's OK to load the environment early in boot.
  360. *
  361. * If CONFIG_OF_CONTROL is defined, we'll check with the FDT to see
  362. * if this is OK (defaulting to saying it's OK).
  363. *
  364. * NOTE: Loading the environment early can be a bad idea if security is
  365. * important, since no verification is done on the environment.
  366. *
  367. * Return: 0 if environment should not be loaded, !=0 if it is ok to load
  368. */
  369. static int should_load_env(void)
  370. {
  371. if (IS_ENABLED(CONFIG_OF_CONTROL))
  372. return ofnode_conf_read_int("load-environment", 1);
  373. if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT))
  374. return 0;
  375. return 1;
  376. }
  377. static int initr_env(void)
  378. {
  379. /* initialize environment */
  380. if (should_load_env())
  381. env_relocate();
  382. else
  383. env_set_default(NULL, 0);
  384. env_import_fdt();
  385. if (IS_ENABLED(CONFIG_OF_CONTROL))
  386. env_set_hex("fdtcontroladdr",
  387. (unsigned long)map_to_sysmem(gd->fdt_blob));
  388. /* Initialize from environment */
  389. image_load_addr = env_get_ulong("loadaddr", 16, image_load_addr);
  390. return 0;
  391. }
  392. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  393. static int initr_malloc_bootparams(void)
  394. {
  395. gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN);
  396. if (!gd->bd->bi_boot_params) {
  397. puts("WARNING: Cannot allocate space for boot parameters\n");
  398. return -ENOMEM;
  399. }
  400. return 0;
  401. }
  402. #endif
  403. #ifdef CONFIG_CMD_NET
  404. static int initr_ethaddr(void)
  405. {
  406. struct bd_info *bd = gd->bd;
  407. /* kept around for legacy kernels only ... ignore the next section */
  408. eth_env_get_enetaddr("ethaddr", bd->bi_enetaddr);
  409. return 0;
  410. }
  411. #endif /* CONFIG_CMD_NET */
  412. #if defined(CONFIG_LED_STATUS)
  413. static int initr_status_led(void)
  414. {
  415. #if defined(CONFIG_LED_STATUS_BOOT)
  416. status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING);
  417. #else
  418. status_led_init();
  419. #endif
  420. return 0;
  421. }
  422. #endif
  423. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  424. static int initr_scsi(void)
  425. {
  426. puts("SCSI: ");
  427. scsi_init();
  428. puts("\n");
  429. return 0;
  430. }
  431. #endif
  432. #ifdef CONFIG_CMD_NET
  433. static int initr_net(void)
  434. {
  435. puts("Net: ");
  436. eth_initialize();
  437. #if defined(CONFIG_RESET_PHY_R)
  438. debug("Reset Ethernet PHY\n");
  439. reset_phy();
  440. #endif
  441. return 0;
  442. }
  443. #endif
  444. #ifdef CONFIG_POST
  445. static int initr_post(void)
  446. {
  447. post_run(NULL, POST_RAM | post_bootmode_get(0));
  448. return 0;
  449. }
  450. #endif
  451. #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
  452. static int initr_ide(void)
  453. {
  454. puts("IDE: ");
  455. #if defined(CONFIG_START_IDE)
  456. if (board_start_ide())
  457. ide_init();
  458. #else
  459. ide_init();
  460. #endif
  461. return 0;
  462. }
  463. #endif
  464. #if defined(CONFIG_PRAM)
  465. /*
  466. * Export available size of memory for Linux, taking into account the
  467. * protected RAM at top of memory
  468. */
  469. int initr_mem(void)
  470. {
  471. ulong pram = 0;
  472. char memsz[32];
  473. pram = env_get_ulong("pram", 10, CONFIG_PRAM);
  474. sprintf(memsz, "%ldk", (long int)((gd->ram_size / 1024) - pram));
  475. env_set("mem", memsz);
  476. return 0;
  477. }
  478. #endif
  479. static int dm_announce(void)
  480. {
  481. int device_count;
  482. int uclass_count;
  483. if (IS_ENABLED(CONFIG_DM)) {
  484. dm_get_stats(&device_count, &uclass_count);
  485. printf("Core: %d devices, %d uclasses", device_count,
  486. uclass_count);
  487. if (CONFIG_IS_ENABLED(OF_REAL))
  488. printf(", devicetree: %s", fdtdec_get_srcname());
  489. printf("\n");
  490. if (IS_ENABLED(CONFIG_OF_HAS_PRIOR_STAGE) &&
  491. (gd->fdt_src == FDTSRC_SEPARATE ||
  492. gd->fdt_src == FDTSRC_EMBED)) {
  493. printf("Warning: Unexpected devicetree source (not from a prior stage)");
  494. printf("Warning: U-Boot may not function properly\n");
  495. }
  496. }
  497. return 0;
  498. }
  499. static int run_main_loop(void)
  500. {
  501. #ifdef CONFIG_SANDBOX
  502. sandbox_main_loop_init();
  503. #endif
  504. /* main_loop() can return to retry autoboot, if so just run it again */
  505. for (;;)
  506. main_loop();
  507. return 0;
  508. }
  509. /*
  510. * We hope to remove most of the driver-related init and do it if/when
  511. * the driver is later used.
  512. *
  513. * TODO: perhaps reset the watchdog in the initcall function after each call?
  514. */
  515. static init_fnc_t init_sequence_r[] = {
  516. initr_trace,
  517. initr_reloc,
  518. /* TODO: could x86/PPC have this also perhaps? */
  519. #if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
  520. initr_caches,
  521. /* Note: For Freescale LS2 SoCs, new MMU table is created in DDR.
  522. * A temporary mapping of IFC high region is since removed,
  523. * so environmental variables in NOR flash is not available
  524. * until board_init() is called below to remap IFC to high
  525. * region.
  526. */
  527. #endif
  528. initr_reloc_global_data,
  529. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  530. initr_unlock_ram_in_cache,
  531. #endif
  532. initr_barrier,
  533. initr_malloc,
  534. log_init,
  535. initr_bootstage, /* Needs malloc() but has its own timer */
  536. #if defined(CONFIG_CONSOLE_RECORD)
  537. console_record_init,
  538. #endif
  539. #ifdef CONFIG_SYS_NONCACHED_MEMORY
  540. noncached_init,
  541. #endif
  542. initr_of_live,
  543. #ifdef CONFIG_DM
  544. initr_dm,
  545. #endif
  546. #ifdef CONFIG_ADDR_MAP
  547. init_addr_map,
  548. #endif
  549. #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
  550. defined(CONFIG_SANDBOX)
  551. board_init, /* Setup chipselects */
  552. #endif
  553. /*
  554. * TODO: printing of the clock inforamtion of the board is now
  555. * implemented as part of bdinfo command. Currently only support for
  556. * davinci SOC's is added. Remove this check once all the board
  557. * implement this.
  558. */
  559. #ifdef CONFIG_CLOCKS
  560. set_cpu_clk_info, /* Setup clock information */
  561. #endif
  562. #ifdef CONFIG_EFI_LOADER
  563. efi_memory_init,
  564. #endif
  565. initr_binman,
  566. #ifdef CONFIG_FSP_VERSION2
  567. arch_fsp_init_r,
  568. #endif
  569. initr_dm_devices,
  570. stdio_init_tables,
  571. serial_initialize,
  572. initr_announce,
  573. dm_announce,
  574. #if CONFIG_IS_ENABLED(WDT)
  575. initr_watchdog,
  576. #endif
  577. INIT_FUNC_WATCHDOG_RESET
  578. #if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_BLOCK_CACHE)
  579. blkcache_init,
  580. #endif
  581. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  582. initr_manual_reloc_cmdtable,
  583. #endif
  584. arch_initr_trap,
  585. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  586. board_early_init_r,
  587. #endif
  588. INIT_FUNC_WATCHDOG_RESET
  589. #ifdef CONFIG_POST
  590. post_output_backlog,
  591. #endif
  592. INIT_FUNC_WATCHDOG_RESET
  593. #if defined(CONFIG_PCI_INIT_R) && defined(CONFIG_SYS_EARLY_PCI_INIT)
  594. /*
  595. * Do early PCI configuration _before_ the flash gets initialised,
  596. * because PCU resources are crucial for flash access on some boards.
  597. */
  598. pci_init,
  599. #endif
  600. #ifdef CONFIG_ARCH_EARLY_INIT_R
  601. arch_early_init_r,
  602. #endif
  603. power_init_board,
  604. #ifdef CONFIG_MTD_NOR_FLASH
  605. initr_flash,
  606. #endif
  607. INIT_FUNC_WATCHDOG_RESET
  608. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
  609. /* initialize higher level parts of CPU like time base and timers */
  610. cpu_init_r,
  611. #endif
  612. #ifdef CONFIG_CMD_NAND
  613. initr_nand,
  614. #endif
  615. #ifdef CONFIG_CMD_ONENAND
  616. initr_onenand,
  617. #endif
  618. #ifdef CONFIG_MMC
  619. initr_mmc,
  620. #endif
  621. #ifdef CONFIG_XEN
  622. xen_init,
  623. #endif
  624. #ifdef CONFIG_PVBLOCK
  625. initr_pvblock,
  626. #endif
  627. initr_env,
  628. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  629. initr_malloc_bootparams,
  630. #endif
  631. INIT_FUNC_WATCHDOG_RESET
  632. cpu_secondary_init_r,
  633. #if defined(CONFIG_ID_EEPROM)
  634. mac_read_from_eeprom,
  635. #endif
  636. INIT_FUNC_WATCHDOG_RESET
  637. #if defined(CONFIG_PCI_INIT_R) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
  638. /*
  639. * Do pci configuration
  640. */
  641. pci_init,
  642. #endif
  643. stdio_add_devices,
  644. jumptable_init,
  645. #ifdef CONFIG_API
  646. api_init,
  647. #endif
  648. console_init_r, /* fully init console as a device */
  649. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  650. console_announce_r,
  651. show_board_info,
  652. #endif
  653. #ifdef CONFIG_ARCH_MISC_INIT
  654. arch_misc_init, /* miscellaneous arch-dependent init */
  655. #endif
  656. #ifdef CONFIG_MISC_INIT_R
  657. misc_init_r, /* miscellaneous platform-dependent init */
  658. #endif
  659. INIT_FUNC_WATCHDOG_RESET
  660. #ifdef CONFIG_CMD_KGDB
  661. kgdb_init,
  662. #endif
  663. interrupt_init,
  664. #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)
  665. timer_init, /* initialize timer */
  666. #endif
  667. #if defined(CONFIG_LED_STATUS)
  668. initr_status_led,
  669. #endif
  670. /* PPC has a udelay(20) here dating from 2002. Why? */
  671. #ifdef CONFIG_CMD_NET
  672. initr_ethaddr,
  673. #endif
  674. #if defined(CONFIG_GPIO_HOG)
  675. gpio_hog_probe_all,
  676. #endif
  677. #ifdef CONFIG_BOARD_LATE_INIT
  678. board_late_init,
  679. #endif
  680. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  681. INIT_FUNC_WATCHDOG_RESET
  682. initr_scsi,
  683. #endif
  684. #ifdef CONFIG_BITBANGMII
  685. bb_miiphy_init,
  686. #endif
  687. #ifdef CONFIG_PCI_ENDPOINT
  688. pci_ep_init,
  689. #endif
  690. #ifdef CONFIG_CMD_NET
  691. INIT_FUNC_WATCHDOG_RESET
  692. initr_net,
  693. #endif
  694. #ifdef CONFIG_POST
  695. initr_post,
  696. #endif
  697. #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
  698. initr_ide,
  699. #endif
  700. #ifdef CONFIG_LAST_STAGE_INIT
  701. INIT_FUNC_WATCHDOG_RESET
  702. /*
  703. * Some parts can be only initialized if all others (like
  704. * Interrupts) are up and running (i.e. the PC-style ISA
  705. * keyboard).
  706. */
  707. last_stage_init,
  708. #endif
  709. #if defined(CONFIG_PRAM)
  710. initr_mem,
  711. #endif
  712. #ifdef CONFIG_EFI_SETUP_EARLY
  713. (init_fnc_t)efi_init_obj_list,
  714. #endif
  715. run_main_loop,
  716. };
  717. void board_init_r(gd_t *new_gd, ulong dest_addr)
  718. {
  719. /*
  720. * Set up the new global data pointer. So far only x86 does this
  721. * here.
  722. * TODO(sjg@chromium.org): Consider doing this for all archs, or
  723. * dropping the new_gd parameter.
  724. */
  725. if (CONFIG_IS_ENABLED(X86_64) && !IS_ENABLED(CONFIG_EFI_APP))
  726. arch_setup_gd(new_gd);
  727. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  728. int i;
  729. #endif
  730. #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
  731. gd = new_gd;
  732. #endif
  733. gd->flags &= ~GD_FLG_LOG_READY;
  734. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  735. for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
  736. init_sequence_r[i] += gd->reloc_off;
  737. #endif
  738. if (initcall_run_list(init_sequence_r))
  739. hang();
  740. /* NOTREACHED - run_main_loop() does not return */
  741. hang();
  742. }