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