board_r.c 18 KB

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