xref: /openbmc/u-boot/arch/sandbox/cpu/spl.c (revision b6152676)
1 /*
2  * Copyright (c) 2016 Google, Inc
3  * SPDX-License-Identifier:	GPL-2.0+
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <os.h>
9 #include <spl.h>
10 #include <asm/spl.h>
11 #include <asm/state.h>
12 
13 DECLARE_GLOBAL_DATA_PTR;
14 
15 void board_init_f(ulong flag)
16 {
17 	struct sandbox_state *state = state_get_current();
18 
19 	gd->arch.ram_buf = state->ram_buf;
20 	gd->ram_size = state->ram_size;
21 }
22 
23 u32 spl_boot_device(void)
24 {
25 	return BOOT_DEVICE_BOARD;
26 }
27 
28 void spl_board_announce_boot_device(void)
29 {
30 	char fname[256];
31 	int ret;
32 
33 	ret = os_find_u_boot(fname, sizeof(fname));
34 	if (ret) {
35 		printf("(%s not found, error %d)\n", fname, ret);
36 		return;
37 	}
38 	printf("%s\n", fname);
39 }
40 
41 int spl_board_load_image(void)
42 {
43 	char fname[256];
44 	int ret;
45 
46 	ret = os_find_u_boot(fname, sizeof(fname));
47 	if (ret)
48 		return ret;
49 
50 	/* Hopefully this will not return */
51 	return os_spl_to_uboot(fname);
52 }
53 
54 void spl_board_init(void)
55 {
56 	struct udevice *dev;
57 
58 	preloader_console_init();
59 
60 	/*
61 	* Scan all the devices so that we can output their platform data. See
62 	* sandbox_spl_probe().
63 	*/
64 	for (uclass_first_device(UCLASS_MISC, &dev);
65 	dev;
66 	uclass_next_device(&dev))
67 		;
68 }
69