1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2011 The Chromium OS Authors.
10 #include <env_internal.h>
14 #include <asm/global_data.h>
16 #include <asm/u-boot-sandbox.h>
19 #include <extension_board.h>
22 * Pointer to initial global data area
24 * Here we initialize it.
28 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
30 * Add a simple GPIO device (don't use with of-platdata as it interferes with
31 * the auto-generated devices)
33 U_BOOT_DRVINFO(gpio_sandbox) = {
34 .name = "sandbox_gpio",
39 /* system timer offset in ms */
40 static unsigned long sandbox_timer_offset;
42 void timer_test_add_offset(unsigned long offset)
44 sandbox_timer_offset += offset;
47 unsigned long timer_read_counter(void)
49 return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
53 /* specific order for sandbox: nowhere is the first value, used by default */
54 static enum env_location env_locations[] = {
60 enum env_location env_get_location(enum env_operation op, int prio)
62 if (prio >= ARRAY_SIZE(env_locations))
65 return env_locations[prio];
70 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
76 if (IS_ENABLED(CONFIG_LED))
82 int ft_board_setup(void *fdt, struct bd_info *bd)
84 /* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/
85 return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000);
88 #ifdef CONFIG_CMD_EXTENSION
89 int extension_board_scan(struct list_head *extension_list)
91 struct extension *extension;
94 for (i = 0; i < 2; i++) {
95 extension = calloc(1, sizeof(struct extension));
96 snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
97 snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
98 snprintf(extension->owner, sizeof(extension->owner), "sandbox");
99 snprintf(extension->version, sizeof(extension->version), "1.1");
100 snprintf(extension->other, sizeof(extension->other), "Fictionnal extension board");
101 list_add_tail(&extension->list, extension_list);
108 #ifdef CONFIG_BOARD_LATE_INIT
109 int board_late_init(void)
114 ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
115 if (ret && ret != -ENODEV) {
116 /* Force console on */
117 gd->flags &= ~GD_FLG_SILENT;
119 printf("cros-ec communications failure %d\n", ret);
120 puts("\nPlease reset with Power+Refresh\n\n");
121 panic("Cannot init cros-ec device");