board_r.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * (C) Copyright 2002-2006
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2002
  7. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  8. * Marius Groeger <mgroeger@sysgo.de>
  9. *
  10. * SPDX-License-Identifier: GPL-2.0+
  11. */
  12. #include <common.h>
  13. /* TODO: can we just include all these headers whether needed or not? */
  14. #if defined(CONFIG_CMD_BEDBUG)
  15. #include <bedbug/type.h>
  16. #endif
  17. #ifdef CONFIG_HAS_DATAFLASH
  18. #include <dataflash.h>
  19. #endif
  20. #include <dm.h>
  21. #include <environment.h>
  22. #include <fdtdec.h>
  23. #if defined(CONFIG_CMD_IDE)
  24. #include <ide.h>
  25. #endif
  26. #include <initcall.h>
  27. #ifdef CONFIG_PS2KBD
  28. #include <keyboard.h>
  29. #endif
  30. #if defined(CONFIG_CMD_KGDB)
  31. #include <kgdb.h>
  32. #endif
  33. #include <logbuff.h>
  34. #include <malloc.h>
  35. #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. #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
  154. static int initr_trap(void)
  155. {
  156. /*
  157. * Setup trap handlers
  158. */
  159. #if defined(CONFIG_PPC)
  160. trap_init(gd->relocaddr);
  161. #else
  162. trap_init(CONFIG_SYS_SDRAM_BASE);
  163. #endif
  164. return 0;
  165. }
  166. #endif
  167. #ifdef CONFIG_ADDR_MAP
  168. static int initr_addr_map(void)
  169. {
  170. init_addr_map();
  171. return 0;
  172. }
  173. #endif
  174. #ifdef CONFIG_LOGBUFFER
  175. unsigned long logbuffer_base(void)
  176. {
  177. return gd->ram_top - LOGBUFF_LEN;
  178. }
  179. static int initr_logbuffer(void)
  180. {
  181. logbuff_init_ptrs();
  182. return 0;
  183. }
  184. #endif
  185. #ifdef CONFIG_POST
  186. static int initr_post_backlog(void)
  187. {
  188. post_output_backlog();
  189. return 0;
  190. }
  191. #endif
  192. #ifdef CONFIG_SYS_DELAYED_ICACHE
  193. static int initr_icache_enable(void)
  194. {
  195. return 0;
  196. }
  197. #endif
  198. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  199. static int initr_unlock_ram_in_cache(void)
  200. {
  201. unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
  202. return 0;
  203. }
  204. #endif
  205. #ifdef CONFIG_PCI
  206. static int initr_pci(void)
  207. {
  208. pci_init();
  209. return 0;
  210. }
  211. #endif
  212. #ifdef CONFIG_WINBOND_83C553
  213. static int initr_w83c553f(void)
  214. {
  215. /*
  216. * Initialise the ISA bridge
  217. */
  218. initialise_w83c553f();
  219. return 0;
  220. }
  221. #endif
  222. static int initr_barrier(void)
  223. {
  224. #ifdef CONFIG_PPC
  225. /* TODO: Can we not use dmb() macros for this? */
  226. asm("sync ; isync");
  227. #endif
  228. return 0;
  229. }
  230. static int initr_malloc(void)
  231. {
  232. ulong malloc_start;
  233. #ifdef CONFIG_SYS_MALLOC_F_LEN
  234. debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
  235. gd->malloc_ptr / 1024);
  236. #endif
  237. /* The malloc area is immediately below the monitor copy in DRAM */
  238. malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
  239. mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
  240. TOTAL_MALLOC_LEN);
  241. return 0;
  242. }
  243. #ifdef CONFIG_SYS_NONCACHED_MEMORY
  244. static int initr_noncached(void)
  245. {
  246. noncached_init();
  247. return 0;
  248. }
  249. #endif
  250. #ifdef CONFIG_DM
  251. static int initr_dm(void)
  252. {
  253. /* Save the pre-reloc driver model and start a new one */
  254. gd->dm_root_f = gd->dm_root;
  255. gd->dm_root = NULL;
  256. return dm_init_and_scan(false);
  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. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  269. static int initr_manual_reloc_cmdtable(void)
  270. {
  271. fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
  272. ll_entry_count(cmd_tbl_t, cmd));
  273. return 0;
  274. }
  275. #endif
  276. #if !defined(CONFIG_SYS_NO_FLASH)
  277. static int initr_flash(void)
  278. {
  279. ulong flash_size = 0;
  280. bd_t *bd = gd->bd;
  281. puts("Flash: ");
  282. if (board_flash_wp_on())
  283. printf("Uninitialized - Write Protect On\n");
  284. else
  285. flash_size = flash_init();
  286. print_size(flash_size, "");
  287. #ifdef CONFIG_SYS_FLASH_CHECKSUM
  288. /*
  289. * Compute and print flash CRC if flashchecksum is set to 'y'
  290. *
  291. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  292. */
  293. if (getenv_yesno("flashchecksum") == 1) {
  294. printf(" CRC: %08X", crc32(0,
  295. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  296. flash_size));
  297. }
  298. #endif /* CONFIG_SYS_FLASH_CHECKSUM */
  299. putc('\n');
  300. /* update start of FLASH memory */
  301. #ifdef CONFIG_SYS_FLASH_BASE
  302. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
  303. #endif
  304. /* size of FLASH memory (final value) */
  305. bd->bi_flashsize = flash_size;
  306. #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
  307. /* Make a update of the Memctrl. */
  308. update_flash_size(flash_size);
  309. #endif
  310. #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
  311. /* flash mapped at end of memory map */
  312. bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
  313. #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
  314. bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
  315. #endif
  316. return 0;
  317. }
  318. #endif
  319. #if defined(CONFIG_PPC) && !defined(CONFIG_DM_SPI)
  320. static int initr_spi(void)
  321. {
  322. /* PPC does this here */
  323. #ifdef CONFIG_SPI
  324. #if !defined(CONFIG_ENV_IS_IN_EEPROM)
  325. spi_init_f();
  326. #endif
  327. spi_init_r();
  328. #endif
  329. return 0;
  330. }
  331. #endif
  332. #ifdef CONFIG_CMD_NAND
  333. /* go init the NAND */
  334. static int initr_nand(void)
  335. {
  336. puts("NAND: ");
  337. nand_init();
  338. return 0;
  339. }
  340. #endif
  341. #if defined(CONFIG_CMD_ONENAND)
  342. /* go init the NAND */
  343. static int initr_onenand(void)
  344. {
  345. puts("NAND: ");
  346. onenand_init();
  347. return 0;
  348. }
  349. #endif
  350. #ifdef CONFIG_GENERIC_MMC
  351. static int initr_mmc(void)
  352. {
  353. puts("MMC: ");
  354. mmc_initialize(gd->bd);
  355. return 0;
  356. }
  357. #endif
  358. #ifdef CONFIG_HAS_DATAFLASH
  359. static int initr_dataflash(void)
  360. {
  361. AT91F_DataflashInit();
  362. dataflash_print_info();
  363. return 0;
  364. }
  365. #endif
  366. /*
  367. * Tell if it's OK to load the environment early in boot.
  368. *
  369. * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
  370. * if this is OK (defaulting to saying it's OK).
  371. *
  372. * NOTE: Loading the environment early can be a bad idea if security is
  373. * important, since no verification is done on the environment.
  374. *
  375. * @return 0 if environment should not be loaded, !=0 if it is ok to load
  376. */
  377. static int should_load_env(void)
  378. {
  379. #ifdef CONFIG_OF_CONTROL
  380. return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
  381. #elif defined CONFIG_DELAY_ENVIRONMENT
  382. return 0;
  383. #else
  384. return 1;
  385. #endif
  386. }
  387. static int initr_env(void)
  388. {
  389. /* initialize environment */
  390. if (should_load_env())
  391. env_relocate();
  392. else
  393. set_default_env(NULL);
  394. /* Initialize from environment */
  395. load_addr = getenv_ulong("loadaddr", 16, load_addr);
  396. #if defined(CONFIG_SYS_EXTBDINFO)
  397. #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
  398. #if defined(CONFIG_I2CFAST)
  399. /*
  400. * set bi_iic_fast for linux taking environment variable
  401. * "i2cfast" into account
  402. */
  403. {
  404. char *s = getenv("i2cfast");
  405. if (s && ((*s == 'y') || (*s == 'Y'))) {
  406. gd->bd->bi_iic_fast[0] = 1;
  407. gd->bd->bi_iic_fast[1] = 1;
  408. }
  409. }
  410. #endif /* CONFIG_I2CFAST */
  411. #endif /* CONFIG_405GP, CONFIG_405EP */
  412. #endif /* CONFIG_SYS_EXTBDINFO */
  413. return 0;
  414. }
  415. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  416. static int initr_malloc_bootparams(void)
  417. {
  418. gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN);
  419. if (!gd->bd->bi_boot_params) {
  420. puts("WARNING: Cannot allocate space for boot parameters\n");
  421. return -ENOMEM;
  422. }
  423. return 0;
  424. }
  425. #endif
  426. #ifdef CONFIG_SC3
  427. /* TODO: with new initcalls, move this into the driver */
  428. extern void sc3_read_eeprom(void);
  429. static int initr_sc3_read_eeprom(void)
  430. {
  431. sc3_read_eeprom();
  432. return 0;
  433. }
  434. #endif
  435. static int initr_jumptable(void)
  436. {
  437. jumptable_init();
  438. return 0;
  439. }
  440. #if defined(CONFIG_API)
  441. static int initr_api(void)
  442. {
  443. /* Initialize API */
  444. api_init();
  445. return 0;
  446. }
  447. #endif
  448. /* enable exceptions */
  449. #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
  450. static int initr_enable_interrupts(void)
  451. {
  452. enable_interrupts();
  453. return 0;
  454. }
  455. #endif
  456. #ifdef CONFIG_CMD_NET
  457. static int initr_ethaddr(void)
  458. {
  459. bd_t *bd = gd->bd;
  460. /* kept around for legacy kernels only ... ignore the next section */
  461. eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
  462. #ifdef CONFIG_HAS_ETH1
  463. eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
  464. #endif
  465. #ifdef CONFIG_HAS_ETH2
  466. eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
  467. #endif
  468. #ifdef CONFIG_HAS_ETH3
  469. eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
  470. #endif
  471. #ifdef CONFIG_HAS_ETH4
  472. eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
  473. #endif
  474. #ifdef CONFIG_HAS_ETH5
  475. eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
  476. #endif
  477. return 0;
  478. }
  479. #endif /* CONFIG_CMD_NET */
  480. #ifdef CONFIG_CMD_KGDB
  481. static int initr_kgdb(void)
  482. {
  483. puts("KGDB: ");
  484. kgdb_init();
  485. return 0;
  486. }
  487. #endif
  488. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  489. static int initr_status_led(void)
  490. {
  491. status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
  492. return 0;
  493. }
  494. #endif
  495. #if defined(CONFIG_CMD_SCSI)
  496. static int initr_scsi(void)
  497. {
  498. puts("SCSI: ");
  499. scsi_init();
  500. return 0;
  501. }
  502. #endif
  503. #if defined(CONFIG_CMD_DOC)
  504. static int initr_doc(void)
  505. {
  506. puts("DOC: ");
  507. doc_init();
  508. return 0;
  509. }
  510. #endif
  511. #ifdef CONFIG_BITBANGMII
  512. static int initr_bbmii(void)
  513. {
  514. bb_miiphy_init();
  515. return 0;
  516. }
  517. #endif
  518. #ifdef CONFIG_CMD_NET
  519. static int initr_net(void)
  520. {
  521. puts("Net: ");
  522. eth_initialize(gd->bd);
  523. #if defined(CONFIG_RESET_PHY_R)
  524. debug("Reset Ethernet PHY\n");
  525. reset_phy();
  526. #endif
  527. return 0;
  528. }
  529. #endif
  530. #ifdef CONFIG_POST
  531. static int initr_post(void)
  532. {
  533. post_run(NULL, POST_RAM | post_bootmode_get(0));
  534. return 0;
  535. }
  536. #endif
  537. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
  538. static int initr_pcmcia(void)
  539. {
  540. puts("PCMCIA:");
  541. pcmcia_init();
  542. return 0;
  543. }
  544. #endif
  545. #if defined(CONFIG_CMD_IDE)
  546. static int initr_ide(void)
  547. {
  548. #ifdef CONFIG_IDE_8xx_PCCARD
  549. puts("PCMCIA:");
  550. #else
  551. puts("IDE: ");
  552. #endif
  553. #if defined(CONFIG_START_IDE)
  554. if (board_start_ide())
  555. ide_init();
  556. #else
  557. ide_init();
  558. #endif
  559. return 0;
  560. }
  561. #endif
  562. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  563. /*
  564. * Export available size of memory for Linux, taking into account the
  565. * protected RAM at top of memory
  566. */
  567. int initr_mem(void)
  568. {
  569. ulong pram = 0;
  570. char memsz[32];
  571. # ifdef CONFIG_PRAM
  572. pram = getenv_ulong("pram", 10, CONFIG_PRAM);
  573. # endif
  574. # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
  575. /* Also take the logbuffer into account (pram is in kB) */
  576. pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
  577. # endif
  578. sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram));
  579. setenv("mem", memsz);
  580. return 0;
  581. }
  582. #endif
  583. #ifdef CONFIG_CMD_BEDBUG
  584. static int initr_bedbug(void)
  585. {
  586. bedbug_init();
  587. return 0;
  588. }
  589. #endif
  590. #ifdef CONFIG_PS2KBD
  591. static int initr_kbd(void)
  592. {
  593. puts("PS/2: ");
  594. kbd_init();
  595. return 0;
  596. }
  597. #endif
  598. static int run_main_loop(void)
  599. {
  600. #ifdef CONFIG_SANDBOX
  601. sandbox_main_loop_init();
  602. #endif
  603. /* main_loop() can return to retry autoboot, if so just run it again */
  604. for (;;)
  605. main_loop();
  606. return 0;
  607. }
  608. /*
  609. * Over time we hope to remove these functions with code fragments and
  610. * stub funtcions, and instead call the relevant function directly.
  611. *
  612. * We also hope to remove most of the driver-related init and do it if/when
  613. * the driver is later used.
  614. *
  615. * TODO: perhaps reset the watchdog in the initcall function after each call?
  616. */
  617. init_fnc_t init_sequence_r[] = {
  618. initr_trace,
  619. initr_reloc,
  620. /* TODO: could x86/PPC have this also perhaps? */
  621. #ifdef CONFIG_ARM
  622. initr_caches,
  623. #endif
  624. initr_reloc_global_data,
  625. #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
  626. initr_unlock_ram_in_cache,
  627. #endif
  628. initr_barrier,
  629. initr_malloc,
  630. #ifdef CONFIG_SYS_NONCACHED_MEMORY
  631. initr_noncached,
  632. #endif
  633. bootstage_relocate,
  634. #ifdef CONFIG_DM
  635. initr_dm,
  636. #endif
  637. #ifdef CONFIG_ARM
  638. board_init, /* Setup chipselects */
  639. #endif
  640. /*
  641. * TODO: printing of the clock inforamtion of the board is now
  642. * implemented as part of bdinfo command. Currently only support for
  643. * davinci SOC's is added. Remove this check once all the board
  644. * implement this.
  645. */
  646. #ifdef CONFIG_CLOCKS
  647. set_cpu_clk_info, /* Setup clock information */
  648. #endif
  649. stdio_init_tables,
  650. initr_serial,
  651. initr_announce,
  652. INIT_FUNC_WATCHDOG_RESET
  653. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  654. initr_manual_reloc_cmdtable,
  655. #endif
  656. #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
  657. initr_trap,
  658. #endif
  659. #ifdef CONFIG_ADDR_MAP
  660. initr_addr_map,
  661. #endif
  662. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  663. board_early_init_r,
  664. #endif
  665. INIT_FUNC_WATCHDOG_RESET
  666. #ifdef CONFIG_LOGBUFFER
  667. initr_logbuffer,
  668. #endif
  669. #ifdef CONFIG_POST
  670. initr_post_backlog,
  671. #endif
  672. INIT_FUNC_WATCHDOG_RESET
  673. #ifdef CONFIG_SYS_DELAYED_ICACHE
  674. initr_icache_enable,
  675. #endif
  676. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
  677. /*
  678. * Do early PCI configuration _before_ the flash gets initialised,
  679. * because PCU ressources are crucial for flash access on some boards.
  680. */
  681. initr_pci,
  682. #endif
  683. #ifdef CONFIG_WINBOND_83C553
  684. initr_w83c553f,
  685. #endif
  686. #ifdef CONFIG_ARCH_EARLY_INIT_R
  687. arch_early_init_r,
  688. #endif
  689. power_init_board,
  690. #ifndef CONFIG_SYS_NO_FLASH
  691. initr_flash,
  692. #endif
  693. INIT_FUNC_WATCHDOG_RESET
  694. #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
  695. /* initialize higher level parts of CPU like time base and timers */
  696. cpu_init_r,
  697. #endif
  698. #ifdef CONFIG_PPC
  699. initr_spi,
  700. #endif
  701. #if defined(CONFIG_X86) && defined(CONFIG_SPI)
  702. init_func_spi,
  703. #endif
  704. #ifdef CONFIG_CMD_NAND
  705. initr_nand,
  706. #endif
  707. #ifdef CONFIG_CMD_ONENAND
  708. initr_onenand,
  709. #endif
  710. #ifdef CONFIG_GENERIC_MMC
  711. initr_mmc,
  712. #endif
  713. #ifdef CONFIG_HAS_DATAFLASH
  714. initr_dataflash,
  715. #endif
  716. initr_env,
  717. #ifdef CONFIG_SYS_BOOTPARAMS_LEN
  718. initr_malloc_bootparams,
  719. #endif
  720. INIT_FUNC_WATCHDOG_RESET
  721. initr_secondary_cpu,
  722. #ifdef CONFIG_SC3
  723. initr_sc3_read_eeprom,
  724. #endif
  725. #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
  726. mac_read_from_eeprom,
  727. #endif
  728. INIT_FUNC_WATCHDOG_RESET
  729. #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
  730. /*
  731. * Do pci configuration
  732. */
  733. initr_pci,
  734. #endif
  735. stdio_add_devices,
  736. initr_jumptable,
  737. #ifdef CONFIG_API
  738. initr_api,
  739. #endif
  740. console_init_r, /* fully init console as a device */
  741. #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
  742. show_board_info,
  743. #endif
  744. #ifdef CONFIG_ARCH_MISC_INIT
  745. arch_misc_init, /* miscellaneous arch-dependent init */
  746. #endif
  747. #ifdef CONFIG_MISC_INIT_R
  748. misc_init_r, /* miscellaneous platform-dependent init */
  749. #endif
  750. INIT_FUNC_WATCHDOG_RESET
  751. #ifdef CONFIG_CMD_KGDB
  752. initr_kgdb,
  753. #endif
  754. interrupt_init,
  755. #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
  756. initr_enable_interrupts,
  757. #endif
  758. #if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) \
  759. || defined(CONFIG_M68K)
  760. timer_init, /* initialize timer */
  761. #endif
  762. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  763. initr_status_led,
  764. #endif
  765. /* PPC has a udelay(20) here dating from 2002. Why? */
  766. #ifdef CONFIG_CMD_NET
  767. initr_ethaddr,
  768. #endif
  769. #ifdef CONFIG_BOARD_LATE_INIT
  770. board_late_init,
  771. #endif
  772. #ifdef CONFIG_CMD_SCSI
  773. INIT_FUNC_WATCHDOG_RESET
  774. initr_scsi,
  775. #endif
  776. #ifdef CONFIG_CMD_DOC
  777. INIT_FUNC_WATCHDOG_RESET
  778. initr_doc,
  779. #endif
  780. #ifdef CONFIG_BITBANGMII
  781. initr_bbmii,
  782. #endif
  783. #ifdef CONFIG_CMD_NET
  784. INIT_FUNC_WATCHDOG_RESET
  785. initr_net,
  786. #endif
  787. #ifdef CONFIG_POST
  788. initr_post,
  789. #endif
  790. #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
  791. initr_pcmcia,
  792. #endif
  793. #if defined(CONFIG_CMD_IDE)
  794. initr_ide,
  795. #endif
  796. #ifdef CONFIG_LAST_STAGE_INIT
  797. INIT_FUNC_WATCHDOG_RESET
  798. /*
  799. * Some parts can be only initialized if all others (like
  800. * Interrupts) are up and running (i.e. the PC-style ISA
  801. * keyboard).
  802. */
  803. last_stage_init,
  804. #endif
  805. #ifdef CONFIG_CMD_BEDBUG
  806. INIT_FUNC_WATCHDOG_RESET
  807. initr_bedbug,
  808. #endif
  809. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  810. initr_mem,
  811. #endif
  812. #ifdef CONFIG_PS2KBD
  813. initr_kbd,
  814. #endif
  815. run_main_loop,
  816. };
  817. void board_init_r(gd_t *new_gd, ulong dest_addr)
  818. {
  819. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  820. int i;
  821. #endif
  822. #ifdef CONFIG_AVR32
  823. mmu_init_r(dest_addr);
  824. #endif
  825. #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
  826. gd = new_gd;
  827. #endif
  828. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  829. for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
  830. init_sequence_r[i] += gd->reloc_off;
  831. #endif
  832. if (initcall_run_list(init_sequence_r))
  833. hang();
  834. /* NOTREACHED - run_main_loop() does not return */
  835. hang();
  836. }