board_r.c 18 KB

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