board_r.c 17 KB

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