1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2011 The Chromium OS Authors.
12 #include <efi_loader.h>
13 #include <env_internal.h>
17 #include <asm/global_data.h>
19 #include <asm/u-boot-sandbox.h>
20 #include <linux/kernel.h>
23 #include <extension_board.h>
26 * Pointer to initial global data area
28 * Here we initialize it.
32 #if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT)
33 /* GUIDs for capsule updatable firmware images */
34 #define SANDBOX_UBOOT_IMAGE_GUID \
35 EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
36 0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
38 #define SANDBOX_UBOOT_ENV_IMAGE_GUID \
39 EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
40 0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
42 #define SANDBOX_FIT_IMAGE_GUID \
43 EFI_GUID(0x3673b45d, 0x6a7c, 0x46f3, 0x9e, 0x60, \
44 0xad, 0xab, 0xb0, 0x3f, 0x79, 0x37)
46 struct efi_fw_image fw_images[] = {
47 #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)
49 .image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
50 .fw_name = u"SANDBOX-UBOOT",
54 .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
55 .fw_name = u"SANDBOX-UBOOT-ENV",
58 #elif defined(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)
60 .image_type_id = SANDBOX_FIT_IMAGE_GUID,
61 .fw_name = u"SANDBOX-FIT",
67 struct efi_capsule_update_info update_info = {
68 .dfu_string = "sf 0:0=u-boot-bin raw 0x100000 0x50000;"
69 "u-boot-env raw 0x150000 0x200000",
73 u8 num_image_type_guids = ARRAY_SIZE(fw_images);
74 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
76 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
78 * Add a simple GPIO device (don't use with of-platdata as it interferes with
79 * the auto-generated devices)
81 U_BOOT_DRVINFO(gpio_sandbox) = {
82 .name = "sandbox_gpio",
87 /* system timer offset in ms */
88 static unsigned long sandbox_timer_offset;
90 void timer_test_add_offset(unsigned long offset)
92 sandbox_timer_offset += offset;
95 unsigned long timer_read_counter(void)
97 return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
101 /* specific order for sandbox: nowhere is the first value, used by default */
102 static enum env_location env_locations[] = {
108 enum env_location env_get_location(enum env_operation op, int prio)
110 if (prio >= ARRAY_SIZE(env_locations))
113 return env_locations[prio];
118 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
127 int ft_board_setup(void *fdt, struct bd_info *bd)
129 /* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/
130 return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000);
133 #ifdef CONFIG_CMD_EXTENSION
134 int extension_board_scan(struct list_head *extension_list)
136 struct extension *extension;
139 for (i = 0; i < 2; i++) {
140 extension = calloc(1, sizeof(struct extension));
141 snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
142 snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
143 snprintf(extension->owner, sizeof(extension->owner), "sandbox");
144 snprintf(extension->version, sizeof(extension->version), "1.1");
145 snprintf(extension->other, sizeof(extension->other), "Fictional extension board");
146 list_add_tail(&extension->list, extension_list);
153 #ifdef CONFIG_BOARD_LATE_INIT
154 int board_late_init(void)
159 ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
160 if (ret && ret != -ENODEV) {
161 /* Force console on */
162 gd->flags &= ~GD_FLG_SILENT;
164 printf("cros-ec communications failure %d\n", ret);
165 puts("\nPlease reset with Power+Refresh\n\n");
166 panic("Cannot init cros-ec device");
173 int init_addr_map(void)
175 if (IS_ENABLED(CONFIG_ADDR_MAP))
176 addrmap_set_entry(0, 0, CONFIG_SYS_SDRAM_SIZE, 0);
181 #if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
182 void fwu_plat_get_bootidx(uint *boot_idx)