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