2 * Copyright (c) 2016 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0
8 #include <debug_uart.h>
12 #include <asm/processor.h>
13 #include <asm-generic/sections.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 __weak int arch_cpu_init_dm(void)
22 static int x86_spl_init(void)
25 * TODO(sjg@chromium.org): We use this area of RAM for the stack
26 * and global_data in SPL. Once U-Boot starts up and releocates it
27 * is not needed. We could make this a CONFIG option or perhaps
28 * place it immediately below CONFIG_SYS_TEXT_BASE.
30 char *ptr = (char *)0x110000;
33 debug("%s starting\n", __func__);
36 debug("%s: spl_init() failed\n", __func__);
39 ret = arch_cpu_init();
41 debug("%s: arch_cpu_init() failed\n", __func__);
44 ret = arch_cpu_init_dm();
46 debug("%s: arch_cpu_init_dm() failed\n", __func__);
49 preloader_console_init();
50 ret = print_cpuinfo();
52 debug("%s: print_cpuinfo() failed\n", __func__);
57 debug("%s: dram_init() failed\n", __func__);
60 memset(&__bss_start, 0, (ulong)&__bss_end - (ulong)&__bss_start);
62 /* TODO(sjg@chromium.org): Consider calling cpu_init_r() here */
63 ret = interrupt_init();
65 debug("%s: interrupt_init() failed\n", __func__);
70 * The stack grows down from ptr. Put the global data at ptr. This
71 * will only be used for SPL. Once SPL loads U-Boot proper it will
72 * set up its own stack.
74 gd->new_gd = (struct global_data *)ptr;
75 memcpy(gd->new_gd, gd, sizeof(*gd));
76 arch_setup_gd(gd->new_gd);
77 gd->start_addr_sp = (ulong)ptr;
79 /* Cache the SPI flash. Otherwise copying the code to RAM takes ages */
80 ret = mtrr_add_request(MTRR_TYPE_WRBACK,
81 (1ULL << 32) - CONFIG_XIP_ROM_SIZE,
84 debug("%s: SPI cache setup failed\n", __func__);
91 void board_init_f(ulong flags)
97 debug("Error %d\n", ret);
101 /* Uninit CAR and jump to board_init_f_r() */
102 board_init_f_r_trampoline(gd->start_addr_sp);
105 void board_init_f_r(void)
108 gd->flags &= ~GD_FLG_SERIAL_READY;
109 debug("cache status %d\n", dcache_status());
113 u32 spl_boot_device(void)
115 return BOOT_DEVICE_BOARD;
118 int spl_start_uboot(void)
123 void spl_board_announce_boot_device(void)
128 static int spl_board_load_image(struct spl_image_info *spl_image,
129 struct spl_boot_device *bootdev)
131 spl_image->size = CONFIG_SYS_MONITOR_LEN;
132 spl_image->entry_point = CONFIG_SYS_TEXT_BASE;
133 spl_image->load_addr = CONFIG_SYS_TEXT_BASE;
134 spl_image->os = IH_OS_U_BOOT;
135 spl_image->name = "U-Boot";
137 debug("Loading to %lx\n", spl_image->load_addr);
141 SPL_LOAD_IMAGE_METHOD("SPI", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
143 int spl_spi_load_image(void)
148 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
152 printf("Jumping to 64-bit U-Boot: Note many features are missing\n");
153 ret = cpu_jump_to_64bit_uboot(spl_image->entry_point);
154 debug("ret=%d\n", ret);