board_r.c 18 KB

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