1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016 Google, Inc
7 #include <debug_uart.h>
11 #include <asm/processor.h>
12 #include <asm-generic/sections.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 __weak int arch_cpu_init_dm(void)
21 static int x86_spl_init(void)
24 * TODO(sjg@chromium.org): We use this area of RAM for the stack
25 * and global_data in SPL. Once U-Boot starts up and releocates it
26 * is not needed. We could make this a CONFIG option or perhaps
27 * place it immediately below CONFIG_SYS_TEXT_BASE.
29 char *ptr = (char *)0x110000;
32 debug("%s starting\n", __func__);
35 debug("%s: spl_init() failed\n", __func__);
38 ret = arch_cpu_init();
40 debug("%s: arch_cpu_init() failed\n", __func__);
43 ret = arch_cpu_init_dm();
45 debug("%s: arch_cpu_init_dm() failed\n", __func__);
48 preloader_console_init();
49 ret = print_cpuinfo();
51 debug("%s: print_cpuinfo() failed\n", __func__);
56 debug("%s: dram_init() failed\n", __func__);
59 memset(&__bss_start, 0, (ulong)&__bss_end - (ulong)&__bss_start);
61 /* TODO(sjg@chromium.org): Consider calling cpu_init_r() here */
62 ret = interrupt_init();
64 debug("%s: interrupt_init() failed\n", __func__);
69 * The stack grows down from ptr. Put the global data at ptr. This
70 * will only be used for SPL. Once SPL loads U-Boot proper it will
71 * set up its own stack.
73 gd->new_gd = (struct global_data *)ptr;
74 memcpy(gd->new_gd, gd, sizeof(*gd));
75 arch_setup_gd(gd->new_gd);
76 gd->start_addr_sp = (ulong)ptr;
78 /* Cache the SPI flash. Otherwise copying the code to RAM takes ages */
79 ret = mtrr_add_request(MTRR_TYPE_WRBACK,
80 (1ULL << 32) - CONFIG_XIP_ROM_SIZE,
83 debug("%s: SPI cache setup failed\n", __func__);
90 void board_init_f(ulong flags)
96 debug("Error %d\n", ret);
100 /* Uninit CAR and jump to board_init_f_r() */
101 board_init_f_r_trampoline(gd->start_addr_sp);
104 void board_init_f_r(void)
107 gd->flags &= ~GD_FLG_SERIAL_READY;
108 debug("cache status %d\n", dcache_status());
112 u32 spl_boot_device(void)
114 return BOOT_DEVICE_BOARD;
117 int spl_start_uboot(void)
122 void spl_board_announce_boot_device(void)
127 static int spl_board_load_image(struct spl_image_info *spl_image,
128 struct spl_boot_device *bootdev)
130 spl_image->size = CONFIG_SYS_MONITOR_LEN;
131 spl_image->entry_point = CONFIG_SYS_TEXT_BASE;
132 spl_image->load_addr = CONFIG_SYS_TEXT_BASE;
133 spl_image->os = IH_OS_U_BOOT;
134 spl_image->name = "U-Boot";
136 debug("Loading to %lx\n", spl_image->load_addr);
140 SPL_LOAD_IMAGE_METHOD("SPI", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
142 int spl_spi_load_image(void)
147 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
151 printf("Jumping to 64-bit U-Boot: Note many features are missing\n");
152 ret = cpu_jump_to_64bit_uboot(spl_image->entry_point);
153 debug("ret=%d\n", ret);