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