board_r.c 18 KB

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