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>
|
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>
|
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>
|
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>
|
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;
|
|
|
|
|
2014-02-26 22:59:25 +00:00
|
|
|
/* Add a simple GPIO device */
|
|
|
|
U_BOOT_DEVICE(gpio_sandbox) = {
|
2020-06-25 04:10:04 +00:00
|
|
|
.name = "sandbox_gpio",
|
2014-02-26 22:59:25 +00:00
|
|
|
};
|
|
|
|
|
2011-10-07 13:53:38 +00:00
|
|
|
void flush_cache(unsigned long start, unsigned long size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2013-04-26 02:53:43 +00:00
|
|
|
gd->ram_size = CONFIG_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)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_LED))
|
|
|
|
led_default_state();
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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
|