board_r.c 18 KB

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