board_r.c 18 KB

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