board_r.c 17 KB

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