1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2011 The Chromium OS Authors.
11 #include <efi_loader.h>
12 #include <env_internal.h>
16 #include <asm/global_data.h>
18 #include <asm/u-boot-sandbox.h>
19 #include <linux/kernel.h>
22 #include <extension_board.h>
25 * Pointer to initial global data area
27 * Here we initialize it.
31 #if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT)
32 struct efi_fw_image fw_images[] = {
33 #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)
35 .image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
36 .fw_name = u"SANDBOX-UBOOT",
40 .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
41 .fw_name = u"SANDBOX-UBOOT-ENV",
44 #elif defined(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)
46 .image_type_id = SANDBOX_FIT_IMAGE_GUID,
47 .fw_name = u"SANDBOX-FIT",
53 struct efi_capsule_update_info update_info = {
54 .dfu_string = "sf 0:0=u-boot-bin raw 0x100000 0x50000;"
55 "u-boot-env raw 0x150000 0x200000",
59 u8 num_image_type_guids = ARRAY_SIZE(fw_images);
60 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
62 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
64 * Add a simple GPIO device (don't use with of-platdata as it interferes with
65 * the auto-generated devices)
67 U_BOOT_DRVINFO(gpio_sandbox) = {
68 .name = "sandbox_gpio",
73 /* system timer offset in ms */
74 static unsigned long sandbox_timer_offset;
76 void timer_test_add_offset(unsigned long offset)
78 sandbox_timer_offset += offset;
81 unsigned long timer_read_counter(void)
83 return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
87 /* specific order for sandbox: nowhere is the first value, used by default */
88 static enum env_location env_locations[] = {
94 enum env_location env_get_location(enum env_operation op, int prio)
96 if (prio >= ARRAY_SIZE(env_locations))
99 return env_locations[prio];
104 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
110 if (IS_ENABLED(CONFIG_LED))
116 int ft_board_setup(void *fdt, struct bd_info *bd)
118 /* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/
119 return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000);
122 #ifdef CONFIG_CMD_EXTENSION
123 int extension_board_scan(struct list_head *extension_list)
125 struct extension *extension;
128 for (i = 0; i < 2; i++) {
129 extension = calloc(1, sizeof(struct extension));
130 snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
131 snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
132 snprintf(extension->owner, sizeof(extension->owner), "sandbox");
133 snprintf(extension->version, sizeof(extension->version), "1.1");
134 snprintf(extension->other, sizeof(extension->other), "Fictionnal extension board");
135 list_add_tail(&extension->list, extension_list);
142 #ifdef CONFIG_BOARD_LATE_INIT
143 int board_late_init(void)
148 ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
149 if (ret && ret != -ENODEV) {
150 /* Force console on */
151 gd->flags &= ~GD_FLG_SILENT;
153 printf("cros-ec communications failure %d\n", ret);
154 puts("\nPlease reset with Power+Refresh\n\n");
155 panic("Cannot init cros-ec device");