board_r.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  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. #if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
  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. int ret;
  289. if (!CONFIG_IS_ENABLED(BINMAN_FDT))
  290. return 0;
  291. ret = binman_init();
  292. if (ret)
  293. printf("binman_init failed:%d\n", ret);
  294. return ret;
  295. }
  296. #if defined(CONFIG_MTD_NOR_FLASH)
  297. __weak int is_flash_available(void)
  298. {
  299. return 1;
  300. }
  301. static int initr_flash(void)
  302. {
  303. ulong flash_size = 0;
  304. struct bd_info *bd = gd->bd;
  305. if (!is_flash_available())
  306. return 0;
  307. puts("Flash: ");
  308. if (board_flash_wp_on())
  309. printf("Uninitialized - Write Protect On\n");
  310. else
  311. flash_size = flash_init();
  312. print_size(flash_size, "");
  313. #ifdef CONFIG_SYS_FLASH_CHECKSUM
  314. /*
  315. * Compute and print flash CRC if flashchecksum is set to 'y'
  316. *
  317. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  318. */
  319. if (env_get_yesno("flashchecksum") == 1) {
  320. const uchar *flash_base = (const uchar *)CONFIG_SYS_FLASH_BASE;
  321. printf(" CRC: %08X", crc32(0,
  322. flash_base,
  323. flash_size));
  324. }
  325. #endif /* CONFIG_SYS_FLASH_CHECKSUM */
  326. putc('\n');
  327. /* update start of FLASH memory */
  328. #ifdef CONFIG_SYS_FLASH_BASE
  329. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
  330. #endif
  331. /* size of FLASH memory (final value) */
  332. bd->bi_flashsize = flash_size;
  333. #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
  334. /* Make a update of the Memctrl. */
  335. update_flash_size(flash_size);
  336. #endif
  337. #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
  338. /* flash mapped at end of memory map */
  339. bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
  340. #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
  341. bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
  342. #endif
  343. return 0;
  344. }
  345. #endif
  346. #ifdef CONFIG_CMD_NAND
  347. /* go init the NAND */
  348. static int initr_nand(void)
  349. {
  350. puts("NAND: ");
  351. nand_init();
  352. printf("%lu MiB\n", nand_size() / 1024);
  353. return 0;
  354. }
  355. #endif
  356. #if defined(CONFIG_CMD_ONENAND)
  357. /* go init the NAND */
  358. static int initr_onenand(void)
  359. {
  360. puts("NAND: ");
  361. onenand_init();
  362. return 0;
  363. }
  364. #endif
  365. #ifdef CONFIG_MMC
  366. static int initr_mmc(void)
  367. {
  368. puts("MMC: ");
  369. mmc_initialize(gd->bd);
  370. return 0;
  371. }
  372. #endif
  373. #ifdef CONFIG_PVBLOCK
  374. static int initr_pvblock(void)
  375. {
  376. puts("PVBLOCK: ");
  377. pvblock_init();
  378. return 0;
  379. }
  380. #endif
  381. /*
  382. * Tell if it's OK to load the environment early in boot.
  383. *
  384. * If CONFIG_OF_CONTROL is defined, we'll check with the FDT to see
  385. * if this is OK (defaulting to saying it's OK).
  386. *
  387. * NOTE: Loading the environment early can be a bad idea if security is
  388. * important, since no verification is done on the environment.
  389. *
  390. * @return 0 if environment should not be loaded, !=0 if it is ok to load
  391. */
  392. static int should_load_env(void)
  393. {
  394. if (IS_ENABLED(CONFIG_OF_CONTROL))
  395. return fdtdec_get_config_int(gd->fdt_blob,
  396. "load-environment", 1);
  397. if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT))
  398. return 0;
  399. return 1;
  400. }
  401. static int initr_env(void)
  402. {
  403. /* initialize environment */
  404. if (should_load_env())
  405. env_relocate();
  406. else
  407. env_set_default(NULL, 0);
  408. env_import_fdt();
  409. if (IS_ENABLED(CONFIG_OF_CONTROL))
  410. env_set_hex("fdtcontroladdr",
  411. (unsigned long)map_to_sysmem(gd->fdt_blob));
  412. /* Initialize from environment */
  413. image_load_addr = env_get_ulong("loadaddr", 16, image_load_addr);
  414. return 0;
  415. }
  416. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  417. static int initr_malloc_bootparams(void)
  418. {
  419. gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN);
  420. if (!gd->bd->bi_boot_params) {
  421. puts("WARNING: Cannot allocate space for boot parameters\n");
  422. return -ENOMEM;
  423. }
  424. return 0;
  425. }
  426. #endif
  427. #ifdef CONFIG_CMD_NET
  428. static int initr_ethaddr(void)
  429. {
  430. struct bd_info *bd = gd->bd;
  431. /* kept around for legacy kernels only ... ignore the next section */
  432. eth_env_get_enetaddr("ethaddr", bd->bi_enetaddr);
  433. return 0;
  434. }
  435. #endif /* CONFIG_CMD_NET */
  436. #ifdef CONFIG_CMD_KGDB
  437. static int initr_kgdb(void)
  438. {
  439. puts("KGDB: ");
  440. kgdb_init();
  441. return 0;
  442. }
  443. #endif
  444. #if defined(CONFIG_LED_STATUS)
  445. static int initr_status_led(void)
  446. {
  447. #if defined(CONFIG_LED_STATUS_BOOT)
  448. status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING);
  449. #else
  450. status_led_init();
  451. #endif
  452. return 0;
  453. }
  454. #endif
  455. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  456. static int initr_scsi(void)
  457. {
  458. puts("SCSI: ");
  459. scsi_init();
  460. puts("\n");
  461. return 0;
  462. }
  463. #endif
  464. #ifdef CONFIG_CMD_NET
  465. static int initr_net(void)
  466. {
  467. puts("Net: ");
  468. eth_initialize();
  469. #if defined(CONFIG_RESET_PHY_R)
  470. debug("Reset Ethernet PHY\n");
  471. reset_phy();
  472. #endif
  473. return 0;
  474. }
  475. #endif
  476. #ifdef CONFIG_POST
  477. static int initr_post(void)
  478. {
  479. post_run(NULL, POST_RAM | post_bootmode_get(0));
  480. return 0;
  481. }
  482. #endif
  483. #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
  484. static int initr_ide(void)
  485. {
  486. puts("IDE: ");
  487. #if defined(CONFIG_START_IDE)
  488. if (board_start_ide())
  489. ide_init();
  490. #else
  491. ide_init();
  492. #endif
  493. return 0;
  494. }
  495. #endif
  496. #if defined(CONFIG_PRAM)
  497. /*
  498. * Export available size of memory for Linux, taking into account the
  499. * protected RAM at top of memory
  500. */
  501. int initr_mem(void)
  502. {
  503. ulong pram = 0;
  504. char memsz[32];
  505. pram = env_get_ulong("pram", 10, CONFIG_PRAM);
  506. sprintf(memsz, "%ldk", (long int)((gd->ram_size / 1024) - pram));
  507. env_set("mem", memsz);
  508. return 0;
  509. }
  510. #endif
  511. static int run_main_loop(void)
  512. {
  513. #ifdef CONFIG_SANDBOX
  514. sandbox_main_loop_init();
  515. #endif
  516. /* main_loop() can return to retry autoboot, if so just run it again */
  517. for (;;)
  518. main_loop();
  519. return 0;
  520. }
  521. /*
  522. * We hope to remove most of the driver-related init and do it if/when
  523. * the driver is later used.
  524. *
  525. * TODO: perhaps reset the watchdog in the initcall function after each call?
  526. */
  527. static init_fnc_t init_sequence_r[] = {
  528. initr_trace,
  529. initr_reloc,
  530. /* TODO: could x86/PPC have this also perhaps? */
  531. #if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
  532. initr_caches,
  533. /* Note: For Freescale LS2 SoCs, new MMU table is created in DDR.
  534. * A temporary mapping of IFC high region is since removed,
  535. * so environmental variables in NOR flash is not available
  536. * until board_init() is called below to remap IFC to high
  537. * region.
  538. */
  539. #endif
  540. initr_reloc_global_data,
  541. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  542. initr_unlock_ram_in_cache,
  543. #endif
  544. initr_barrier,
  545. initr_malloc,
  546. log_init,
  547. initr_bootstage, /* Needs malloc() but has its own timer */
  548. #if defined(CONFIG_CONSOLE_RECORD)
  549. console_record_init,
  550. #endif
  551. #ifdef CONFIG_SYS_NONCACHED_MEMORY
  552. noncached_init,
  553. #endif
  554. initr_of_live,
  555. #ifdef CONFIG_DM
  556. initr_dm,
  557. #endif
  558. #ifdef CONFIG_ADDR_MAP
  559. initr_addr_map,
  560. #endif
  561. #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
  562. defined(CONFIG_SANDBOX)
  563. board_init, /* Setup chipselects */
  564. #endif
  565. /*
  566. * TODO: printing of the clock inforamtion of the board is now
  567. * implemented as part of bdinfo command. Currently only support for
  568. * davinci SOC's is added. Remove this check once all the board
  569. * implement this.
  570. */
  571. #ifdef CONFIG_CLOCKS
  572. set_cpu_clk_info, /* Setup clock information */
  573. #endif
  574. #ifdef CONFIG_EFI_LOADER
  575. efi_memory_init,
  576. #endif
  577. initr_binman,
  578. #ifdef CONFIG_FSP_VERSION2
  579. arch_fsp_init_r,
  580. #endif
  581. initr_dm_devices,
  582. stdio_init_tables,
  583. serial_initialize,
  584. initr_announce,
  585. #if CONFIG_IS_ENABLED(WDT)
  586. initr_watchdog,
  587. #endif
  588. INIT_FUNC_WATCHDOG_RESET
  589. #if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_BLOCK_CACHE)
  590. blkcache_init,
  591. #endif
  592. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  593. initr_manual_reloc_cmdtable,
  594. #endif
  595. arch_initr_trap,
  596. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  597. board_early_init_r,
  598. #endif
  599. INIT_FUNC_WATCHDOG_RESET
  600. #ifdef CONFIG_POST
  601. post_output_backlog,
  602. #endif
  603. INIT_FUNC_WATCHDOG_RESET
  604. #if defined(CONFIG_PCI_INIT_R) && defined(CONFIG_SYS_EARLY_PCI_INIT)
  605. /*
  606. * Do early PCI configuration _before_ the flash gets initialised,
  607. * because PCU resources are crucial for flash access on some boards.
  608. */
  609. pci_init,
  610. #endif
  611. #ifdef CONFIG_ARCH_EARLY_INIT_R
  612. arch_early_init_r,
  613. #endif
  614. #if CONFIG_IS_ENABLED(TARGET_STARFIVE_DEVKITS)
  615. set_pmic,
  616. #endif
  617. power_init_board,
  618. #ifdef CONFIG_MTD_NOR_FLASH
  619. initr_flash,
  620. #endif
  621. INIT_FUNC_WATCHDOG_RESET
  622. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
  623. /* initialize higher level parts of CPU like time base and timers */
  624. cpu_init_r,
  625. #endif
  626. #ifdef CONFIG_CMD_NAND
  627. initr_nand,
  628. #endif
  629. #ifdef CONFIG_CMD_ONENAND
  630. initr_onenand,
  631. #endif
  632. #ifdef CONFIG_MMC
  633. initr_mmc,
  634. #endif
  635. #ifdef CONFIG_XEN
  636. xen_init,
  637. #endif
  638. #ifdef CONFIG_PVBLOCK
  639. initr_pvblock,
  640. #endif
  641. initr_env,
  642. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  643. initr_malloc_bootparams,
  644. #endif
  645. INIT_FUNC_WATCHDOG_RESET
  646. cpu_secondary_init_r,
  647. #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
  648. mac_read_from_eeprom,
  649. #endif
  650. INIT_FUNC_WATCHDOG_RESET
  651. #if defined(CONFIG_PCI_INIT_R) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
  652. /*
  653. * Do pci configuration
  654. */
  655. pci_init,
  656. #endif
  657. stdio_add_devices,
  658. jumptable_init,
  659. #ifdef CONFIG_API
  660. api_init,
  661. #endif
  662. console_init_r, /* fully init console as a device */
  663. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  664. console_announce_r,
  665. show_board_info,
  666. #endif
  667. #ifdef CONFIG_ARCH_MISC_INIT
  668. arch_misc_init, /* miscellaneous arch-dependent init */
  669. #endif
  670. #ifdef CONFIG_MISC_INIT_R
  671. misc_init_r, /* miscellaneous platform-dependent init */
  672. #endif
  673. INIT_FUNC_WATCHDOG_RESET
  674. #ifdef CONFIG_CMD_KGDB
  675. initr_kgdb,
  676. #endif
  677. interrupt_init,
  678. #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)
  679. timer_init, /* initialize timer */
  680. #endif
  681. #if defined(CONFIG_LED_STATUS)
  682. initr_status_led,
  683. #endif
  684. /* PPC has a udelay(20) here dating from 2002. Why? */
  685. #ifdef CONFIG_CMD_NET
  686. initr_ethaddr,
  687. #endif
  688. #if defined(CONFIG_GPIO_HOG)
  689. gpio_hog_probe_all,
  690. #endif
  691. #ifdef CONFIG_BOARD_LATE_INIT
  692. board_late_init,
  693. #endif
  694. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  695. INIT_FUNC_WATCHDOG_RESET
  696. initr_scsi,
  697. #endif
  698. #ifdef CONFIG_BITBANGMII
  699. bb_miiphy_init,
  700. #endif
  701. #ifdef CONFIG_PCI_ENDPOINT
  702. pci_ep_init,
  703. #endif
  704. #ifdef CONFIG_CMD_NET
  705. INIT_FUNC_WATCHDOG_RESET
  706. initr_net,
  707. #endif
  708. #ifdef CONFIG_POST
  709. initr_post,
  710. #endif
  711. #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
  712. initr_ide,
  713. #endif
  714. #ifdef CONFIG_LAST_STAGE_INIT
  715. INIT_FUNC_WATCHDOG_RESET
  716. /*
  717. * Some parts can be only initialized if all others (like
  718. * Interrupts) are up and running (i.e. the PC-style ISA
  719. * keyboard).
  720. */
  721. last_stage_init,
  722. #endif
  723. #ifdef CONFIG_CMD_BEDBUG
  724. INIT_FUNC_WATCHDOG_RESET
  725. bedbug_init,
  726. #endif
  727. #if defined(CONFIG_PRAM)
  728. initr_mem,
  729. #endif
  730. #ifdef CONFIG_EFI_SETUP_EARLY
  731. (init_fnc_t)efi_init_obj_list,
  732. #endif
  733. run_main_loop,
  734. };
  735. void board_init_r(gd_t *new_gd, ulong dest_addr)
  736. {
  737. /*
  738. * Set up the new global data pointer. So far only x86 does this
  739. * here.
  740. * TODO(sjg@chromium.org): Consider doing this for all archs, or
  741. * dropping the new_gd parameter.
  742. */
  743. #if CONFIG_IS_ENABLED(X86_64)
  744. arch_setup_gd(new_gd);
  745. #endif
  746. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  747. int i;
  748. #endif
  749. #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
  750. gd = new_gd;
  751. #endif
  752. gd->flags &= ~GD_FLG_LOG_READY;
  753. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  754. for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
  755. init_sequence_r[i] += gd->reloc_off;
  756. #endif
  757. if (initcall_run_list(init_sequence_r))
  758. hang();
  759. /* NOTREACHED - run_main_loop() does not return */
  760. hang();
  761. }