blob: 49f98644c02f80ed1e184b38a500212e5990956d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glasse961a662016-07-04 11:57:51 -06002/*
3 * Copyright (c) 2016 Google, Inc
Simon Glasse961a662016-07-04 11:57:51 -06004 */
5
6#include <common.h>
7#include <dm.h>
8#include <os.h>
Simon Glassa091a8f2016-07-04 11:57:55 -06009#include <spl.h>
Simon Glasse961a662016-07-04 11:57:51 -060010#include <asm/spl.h>
11#include <asm/state.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15void 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
23u32 spl_boot_device(void)
24{
25 return BOOT_DEVICE_BOARD;
26}
27
Simon Glass2a2ee2a2016-09-24 18:20:13 -060028static int spl_board_load_image(struct spl_image_info *spl_image,
29 struct spl_boot_device *bootdev)
Simon Glasse961a662016-07-04 11:57:51 -060030{
31 char fname[256];
32 int ret;
33
34 ret = os_find_u_boot(fname, sizeof(fname));
Simon Glassf831b8e2016-11-30 15:30:56 -070035 if (ret) {
36 printf("(%s not found, error %d)\n", fname, ret);
Simon Glasse961a662016-07-04 11:57:51 -060037 return ret;
Simon Glassf831b8e2016-11-30 15:30:56 -070038 }
Simon Glasse961a662016-07-04 11:57:51 -060039
40 /* Hopefully this will not return */
41 return os_spl_to_uboot(fname);
42}
Simon Glassebc4ef62016-11-30 15:30:50 -070043SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
Simon Glassa091a8f2016-07-04 11:57:55 -060044
45void spl_board_init(void)
46{
Simon Glass1ca910b2018-11-15 18:44:01 -070047 struct sandbox_state *state = state_get_current();
48 struct udevice *dev;
49
Simon Glassa091a8f2016-07-04 11:57:55 -060050 preloader_console_init();
Simon Glass1ca910b2018-11-15 18:44:01 -070051 if (state->show_of_platdata) {
52 /*
53 * Scan all the devices so that we can output their platform
54 * data. See sandbox_spl_probe().
55 */
56 printf("Scanning misc devices\n");
57 for (uclass_first_device(UCLASS_MISC, &dev);
58 dev;
59 uclass_next_device(&dev))
60 ;
61 }
Simon Glassa091a8f2016-07-04 11:57:55 -060062}