xref: /openbmc/u-boot/arch/sandbox/cpu/spl.c (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2e961a66dSSimon Glass /*
3e961a66dSSimon Glass  * Copyright (c) 2016 Google, Inc
4e961a66dSSimon Glass  */
5e961a66dSSimon Glass 
6e961a66dSSimon Glass #include <common.h>
7e961a66dSSimon Glass #include <dm.h>
8e961a66dSSimon Glass #include <os.h>
9a091a8f0SSimon Glass #include <spl.h>
10e961a66dSSimon Glass #include <asm/spl.h>
11e961a66dSSimon Glass #include <asm/state.h>
12e961a66dSSimon Glass 
13e961a66dSSimon Glass DECLARE_GLOBAL_DATA_PTR;
14e961a66dSSimon Glass 
15e961a66dSSimon Glass void board_init_f(ulong flag)
16e961a66dSSimon Glass {
17e961a66dSSimon Glass 	struct sandbox_state *state = state_get_current();
18e961a66dSSimon Glass 
19e961a66dSSimon Glass 	gd->arch.ram_buf = state->ram_buf;
20e961a66dSSimon Glass 	gd->ram_size = state->ram_size;
21e961a66dSSimon Glass }
22e961a66dSSimon Glass 
23e961a66dSSimon Glass u32 spl_boot_device(void)
24e961a66dSSimon Glass {
25e961a66dSSimon Glass 	return BOOT_DEVICE_BOARD;
26e961a66dSSimon Glass }
27e961a66dSSimon Glass 
282a2ee2acSSimon Glass static int spl_board_load_image(struct spl_image_info *spl_image,
292a2ee2acSSimon Glass 				struct spl_boot_device *bootdev)
30e961a66dSSimon Glass {
31e961a66dSSimon Glass 	char fname[256];
32e961a66dSSimon Glass 	int ret;
33e961a66dSSimon Glass 
34e961a66dSSimon Glass 	ret = os_find_u_boot(fname, sizeof(fname));
35f831b8e4SSimon Glass 	if (ret) {
36f831b8e4SSimon Glass 		printf("(%s not found, error %d)\n", fname, ret);
37e961a66dSSimon Glass 		return ret;
38f831b8e4SSimon Glass 	}
39e961a66dSSimon Glass 
40e961a66dSSimon Glass 	/* Hopefully this will not return */
41e961a66dSSimon Glass 	return os_spl_to_uboot(fname);
42e961a66dSSimon Glass }
43ebc4ef61SSimon Glass SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
44a091a8f0SSimon Glass 
45a091a8f0SSimon Glass void spl_board_init(void)
46a091a8f0SSimon Glass {
47a091a8f0SSimon Glass 	preloader_console_init();
48a091a8f0SSimon Glass }
49