]> git.ipfire.org Git - people/ms/u-boot.git/blame - common/board_r.c
sparc: Kconfig: Move the CMD_AMBAPP command to Kconfig
[people/ms/u-boot.git] / common / board_r.c
CommitLineData
6f6430d7
SG
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 *
1a459660 10 * SPDX-License-Identifier: GPL-2.0+
6f6430d7
SG
11 */
12
13#include <common.h>
c2240d4d
SG
14/* TODO: can we just include all these headers whether needed or not? */
15#if defined(CONFIG_CMD_BEDBUG)
16#include <bedbug/type.h>
17#endif
6f6430d7
SG
18#ifdef CONFIG_HAS_DATAFLASH
19#include <dataflash.h>
20#endif
1ce60176 21#include <dm.h>
6f6430d7
SG
22#include <environment.h>
23#include <fdtdec.h>
c2240d4d
SG
24#if defined(CONFIG_CMD_IDE)
25#include <ide.h>
26#endif
6f6430d7 27#include <initcall.h>
c2240d4d
SG
28#ifdef CONFIG_PS2KBD
29#include <keyboard.h>
30#endif
31#if defined(CONFIG_CMD_KGDB)
32#include <kgdb.h>
33#endif
6f6430d7
SG
34#include <logbuff.h>
35#include <malloc.h>
0eb25b61 36#include <mapmem.h>
c2240d4d
SG
37#ifdef CONFIG_BITBANGMII
38#include <miiphy.h>
39#endif
6f6430d7
SG
40#include <mmc.h>
41#include <nand.h>
42#include <onenand_uboot.h>
c2240d4d 43#include <scsi.h>
6f6430d7 44#include <serial.h>
c2240d4d 45#include <spi.h>
6f6430d7 46#include <stdio_dev.h>
71c52dba 47#include <trace.h>
c2240d4d 48#include <watchdog.h>
3f33f6a2
FR
49#ifdef CONFIG_CMD_AMBAPP
50#include <ambapp.h>
51#endif
c2240d4d
SG
52#ifdef CONFIG_ADDR_MAP
53#include <asm/mmu.h>
54#endif
6f6430d7 55#include <asm/sections.h>
be274b99
SG
56#ifdef CONFIG_X86
57#include <asm/init_helpers.h>
58#endif
1ce60176 59#include <dm/root.h>
c2240d4d 60#include <linux/compiler.h>
1ce60176 61#include <linux/err.h>
a752a8b4
AB
62#ifdef CONFIG_AVR32
63#include <asm/arch/mmu.h>
64#endif
6f6430d7
SG
65
66DECLARE_GLOBAL_DATA_PTR;
67
68ulong monitor_flash_len;
69
dd2a6cd0 70__weak int board_flash_wp_on(void)
c2240d4d
SG
71{
72 /*
73 * Most flashes can't be detected when write protection is enabled,
74 * so provide a way to let U-Boot gracefully ignore write protected
75 * devices.
76 */
77 return 0;
78}
79
dd2a6cd0 80__weak void cpu_secondary_init_r(void)
c2240d4d
SG
81{
82}
83
c2240d4d
SG
84static int initr_secondary_cpu(void)
85{
86 /*
87 * after non-volatile devices & environment is setup and cpu code have
88 * another round to deal with any initialization that might require
89 * full access to the environment or loading of some image (firmware)
90 * from a non-volatile device
91 */
92 /* TODO: maybe define this for all archs? */
93 cpu_secondary_init_r();
94
95 return 0;
96}
6f6430d7 97
71c52dba
SG
98static int initr_trace(void)
99{
100#ifdef CONFIG_TRACE
101 trace_init(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE);
102#endif
103
104 return 0;
105}
106
6f6430d7
SG
107static int initr_reloc(void)
108{
c9356be3
SG
109 /* tell others: relocation done */
110 gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT;
6f6430d7
SG
111 bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
112
113 return 0;
114}
115
116#ifdef CONFIG_ARM
117/*
118 * Some of these functions are needed purely because the functions they
119 * call return void. If we change them to return 0, these stubs can go away.
120 */
121static int initr_caches(void)
122{
123 /* Enable caches */
124 enable_caches();
125 return 0;
126}
127#endif
128
c2240d4d
SG
129__weak int fixup_cpu(void)
130{
131 return 0;
132}
133
6f6430d7
SG
134static int initr_reloc_global_data(void)
135{
b60eff31
AA
136#ifdef __ARM__
137 monitor_flash_len = _end - __image_copy_start;
2e88bb28
KHH
138#elif defined(CONFIG_NDS32)
139 monitor_flash_len = (ulong)&_end - (ulong)&_start;
5ff10aa7 140#elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
a0ba279a 141 monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
6f6430d7 142#endif
c2240d4d
SG
143#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
144 /*
145 * The gd->cpu pointer is set to an address in flash before relocation.
146 * We need to update it to point to the same CPU entry in RAM.
147 * TODO: why not just add gd->reloc_ofs?
148 */
a0ba279a 149 gd->arch.cpu += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
c2240d4d
SG
150
151 /*
152 * If we didn't know the cpu mask & # cores, we can save them of
153 * now rather than 'computing' them constantly
154 */
155 fixup_cpu();
156#endif
157#ifdef CONFIG_SYS_EXTRA_ENV_RELOC
158 /*
159 * Some systems need to relocate the env_addr pointer early because the
160 * location it points to will get invalidated before env_relocate is
161 * called. One example is on systems that might use a L2 or L3 cache
162 * in SRAM mode and initialize that cache from SRAM mode back to being
163 * a cache in cpu_init_r.
164 */
a0ba279a 165 gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
c2240d4d
SG
166#endif
167 return 0;
6f6430d7
SG
168}
169
170static int initr_serial(void)
171{
172 serial_initialize();
173 return 0;
174}
175
e310b93e 176#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
c2240d4d
SG
177static int initr_trap(void)
178{
179 /*
180 * Setup trap handlers
181 */
e310b93e 182#if defined(CONFIG_PPC)
a0ba279a 183 trap_init(gd->relocaddr);
e310b93e 184#else
185 trap_init(CONFIG_SYS_SDRAM_BASE);
186#endif
c2240d4d
SG
187 return 0;
188}
189#endif
190
191#ifdef CONFIG_ADDR_MAP
192static int initr_addr_map(void)
193{
194 init_addr_map();
195
196 return 0;
197}
198#endif
199
6f6430d7
SG
200#ifdef CONFIG_LOGBUFFER
201unsigned long logbuffer_base(void)
202{
203 return gd->ram_top - LOGBUFF_LEN;
204}
205
206static int initr_logbuffer(void)
207{
208 logbuff_init_ptrs();
209 return 0;
210}
211#endif
212
213#ifdef CONFIG_POST
214static int initr_post_backlog(void)
215{
216 post_output_backlog();
217 return 0;
218}
219#endif
220
c2240d4d
SG
221#ifdef CONFIG_SYS_DELAYED_ICACHE
222static int initr_icache_enable(void)
223{
224 return 0;
225}
226#endif
227
228#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
229static int initr_unlock_ram_in_cache(void)
230{
231 unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
232 return 0;
233}
234#endif
235
236#ifdef CONFIG_PCI
237static int initr_pci(void)
238{
ff3e077b 239#ifndef CONFIG_DM_PCI
c2240d4d 240 pci_init();
ff3e077b 241#endif
c2240d4d
SG
242
243 return 0;
244}
245#endif
246
247#ifdef CONFIG_WINBOND_83C553
248static int initr_w83c553f(void)
249{
250 /*
251 * Initialise the ISA bridge
252 */
253 initialise_w83c553f();
254 return 0;
255}
256#endif
257
258static int initr_barrier(void)
259{
260#ifdef CONFIG_PPC
261 /* TODO: Can we not use dmb() macros for this? */
262 asm("sync ; isync");
263#endif
264 return 0;
265}
266
6f6430d7
SG
267static int initr_malloc(void)
268{
269 ulong malloc_start;
270
d59476b6
SG
271#ifdef CONFIG_SYS_MALLOC_F_LEN
272 debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
273 gd->malloc_ptr / 1024);
274#endif
6f6430d7 275 /* The malloc area is immediately below the monitor copy in DRAM */
a0ba279a 276 malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
a733b06b
SG
277 mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
278 TOTAL_MALLOC_LEN);
6f6430d7
SG
279 return 0;
280}
281
671fa63e
JK
282#ifdef CONFIG_SYS_NONCACHED_MEMORY
283static int initr_noncached(void)
284{
285 noncached_init();
286 return 0;
287}
288#endif
289
1ce60176
SG
290#ifdef CONFIG_DM
291static int initr_dm(void)
292{
ab7cd627
SG
293 /* Save the pre-reloc driver model and start a new one */
294 gd->dm_root_f = gd->dm_root;
295 gd->dm_root = NULL;
8f41b878
TC
296#ifdef CONFIG_TIMER
297 gd->timer = NULL;
298#endif
ab7cd627 299 return dm_init_and_scan(false);
1ce60176
SG
300}
301#endif
302
6f6430d7
SG
303__weak int power_init_board(void)
304{
305 return 0;
306}
307
308static int initr_announce(void)
309{
a0ba279a 310 debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr);
6f6430d7
SG
311 return 0;
312}
313
61d7b1bb
AB
314#ifdef CONFIG_NEEDS_MANUAL_RELOC
315static int initr_manual_reloc_cmdtable(void)
316{
317 fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
318 ll_entry_count(cmd_tbl_t, cmd));
319 return 0;
320}
321#endif
322
6f6430d7
SG
323#if !defined(CONFIG_SYS_NO_FLASH)
324static int initr_flash(void)
325{
c2240d4d
SG
326 ulong flash_size = 0;
327 bd_t *bd = gd->bd;
6f6430d7
SG
328
329 puts("Flash: ");
330
70879a92 331 if (board_flash_wp_on())
c2240d4d 332 printf("Uninitialized - Write Protect On\n");
70879a92 333 else
c2240d4d 334 flash_size = flash_init();
70879a92 335
6f6430d7
SG
336 print_size(flash_size, "");
337#ifdef CONFIG_SYS_FLASH_CHECKSUM
338 /*
339 * Compute and print flash CRC if flashchecksum is set to 'y'
340 *
341 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
342 */
343 if (getenv_yesno("flashchecksum") == 1) {
344 printf(" CRC: %08X", crc32(0,
345 (const unsigned char *) CONFIG_SYS_FLASH_BASE,
346 flash_size));
347 }
348#endif /* CONFIG_SYS_FLASH_CHECKSUM */
349 putc('\n');
350
c2240d4d
SG
351 /* update start of FLASH memory */
352#ifdef CONFIG_SYS_FLASH_BASE
353 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
354#endif
355 /* size of FLASH memory (final value) */
356 bd->bi_flashsize = flash_size;
357
358#if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
359 /* Make a update of the Memctrl. */
360 update_flash_size(flash_size);
361#endif
362
363
364#if defined(CONFIG_OXC) || defined(CONFIG_RMU)
365 /* flash mapped at end of memory map */
366 bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
367#elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
368 bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
369#endif
370 return 0;
371}
372#endif
373
ebe76a2d 374#if defined(CONFIG_PPC) && !defined(CONFIG_DM_SPI)
c2240d4d
SG
375static int initr_spi(void)
376{
377 /* PPC does this here */
378#ifdef CONFIG_SPI
379#if !defined(CONFIG_ENV_IS_IN_EEPROM)
380 spi_init_f();
381#endif
382 spi_init_r();
383#endif
6f6430d7
SG
384 return 0;
385}
386#endif
387
388#ifdef CONFIG_CMD_NAND
389/* go init the NAND */
2588ba14 390static int initr_nand(void)
6f6430d7
SG
391{
392 puts("NAND: ");
393 nand_init();
394 return 0;
395}
396#endif
397
398#if defined(CONFIG_CMD_ONENAND)
399/* go init the NAND */
2588ba14 400static int initr_onenand(void)
6f6430d7
SG
401{
402 puts("NAND: ");
403 onenand_init();
404 return 0;
405}
406#endif
407
408#ifdef CONFIG_GENERIC_MMC
2588ba14 409static int initr_mmc(void)
6f6430d7
SG
410{
411 puts("MMC: ");
412 mmc_initialize(gd->bd);
413 return 0;
414}
415#endif
416
417#ifdef CONFIG_HAS_DATAFLASH
2588ba14 418static int initr_dataflash(void)
6f6430d7
SG
419{
420 AT91F_DataflashInit();
421 dataflash_print_info();
422 return 0;
423}
424#endif
425
426/*
427 * Tell if it's OK to load the environment early in boot.
428 *
429 * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
430 * if this is OK (defaulting to saying it's OK).
431 *
432 * NOTE: Loading the environment early can be a bad idea if security is
433 * important, since no verification is done on the environment.
434 *
435 * @return 0 if environment should not be loaded, !=0 if it is ok to load
436 */
437static int should_load_env(void)
438{
439#ifdef CONFIG_OF_CONTROL
440 return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
441#elif defined CONFIG_DELAY_ENVIRONMENT
442 return 0;
443#else
444 return 1;
445#endif
446}
447
448static int initr_env(void)
449{
450 /* initialize environment */
451 if (should_load_env())
452 env_relocate();
453 else
454 set_default_env(NULL);
545dfd10
TC
455#ifdef CONFIG_OF_CONTROL
456 setenv_addr("fdtcontroladdr", gd->fdt_blob);
457#endif
6f6430d7
SG
458
459 /* Initialize from environment */
460 load_addr = getenv_ulong("loadaddr", 16, load_addr);
c2240d4d
SG
461#if defined(CONFIG_SYS_EXTBDINFO)
462#if defined(CONFIG_405GP) || defined(CONFIG_405EP)
463#if defined(CONFIG_I2CFAST)
464 /*
465 * set bi_iic_fast for linux taking environment variable
466 * "i2cfast" into account
467 */
468 {
469 char *s = getenv("i2cfast");
470
471 if (s && ((*s == 'y') || (*s == 'Y'))) {
472 gd->bd->bi_iic_fast[0] = 1;
473 gd->bd->bi_iic_fast[1] = 1;
474 }
475 }
476#endif /* CONFIG_I2CFAST */
477#endif /* CONFIG_405GP, CONFIG_405EP */
478#endif /* CONFIG_SYS_EXTBDINFO */
479 return 0;
480}
481
c722f0b0
AB
482#ifdef CONFIG_SYS_BOOTPARAMS_LEN
483static int initr_malloc_bootparams(void)
484{
485 gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN);
486 if (!gd->bd->bi_boot_params) {
487 puts("WARNING: Cannot allocate space for boot parameters\n");
488 return -ENOMEM;
489 }
490 return 0;
491}
492#endif
493
6f6430d7
SG
494static int initr_jumptable(void)
495{
496 jumptable_init();
497 return 0;
498}
499
500#if defined(CONFIG_API)
501static int initr_api(void)
502{
503 /* Initialize API */
504 api_init();
505 return 0;
506}
507#endif
508
6f6430d7 509/* enable exceptions */
a752a8b4 510#if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
6f6430d7
SG
511static int initr_enable_interrupts(void)
512{
513 enable_interrupts();
514 return 0;
515}
e424c15c 516#endif
6f6430d7
SG
517
518#ifdef CONFIG_CMD_NET
519static int initr_ethaddr(void)
520{
c2240d4d
SG
521 bd_t *bd = gd->bd;
522
523 /* kept around for legacy kernels only ... ignore the next section */
524 eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
525#ifdef CONFIG_HAS_ETH1
526 eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
527#endif
528#ifdef CONFIG_HAS_ETH2
529 eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
530#endif
531#ifdef CONFIG_HAS_ETH3
532 eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
533#endif
534#ifdef CONFIG_HAS_ETH4
535 eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
536#endif
537#ifdef CONFIG_HAS_ETH5
538 eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
539#endif
540 return 0;
541}
542#endif /* CONFIG_CMD_NET */
543
544#ifdef CONFIG_CMD_KGDB
545static int initr_kgdb(void)
546{
547 puts("KGDB: ");
548 kgdb_init();
549 return 0;
550}
551#endif
552
13cfbe51 553#if defined(CONFIG_STATUS_LED)
c2240d4d
SG
554static int initr_status_led(void)
555{
13cfbe51 556#if defined(STATUS_LED_BOOT)
c2240d4d 557 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
13cfbe51
BN
558#else
559 status_led_init();
560#endif
c2240d4d
SG
561 return 0;
562}
563#endif
564
3f33f6a2
FR
565#if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
566extern int do_ambapp_print(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
567
568static int initr_ambapp_print(void)
569{
570 puts("AMBA:\n");
571 do_ambapp_print(NULL, 0, 0, NULL);
572
573 return 0;
574}
575#endif
576
c2240d4d
SG
577#if defined(CONFIG_CMD_SCSI)
578static int initr_scsi(void)
579{
c2240d4d
SG
580 puts("SCSI: ");
581 scsi_init();
6f6430d7
SG
582
583 return 0;
584}
2c997e7a 585#endif
6f6430d7 586
c2240d4d
SG
587#if defined(CONFIG_CMD_DOC)
588static int initr_doc(void)
589{
590 puts("DOC: ");
591 doc_init();
19ad527d 592 return 0;
c2240d4d
SG
593}
594#endif
595
6f6430d7
SG
596#ifdef CONFIG_BITBANGMII
597static int initr_bbmii(void)
598{
599 bb_miiphy_init();
600 return 0;
601}
602#endif
603
604#ifdef CONFIG_CMD_NET
605static int initr_net(void)
606{
607 puts("Net: ");
d2eaec60 608 eth_initialize();
6f6430d7
SG
609#if defined(CONFIG_RESET_PHY_R)
610 debug("Reset Ethernet PHY\n");
611 reset_phy();
612#endif
613 return 0;
614}
615#endif
616
617#ifdef CONFIG_POST
618static int initr_post(void)
619{
620 post_run(NULL, POST_RAM | post_bootmode_get(0));
621 return 0;
622}
623#endif
624
c2240d4d
SG
625#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
626static int initr_pcmcia(void)
627{
628 puts("PCMCIA:");
629 pcmcia_init();
630 return 0;
631}
632#endif
633
634#if defined(CONFIG_CMD_IDE)
635static int initr_ide(void)
636{
637#ifdef CONFIG_IDE_8xx_PCCARD
638 puts("PCMCIA:");
639#else
640 puts("IDE: ");
641#endif
642#if defined(CONFIG_START_IDE)
643 if (board_start_ide())
644 ide_init();
645#else
646 ide_init();
647#endif
648 return 0;
649}
650#endif
651
6f6430d7
SG
652#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
653/*
654 * Export available size of memory for Linux, taking into account the
655 * protected RAM at top of memory
656 */
657int initr_mem(void)
658{
659 ulong pram = 0;
660 char memsz[32];
661
662# ifdef CONFIG_PRAM
663 pram = getenv_ulong("pram", 10, CONFIG_PRAM);
664# endif
665# if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
666 /* Also take the logbuffer into account (pram is in kB) */
667 pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
668# endif
ae1a74eb 669 sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram));
6f6430d7 670 setenv("mem", memsz);
c2240d4d
SG
671
672 return 0;
673}
674#endif
675
676#ifdef CONFIG_CMD_BEDBUG
677static int initr_bedbug(void)
678{
679 bedbug_init();
680
681 return 0;
682}
683#endif
684
685#ifdef CONFIG_PS2KBD
686static int initr_kbd(void)
687{
688 puts("PS/2: ");
689 kbd_init();
690 return 0;
691}
692#endif
693
6f6430d7
SG
694static int run_main_loop(void)
695{
a733b06b
SG
696#ifdef CONFIG_SANDBOX
697 sandbox_main_loop_init();
698#endif
6f6430d7
SG
699 /* main_loop() can return to retry autoboot, if so just run it again */
700 for (;;)
701 main_loop();
702 return 0;
703}
704
705/*
706 * Over time we hope to remove these functions with code fragments and
707 * stub funtcions, and instead call the relevant function directly.
708 *
709 * We also hope to remove most of the driver-related init and do it if/when
710 * the driver is later used.
c2240d4d
SG
711 *
712 * TODO: perhaps reset the watchdog in the initcall function after each call?
6f6430d7
SG
713 */
714init_fnc_t init_sequence_r[] = {
71c52dba 715 initr_trace,
6f6430d7 716 initr_reloc,
c2240d4d 717 /* TODO: could x86/PPC have this also perhaps? */
6f6430d7
SG
718#ifdef CONFIG_ARM
719 initr_caches,
12eaf31c
YS
720 /* Note: For Freescale LS2 SoCs, new MMU table is created in DDR.
721 * A temporary mapping of IFC high region is since removed,
722 * so environmental variables in NOR flash is not availble
723 * until board_init() is called below to remap IFC to high
724 * region.
725 */
9fb02491
SG
726#endif
727 initr_reloc_global_data,
fef3e25f
YS
728#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
729 initr_unlock_ram_in_cache,
730#endif
9fb02491
SG
731 initr_barrier,
732 initr_malloc,
671fa63e
JK
733#ifdef CONFIG_SYS_NONCACHED_MEMORY
734 initr_noncached,
735#endif
9fb02491
SG
736 bootstage_relocate,
737#ifdef CONFIG_DM
738 initr_dm,
739#endif
2e88bb28 740#if defined(CONFIG_ARM) || defined(CONFIG_NDS32)
6f6430d7 741 board_init, /* Setup chipselects */
c2240d4d
SG
742#endif
743 /*
744 * TODO: printing of the clock inforamtion of the board is now
745 * implemented as part of bdinfo command. Currently only support for
746 * davinci SOC's is added. Remove this check once all the board
747 * implement this.
748 */
749#ifdef CONFIG_CLOCKS
750 set_cpu_clk_info, /* Setup clock information */
6f6430d7 751#endif
9fb02491 752 stdio_init_tables,
6f6430d7
SG
753 initr_serial,
754 initr_announce,
c2240d4d 755 INIT_FUNC_WATCHDOG_RESET
61d7b1bb
AB
756#ifdef CONFIG_NEEDS_MANUAL_RELOC
757 initr_manual_reloc_cmdtable,
758#endif
e310b93e 759#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
c2240d4d
SG
760 initr_trap,
761#endif
762#ifdef CONFIG_ADDR_MAP
763 initr_addr_map,
764#endif
765#if defined(CONFIG_BOARD_EARLY_INIT_R)
766 board_early_init_r,
767#endif
768 INIT_FUNC_WATCHDOG_RESET
6f6430d7
SG
769#ifdef CONFIG_LOGBUFFER
770 initr_logbuffer,
771#endif
772#ifdef CONFIG_POST
773 initr_post_backlog,
774#endif
c2240d4d
SG
775 INIT_FUNC_WATCHDOG_RESET
776#ifdef CONFIG_SYS_DELAYED_ICACHE
777 initr_icache_enable,
778#endif
c2240d4d
SG
779#if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
780 /*
781 * Do early PCI configuration _before_ the flash gets initialised,
782 * because PCU ressources are crucial for flash access on some boards.
783 */
784 initr_pci,
785#endif
786#ifdef CONFIG_WINBOND_83C553
787 initr_w83c553f,
1ce60176 788#endif
6f6430d7
SG
789#ifdef CONFIG_ARCH_EARLY_INIT_R
790 arch_early_init_r,
791#endif
792 power_init_board,
793#ifndef CONFIG_SYS_NO_FLASH
794 initr_flash,
c2240d4d
SG
795#endif
796 INIT_FUNC_WATCHDOG_RESET
bcb0c61e 797#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
c2240d4d
SG
798 /* initialize higher level parts of CPU like time base and timers */
799 cpu_init_r,
be274b99
SG
800#endif
801#ifdef CONFIG_PPC
c2240d4d 802 initr_spi,
6f6430d7
SG
803#endif
804#ifdef CONFIG_CMD_NAND
805 initr_nand,
806#endif
807#ifdef CONFIG_CMD_ONENAND
808 initr_onenand,
809#endif
810#ifdef CONFIG_GENERIC_MMC
811 initr_mmc,
812#endif
813#ifdef CONFIG_HAS_DATAFLASH
814 initr_dataflash,
815#endif
816 initr_env,
c722f0b0
AB
817#ifdef CONFIG_SYS_BOOTPARAMS_LEN
818 initr_malloc_bootparams,
819#endif
c2240d4d
SG
820 INIT_FUNC_WATCHDOG_RESET
821 initr_secondary_cpu,
c2240d4d
SG
822#if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
823 mac_read_from_eeprom,
824#endif
825 INIT_FUNC_WATCHDOG_RESET
826#if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
827 /*
828 * Do pci configuration
829 */
830 initr_pci,
831#endif
9fb02491 832 stdio_add_devices,
6f6430d7
SG
833 initr_jumptable,
834#ifdef CONFIG_API
835 initr_api,
836#endif
837 console_init_r, /* fully init console as a device */
838#ifdef CONFIG_DISPLAY_BOARDINFO_LATE
0365ffcc 839 show_board_info,
6f6430d7
SG
840#endif
841#ifdef CONFIG_ARCH_MISC_INIT
842 arch_misc_init, /* miscellaneous arch-dependent init */
843#endif
844#ifdef CONFIG_MISC_INIT_R
845 misc_init_r, /* miscellaneous platform-dependent init */
c2240d4d
SG
846#endif
847 INIT_FUNC_WATCHDOG_RESET
848#ifdef CONFIG_CMD_KGDB
849 initr_kgdb,
6f6430d7
SG
850#endif
851 interrupt_init,
a752a8b4 852#if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
6f6430d7 853 initr_enable_interrupts,
c2240d4d 854#endif
e310b93e 855#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) \
856 || defined(CONFIG_M68K)
be274b99
SG
857 timer_init, /* initialize timer */
858#endif
13cfbe51 859#if defined(CONFIG_STATUS_LED)
c2240d4d
SG
860 initr_status_led,
861#endif
862 /* PPC has a udelay(20) here dating from 2002. Why? */
6f6430d7
SG
863#ifdef CONFIG_CMD_NET
864 initr_ethaddr,
865#endif
866#ifdef CONFIG_BOARD_LATE_INIT
867 board_late_init,
868#endif
3f33f6a2
FR
869#if defined(CONFIG_CMD_AMBAPP)
870 ambapp_init_reloc,
871#if defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
872 initr_ambapp_print,
873#endif
874#endif
c2240d4d
SG
875#ifdef CONFIG_CMD_SCSI
876 INIT_FUNC_WATCHDOG_RESET
877 initr_scsi,
878#endif
879#ifdef CONFIG_CMD_DOC
880 INIT_FUNC_WATCHDOG_RESET
881 initr_doc,
882#endif
6f6430d7
SG
883#ifdef CONFIG_BITBANGMII
884 initr_bbmii,
885#endif
886#ifdef CONFIG_CMD_NET
c2240d4d 887 INIT_FUNC_WATCHDOG_RESET
6f6430d7
SG
888 initr_net,
889#endif
890#ifdef CONFIG_POST
891 initr_post,
c2240d4d
SG
892#endif
893#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
894 initr_pcmcia,
895#endif
896#if defined(CONFIG_CMD_IDE)
897 initr_ide,
898#endif
899#ifdef CONFIG_LAST_STAGE_INIT
900 INIT_FUNC_WATCHDOG_RESET
901 /*
902 * Some parts can be only initialized if all others (like
903 * Interrupts) are up and running (i.e. the PC-style ISA
904 * keyboard).
905 */
906 last_stage_init,
907#endif
908#ifdef CONFIG_CMD_BEDBUG
909 INIT_FUNC_WATCHDOG_RESET
910 initr_bedbug,
911#endif
912#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
913 initr_mem,
914#endif
915#ifdef CONFIG_PS2KBD
916 initr_kbd,
6f6430d7
SG
917#endif
918 run_main_loop,
919};
920
921void board_init_r(gd_t *new_gd, ulong dest_addr)
922{
7395398a
AB
923#ifdef CONFIG_NEEDS_MANUAL_RELOC
924 int i;
925#endif
926
a752a8b4
AB
927#ifdef CONFIG_AVR32
928 mmu_init_r(dest_addr);
929#endif
930
47a602ea 931#if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
6f6430d7 932 gd = new_gd;
be274b99 933#endif
7395398a
AB
934
935#ifdef CONFIG_NEEDS_MANUAL_RELOC
936 for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
937 init_sequence_r[i] += gd->reloc_off;
938#endif
939
6f6430d7
SG
940 if (initcall_run_list(init_sequence_r))
941 hang();
942
943 /* NOTREACHED - run_main_loop() does not return */
944 hang();
945}