board_r.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  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. 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. int board_flash_wp_on(void)
  69. __attribute__ ((weak, alias("__board_flash_wp_on")));
  70. void __cpu_secondary_init_r(void)
  71. {
  72. }
  73. void cpu_secondary_init_r(void)
  74. __attribute__ ((weak, alias("__cpu_secondary_init_r")));
  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. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  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)
  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. /* The malloc area is immediately below the monitor copy in DRAM */
  230. malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
  231. mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
  232. TOTAL_MALLOC_LEN);
  233. return 0;
  234. }
  235. #ifdef CONFIG_DM
  236. static int initr_dm(void)
  237. {
  238. int ret;
  239. ret = dm_init();
  240. if (ret) {
  241. debug("dm_init() failed: %d\n", ret);
  242. return ret;
  243. }
  244. ret = dm_scan_platdata();
  245. if (ret) {
  246. debug("dm_scan_platdata() failed: %d\n", ret);
  247. return ret;
  248. }
  249. #ifdef CONFIG_OF_CONTROL
  250. ret = dm_scan_fdt(gd->fdt_blob);
  251. if (ret) {
  252. debug("dm_scan_fdt() failed: %d\n", ret);
  253. return ret;
  254. }
  255. #endif
  256. return 0;
  257. }
  258. #endif
  259. __weak int power_init_board(void)
  260. {
  261. return 0;
  262. }
  263. static int initr_announce(void)
  264. {
  265. debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr);
  266. return 0;
  267. }
  268. #if !defined(CONFIG_SYS_NO_FLASH)
  269. static int initr_flash(void)
  270. {
  271. ulong flash_size = 0;
  272. bd_t *bd = gd->bd;
  273. int ok;
  274. puts("Flash: ");
  275. if (board_flash_wp_on()) {
  276. printf("Uninitialized - Write Protect On\n");
  277. /* Since WP is on, we can't find real size. Set to 0 */
  278. ok = 1;
  279. } else {
  280. flash_size = flash_init();
  281. ok = flash_size > 0;
  282. }
  283. if (!ok) {
  284. puts("*** failed ***\n");
  285. #ifdef CONFIG_PPC
  286. /* Why does PPC do this? */
  287. hang();
  288. #endif
  289. return -1;
  290. }
  291. print_size(flash_size, "");
  292. #ifdef CONFIG_SYS_FLASH_CHECKSUM
  293. /*
  294. * Compute and print flash CRC if flashchecksum is set to 'y'
  295. *
  296. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  297. */
  298. if (getenv_yesno("flashchecksum") == 1) {
  299. printf(" CRC: %08X", crc32(0,
  300. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  301. flash_size));
  302. }
  303. #endif /* CONFIG_SYS_FLASH_CHECKSUM */
  304. putc('\n');
  305. /* update start of FLASH memory */
  306. #ifdef CONFIG_SYS_FLASH_BASE
  307. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
  308. #endif
  309. /* size of FLASH memory (final value) */
  310. bd->bi_flashsize = flash_size;
  311. #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
  312. /* Make a update of the Memctrl. */
  313. update_flash_size(flash_size);
  314. #endif
  315. #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
  316. /* flash mapped at end of memory map */
  317. bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
  318. #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
  319. bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
  320. #endif
  321. return 0;
  322. }
  323. #endif
  324. #ifdef CONFIG_PPC
  325. static int initr_spi(void)
  326. {
  327. /* PPC does this here */
  328. #ifdef CONFIG_SPI
  329. #if !defined(CONFIG_ENV_IS_IN_EEPROM)
  330. spi_init_f();
  331. #endif
  332. spi_init_r();
  333. #endif
  334. return 0;
  335. }
  336. #endif
  337. #ifdef CONFIG_CMD_NAND
  338. /* go init the NAND */
  339. int initr_nand(void)
  340. {
  341. puts("NAND: ");
  342. nand_init();
  343. return 0;
  344. }
  345. #endif
  346. #if defined(CONFIG_CMD_ONENAND)
  347. /* go init the NAND */
  348. int initr_onenand(void)
  349. {
  350. puts("NAND: ");
  351. onenand_init();
  352. return 0;
  353. }
  354. #endif
  355. #ifdef CONFIG_GENERIC_MMC
  356. int initr_mmc(void)
  357. {
  358. puts("MMC: ");
  359. mmc_initialize(gd->bd);
  360. return 0;
  361. }
  362. #endif
  363. #ifdef CONFIG_HAS_DATAFLASH
  364. int initr_dataflash(void)
  365. {
  366. AT91F_DataflashInit();
  367. dataflash_print_info();
  368. return 0;
  369. }
  370. #endif
  371. /*
  372. * Tell if it's OK to load the environment early in boot.
  373. *
  374. * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
  375. * if this is OK (defaulting to saying it's OK).
  376. *
  377. * NOTE: Loading the environment early can be a bad idea if security is
  378. * important, since no verification is done on the environment.
  379. *
  380. * @return 0 if environment should not be loaded, !=0 if it is ok to load
  381. */
  382. static int should_load_env(void)
  383. {
  384. #ifdef CONFIG_OF_CONTROL
  385. return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
  386. #elif defined CONFIG_DELAY_ENVIRONMENT
  387. return 0;
  388. #else
  389. return 1;
  390. #endif
  391. }
  392. static int initr_env(void)
  393. {
  394. /* initialize environment */
  395. if (should_load_env())
  396. env_relocate();
  397. else
  398. set_default_env(NULL);
  399. /* Initialize from environment */
  400. load_addr = getenv_ulong("loadaddr", 16, load_addr);
  401. #if defined(CONFIG_SYS_EXTBDINFO)
  402. #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
  403. #if defined(CONFIG_I2CFAST)
  404. /*
  405. * set bi_iic_fast for linux taking environment variable
  406. * "i2cfast" into account
  407. */
  408. {
  409. char *s = getenv("i2cfast");
  410. if (s && ((*s == 'y') || (*s == 'Y'))) {
  411. gd->bd->bi_iic_fast[0] = 1;
  412. gd->bd->bi_iic_fast[1] = 1;
  413. }
  414. }
  415. #endif /* CONFIG_I2CFAST */
  416. #endif /* CONFIG_405GP, CONFIG_405EP */
  417. #endif /* CONFIG_SYS_EXTBDINFO */
  418. return 0;
  419. }
  420. #ifdef CONFIG_HERMES
  421. static int initr_hermes(void)
  422. {
  423. if ((gd->board_type >> 16) == 2)
  424. gd->bd->bi_ethspeed = gd->board_type & 0xFFFF;
  425. else
  426. gd->bd->bi_ethspeed = 0xFFFF;
  427. return 0;
  428. }
  429. static int initr_hermes_start(void)
  430. {
  431. if (gd->bd->bi_ethspeed != 0xFFFF)
  432. hermes_start_lxt980((int) gd->bd->bi_ethspeed);
  433. return 0;
  434. }
  435. #endif
  436. #ifdef CONFIG_SC3
  437. /* TODO: with new initcalls, move this into the driver */
  438. extern void sc3_read_eeprom(void);
  439. static int initr_sc3_read_eeprom(void)
  440. {
  441. sc3_read_eeprom();
  442. return 0;
  443. }
  444. #endif
  445. static int initr_jumptable(void)
  446. {
  447. jumptable_init();
  448. return 0;
  449. }
  450. #if defined(CONFIG_API)
  451. static int initr_api(void)
  452. {
  453. /* Initialize API */
  454. api_init();
  455. return 0;
  456. }
  457. #endif
  458. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  459. static int show_model_r(void)
  460. {
  461. /* Put this here so it appears on the LCD, now it is ready */
  462. # ifdef CONFIG_OF_CONTROL
  463. const char *model;
  464. model = (char *)fdt_getprop(gd->fdt_blob, 0, "model", NULL);
  465. printf("Model: %s\n", model ? model : "<unknown>");
  466. # else
  467. checkboard();
  468. # endif
  469. }
  470. #endif
  471. /* enable exceptions */
  472. #ifdef CONFIG_ARM
  473. static int initr_enable_interrupts(void)
  474. {
  475. enable_interrupts();
  476. return 0;
  477. }
  478. #endif
  479. #ifdef CONFIG_CMD_NET
  480. static int initr_ethaddr(void)
  481. {
  482. bd_t *bd = gd->bd;
  483. /* kept around for legacy kernels only ... ignore the next section */
  484. eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
  485. #ifdef CONFIG_HAS_ETH1
  486. eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
  487. #endif
  488. #ifdef CONFIG_HAS_ETH2
  489. eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
  490. #endif
  491. #ifdef CONFIG_HAS_ETH3
  492. eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
  493. #endif
  494. #ifdef CONFIG_HAS_ETH4
  495. eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
  496. #endif
  497. #ifdef CONFIG_HAS_ETH5
  498. eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
  499. #endif
  500. return 0;
  501. }
  502. #endif /* CONFIG_CMD_NET */
  503. #ifdef CONFIG_CMD_KGDB
  504. static int initr_kgdb(void)
  505. {
  506. puts("KGDB: ");
  507. kgdb_init();
  508. return 0;
  509. }
  510. #endif
  511. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  512. static int initr_status_led(void)
  513. {
  514. status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
  515. return 0;
  516. }
  517. #endif
  518. #if defined(CONFIG_CMD_SCSI)
  519. static int initr_scsi(void)
  520. {
  521. /* Not supported properly on ARM yet */
  522. #ifndef CONFIG_ARM
  523. puts("SCSI: ");
  524. scsi_init();
  525. #endif
  526. return 0;
  527. }
  528. #endif /* CONFIG_CMD_NET */
  529. #if defined(CONFIG_CMD_DOC)
  530. static int initr_doc(void)
  531. {
  532. puts("DOC: ");
  533. doc_init();
  534. }
  535. #endif
  536. #ifdef CONFIG_BITBANGMII
  537. static int initr_bbmii(void)
  538. {
  539. bb_miiphy_init();
  540. return 0;
  541. }
  542. #endif
  543. #ifdef CONFIG_CMD_NET
  544. static int initr_net(void)
  545. {
  546. puts("Net: ");
  547. eth_initialize(gd->bd);
  548. #if defined(CONFIG_RESET_PHY_R)
  549. debug("Reset Ethernet PHY\n");
  550. reset_phy();
  551. #endif
  552. return 0;
  553. }
  554. #endif
  555. #ifdef CONFIG_POST
  556. static int initr_post(void)
  557. {
  558. post_run(NULL, POST_RAM | post_bootmode_get(0));
  559. return 0;
  560. }
  561. #endif
  562. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
  563. static int initr_pcmcia(void)
  564. {
  565. puts("PCMCIA:");
  566. pcmcia_init();
  567. return 0;
  568. }
  569. #endif
  570. #if defined(CONFIG_CMD_IDE)
  571. static int initr_ide(void)
  572. {
  573. #ifdef CONFIG_IDE_8xx_PCCARD
  574. puts("PCMCIA:");
  575. #else
  576. puts("IDE: ");
  577. #endif
  578. #if defined(CONFIG_START_IDE)
  579. if (board_start_ide())
  580. ide_init();
  581. #else
  582. ide_init();
  583. #endif
  584. return 0;
  585. }
  586. #endif
  587. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  588. /*
  589. * Export available size of memory for Linux, taking into account the
  590. * protected RAM at top of memory
  591. */
  592. int initr_mem(void)
  593. {
  594. ulong pram = 0;
  595. char memsz[32];
  596. # ifdef CONFIG_PRAM
  597. pram = getenv_ulong("pram", 10, CONFIG_PRAM);
  598. # endif
  599. # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
  600. /* Also take the logbuffer into account (pram is in kB) */
  601. pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
  602. # endif
  603. sprintf(memsz, "%ldk", (gd->ram_size / 1024) - pram);
  604. setenv("mem", memsz);
  605. return 0;
  606. }
  607. #endif
  608. #ifdef CONFIG_CMD_BEDBUG
  609. static int initr_bedbug(void)
  610. {
  611. bedbug_init();
  612. return 0;
  613. }
  614. #endif
  615. #ifdef CONFIG_PS2KBD
  616. static int initr_kbd(void)
  617. {
  618. puts("PS/2: ");
  619. kbd_init();
  620. return 0;
  621. }
  622. #endif
  623. #ifdef CONFIG_MODEM_SUPPORT
  624. static int initr_modem(void)
  625. {
  626. /* TODO: with new initcalls, move this into the driver */
  627. extern int do_mdm_init;
  628. do_mdm_init = gd->do_mdm_init;
  629. return 0;
  630. }
  631. #endif
  632. static int run_main_loop(void)
  633. {
  634. #ifdef CONFIG_SANDBOX
  635. sandbox_main_loop_init();
  636. #endif
  637. /* main_loop() can return to retry autoboot, if so just run it again */
  638. for (;;)
  639. main_loop();
  640. return 0;
  641. }
  642. /*
  643. * Over time we hope to remove these functions with code fragments and
  644. * stub funtcions, and instead call the relevant function directly.
  645. *
  646. * We also hope to remove most of the driver-related init and do it if/when
  647. * the driver is later used.
  648. *
  649. * TODO: perhaps reset the watchdog in the initcall function after each call?
  650. */
  651. init_fnc_t init_sequence_r[] = {
  652. initr_trace,
  653. initr_reloc,
  654. /* TODO: could x86/PPC have this also perhaps? */
  655. #ifdef CONFIG_ARM
  656. initr_caches,
  657. board_init, /* Setup chipselects */
  658. #endif
  659. /*
  660. * TODO: printing of the clock inforamtion of the board is now
  661. * implemented as part of bdinfo command. Currently only support for
  662. * davinci SOC's is added. Remove this check once all the board
  663. * implement this.
  664. */
  665. #ifdef CONFIG_CLOCKS
  666. set_cpu_clk_info, /* Setup clock information */
  667. #endif
  668. initr_reloc_global_data,
  669. initr_serial,
  670. initr_announce,
  671. INIT_FUNC_WATCHDOG_RESET
  672. #ifdef CONFIG_PPC
  673. initr_trap,
  674. #endif
  675. #ifdef CONFIG_ADDR_MAP
  676. initr_addr_map,
  677. #endif
  678. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  679. board_early_init_r,
  680. #endif
  681. INIT_FUNC_WATCHDOG_RESET
  682. #ifdef CONFIG_LOGBUFFER
  683. initr_logbuffer,
  684. #endif
  685. #ifdef CONFIG_POST
  686. initr_post_backlog,
  687. #endif
  688. INIT_FUNC_WATCHDOG_RESET
  689. #ifdef CONFIG_SYS_DELAYED_ICACHE
  690. initr_icache_enable,
  691. #endif
  692. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  693. initr_unlock_ram_in_cache,
  694. #endif
  695. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
  696. /*
  697. * Do early PCI configuration _before_ the flash gets initialised,
  698. * because PCU ressources are crucial for flash access on some boards.
  699. */
  700. initr_pci,
  701. #endif
  702. #ifdef CONFIG_WINBOND_83C553
  703. initr_w83c553f,
  704. #endif
  705. initr_barrier,
  706. initr_malloc,
  707. bootstage_relocate,
  708. #ifdef CONFIG_DM
  709. initr_dm,
  710. #endif
  711. #ifdef CONFIG_ARCH_EARLY_INIT_R
  712. arch_early_init_r,
  713. #endif
  714. power_init_board,
  715. #ifndef CONFIG_SYS_NO_FLASH
  716. initr_flash,
  717. #endif
  718. INIT_FUNC_WATCHDOG_RESET
  719. #if defined(CONFIG_PPC) || defined(CONFIG_X86)
  720. /* initialize higher level parts of CPU like time base and timers */
  721. cpu_init_r,
  722. #endif
  723. #ifdef CONFIG_PPC
  724. initr_spi,
  725. #endif
  726. #if defined(CONFIG_X86) && defined(CONFIG_SPI)
  727. init_func_spi,
  728. #endif
  729. #ifdef CONFIG_CMD_NAND
  730. initr_nand,
  731. #endif
  732. #ifdef CONFIG_CMD_ONENAND
  733. initr_onenand,
  734. #endif
  735. #ifdef CONFIG_GENERIC_MMC
  736. initr_mmc,
  737. #endif
  738. #ifdef CONFIG_HAS_DATAFLASH
  739. initr_dataflash,
  740. #endif
  741. initr_env,
  742. INIT_FUNC_WATCHDOG_RESET
  743. initr_secondary_cpu,
  744. #ifdef CONFIG_SC3
  745. initr_sc3_read_eeprom,
  746. #endif
  747. #ifdef CONFIG_HERMES
  748. initr_hermes,
  749. #endif
  750. #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
  751. mac_read_from_eeprom,
  752. #endif
  753. INIT_FUNC_WATCHDOG_RESET
  754. #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
  755. /*
  756. * Do pci configuration
  757. */
  758. initr_pci,
  759. #endif
  760. stdio_init,
  761. initr_jumptable,
  762. #ifdef CONFIG_API
  763. initr_api,
  764. #endif
  765. console_init_r, /* fully init console as a device */
  766. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  767. show_model_r,
  768. #endif
  769. #ifdef CONFIG_ARCH_MISC_INIT
  770. arch_misc_init, /* miscellaneous arch-dependent init */
  771. #endif
  772. #ifdef CONFIG_MISC_INIT_R
  773. misc_init_r, /* miscellaneous platform-dependent init */
  774. #endif
  775. #ifdef CONFIG_HERMES
  776. initr_hermes_start,
  777. #endif
  778. INIT_FUNC_WATCHDOG_RESET
  779. #ifdef CONFIG_CMD_KGDB
  780. initr_kgdb,
  781. #endif
  782. #ifdef CONFIG_X86
  783. board_early_init_r,
  784. #endif
  785. interrupt_init,
  786. #if defined(CONFIG_ARM) || defined(CONFIG_x86)
  787. initr_enable_interrupts,
  788. #endif
  789. #ifdef CONFIG_X86
  790. timer_init, /* initialize timer */
  791. #endif
  792. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  793. initr_status_led,
  794. #endif
  795. /* PPC has a udelay(20) here dating from 2002. Why? */
  796. #ifdef CONFIG_CMD_NET
  797. initr_ethaddr,
  798. #endif
  799. #ifdef CONFIG_BOARD_LATE_INIT
  800. board_late_init,
  801. #endif
  802. #ifdef CONFIG_CMD_SCSI
  803. INIT_FUNC_WATCHDOG_RESET
  804. initr_scsi,
  805. #endif
  806. #ifdef CONFIG_CMD_DOC
  807. INIT_FUNC_WATCHDOG_RESET
  808. initr_doc,
  809. #endif
  810. #ifdef CONFIG_BITBANGMII
  811. initr_bbmii,
  812. #endif
  813. #ifdef CONFIG_CMD_NET
  814. INIT_FUNC_WATCHDOG_RESET
  815. initr_net,
  816. #endif
  817. #ifdef CONFIG_POST
  818. initr_post,
  819. #endif
  820. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
  821. initr_pcmcia,
  822. #endif
  823. #if defined(CONFIG_CMD_IDE)
  824. initr_ide,
  825. #endif
  826. #ifdef CONFIG_LAST_STAGE_INIT
  827. INIT_FUNC_WATCHDOG_RESET
  828. /*
  829. * Some parts can be only initialized if all others (like
  830. * Interrupts) are up and running (i.e. the PC-style ISA
  831. * keyboard).
  832. */
  833. last_stage_init,
  834. #endif
  835. #ifdef CONFIG_CMD_BEDBUG
  836. INIT_FUNC_WATCHDOG_RESET
  837. initr_bedbug,
  838. #endif
  839. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  840. initr_mem,
  841. #endif
  842. #ifdef CONFIG_PS2KBD
  843. initr_kbd,
  844. #endif
  845. #ifdef CONFIG_MODEM_SUPPORT
  846. initr_modem,
  847. #endif
  848. run_main_loop,
  849. };
  850. void board_init_r(gd_t *new_gd, ulong dest_addr)
  851. {
  852. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  853. int i;
  854. #endif
  855. #ifndef CONFIG_X86
  856. gd = new_gd;
  857. #endif
  858. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  859. for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
  860. init_sequence_r[i] += gd->reloc_off;
  861. #endif
  862. if (initcall_run_list(init_sequence_r))
  863. hang();
  864. /* NOTREACHED - run_main_loop() does not return */
  865. hang();
  866. }