2 * Copyright (c) 2016 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0
8 #include <debug_uart.h>
9 #include <init_helpers.h>
13 #include <asm/processor.h>
14 #include <asm-generic/sections.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 __weak int arch_cpu_init_dm(void)
23 static int x86_spl_init(void)
26 * TODO(sjg@chromium.org): We use this area of RAM for the stack
27 * and global_data in SPL. Once U-Boot starts up and releocates it
28 * is not needed. We could make this a CONFIG option or perhaps
29 * place it immediately below CONFIG_SYS_TEXT_BASE.
31 char *ptr = (char *)0x110000;
34 debug("%s starting\n", __func__);
37 debug("%s: spl_init() failed\n", __func__);
40 preloader_console_init();
42 ret = arch_cpu_init();
44 debug("%s: arch_cpu_init() failed\n", __func__);
47 ret = arch_cpu_init_dm();
49 debug("%s: arch_cpu_init_dm() failed\n", __func__);
52 ret = print_cpuinfo();
54 debug("%s: print_cpuinfo() failed\n", __func__);
59 debug("%s: dram_init() failed\n", __func__);
62 memset(&__bss_start, 0, (ulong)&__bss_end - (ulong)&__bss_start);
64 /* TODO(sjg@chromium.org): Consider calling cpu_init_r() here */
65 ret = interrupt_init();
67 debug("%s: interrupt_init() failed\n", __func__);
72 * The stack grows down from ptr. Put the global data at ptr. This
73 * will only be used for SPL. Once SPL loads U-Boot proper it will
74 * set up its own stack.
76 gd->new_gd = (struct global_data *)ptr;
77 memcpy(gd->new_gd, gd, sizeof(*gd));
78 arch_setup_gd(gd->new_gd);
79 gd->start_addr_sp = (ulong)ptr;
81 /* Cache the SPI flash. Otherwise copying the code to RAM takes ages */
82 ret = mtrr_add_request(MTRR_TYPE_WRBACK,
83 (1ULL << 32) - CONFIG_XIP_ROM_SIZE,
86 debug("%s: SPI cache setup failed\n", __func__);
93 void board_init_f(ulong flags)
99 debug("Error %d\n", ret);
103 /* Uninit CAR and jump to board_init_f_r() */
104 board_init_f_r_trampoline(gd->start_addr_sp);
107 void board_init_f_r(void)
110 gd->flags &= ~GD_FLG_SERIAL_READY;
111 debug("cache status %d\n", dcache_status());
115 u32 spl_boot_device(void)
117 return BOOT_DEVICE_BOARD;
120 int spl_start_uboot(void)
125 void spl_board_announce_boot_device(void)
130 static int spl_board_load_image(struct spl_image_info *spl_image,
131 struct spl_boot_device *bootdev)
133 spl_image->size = CONFIG_SYS_MONITOR_LEN;
134 spl_image->entry_point = CONFIG_SYS_TEXT_BASE;
135 spl_image->load_addr = CONFIG_SYS_TEXT_BASE;
136 spl_image->os = IH_OS_U_BOOT;
137 spl_image->name = "U-Boot";
139 debug("Loading to %lx\n", spl_image->load_addr);
143 SPL_LOAD_IMAGE_METHOD("SPI", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
145 int spl_spi_load_image(void)
150 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
154 printf("Jumping to 64-bit U-Boot: Note many features are missing\n");
155 ret = cpu_jump_to_64bit_uboot(spl_image->entry_point);
156 debug("ret=%d\n", ret);