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 struct efi_fw_image fw_images[] = {
34 #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)
36 .image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
37 .fw_name = u"SANDBOX-UBOOT",
41 .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
42 .fw_name = u"SANDBOX-UBOOT-ENV",
45 #elif defined(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)
47 .image_type_id = SANDBOX_FIT_IMAGE_GUID,
48 .fw_name = u"SANDBOX-FIT",
54 struct efi_capsule_update_info update_info = {
55 .dfu_string = "sf 0:0=u-boot-bin raw 0x100000 0x50000;"
56 "u-boot-env raw 0x150000 0x200000",
60 u8 num_image_type_guids = ARRAY_SIZE(fw_images);
61 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
63 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
65 * Add a simple GPIO device (don't use with of-platdata as it interferes with
66 * the auto-generated devices)
68 U_BOOT_DRVINFO(gpio_sandbox) = {
69 .name = "sandbox_gpio",
74 /* system timer offset in ms */
75 static unsigned long sandbox_timer_offset;
77 void timer_test_add_offset(unsigned long offset)
79 sandbox_timer_offset += offset;
82 unsigned long timer_read_counter(void)
84 return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
88 /* specific order for sandbox: nowhere is the first value, used by default */
89 static enum env_location env_locations[] = {
95 enum env_location env_get_location(enum env_operation op, int prio)
97 if (prio >= ARRAY_SIZE(env_locations))
100 return env_locations[prio];
105 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
114 int ft_board_setup(void *fdt, struct bd_info *bd)
116 /* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/
117 return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000);
120 #ifdef CONFIG_CMD_EXTENSION
121 int extension_board_scan(struct list_head *extension_list)
123 struct extension *extension;
126 for (i = 0; i < 2; i++) {
127 extension = calloc(1, sizeof(struct extension));
128 snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
129 snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
130 snprintf(extension->owner, sizeof(extension->owner), "sandbox");
131 snprintf(extension->version, sizeof(extension->version), "1.1");
132 snprintf(extension->other, sizeof(extension->other), "Fictional extension board");
133 list_add_tail(&extension->list, extension_list);
140 #ifdef CONFIG_BOARD_LATE_INIT
141 int board_late_init(void)
146 ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
147 if (ret && ret != -ENODEV) {
148 /* Force console on */
149 gd->flags &= ~GD_FLG_SILENT;
151 printf("cros-ec communications failure %d\n", ret);
152 puts("\nPlease reset with Power+Refresh\n\n");
153 panic("Cannot init cros-ec device");
160 int init_addr_map(void)
162 if (IS_ENABLED(CONFIG_ADDR_MAP))
163 addrmap_set_entry(0, 0, CONFIG_SYS_SDRAM_SIZE, 0);