1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2011 The Chromium OS Authors.
4 * (C) Copyright 2002-2006
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
9 * Marius Groeger <mgroeger@sysgo.de>
14 #include <bootstage.h>
15 #include <clock_legacy.h>
20 #include <display_options.h>
23 #include <env_internal.h>
42 #include <status_led.h>
48 #include <asm/cache.h>
49 #ifdef CONFIG_MACH_TYPE
50 #include <asm/mach-types.h>
52 #if defined(CONFIG_MP) && defined(CONFIG_PPC)
55 #include <asm/global_data.h>
57 #include <asm/sections.h>
59 #include <linux/errno.h>
60 #include <linux/log2.h>
63 * Pointer to initial global data area
65 * Here we initialize it if needed.
67 #ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
68 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
69 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
70 DECLARE_GLOBAL_DATA_PTR = (gd_t *)(CONFIG_SYS_INIT_GD_ADDR);
72 DECLARE_GLOBAL_DATA_PTR;
76 * TODO(sjg@chromium.org): IMO this code should be
77 * refactored to a single function, something like:
79 * void led_set_state(enum led_colour_t colour, int on);
81 /************************************************************************
82 * Coloured LED functionality
83 ************************************************************************
84 * May be supplied by boards if desired
86 __weak void coloured_LED_init(void) {}
87 __weak void red_led_on(void) {}
88 __weak void red_led_off(void) {}
89 __weak void green_led_on(void) {}
90 __weak void green_led_off(void) {}
91 __weak void yellow_led_on(void) {}
92 __weak void yellow_led_off(void) {}
93 __weak void blue_led_on(void) {}
94 __weak void blue_led_off(void) {}
97 * Why is gd allocated a register? Prior to reloc it might be better to
98 * just pass it around to each function in this file?
100 * After reloc one could argue that it is hardly used and doesn't need
101 * to be in a register. Or if it is it should perhaps hold pointers to all
102 * global data for all modules, so that post-reloc we can avoid the massive
103 * literal pool we get on ARM. Or perhaps just encourage each module to use
107 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
108 static int init_func_watchdog_init(void)
110 # if defined(CONFIG_HW_WATCHDOG) && \
111 (defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
112 defined(CONFIG_SH) || \
113 defined(CONFIG_DESIGNWARE_WATCHDOG) || \
114 defined(CONFIG_IMX_WATCHDOG))
116 puts(" Watchdog enabled\n");
123 int init_func_watchdog_reset(void)
129 #endif /* CONFIG_WATCHDOG */
131 __weak void board_add_ram_info(int use_default)
133 /* please define platform specific board_add_ram_info() */
136 static int init_baud_rate(void)
138 gd->baudrate = env_get_ulong("baudrate", 10, CONFIG_BAUDRATE);
142 static int display_text_info(void)
144 #if !defined(CONFIG_SANDBOX) && !defined(CONFIG_EFI_APP)
145 ulong bss_start, bss_end, text_base;
147 bss_start = (ulong)&__bss_start;
148 bss_end = (ulong)&__bss_end;
150 #ifdef CONFIG_SYS_TEXT_BASE
151 text_base = CONFIG_SYS_TEXT_BASE;
153 text_base = CONFIG_SYS_MONITOR_BASE;
156 debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
157 text_base, bss_start, bss_end);
163 #ifdef CONFIG_SYSRESET
164 static int print_resetinfo(void)
170 ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
172 debug("%s: No sysreset device found (error: %d)\n",
174 /* Not all boards have sysreset drivers available during early
175 * boot, so don't fail if one can't be found.
180 if (!sysreset_get_status(dev, status, sizeof(status)))
181 printf("%s", status);
187 #if defined(CONFIG_DISPLAY_CPUINFO) && CONFIG_IS_ENABLED(CPU)
188 static int print_cpuinfo(void)
194 dev = cpu_get_current_dev();
196 debug("%s: Could not get CPU device\n",
201 ret = cpu_get_desc(dev, desc, sizeof(desc));
203 debug("%s: Could not get CPU description (err = %d)\n",
208 printf("CPU: %s\n", desc);
214 static int announce_dram_init(void)
221 * From input size calculate its nearest rounded unit scale (multiply of 2^10)
222 * and value in calculated unit scale multiplied by 10 (as fractional fixed
223 * point number with one decimal digit), which is human natural format,
224 * same what uses print_size() function for displaying. Mathematically it is:
225 * round_nearest(val * 2^scale) = size * 10; where: 10 <= val < 10240.
227 * For example for size=87654321 we calculate scale=20 and val=836 which means
228 * that input has natural human format 83.6 M (mega = 2^20).
230 #define compute_size_scale_val(size, scale, val) do { \
231 scale = ilog2(size) / 10 * 10; \
232 val = (10 * size + ((1ULL << scale) >> 1)) >> scale; \
233 if (val == 10240) { val = 10; scale += 10; } \
237 * Check if the sizes in their natural units written in decimal format with
238 * one fraction number are same.
240 static int sizes_near(unsigned long long size1, unsigned long long size2)
242 unsigned int size1_scale, size1_val, size2_scale, size2_val;
244 compute_size_scale_val(size1, size1_scale, size1_val);
245 compute_size_scale_val(size2, size2_scale, size2_val);
247 return size1_scale == size2_scale && size1_val == size2_val;
250 static int show_dram_config(void)
252 unsigned long long size;
255 debug("\nRAM Configuration:\n");
256 for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
257 size += gd->bd->bi_dram[i].size;
258 debug("Bank #%d: %llx ", i,
259 (unsigned long long)(gd->bd->bi_dram[i].start));
261 print_size(gd->bd->bi_dram[i].size, "\n");
266 print_size(gd->ram_size, "");
267 if (!sizes_near(gd->ram_size, size)) {
268 printf(" (effective ");
269 print_size(size, ")");
271 board_add_ram_info(0);
277 __weak int dram_init_banksize(void)
279 gd->bd->bi_dram[0].start = gd->ram_base;
280 gd->bd->bi_dram[0].size = get_effective_memsize();
285 #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
286 static int init_func_i2c(void)
295 #if defined(CONFIG_VID)
296 __weak int init_func_vid(void)
302 static int setup_mon_len(void)
304 #if defined(__ARM__) || defined(__MICROBLAZE__)
305 gd->mon_len = (ulong)&__bss_end - (ulong)_start;
306 #elif defined(CONFIG_SANDBOX)
308 #elif defined(CONFIG_EFI_APP)
309 gd->mon_len = (ulong)&_end - (ulong)_init;
310 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
311 gd->mon_len = CONFIG_SYS_MONITOR_LEN;
312 #elif defined(CONFIG_SH) || defined(CONFIG_RISCV)
313 gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
314 #elif defined(CONFIG_SYS_MONITOR_BASE)
315 /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
316 gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
321 static int setup_spl_handoff(void)
323 #if CONFIG_IS_ENABLED(HANDOFF)
324 gd->spl_handoff = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF,
325 sizeof(struct spl_handoff));
326 debug("Found SPL hand-off info %p\n", gd->spl_handoff);
332 __weak int arch_cpu_init(void)
337 __weak int mach_cpu_init(void)
342 /* Get the top of usable RAM */
343 __weak phys_size_t board_get_usable_ram_top(phys_size_t total_size)
345 #if defined(CONFIG_SYS_SDRAM_BASE) && CONFIG_SYS_SDRAM_BASE > 0
347 * Detect whether we have so much RAM that it goes past the end of our
348 * 32-bit address space. If so, clip the usable RAM so it doesn't.
350 if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
352 * Will wrap back to top of 32-bit space when reservations
360 static int setup_dest_addr(void)
362 debug("Monitor len: %08lX\n", gd->mon_len);
364 * Ram is setup, size stored in gd !!
366 debug("Ram size: %08llX\n", (unsigned long long)gd->ram_size);
367 #if CONFIG_VAL(SYS_MEM_TOP_HIDE)
369 * Subtract specified amount of memory to hide so that it won't
370 * get "touched" at all by U-Boot. By fixing up gd->ram_size
371 * the Linux kernel should now get passed the now "corrected"
372 * memory size and won't touch it either. This should work
373 * for arch/ppc and arch/powerpc. Only Linux board ports in
374 * arch/powerpc with bootwrapper support, that recalculate the
375 * memory size from the SDRAM controller setup will have to
378 gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
380 #ifdef CONFIG_SYS_SDRAM_BASE
381 gd->ram_base = CONFIG_SYS_SDRAM_BASE;
383 gd->ram_top = gd->ram_base + get_effective_memsize();
384 gd->ram_top = board_get_usable_ram_top(gd->mon_len);
385 gd->relocaddr = gd->ram_top;
386 debug("Ram top: %08llX\n", (unsigned long long)gd->ram_top);
387 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
389 * We need to make sure the location we intend to put secondary core
390 * boot code is reserved and not used by any part of u-boot
392 if (gd->relocaddr > determine_mp_bootpg(NULL)) {
393 gd->relocaddr = determine_mp_bootpg(NULL);
394 debug("Reserving MP boot page to %08lx\n", gd->relocaddr);
401 /* reserve protected RAM */
402 static int reserve_pram(void)
406 reg = env_get_ulong("pram", 10, CONFIG_PRAM);
407 gd->relocaddr -= (reg << 10); /* size is in kB */
408 debug("Reserving %ldk for protected RAM at %08lx\n", reg,
412 #endif /* CONFIG_PRAM */
414 /* Round memory pointer down to next 4 kB limit */
415 static int reserve_round_4k(void)
417 gd->relocaddr &= ~(4096 - 1);
421 __weak int arch_reserve_mmu(void)
426 static int reserve_video(void)
428 #ifdef CONFIG_DM_VIDEO
432 addr = gd->relocaddr;
433 ret = video_reserve(&addr);
436 debug("Reserving %luk for video at: %08lx\n",
437 ((unsigned long)gd->relocaddr - addr) >> 10, addr);
438 gd->relocaddr = addr;
439 #elif defined(CONFIG_LCD)
440 /* reserve memory for LCD display (always full pages) */
441 gd->relocaddr = lcd_setmem(gd->relocaddr);
442 gd->fb_base = gd->relocaddr;
448 static int reserve_trace(void)
451 gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
452 gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
453 debug("Reserving %luk for trace data at: %08lx\n",
454 (unsigned long)CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
460 static int reserve_uboot(void)
462 if (!(gd->flags & GD_FLG_SKIP_RELOC)) {
464 * reserve memory for U-Boot code, data & bss
465 * round down to next 4 kB limit
467 gd->relocaddr -= gd->mon_len;
468 gd->relocaddr &= ~(4096 - 1);
469 #if defined(CONFIG_E500) || defined(CONFIG_MIPS)
470 /* round down to next 64 kB limit so that IVPR stays aligned */
471 gd->relocaddr &= ~(65536 - 1);
474 debug("Reserving %ldk for U-Boot at: %08lx\n",
475 gd->mon_len >> 10, gd->relocaddr);
478 gd->start_addr_sp = gd->relocaddr;
484 * reserve after start_addr_sp the requested size and make the stack pointer
485 * 16-byte aligned, this alignment is needed for cast on the reserved memory
486 * ref = x86_64 ABI: https://reviews.llvm.org/D30049: 16 bytes
487 * = ARMv8 Instruction Set Overview: quad word, 16 bytes
489 static unsigned long reserve_stack_aligned(size_t size)
491 return ALIGN_DOWN(gd->start_addr_sp - size, 16);
494 #ifdef CONFIG_SYS_NONCACHED_MEMORY
495 static int reserve_noncached(void)
498 * The value of gd->start_addr_sp must match the value of malloc_start
499 * calculated in boatrd_f.c:initr_malloc(), which is passed to
500 * board_r.c:mem_malloc_init() and then used by
501 * cache.c:noncached_init()
503 * These calculations must match the code in cache.c:noncached_init()
505 gd->start_addr_sp = ALIGN(gd->start_addr_sp, MMU_SECTION_SIZE) -
507 gd->start_addr_sp -= ALIGN(CONFIG_SYS_NONCACHED_MEMORY,
509 debug("Reserving %dM for noncached_alloc() at: %08lx\n",
510 CONFIG_SYS_NONCACHED_MEMORY >> 20, gd->start_addr_sp);
516 /* reserve memory for malloc() area */
517 static int reserve_malloc(void)
519 gd->start_addr_sp = reserve_stack_aligned(TOTAL_MALLOC_LEN);
520 debug("Reserving %dk for malloc() at: %08lx\n",
521 TOTAL_MALLOC_LEN >> 10, gd->start_addr_sp);
522 #ifdef CONFIG_SYS_NONCACHED_MEMORY
529 /* (permanently) allocate a Board Info struct */
530 static int reserve_board(void)
533 gd->start_addr_sp = reserve_stack_aligned(sizeof(struct bd_info));
534 gd->bd = (struct bd_info *)map_sysmem(gd->start_addr_sp,
535 sizeof(struct bd_info));
536 memset(gd->bd, '\0', sizeof(struct bd_info));
537 debug("Reserving %zu Bytes for Board Info at: %08lx\n",
538 sizeof(struct bd_info), gd->start_addr_sp);
543 static int reserve_global_data(void)
545 gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t));
546 gd->new_gd = (gd_t *)map_sysmem(gd->start_addr_sp, sizeof(gd_t));
547 debug("Reserving %zu Bytes for Global Data at: %08lx\n",
548 sizeof(gd_t), gd->start_addr_sp);
552 static int reserve_fdt(void)
554 if (!IS_ENABLED(CONFIG_OF_EMBED)) {
556 * If the device tree is sitting immediately above our image
557 * then we must relocate it. If it is embedded in the data
558 * section, then it will be relocated with other data.
561 gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob), 32);
563 gd->start_addr_sp = reserve_stack_aligned(gd->fdt_size);
564 gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
565 debug("Reserving %lu Bytes for FDT at: %08lx\n",
566 gd->fdt_size, gd->start_addr_sp);
573 static int reserve_bootstage(void)
575 #ifdef CONFIG_BOOTSTAGE
576 int size = bootstage_get_size();
578 gd->start_addr_sp = reserve_stack_aligned(size);
579 gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
580 debug("Reserving %#x Bytes for bootstage at: %08lx\n", size,
587 __weak int arch_reserve_stacks(void)
592 static int reserve_stacks(void)
594 /* make stack pointer 16-byte aligned */
595 gd->start_addr_sp = reserve_stack_aligned(16);
598 * let the architecture-specific code tailor gd->start_addr_sp and
601 return arch_reserve_stacks();
604 static int reserve_bloblist(void)
606 #ifdef CONFIG_BLOBLIST
607 /* Align to a 4KB boundary for easier reading of addresses */
608 gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp -
609 CONFIG_BLOBLIST_SIZE_RELOC, 0x1000);
610 gd->new_bloblist = map_sysmem(gd->start_addr_sp,
611 CONFIG_BLOBLIST_SIZE_RELOC);
617 static int display_new_sp(void)
619 debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
624 __weak int arch_setup_bdinfo(void)
629 int setup_bdinfo(void)
631 struct bd_info *bd = gd->bd;
633 if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
634 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */
635 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */
638 #ifdef CONFIG_MACH_TYPE
639 bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
642 return arch_setup_bdinfo();
646 static int init_post(void)
648 post_bootmode_init();
649 post_run(NULL, POST_ROM | post_bootmode_get(0));
655 static int reloc_fdt(void)
657 if (!IS_ENABLED(CONFIG_OF_EMBED)) {
658 if (gd->flags & GD_FLG_SKIP_RELOC)
661 memcpy(gd->new_fdt, gd->fdt_blob,
662 fdt_totalsize(gd->fdt_blob));
663 gd->fdt_blob = gd->new_fdt;
670 static int reloc_bootstage(void)
672 #ifdef CONFIG_BOOTSTAGE
673 if (gd->flags & GD_FLG_SKIP_RELOC)
675 if (gd->new_bootstage) {
676 int size = bootstage_get_size();
678 debug("Copying bootstage from %p to %p, size %x\n",
679 gd->bootstage, gd->new_bootstage, size);
680 memcpy(gd->new_bootstage, gd->bootstage, size);
681 gd->bootstage = gd->new_bootstage;
682 bootstage_relocate();
689 static int reloc_bloblist(void)
691 #ifdef CONFIG_BLOBLIST
693 * Relocate only if we are supposed to send it
695 if ((gd->flags & GD_FLG_SKIP_RELOC) &&
696 CONFIG_BLOBLIST_SIZE == CONFIG_BLOBLIST_SIZE_RELOC) {
697 debug("Not relocating bloblist\n");
700 if (gd->new_bloblist) {
701 int size = CONFIG_BLOBLIST_SIZE;
703 debug("Copying bloblist from %p to %p, size %x\n",
704 gd->bloblist, gd->new_bloblist, size);
705 bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC,
707 gd->bloblist = gd->new_bloblist;
714 static int setup_reloc(void)
716 if (!(gd->flags & GD_FLG_SKIP_RELOC)) {
717 #ifdef CONFIG_SYS_TEXT_BASE
719 gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
720 #elif defined(CONFIG_MICROBLAZE)
721 gd->reloc_off = gd->relocaddr - (u32)_start;
722 #elif defined(CONFIG_M68K)
724 * On all ColdFire arch cpu, monitor code starts always
725 * just after the default vector table location, so at 0x400
727 gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
728 #elif !defined(CONFIG_SANDBOX)
729 gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
734 memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
736 if (gd->flags & GD_FLG_SKIP_RELOC) {
737 debug("Skipping relocation due to flag\n");
739 debug("Relocation Offset is: %08lx\n", gd->reloc_off);
740 debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n",
741 gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd),
748 #ifdef CONFIG_OF_BOARD_FIXUP
749 static int fix_fdt(void)
751 return board_fix_fdt((void *)gd->fdt_blob);
755 /* ARM calls relocate_code from its crt0.S */
756 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
757 !CONFIG_IS_ENABLED(X86_64)
759 static int jump_to_copy(void)
761 if (gd->flags & GD_FLG_SKIP_RELOC)
764 * x86 is special, but in a nice way. It uses a trampoline which
765 * enables the dcache if possible.
767 * For now, other archs use relocate_code(), which is implemented
768 * similarly for all archs. When we do generic relocation, hopefully
769 * we can make all archs enable the dcache prior to relocation.
771 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
773 * SDRAM and console are now initialised. The final stack can now
774 * be setup in SDRAM. Code execution will continue in Flash, but
775 * with the stack in SDRAM and Global Data in temporary memory
778 arch_setup_gd(gd->new_gd);
779 board_init_f_r_trampoline(gd->start_addr_sp);
781 relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
788 /* Record the board_init_f() bootstage (after arch_cpu_init()) */
789 static int initf_bootstage(void)
791 bool from_spl = IS_ENABLED(CONFIG_SPL_BOOTSTAGE) &&
792 IS_ENABLED(CONFIG_BOOTSTAGE_STASH);
795 ret = bootstage_init(!from_spl);
799 const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
800 CONFIG_BOOTSTAGE_STASH_SIZE);
802 ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
803 if (ret && ret != -ENOENT) {
804 debug("Failed to unstash bootstage: err=%d\n", ret);
809 bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
814 static int initf_dm(void)
816 #if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN)
819 bootstage_start(BOOTSTAGE_ID_ACCUM_DM_F, "dm_f");
820 ret = dm_init_and_scan(true);
821 bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_F);
825 if (IS_ENABLED(CONFIG_TIMER_EARLY)) {
826 ret = dm_timer_init();
835 /* Architecture-specific memory reservation */
836 __weak int reserve_arch(void)
841 __weak int checkcpu(void)
846 __weak int clear_bss(void)
851 static int misc_init_f(void)
853 return event_notify_null(EVT_MISC_INIT_F);
856 static const init_fnc_t init_sequence_f[] = {
858 #ifdef CONFIG_OF_CONTROL
861 #ifdef CONFIG_TRACE_EARLY
866 initf_bootstage, /* uses its own timer, so does not need DM */
869 #ifdef CONFIG_BLOBLIST
873 #if defined(CONFIG_CONSOLE_RECORD_INIT_F)
876 #if defined(CONFIG_HAVE_FSP)
879 arch_cpu_init, /* basic arch cpu dependent setup */
880 mach_cpu_init, /* SoC/machine dependent CPU setup */
882 #if defined(CONFIG_BOARD_EARLY_INIT_F)
885 #if defined(CONFIG_PPC) || defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
886 /* get CPU and bus clocks according to the environment variable */
887 get_clocks, /* get CPU and bus clocks (etc.) */
889 #if !defined(CONFIG_M68K)
890 timer_init, /* initialize timer */
892 #if defined(CONFIG_BOARD_POSTCLK_INIT)
895 env_init, /* initialize environment */
896 init_baud_rate, /* initialze baudrate settings */
897 serial_init, /* serial communications setup */
898 console_init_f, /* stage 1 init of console */
899 display_options, /* say that we are here */
900 display_text_info, /* show debugging info if required */
902 #if defined(CONFIG_SYSRESET)
905 #if defined(CONFIG_DISPLAY_CPUINFO)
906 print_cpuinfo, /* display cpu info (and speed) */
908 #if defined(CONFIG_DTB_RESELECT)
911 #if defined(CONFIG_DISPLAY_BOARDINFO)
914 INIT_FUNC_WATCHDOG_INIT
916 INIT_FUNC_WATCHDOG_RESET
917 #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
920 #if defined(CONFIG_VID) && !defined(CONFIG_SPL)
924 dram_init, /* configure available RAM banks */
928 INIT_FUNC_WATCHDOG_RESET
929 #if defined(CONFIG_SYS_DRAM_TEST)
931 #endif /* CONFIG_SYS_DRAM_TEST */
932 INIT_FUNC_WATCHDOG_RESET
937 INIT_FUNC_WATCHDOG_RESET
939 * Now that we have DRAM mapped and working, we can
940 * relocate the code and continue running from DRAM.
942 * Reserve memory at end of RAM for (top down in that order):
943 * - area that won't get touched by U-Boot and Linux (optional)
944 * - kernel log buffer
948 * - board info struct
951 #ifdef CONFIG_OF_BOARD_FIXUP
972 INIT_FUNC_WATCHDOG_RESET
975 INIT_FUNC_WATCHDOG_RESET
980 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
985 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
986 !CONFIG_IS_ENABLED(X86_64)
992 void board_init_f(ulong boot_flags)
994 gd->flags = boot_flags;
995 gd->have_console = 0;
997 if (initcall_run_list(init_sequence_f))
1000 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
1001 !defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64) && \
1002 !defined(CONFIG_ARC)
1003 /* NOTREACHED - jump_to_copy() does not return */
1008 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
1010 * For now this code is only used on x86.
1012 * init_sequence_f_r is the list of init functions which are run when
1013 * U-Boot is executing from Flash with a semi-limited 'C' environment.
1014 * The following limitations must be considered when implementing an
1016 * - 'static' variables are read-only
1017 * - Global Data (gd->xxx) is read/write
1019 * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
1020 * supported). It _should_, if possible, copy global data to RAM and
1021 * initialise the CPU caches (to speed up the relocation process)
1023 * NOTE: At present only x86 uses this route, but it is intended that
1024 * all archs will move to this when generic relocation is implemented.
1026 static const init_fnc_t init_sequence_f_r[] = {
1027 #if !CONFIG_IS_ENABLED(X86_64)
1034 void board_init_f_r(void)
1036 if (initcall_run_list(init_sequence_f_r))
1040 * The pre-relocation drivers may be using memory that has now gone
1041 * away. Mark serial as unavailable - this will fall back to the debug
1042 * UART if available.
1044 * Do the same with log drivers since the memory may not be available.
1046 gd->flags &= ~(GD_FLG_SERIAL_READY | GD_FLG_LOG_READY);
1052 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
1053 * Transfer execution from Flash to RAM by calculating the address
1054 * of the in-RAM copy of board_init_r() and calling it
1056 (board_init_r + gd->reloc_off)((gd_t *)gd, gd->relocaddr);
1058 /* NOTREACHED - board_init_r() does not return */
1061 #endif /* CONFIG_X86 */