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