board_r.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  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. if (IS_ENABLED(CONFIG_OF_CONTROL))
  405. env_set_hex("fdtcontroladdr",
  406. (unsigned long)map_to_sysmem(gd->fdt_blob));
  407. /* Initialize from environment */
  408. image_load_addr = env_get_ulong("loadaddr", 16, image_load_addr);
  409. return 0;
  410. }
  411. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  412. static int initr_malloc_bootparams(void)
  413. {
  414. gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN);
  415. if (!gd->bd->bi_boot_params) {
  416. puts("WARNING: Cannot allocate space for boot parameters\n");
  417. return -ENOMEM;
  418. }
  419. return 0;
  420. }
  421. #endif
  422. #ifdef CONFIG_CMD_NET
  423. static int initr_ethaddr(void)
  424. {
  425. struct bd_info *bd = gd->bd;
  426. /* kept around for legacy kernels only ... ignore the next section */
  427. eth_env_get_enetaddr("ethaddr", bd->bi_enetaddr);
  428. return 0;
  429. }
  430. #endif /* CONFIG_CMD_NET */
  431. #ifdef CONFIG_CMD_KGDB
  432. static int initr_kgdb(void)
  433. {
  434. puts("KGDB: ");
  435. kgdb_init();
  436. return 0;
  437. }
  438. #endif
  439. #if defined(CONFIG_LED_STATUS)
  440. static int initr_status_led(void)
  441. {
  442. #if defined(CONFIG_LED_STATUS_BOOT)
  443. status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING);
  444. #else
  445. status_led_init();
  446. #endif
  447. return 0;
  448. }
  449. #endif
  450. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  451. static int initr_scsi(void)
  452. {
  453. puts("SCSI: ");
  454. scsi_init();
  455. puts("\n");
  456. return 0;
  457. }
  458. #endif
  459. #ifdef CONFIG_CMD_NET
  460. static int initr_net(void)
  461. {
  462. puts("Net: ");
  463. eth_initialize();
  464. #if defined(CONFIG_RESET_PHY_R)
  465. debug("Reset Ethernet PHY\n");
  466. reset_phy();
  467. #endif
  468. return 0;
  469. }
  470. #endif
  471. #ifdef CONFIG_POST
  472. static int initr_post(void)
  473. {
  474. post_run(NULL, POST_RAM | post_bootmode_get(0));
  475. return 0;
  476. }
  477. #endif
  478. #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
  479. static int initr_ide(void)
  480. {
  481. puts("IDE: ");
  482. #if defined(CONFIG_START_IDE)
  483. if (board_start_ide())
  484. ide_init();
  485. #else
  486. ide_init();
  487. #endif
  488. return 0;
  489. }
  490. #endif
  491. #if defined(CONFIG_PRAM)
  492. /*
  493. * Export available size of memory for Linux, taking into account the
  494. * protected RAM at top of memory
  495. */
  496. int initr_mem(void)
  497. {
  498. ulong pram = 0;
  499. char memsz[32];
  500. pram = env_get_ulong("pram", 10, CONFIG_PRAM);
  501. sprintf(memsz, "%ldk", (long int)((gd->ram_size / 1024) - pram));
  502. env_set("mem", memsz);
  503. return 0;
  504. }
  505. #endif
  506. static int run_main_loop(void)
  507. {
  508. #ifdef CONFIG_SANDBOX
  509. sandbox_main_loop_init();
  510. #endif
  511. /* main_loop() can return to retry autoboot, if so just run it again */
  512. for (;;)
  513. main_loop();
  514. return 0;
  515. }
  516. /*
  517. * We hope to remove most of the driver-related init and do it if/when
  518. * the driver is later used.
  519. *
  520. * TODO: perhaps reset the watchdog in the initcall function after each call?
  521. */
  522. static init_fnc_t init_sequence_r[] = {
  523. initr_trace,
  524. initr_reloc,
  525. /* TODO: could x86/PPC have this also perhaps? */
  526. #ifdef CONFIG_ARM
  527. initr_caches,
  528. /* Note: For Freescale LS2 SoCs, new MMU table is created in DDR.
  529. * A temporary mapping of IFC high region is since removed,
  530. * so environmental variables in NOR flash is not available
  531. * until board_init() is called below to remap IFC to high
  532. * region.
  533. */
  534. #endif
  535. initr_reloc_global_data,
  536. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  537. initr_unlock_ram_in_cache,
  538. #endif
  539. initr_barrier,
  540. initr_malloc,
  541. log_init,
  542. initr_bootstage, /* Needs malloc() but has its own timer */
  543. #if defined(CONFIG_CONSOLE_RECORD)
  544. console_record_init,
  545. #endif
  546. #ifdef CONFIG_SYS_NONCACHED_MEMORY
  547. noncached_init,
  548. #endif
  549. initr_of_live,
  550. #ifdef CONFIG_DM
  551. initr_dm,
  552. #endif
  553. #ifdef CONFIG_ADDR_MAP
  554. initr_addr_map,
  555. #endif
  556. #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
  557. defined(CONFIG_SANDBOX)
  558. board_init, /* Setup chipselects */
  559. #endif
  560. /*
  561. * TODO: printing of the clock inforamtion of the board is now
  562. * implemented as part of bdinfo command. Currently only support for
  563. * davinci SOC's is added. Remove this check once all the board
  564. * implement this.
  565. */
  566. #ifdef CONFIG_CLOCKS
  567. set_cpu_clk_info, /* Setup clock information */
  568. #endif
  569. #ifdef CONFIG_EFI_LOADER
  570. efi_memory_init,
  571. #endif
  572. initr_binman,
  573. #ifdef CONFIG_FSP_VERSION2
  574. arch_fsp_init_r,
  575. #endif
  576. initr_dm_devices,
  577. stdio_init_tables,
  578. serial_initialize,
  579. initr_announce,
  580. #if CONFIG_IS_ENABLED(WDT)
  581. initr_watchdog,
  582. #endif
  583. INIT_FUNC_WATCHDOG_RESET
  584. #if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_BLOCK_CACHE)
  585. blkcache_init,
  586. #endif
  587. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  588. initr_manual_reloc_cmdtable,
  589. #endif
  590. arch_initr_trap,
  591. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  592. board_early_init_r,
  593. #endif
  594. INIT_FUNC_WATCHDOG_RESET
  595. #ifdef CONFIG_POST
  596. post_output_backlog,
  597. #endif
  598. INIT_FUNC_WATCHDOG_RESET
  599. #if defined(CONFIG_PCI_INIT_R) && defined(CONFIG_SYS_EARLY_PCI_INIT)
  600. /*
  601. * Do early PCI configuration _before_ the flash gets initialised,
  602. * because PCU resources are crucial for flash access on some boards.
  603. */
  604. pci_init,
  605. #endif
  606. #ifdef CONFIG_ARCH_EARLY_INIT_R
  607. arch_early_init_r,
  608. #endif
  609. power_init_board,
  610. #ifdef CONFIG_MTD_NOR_FLASH
  611. initr_flash,
  612. #endif
  613. INIT_FUNC_WATCHDOG_RESET
  614. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
  615. /* initialize higher level parts of CPU like time base and timers */
  616. cpu_init_r,
  617. #endif
  618. #ifdef CONFIG_CMD_NAND
  619. initr_nand,
  620. #endif
  621. #ifdef CONFIG_CMD_ONENAND
  622. initr_onenand,
  623. #endif
  624. #ifdef CONFIG_MMC
  625. initr_mmc,
  626. #endif
  627. #ifdef CONFIG_XEN
  628. xen_init,
  629. #endif
  630. #ifdef CONFIG_PVBLOCK
  631. initr_pvblock,
  632. #endif
  633. initr_env,
  634. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  635. initr_malloc_bootparams,
  636. #endif
  637. INIT_FUNC_WATCHDOG_RESET
  638. cpu_secondary_init_r,
  639. #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
  640. mac_read_from_eeprom,
  641. #endif
  642. INIT_FUNC_WATCHDOG_RESET
  643. #if defined(CONFIG_PCI_INIT_R) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
  644. /*
  645. * Do pci configuration
  646. */
  647. pci_init,
  648. #endif
  649. stdio_add_devices,
  650. jumptable_init,
  651. #ifdef CONFIG_API
  652. api_init,
  653. #endif
  654. console_init_r, /* fully init console as a device */
  655. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  656. console_announce_r,
  657. show_board_info,
  658. #endif
  659. #ifdef CONFIG_ARCH_MISC_INIT
  660. arch_misc_init, /* miscellaneous arch-dependent init */
  661. #endif
  662. #ifdef CONFIG_MISC_INIT_R
  663. misc_init_r, /* miscellaneous platform-dependent init */
  664. #endif
  665. INIT_FUNC_WATCHDOG_RESET
  666. #ifdef CONFIG_CMD_KGDB
  667. initr_kgdb,
  668. #endif
  669. interrupt_init,
  670. #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)
  671. timer_init, /* initialize timer */
  672. #endif
  673. #if defined(CONFIG_LED_STATUS)
  674. initr_status_led,
  675. #endif
  676. /* PPC has a udelay(20) here dating from 2002. Why? */
  677. #ifdef CONFIG_CMD_NET
  678. initr_ethaddr,
  679. #endif
  680. #if defined(CONFIG_GPIO_HOG)
  681. gpio_hog_probe_all,
  682. #endif
  683. #ifdef CONFIG_BOARD_LATE_INIT
  684. board_late_init,
  685. #endif
  686. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  687. INIT_FUNC_WATCHDOG_RESET
  688. initr_scsi,
  689. #endif
  690. #ifdef CONFIG_BITBANGMII
  691. bb_miiphy_init,
  692. #endif
  693. #ifdef CONFIG_PCI_ENDPOINT
  694. pci_ep_init,
  695. #endif
  696. #ifdef CONFIG_CMD_NET
  697. INIT_FUNC_WATCHDOG_RESET
  698. initr_net,
  699. #endif
  700. #ifdef CONFIG_POST
  701. initr_post,
  702. #endif
  703. #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
  704. initr_ide,
  705. #endif
  706. #ifdef CONFIG_LAST_STAGE_INIT
  707. INIT_FUNC_WATCHDOG_RESET
  708. /*
  709. * Some parts can be only initialized if all others (like
  710. * Interrupts) are up and running (i.e. the PC-style ISA
  711. * keyboard).
  712. */
  713. last_stage_init,
  714. #endif
  715. #ifdef CONFIG_CMD_BEDBUG
  716. INIT_FUNC_WATCHDOG_RESET
  717. bedbug_init,
  718. #endif
  719. #if defined(CONFIG_PRAM)
  720. initr_mem,
  721. #endif
  722. #ifdef CONFIG_EFI_SETUP_EARLY
  723. (init_fnc_t)efi_init_obj_list,
  724. #endif
  725. run_main_loop,
  726. };
  727. void board_init_r(gd_t *new_gd, ulong dest_addr)
  728. {
  729. /*
  730. * Set up the new global data pointer. So far only x86 does this
  731. * here.
  732. * TODO(sjg@chromium.org): Consider doing this for all archs, or
  733. * dropping the new_gd parameter.
  734. */
  735. #if CONFIG_IS_ENABLED(X86_64)
  736. arch_setup_gd(new_gd);
  737. #endif
  738. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  739. int i;
  740. #endif
  741. #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
  742. gd = new_gd;
  743. #endif
  744. gd->flags &= ~GD_FLG_LOG_READY;
  745. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  746. for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
  747. init_sequence_r[i] += gd->reloc_off;
  748. #endif
  749. if (initcall_run_list(init_sequence_r))
  750. hang();
  751. /* NOTREACHED - run_main_loop() does not return */
  752. hang();
  753. }