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