2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2011-10-07 13:53:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 The Chromium OS Authors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2022-07-13 12:06:58 +00:00
|
|
|
#include <addr_map.h>
|
2019-11-14 19:57:39 +00:00
|
|
|
#include <cpu_func.h>
|
2014-02-27 20:26:13 +00:00
|
|
|
#include <cros_ec.h>
|
2014-02-26 22:59:25 +00:00
|
|
|
#include <dm.h>
|
2022-04-15 05:59:34 +00:00
|
|
|
#include <efi.h>
|
|
|
|
#include <efi_loader.h>
|
2020-07-28 09:51:22 +00:00
|
|
|
#include <env_internal.h>
|
2019-11-14 19:57:46 +00:00
|
|
|
#include <init.h>
|
2018-07-27 14:37:09 +00:00
|
|
|
#include <led.h>
|
2011-11-29 11:16:40 +00:00
|
|
|
#include <os.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2015-04-21 18:57:18 +00:00
|
|
|
#include <asm/test.h>
|
2014-02-27 20:26:19 +00:00
|
|
|
#include <asm/u-boot-sandbox.h>
|
2022-04-15 05:59:34 +00:00
|
|
|
#include <linux/kernel.h>
|
2021-05-04 17:31:23 +00:00
|
|
|
#include <malloc.h>
|
|
|
|
|
|
|
|
#include <extension_board.h>
|
2011-11-29 11:16:40 +00:00
|
|
|
|
2011-10-07 13:53:38 +00:00
|
|
|
/*
|
|
|
|
* Pointer to initial global data area
|
|
|
|
*
|
|
|
|
* Here we initialize it.
|
|
|
|
*/
|
|
|
|
gd_t *gd;
|
|
|
|
|
2023-02-05 22:39:42 +00:00
|
|
|
#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
|
2022-11-10 17:04:30 +00:00
|
|
|
/* GUIDs for capsule updatable firmware images */
|
|
|
|
#define SANDBOX_UBOOT_IMAGE_GUID \
|
|
|
|
EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
|
|
|
|
0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
|
|
|
|
|
|
|
|
#define SANDBOX_UBOOT_ENV_IMAGE_GUID \
|
|
|
|
EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
|
|
|
|
0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
|
|
|
|
|
|
|
|
#define SANDBOX_FIT_IMAGE_GUID \
|
|
|
|
EFI_GUID(0x3673b45d, 0x6a7c, 0x46f3, 0x9e, 0x60, \
|
|
|
|
0xad, 0xab, 0xb0, 0x3f, 0x79, 0x37)
|
|
|
|
|
2022-04-15 05:59:34 +00:00
|
|
|
struct efi_fw_image fw_images[] = {
|
|
|
|
#if defined(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)
|
|
|
|
{
|
|
|
|
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
|
|
|
|
.fw_name = u"SANDBOX-UBOOT",
|
|
|
|
.image_index = 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
|
|
|
|
.fw_name = u"SANDBOX-UBOOT-ENV",
|
|
|
|
.image_index = 2,
|
|
|
|
},
|
|
|
|
#elif defined(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)
|
|
|
|
{
|
|
|
|
.image_type_id = SANDBOX_FIT_IMAGE_GUID,
|
|
|
|
.fw_name = u"SANDBOX-FIT",
|
|
|
|
.image_index = 1,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct efi_capsule_update_info update_info = {
|
|
|
|
.dfu_string = "sf 0:0=u-boot-bin raw 0x100000 0x50000;"
|
|
|
|
"u-boot-env raw 0x150000 0x200000",
|
|
|
|
.images = fw_images,
|
|
|
|
};
|
|
|
|
|
|
|
|
u8 num_image_type_guids = ARRAY_SIZE(fw_images);
|
|
|
|
#endif /* EFI_HAVE_CAPSULE_SUPPORT */
|
|
|
|
|
2020-10-03 17:31:23 +00:00
|
|
|
#if !CONFIG_IS_ENABLED(OF_PLATDATA)
|
2021-08-07 13:24:04 +00:00
|
|
|
/*
|
|
|
|
* Add a simple GPIO device (don't use with of-platdata as it interferes with
|
|
|
|
* the auto-generated devices)
|
|
|
|
*/
|
2020-12-29 03:34:54 +00:00
|
|
|
U_BOOT_DRVINFO(gpio_sandbox) = {
|
2020-06-25 04:10:04 +00:00
|
|
|
.name = "sandbox_gpio",
|
2014-02-26 22:59:25 +00:00
|
|
|
};
|
2020-10-03 17:31:23 +00:00
|
|
|
#endif
|
2014-02-26 22:59:25 +00:00
|
|
|
|
2015-10-30 07:35:52 +00:00
|
|
|
#ifndef CONFIG_TIMER
|
2015-04-21 18:57:18 +00:00
|
|
|
/* system timer offset in ms */
|
|
|
|
static unsigned long sandbox_timer_offset;
|
|
|
|
|
regmap: fix regmap_read_poll_timeout warning about sandbox_timer_add_offset
When fixing sandbox test for regmap_read_poll_timeout(), the
sandbox_timer_add_offset was introduced but only defined in sandbox code
thus generating warnings when used out of sandbox :
include/regmap.h:289:2: note: in expansion of macro 'regmap_read_poll_timeout_test'
regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/spi/meson_spifc.c:169:8: note: in expansion of macro 'regmap_read_poll_timeout'
ret = regmap_read_poll_timeout(spifc->regmap, REG_SLAVE, data,
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/spi/meson_spifc.c: In function 'meson_spifc_txrx':
include/regmap.h:277:4: warning: implicit declaration of function 'sandbox_timer_add_offset' [-Wimplicit-function-declaration]
This fix adds a timer_test_add_offset() only defined in sandbox, and
renames the previous sandbox_timer_add_offset() to it.
Cc: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
Fixes: df9cf1cc08 ("test: dm: regmap: Fix the long test delay")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2019-04-11 15:01:23 +00:00
|
|
|
void timer_test_add_offset(unsigned long offset)
|
2015-04-21 18:57:18 +00:00
|
|
|
{
|
|
|
|
sandbox_timer_offset += offset;
|
|
|
|
}
|
|
|
|
|
2013-11-08 14:40:44 +00:00
|
|
|
unsigned long timer_read_counter(void)
|
2012-02-21 05:21:17 +00:00
|
|
|
{
|
2015-04-21 18:57:18 +00:00
|
|
|
return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
|
2011-10-07 13:53:38 +00:00
|
|
|
}
|
2015-10-30 07:35:52 +00:00
|
|
|
#endif
|
2011-10-07 13:53:38 +00:00
|
|
|
|
2020-07-28 09:51:22 +00:00
|
|
|
/* specific order for sandbox: nowhere is the first value, used by default */
|
|
|
|
static enum env_location env_locations[] = {
|
|
|
|
ENVL_NOWHERE,
|
|
|
|
ENVL_EXT4,
|
2021-03-04 18:28:37 +00:00
|
|
|
ENVL_FAT,
|
2020-07-28 09:51:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum env_location env_get_location(enum env_operation op, int prio)
|
|
|
|
{
|
|
|
|
if (prio >= ARRAY_SIZE(env_locations))
|
|
|
|
return ENVL_UNKNOWN;
|
|
|
|
|
|
|
|
return env_locations[prio];
|
|
|
|
}
|
|
|
|
|
2011-10-07 13:53:38 +00:00
|
|
|
int dram_init(void)
|
|
|
|
{
|
2022-11-16 18:10:37 +00:00
|
|
|
gd->ram_size = CFG_SYS_SDRAM_SIZE;
|
2011-10-07 13:53:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-02-27 20:26:13 +00:00
|
|
|
|
2018-07-27 14:37:09 +00:00
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
int ft_board_setup(void *fdt, struct bd_info *bd)
|
2020-03-14 11:13:40 +00:00
|
|
|
{
|
|
|
|
/* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/
|
|
|
|
return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000);
|
|
|
|
}
|
|
|
|
|
2021-05-04 17:31:23 +00:00
|
|
|
#ifdef CONFIG_CMD_EXTENSION
|
|
|
|
int extension_board_scan(struct list_head *extension_list)
|
|
|
|
{
|
|
|
|
struct extension *extension;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
extension = calloc(1, sizeof(struct extension));
|
|
|
|
snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
|
|
|
|
snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
|
|
|
|
snprintf(extension->owner, sizeof(extension->owner), "sandbox");
|
|
|
|
snprintf(extension->version, sizeof(extension->version), "1.1");
|
2022-10-16 20:17:46 +00:00
|
|
|
snprintf(extension->other, sizeof(extension->other), "Fictional extension board");
|
2021-05-04 17:31:23 +00:00
|
|
|
list_add_tail(&extension->list, extension_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-27 20:26:13 +00:00
|
|
|
#ifdef CONFIG_BOARD_LATE_INIT
|
|
|
|
int board_late_init(void)
|
|
|
|
{
|
2018-11-06 22:21:26 +00:00
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
|
|
|
|
if (ret && ret != -ENODEV) {
|
2014-02-27 20:26:13 +00:00
|
|
|
/* Force console on */
|
|
|
|
gd->flags &= ~GD_FLG_SILENT;
|
|
|
|
|
2018-11-06 22:21:26 +00:00
|
|
|
printf("cros-ec communications failure %d\n", ret);
|
2014-02-27 20:26:13 +00:00
|
|
|
puts("\nPlease reset with Power+Refresh\n\n");
|
|
|
|
panic("Cannot init cros-ec device");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2022-07-13 12:06:58 +00:00
|
|
|
|
|
|
|
int init_addr_map(void)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_ADDR_MAP))
|
2022-11-16 18:10:37 +00:00
|
|
|
addrmap_set_entry(0, 0, CFG_SYS_SDRAM_SIZE, 0);
|
2022-07-13 12:06:58 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-10-21 12:46:05 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
|
|
|
|
void fwu_plat_get_bootidx(uint *boot_idx)
|
|
|
|
{
|
|
|
|
/* Dummy value */
|
|
|
|
*boot_idx = 0;
|
|
|
|
}
|
|
|
|
#endif
|