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>
14 #include <extension_board.h>
20 #include <acpi/acpi_table.h>
21 #include <asm/global_data.h>
23 #include <asm/u-boot-sandbox.h>
24 #include <linux/kernel.h>
25 #include <linux/sizes.h>
28 * Pointer to initial global data area
30 * Here we initialize it.
34 #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
35 /* GUIDs for capsule updatable firmware images */
36 #define SANDBOX_UBOOT_IMAGE_GUID \
37 EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
38 0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
40 #define SANDBOX_UBOOT_ENV_IMAGE_GUID \
41 EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
42 0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
44 #define SANDBOX_FIT_IMAGE_GUID \
45 EFI_GUID(0x3673b45d, 0x6a7c, 0x46f3, 0x9e, 0x60, \
46 0xad, 0xab, 0xb0, 0x3f, 0x79, 0x37)
48 struct efi_fw_image fw_images[] = {
49 #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)
51 .image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
52 .fw_name = u"SANDBOX-UBOOT",
56 .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
57 .fw_name = u"SANDBOX-UBOOT-ENV",
60 #elif defined(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)
62 .image_type_id = SANDBOX_FIT_IMAGE_GUID,
63 .fw_name = u"SANDBOX-FIT",
69 struct efi_capsule_update_info update_info = {
70 .dfu_string = "sf 0:0=u-boot-bin raw 0x100000 0x50000;"
71 "u-boot-env raw 0x150000 0x200000",
72 .num_images = ARRAY_SIZE(fw_images),
76 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
78 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
80 * Add a simple GPIO device (don't use with of-platdata as it interferes with
81 * the auto-generated devices)
83 U_BOOT_DRVINFO(gpio_sandbox) = {
84 .name = "sandbox_gpio",
89 /* system timer offset in ms */
90 static unsigned long sandbox_timer_offset;
92 void timer_test_add_offset(unsigned long offset)
94 sandbox_timer_offset += offset;
97 unsigned long timer_read_counter(void)
99 return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
103 /* specific order for sandbox: nowhere is the first value, used by default */
104 static enum env_location env_locations[] = {
110 enum env_location env_get_location(enum env_operation op, int prio)
112 if (prio >= ARRAY_SIZE(env_locations))
115 return env_locations[prio];
120 gd->ram_size = CFG_SYS_SDRAM_SIZE;
129 int ft_board_setup(void *fdt, struct bd_info *bd)
131 /* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/
132 return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000);
135 #ifdef CONFIG_CMD_EXTENSION
136 int extension_board_scan(struct list_head *extension_list)
138 struct extension *extension;
141 for (i = 0; i < 2; i++) {
142 extension = calloc(1, sizeof(struct extension));
143 snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
144 snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
145 snprintf(extension->owner, sizeof(extension->owner), "sandbox");
146 snprintf(extension->version, sizeof(extension->version), "1.1");
147 snprintf(extension->other, sizeof(extension->other), "Fictional extension board");
148 list_add_tail(&extension->list, extension_list);
155 #ifdef CONFIG_BOARD_LATE_INIT
156 int board_late_init(void)
163 ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
164 if (ret && ret != -ENODEV) {
165 /* Force console on */
166 gd->flags &= ~GD_FLG_SILENT;
168 printf("cros-ec communications failure %d\n", ret);
169 puts("\nPlease reset with Power+Refresh\n\n");
170 panic("Cannot init cros-ec device");
174 if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
175 /* Reserve 64K for ACPI tables, aligned to a 4K boundary */
176 ptr = memalign(SZ_4K, SZ_64K);
177 addr = map_to_sysmem(ptr);
179 /* Generate ACPI tables */
180 end = write_acpi_tables(addr);
181 gd->arch.table_start = addr;
182 gd->arch.table_end = addr;
189 int init_addr_map(void)
191 if (IS_ENABLED(CONFIG_ADDR_MAP))
192 addrmap_set_entry(0, 0, CFG_SYS_SDRAM_SIZE, 0);
197 #if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
198 void fwu_plat_get_bootidx(uint *boot_idx)