board_r.c 18 KB

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