board_r.c 18 KB

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