board_r.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * (C) Copyright 2002-2006
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2002
  7. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  8. * Marius Groeger <mgroeger@sysgo.de>
  9. *
  10. * SPDX-License-Identifier: GPL-2.0+
  11. */
  12. #include <common.h>
  13. #include <api.h>
  14. /* TODO: can we just include all these headers whether needed or not? */
  15. #if defined(CONFIG_CMD_BEDBUG)
  16. #include <bedbug/type.h>
  17. #endif
  18. #include <command.h>
  19. #include <console.h>
  20. #ifdef CONFIG_HAS_DATAFLASH
  21. #include <dataflash.h>
  22. #endif
  23. #include <dm.h>
  24. #include <environment.h>
  25. #include <fdtdec.h>
  26. #include <ide.h>
  27. #include <initcall.h>
  28. #include <init_helpers.h>
  29. #ifdef CONFIG_PS2KBD
  30. #include <keyboard.h>
  31. #endif
  32. #if defined(CONFIG_CMD_KGDB)
  33. #include <kgdb.h>
  34. #endif
  35. #include <logbuff.h>
  36. #include <malloc.h>
  37. #include <mapmem.h>
  38. #ifdef CONFIG_BITBANGMII
  39. #include <miiphy.h>
  40. #endif
  41. #include <mmc.h>
  42. #include <nand.h>
  43. #include <of_live.h>
  44. #include <onenand_uboot.h>
  45. #include <scsi.h>
  46. #include <serial.h>
  47. #include <spi.h>
  48. #include <stdio_dev.h>
  49. #include <timer.h>
  50. #include <trace.h>
  51. #include <watchdog.h>
  52. #ifdef CONFIG_ADDR_MAP
  53. #include <asm/mmu.h>
  54. #endif
  55. #include <asm/sections.h>
  56. #include <dm/root.h>
  57. #include <linux/compiler.h>
  58. #include <linux/err.h>
  59. #ifdef CONFIG_AVR32
  60. #include <asm/arch/mmu.h>
  61. #endif
  62. #include <efi_loader.h>
  63. DECLARE_GLOBAL_DATA_PTR;
  64. ulong monitor_flash_len;
  65. __weak int board_flash_wp_on(void)
  66. {
  67. /*
  68. * Most flashes can't be detected when write protection is enabled,
  69. * so provide a way to let U-Boot gracefully ignore write protected
  70. * devices.
  71. */
  72. return 0;
  73. }
  74. __weak void cpu_secondary_init_r(void)
  75. {
  76. }
  77. static int initr_secondary_cpu(void)
  78. {
  79. /*
  80. * after non-volatile devices & environment is setup and cpu code have
  81. * another round to deal with any initialization that might require
  82. * full access to the environment or loading of some image (firmware)
  83. * from a non-volatile device
  84. */
  85. /* TODO: maybe define this for all archs? */
  86. cpu_secondary_init_r();
  87. return 0;
  88. }
  89. static int initr_trace(void)
  90. {
  91. #ifdef CONFIG_TRACE
  92. trace_init(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE);
  93. #endif
  94. return 0;
  95. }
  96. static int initr_reloc(void)
  97. {
  98. /* tell others: relocation done */
  99. gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT;
  100. return 0;
  101. }
  102. #ifdef CONFIG_ARM
  103. /*
  104. * Some of these functions are needed purely because the functions they
  105. * call return void. If we change them to return 0, these stubs can go away.
  106. */
  107. static int initr_caches(void)
  108. {
  109. /* Enable caches */
  110. enable_caches();
  111. return 0;
  112. }
  113. #endif
  114. __weak int fixup_cpu(void)
  115. {
  116. return 0;
  117. }
  118. static int initr_reloc_global_data(void)
  119. {
  120. #ifdef __ARM__
  121. monitor_flash_len = _end - __image_copy_start;
  122. #elif defined(CONFIG_NDS32)
  123. monitor_flash_len = (ulong)&_end - (ulong)&_start;
  124. #elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
  125. monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
  126. #endif
  127. #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
  128. /*
  129. * The gd->cpu pointer is set to an address in flash before relocation.
  130. * We need to update it to point to the same CPU entry in RAM.
  131. * TODO: why not just add gd->reloc_ofs?
  132. */
  133. gd->arch.cpu += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
  134. /*
  135. * If we didn't know the cpu mask & # cores, we can save them of
  136. * now rather than 'computing' them constantly
  137. */
  138. fixup_cpu();
  139. #endif
  140. #ifdef CONFIG_SYS_EXTRA_ENV_RELOC
  141. /*
  142. * Some systems need to relocate the env_addr pointer early because the
  143. * location it points to will get invalidated before env_relocate is
  144. * called. One example is on systems that might use a L2 or L3 cache
  145. * in SRAM mode and initialize that cache from SRAM mode back to being
  146. * a cache in cpu_init_r.
  147. */
  148. gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
  149. #endif
  150. #ifdef CONFIG_OF_EMBED
  151. /*
  152. * The fdt_blob needs to be moved to new relocation address
  153. * incase of FDT blob is embedded with in image
  154. */
  155. gd->fdt_blob += gd->reloc_off;
  156. #endif
  157. #ifdef CONFIG_EFI_LOADER
  158. efi_runtime_relocate(gd->relocaddr, NULL);
  159. #endif
  160. return 0;
  161. }
  162. static int initr_serial(void)
  163. {
  164. serial_initialize();
  165. return 0;
  166. }
  167. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
  168. static int initr_trap(void)
  169. {
  170. /*
  171. * Setup trap handlers
  172. */
  173. #if defined(CONFIG_PPC)
  174. trap_init(gd->relocaddr);
  175. #else
  176. trap_init(CONFIG_SYS_SDRAM_BASE);
  177. #endif
  178. return 0;
  179. }
  180. #endif
  181. #ifdef CONFIG_ADDR_MAP
  182. static int initr_addr_map(void)
  183. {
  184. init_addr_map();
  185. return 0;
  186. }
  187. #endif
  188. #ifdef CONFIG_LOGBUFFER
  189. unsigned long logbuffer_base(void)
  190. {
  191. return gd->ram_top - LOGBUFF_LEN;
  192. }
  193. static int initr_logbuffer(void)
  194. {
  195. logbuff_init_ptrs();
  196. return 0;
  197. }
  198. #endif
  199. #ifdef CONFIG_POST
  200. static int initr_post_backlog(void)
  201. {
  202. post_output_backlog();
  203. return 0;
  204. }
  205. #endif
  206. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  207. static int initr_unlock_ram_in_cache(void)
  208. {
  209. unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
  210. return 0;
  211. }
  212. #endif
  213. #ifdef CONFIG_PCI
  214. static int initr_pci(void)
  215. {
  216. #ifndef CONFIG_DM_PCI
  217. pci_init();
  218. #endif
  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. #ifdef CONFIG_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. 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(BOOTSTATE_ID_ACCUM_DM_R, "dm_r");
  281. ret = dm_init_and_scan(false);
  282. bootstage_accum(BOOTSTATE_ID_ACCUM_DM_R);
  283. if (ret)
  284. return ret;
  285. #ifdef CONFIG_TIMER_EARLY
  286. ret = dm_timer_init();
  287. if (ret)
  288. return ret;
  289. #endif
  290. return 0;
  291. }
  292. #endif
  293. static int initr_bootstage(void)
  294. {
  295. bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
  296. return 0;
  297. }
  298. __weak int power_init_board(void)
  299. {
  300. return 0;
  301. }
  302. static int initr_announce(void)
  303. {
  304. debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr);
  305. return 0;
  306. }
  307. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  308. static int initr_manual_reloc_cmdtable(void)
  309. {
  310. fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
  311. ll_entry_count(cmd_tbl_t, cmd));
  312. return 0;
  313. }
  314. #endif
  315. #if defined(CONFIG_MTD_NOR_FLASH)
  316. static int initr_flash(void)
  317. {
  318. ulong flash_size = 0;
  319. bd_t *bd = gd->bd;
  320. puts("Flash: ");
  321. if (board_flash_wp_on())
  322. printf("Uninitialized - Write Protect On\n");
  323. else
  324. flash_size = flash_init();
  325. print_size(flash_size, "");
  326. #ifdef CONFIG_SYS_FLASH_CHECKSUM
  327. /*
  328. * Compute and print flash CRC if flashchecksum is set to 'y'
  329. *
  330. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  331. */
  332. if (getenv_yesno("flashchecksum") == 1) {
  333. printf(" CRC: %08X", crc32(0,
  334. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  335. flash_size));
  336. }
  337. #endif /* CONFIG_SYS_FLASH_CHECKSUM */
  338. putc('\n');
  339. /* update start of FLASH memory */
  340. #ifdef CONFIG_SYS_FLASH_BASE
  341. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
  342. #endif
  343. /* size of FLASH memory (final value) */
  344. bd->bi_flashsize = flash_size;
  345. #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
  346. /* Make a update of the Memctrl. */
  347. update_flash_size(flash_size);
  348. #endif
  349. #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
  350. /* flash mapped at end of memory map */
  351. bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
  352. #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
  353. bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
  354. #endif
  355. return 0;
  356. }
  357. #endif
  358. #if defined(CONFIG_PPC) && !defined(CONFIG_DM_SPI)
  359. static int initr_spi(void)
  360. {
  361. /* PPC does this here */
  362. #ifdef CONFIG_SPI
  363. #if !defined(CONFIG_ENV_IS_IN_EEPROM)
  364. spi_init_f();
  365. #endif
  366. spi_init_r();
  367. #endif
  368. return 0;
  369. }
  370. #endif
  371. #ifdef CONFIG_CMD_NAND
  372. /* go init the NAND */
  373. static int initr_nand(void)
  374. {
  375. puts("NAND: ");
  376. nand_init();
  377. printf("%lu MiB\n", nand_size() / 1024);
  378. return 0;
  379. }
  380. #endif
  381. #if defined(CONFIG_CMD_ONENAND)
  382. /* go init the NAND */
  383. static int initr_onenand(void)
  384. {
  385. puts("NAND: ");
  386. onenand_init();
  387. return 0;
  388. }
  389. #endif
  390. #ifdef CONFIG_MMC
  391. static int initr_mmc(void)
  392. {
  393. puts("MMC: ");
  394. mmc_initialize(gd->bd);
  395. return 0;
  396. }
  397. #endif
  398. #ifdef CONFIG_HAS_DATAFLASH
  399. static int initr_dataflash(void)
  400. {
  401. AT91F_DataflashInit();
  402. dataflash_print_info();
  403. return 0;
  404. }
  405. #endif
  406. /*
  407. * Tell if it's OK to load the environment early in boot.
  408. *
  409. * If CONFIG_OF_CONTROL is defined, we'll check with the FDT to see
  410. * if this is OK (defaulting to saying it's OK).
  411. *
  412. * NOTE: Loading the environment early can be a bad idea if security is
  413. * important, since no verification is done on the environment.
  414. *
  415. * @return 0 if environment should not be loaded, !=0 if it is ok to load
  416. */
  417. static int should_load_env(void)
  418. {
  419. #ifdef CONFIG_OF_CONTROL
  420. return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
  421. #elif defined CONFIG_DELAY_ENVIRONMENT
  422. return 0;
  423. #else
  424. return 1;
  425. #endif
  426. }
  427. static int initr_env(void)
  428. {
  429. /* initialize environment */
  430. if (should_load_env())
  431. env_relocate();
  432. else
  433. set_default_env(NULL);
  434. #ifdef CONFIG_OF_CONTROL
  435. setenv_addr("fdtcontroladdr", gd->fdt_blob);
  436. #endif
  437. /* Initialize from environment */
  438. load_addr = getenv_ulong("loadaddr", 16, 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. /* enable exceptions */
  466. #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
  467. static int initr_enable_interrupts(void)
  468. {
  469. enable_interrupts();
  470. return 0;
  471. }
  472. #endif
  473. #ifdef CONFIG_CMD_NET
  474. static int initr_ethaddr(void)
  475. {
  476. bd_t *bd = gd->bd;
  477. /* kept around for legacy kernels only ... ignore the next section */
  478. eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
  479. #ifdef CONFIG_HAS_ETH1
  480. eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
  481. #endif
  482. #ifdef CONFIG_HAS_ETH2
  483. eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
  484. #endif
  485. #ifdef CONFIG_HAS_ETH3
  486. eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
  487. #endif
  488. #ifdef CONFIG_HAS_ETH4
  489. eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
  490. #endif
  491. #ifdef CONFIG_HAS_ETH5
  492. eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
  493. #endif
  494. return 0;
  495. }
  496. #endif /* CONFIG_CMD_NET */
  497. #ifdef CONFIG_CMD_KGDB
  498. static int initr_kgdb(void)
  499. {
  500. puts("KGDB: ");
  501. kgdb_init();
  502. return 0;
  503. }
  504. #endif
  505. #if defined(CONFIG_LED_STATUS)
  506. static int initr_status_led(void)
  507. {
  508. #if defined(CONFIG_LED_STATUS_BOOT)
  509. status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING);
  510. #else
  511. status_led_init();
  512. #endif
  513. return 0;
  514. }
  515. #endif
  516. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  517. static int initr_scsi(void)
  518. {
  519. puts("SCSI: ");
  520. scsi_init();
  521. return 0;
  522. }
  523. #endif
  524. #ifdef CONFIG_BITBANGMII
  525. static int initr_bbmii(void)
  526. {
  527. bb_miiphy_init();
  528. return 0;
  529. }
  530. #endif
  531. #ifdef CONFIG_CMD_NET
  532. static int initr_net(void)
  533. {
  534. puts("Net: ");
  535. eth_initialize();
  536. #if defined(CONFIG_RESET_PHY_R)
  537. debug("Reset Ethernet PHY\n");
  538. reset_phy();
  539. #endif
  540. return 0;
  541. }
  542. #endif
  543. #ifdef CONFIG_POST
  544. static int initr_post(void)
  545. {
  546. post_run(NULL, POST_RAM | post_bootmode_get(0));
  547. return 0;
  548. }
  549. #endif
  550. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_IDE)
  551. static int initr_pcmcia(void)
  552. {
  553. puts("PCMCIA:");
  554. pcmcia_init();
  555. return 0;
  556. }
  557. #endif
  558. #if defined(CONFIG_IDE)
  559. static int initr_ide(void)
  560. {
  561. puts("IDE: ");
  562. #if defined(CONFIG_START_IDE)
  563. if (board_start_ide())
  564. ide_init();
  565. #else
  566. ide_init();
  567. #endif
  568. return 0;
  569. }
  570. #endif
  571. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  572. /*
  573. * Export available size of memory for Linux, taking into account the
  574. * protected RAM at top of memory
  575. */
  576. int initr_mem(void)
  577. {
  578. ulong pram = 0;
  579. char memsz[32];
  580. # ifdef CONFIG_PRAM
  581. pram = getenv_ulong("pram", 10, CONFIG_PRAM);
  582. # endif
  583. # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
  584. /* Also take the logbuffer into account (pram is in kB) */
  585. pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
  586. # endif
  587. sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram));
  588. setenv("mem", memsz);
  589. return 0;
  590. }
  591. #endif
  592. #ifdef CONFIG_CMD_BEDBUG
  593. static int initr_bedbug(void)
  594. {
  595. bedbug_init();
  596. return 0;
  597. }
  598. #endif
  599. #ifdef CONFIG_PS2KBD
  600. static int initr_kbd(void)
  601. {
  602. puts("PS/2: ");
  603. kbd_init();
  604. return 0;
  605. }
  606. #endif
  607. static int run_main_loop(void)
  608. {
  609. #ifdef CONFIG_SANDBOX
  610. sandbox_main_loop_init();
  611. #endif
  612. /* main_loop() can return to retry autoboot, if so just run it again */
  613. for (;;)
  614. main_loop();
  615. return 0;
  616. }
  617. /*
  618. * Over time we hope to remove these functions with code fragments and
  619. * stub funtcions, and instead call the relevant function directly.
  620. *
  621. * We also hope to remove most of the driver-related init and do it if/when
  622. * the driver is later used.
  623. *
  624. * TODO: perhaps reset the watchdog in the initcall function after each call?
  625. */
  626. static init_fnc_t init_sequence_r[] = {
  627. initr_trace,
  628. initr_reloc,
  629. /* TODO: could x86/PPC have this also perhaps? */
  630. #ifdef CONFIG_ARM
  631. initr_caches,
  632. /* Note: For Freescale LS2 SoCs, new MMU table is created in DDR.
  633. * A temporary mapping of IFC high region is since removed,
  634. * so environmental variables in NOR flash is not availble
  635. * until board_init() is called below to remap IFC to high
  636. * region.
  637. */
  638. #endif
  639. initr_reloc_global_data,
  640. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  641. initr_unlock_ram_in_cache,
  642. #endif
  643. initr_barrier,
  644. initr_malloc,
  645. initr_bootstage, /* Needs malloc() but has its own timer */
  646. initr_console_record,
  647. #ifdef CONFIG_SYS_NONCACHED_MEMORY
  648. initr_noncached,
  649. #endif
  650. bootstage_relocate,
  651. #ifdef CONFIG_OF_LIVE
  652. initr_of_live,
  653. #endif
  654. #ifdef CONFIG_DM
  655. initr_dm,
  656. #endif
  657. #if defined(CONFIG_ARM) || defined(CONFIG_NDS32)
  658. board_init, /* Setup chipselects */
  659. #endif
  660. /*
  661. * TODO: printing of the clock inforamtion of the board is now
  662. * implemented as part of bdinfo command. Currently only support for
  663. * davinci SOC's is added. Remove this check once all the board
  664. * implement this.
  665. */
  666. #ifdef CONFIG_CLOCKS
  667. set_cpu_clk_info, /* Setup clock information */
  668. #endif
  669. #ifdef CONFIG_EFI_LOADER
  670. efi_memory_init,
  671. #endif
  672. stdio_init_tables,
  673. initr_serial,
  674. initr_announce,
  675. INIT_FUNC_WATCHDOG_RESET
  676. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  677. initr_manual_reloc_cmdtable,
  678. #endif
  679. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
  680. initr_trap,
  681. #endif
  682. #ifdef CONFIG_ADDR_MAP
  683. initr_addr_map,
  684. #endif
  685. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  686. board_early_init_r,
  687. #endif
  688. INIT_FUNC_WATCHDOG_RESET
  689. #ifdef CONFIG_LOGBUFFER
  690. initr_logbuffer,
  691. #endif
  692. #ifdef CONFIG_POST
  693. initr_post_backlog,
  694. #endif
  695. INIT_FUNC_WATCHDOG_RESET
  696. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
  697. /*
  698. * Do early PCI configuration _before_ the flash gets initialised,
  699. * because PCU ressources are crucial for flash access on some boards.
  700. */
  701. initr_pci,
  702. #endif
  703. #ifdef CONFIG_ARCH_EARLY_INIT_R
  704. arch_early_init_r,
  705. #endif
  706. power_init_board,
  707. #ifdef CONFIG_MTD_NOR_FLASH
  708. initr_flash,
  709. #endif
  710. INIT_FUNC_WATCHDOG_RESET
  711. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
  712. /* initialize higher level parts of CPU like time base and timers */
  713. cpu_init_r,
  714. #endif
  715. #ifdef CONFIG_PPC
  716. initr_spi,
  717. #endif
  718. #ifdef CONFIG_CMD_NAND
  719. initr_nand,
  720. #endif
  721. #ifdef CONFIG_CMD_ONENAND
  722. initr_onenand,
  723. #endif
  724. #ifdef CONFIG_MMC
  725. initr_mmc,
  726. #endif
  727. #ifdef CONFIG_HAS_DATAFLASH
  728. initr_dataflash,
  729. #endif
  730. initr_env,
  731. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  732. initr_malloc_bootparams,
  733. #endif
  734. INIT_FUNC_WATCHDOG_RESET
  735. initr_secondary_cpu,
  736. #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
  737. mac_read_from_eeprom,
  738. #endif
  739. INIT_FUNC_WATCHDOG_RESET
  740. #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
  741. /*
  742. * Do pci configuration
  743. */
  744. initr_pci,
  745. #endif
  746. stdio_add_devices,
  747. initr_jumptable,
  748. #ifdef CONFIG_API
  749. initr_api,
  750. #endif
  751. console_init_r, /* fully init console as a device */
  752. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  753. show_board_info,
  754. #endif
  755. #ifdef CONFIG_ARCH_MISC_INIT
  756. arch_misc_init, /* miscellaneous arch-dependent init */
  757. #endif
  758. #ifdef CONFIG_MISC_INIT_R
  759. misc_init_r, /* miscellaneous platform-dependent init */
  760. #endif
  761. INIT_FUNC_WATCHDOG_RESET
  762. #ifdef CONFIG_CMD_KGDB
  763. initr_kgdb,
  764. #endif
  765. interrupt_init,
  766. #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
  767. initr_enable_interrupts,
  768. #endif
  769. #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) || defined(CONFIG_M68K)
  770. timer_init, /* initialize timer */
  771. #endif
  772. #if defined(CONFIG_LED_STATUS)
  773. initr_status_led,
  774. #endif
  775. /* PPC has a udelay(20) here dating from 2002. Why? */
  776. #ifdef CONFIG_CMD_NET
  777. initr_ethaddr,
  778. #endif
  779. #ifdef CONFIG_BOARD_LATE_INIT
  780. board_late_init,
  781. #endif
  782. #if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
  783. INIT_FUNC_WATCHDOG_RESET
  784. initr_scsi,
  785. #endif
  786. #ifdef CONFIG_BITBANGMII
  787. initr_bbmii,
  788. #endif
  789. #ifdef CONFIG_CMD_NET
  790. INIT_FUNC_WATCHDOG_RESET
  791. initr_net,
  792. #endif
  793. #ifdef CONFIG_POST
  794. initr_post,
  795. #endif
  796. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_IDE)
  797. initr_pcmcia,
  798. #endif
  799. #if defined(CONFIG_IDE)
  800. initr_ide,
  801. #endif
  802. #ifdef CONFIG_LAST_STAGE_INIT
  803. INIT_FUNC_WATCHDOG_RESET
  804. /*
  805. * Some parts can be only initialized if all others (like
  806. * Interrupts) are up and running (i.e. the PC-style ISA
  807. * keyboard).
  808. */
  809. last_stage_init,
  810. #endif
  811. #ifdef CONFIG_CMD_BEDBUG
  812. INIT_FUNC_WATCHDOG_RESET
  813. initr_bedbug,
  814. #endif
  815. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  816. initr_mem,
  817. #endif
  818. #ifdef CONFIG_PS2KBD
  819. initr_kbd,
  820. #endif
  821. run_main_loop,
  822. };
  823. void board_init_r(gd_t *new_gd, ulong dest_addr)
  824. {
  825. /*
  826. * Set up the new global data pointer. So far only x86 does this
  827. * here.
  828. * TODO(sjg@chromium.org): Consider doing this for all archs, or
  829. * dropping the new_gd parameter.
  830. */
  831. #if CONFIG_IS_ENABLED(X86_64)
  832. arch_setup_gd(new_gd);
  833. #endif
  834. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  835. int i;
  836. #endif
  837. #ifdef CONFIG_AVR32
  838. mmu_init_r(dest_addr);
  839. #endif
  840. #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
  841. gd = new_gd;
  842. #endif
  843. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  844. for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
  845. init_sequence_r[i] += gd->reloc_off;
  846. #endif
  847. if (initcall_run_list(init_sequence_r))
  848. hang();
  849. /* NOTREACHED - run_main_loop() does not return */
  850. hang();
  851. }