Commit 11636258 authored by Stephen Warren's avatar Stephen Warren Committed by Simon Glass

Rename reset to sysreset

The current reset API implements a method to reset the entire system.
In the near future, I'd like to introduce code that implements the device
tree reset bindings; i.e. the equivalent of the Linux kernel's reset API.
This controls resets to individual HW blocks or external chips with reset
signals. It doesn't make sense to merge the two APIs into one since they
have different semantic purposes. Resolve the naming conflict by renaming
the existing reset API to sysreset instead, so the new reset API can be
called just reset.
Signed-off-by: 's avatarStephen Warren <swarren@nvidia.com>
Acked-by: 's avatarSimon Glass <sjg@chromium.org>
parent 6f82fac2
......@@ -46,7 +46,7 @@ obj-y += interrupts_64.o
else
obj-y += interrupts.o
endif
ifndef CONFIG_RESET
ifndef CONFIG_SYSRESET
obj-y += reset.o
endif
......
......@@ -7,24 +7,24 @@
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <reset.h>
#include <sysreset.h>
#include <asm/io.h>
#include <asm/arch/clock.h>
#include <asm/arch/cru_rk3036.h>
#include <asm/arch/hardware.h>
#include <linux/err.h>
int rk3036_reset_request(struct udevice *dev, enum reset_t type)
int rk3036_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
struct rk3036_cru *cru = rockchip_get_cru();
if (IS_ERR(cru))
return PTR_ERR(cru);
switch (type) {
case RESET_WARM:
case SYSRESET_WARM:
writel(0xeca8, &cru->cru_glb_srst_snd_value);
break;
case RESET_COLD:
case SYSRESET_COLD:
writel(0xfdb9, &cru->cru_glb_srst_fst_value);
break;
default:
......@@ -34,12 +34,12 @@ int rk3036_reset_request(struct udevice *dev, enum reset_t type)
return -EINPROGRESS;
}
static struct reset_ops rk3036_reset = {
.request = rk3036_reset_request,
static struct sysreset_ops rk3036_sysreset = {
.request = rk3036_sysreset_request,
};
U_BOOT_DRIVER(reset_rk3036) = {
.name = "rk3036_reset",
.id = UCLASS_RESET,
.ops = &rk3036_reset,
U_BOOT_DRIVER(sysreset_rk3036) = {
.name = "rk3036_sysreset",
.id = UCLASS_SYSRESET,
.ops = &rk3036_sysreset,
};
......@@ -7,25 +7,25 @@
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <reset.h>
#include <sysreset.h>
#include <asm/io.h>
#include <asm/arch/clock.h>
#include <asm/arch/cru_rk3288.h>
#include <asm/arch/hardware.h>
#include <linux/err.h>
int rk3288_reset_request(struct udevice *dev, enum reset_t type)
int rk3288_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
struct rk3288_cru *cru = rockchip_get_cru();
if (IS_ERR(cru))
return PTR_ERR(cru);
switch (type) {
case RESET_WARM:
case SYSRESET_WARM:
rk_clrreg(&cru->cru_mode_con, 0xffff);
writel(0xeca8, &cru->cru_glb_srst_snd_value);
break;
case RESET_COLD:
case SYSRESET_COLD:
rk_clrreg(&cru->cru_mode_con, 0xffff);
writel(0xfdb9, &cru->cru_glb_srst_fst_value);
break;
......@@ -36,12 +36,12 @@ int rk3288_reset_request(struct udevice *dev, enum reset_t type)
return -EINPROGRESS;
}
static struct reset_ops rk3288_reset = {
.request = rk3288_reset_request,
static struct sysreset_ops rk3288_sysreset = {
.request = rk3288_sysreset_request,
};
U_BOOT_DRIVER(reset_rk3288) = {
.name = "rk3288_reset",
.id = UCLASS_RESET,
.ops = &rk3288_reset,
U_BOOT_DRIVER(sysreset_rk3288) = {
.name = "rk3288_sysreset",
.id = UCLASS_SYSRESET,
.ops = &rk3288_sysreset,
};
......@@ -9,12 +9,12 @@
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <reset.h>
#include <sysreset.h>
#include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
static int msm_reset_request(struct udevice *dev, enum reset_t type)
static int msm_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
phys_addr_t addr = dev_get_addr(dev);
if (!addr)
......@@ -23,18 +23,18 @@ static int msm_reset_request(struct udevice *dev, enum reset_t type)
return -EINPROGRESS;
}
static struct reset_ops msm_reset_ops = {
.request = msm_reset_request,
static struct sysreset_ops msm_sysreset_ops = {
.request = msm_sysreset_request,
};
static const struct udevice_id msm_reset_ids[] = {
static const struct udevice_id msm_sysreset_ids[] = {
{ .compatible = "qcom,pshold" },
{ }
};
U_BOOT_DRIVER(msm_reset) = {
.name = "msm_reset",
.id = UCLASS_RESET,
.of_match = msm_reset_ids,
.ops = &msm_reset_ops,
.name = "msm_sysreset",
.id = UCLASS_SYSRESET,
.of_match = msm_sysreset_ids,
.ops = &msm_sysreset_ops,
};
......@@ -360,8 +360,8 @@ int state_init(void)
assert(state->ram_buf);
/* No reset yet, so mark it as such. Always allow power reset */
state->last_reset = RESET_COUNT;
state->reset_allowed[RESET_POWER] = true;
state->last_sysreset = SYSRESET_COUNT;
state->sysreset_allowed[SYSRESET_POWER] = true;
/*
* Example of how to use GPIOs:
......
......@@ -7,7 +7,7 @@
#define __SANDBOX_STATE_H
#include <config.h>
#include <reset.h>
#include <sysreset.h>
#include <stdbool.h>
#include <linux/stringify.h>
......@@ -60,8 +60,8 @@ struct sandbox_state {
bool write_state; /* Write sandbox state on exit */
bool ignore_missing_state_on_read; /* No error if state missing */
bool show_lcd; /* Show LCD on start-up */
enum reset_t last_reset; /* Last reset type */
bool reset_allowed[RESET_COUNT]; /* Allowed reset types */
enum sysreset_t last_sysreset; /* Last system reset type */
bool sysreset_allowed[SYSRESET_COUNT]; /* Allowed system reset types */
enum state_terminal_raw term_raw; /* Terminal raw/cooked */
bool skip_delays; /* Ignore any time delays (for test) */
bool show_test_output; /* Don't suppress stdout in tests */
......
......@@ -47,7 +47,7 @@ CONFIG_CMD_CROS_EC=y
CONFIG_CROS_EC=y
CONFIG_CROS_EC_SPI=y
CONFIG_PWRSEQ=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_ROCKCHIP_DWMMC=y
CONFIG_PINCTRL=y
......
......@@ -23,7 +23,7 @@ CONFIG_MSM_GPIO=y
CONFIG_PM8916_GPIO=y
CONFIG_LED=y
CONFIG_LED_GPIO=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_MSM_SDHCI=y
CONFIG_DM_PMIC=y
......
......@@ -28,7 +28,7 @@ CONFIG_CLK=y
CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_LED=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_ROCKCHIP_DWMMC=y
CONFIG_PINCTRL=y
......
......@@ -40,7 +40,7 @@ CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_LED=y
CONFIG_LED_GPIO=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_ROCKCHIP_DWMMC=y
CONFIG_PINCTRL=y
......
......@@ -28,7 +28,7 @@ CONFIG_CLK=y
CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_LED=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_ROCKCHIP_DWMMC=y
CONFIG_PINCTRL=y
......
......@@ -38,7 +38,7 @@ CONFIG_CLK=y
CONFIG_SPL_CLK=y
CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_ROCKCHIP_DWMMC=y
CONFIG_PINCTRL=y
......
......@@ -97,7 +97,7 @@ CONFIG_CROS_EC_SANDBOX=y
CONFIG_CROS_EC_SPI=y
CONFIG_PWRSEQ=y
CONFIG_SPL_PWRSEQ=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_SANDBOX_MMC=y
CONFIG_SPI_FLASH_SANDBOX=y
......
......@@ -94,7 +94,7 @@ CONFIG_CROS_EC_SANDBOX=y
CONFIG_CROS_EC_SPI=y
CONFIG_PWRSEQ=y
CONFIG_SPL_PWRSEQ=y
CONFIG_RESET=y
CONFIG_SYSRESET=y
CONFIG_DM_MMC=y
CONFIG_SPI_FLASH_SANDBOX=y
CONFIG_SPI_FLASH=y
......
......@@ -407,7 +407,7 @@ static int rk3036_clk_bind(struct udevice *dev)
}
/* The reset driver does not have a device node, so bind it here */
ret = device_bind_driver(gd->dm_root, "rk3036_reset", "reset", &dev);
ret = device_bind_driver(gd->dm_root, "rk3036_sysreset", "reset", &dev);
if (ret)
debug("Warning: No RK3036 reset driver: ret=%d\n", ret);
......
......@@ -877,7 +877,7 @@ static int rk3288_clk_bind(struct udevice *dev)
}
/* The reset driver does not have a device node, so bind it here */
ret = device_bind_driver(gd->dm_root, "rk3288_reset", "reset", &dev);
ret = device_bind_driver(gd->dm_root, "rk3288_sysreset", "reset", &dev);
if (ret)
debug("Warning: No RK3288 reset driver: ret=%d\n", ret);
......
......@@ -121,13 +121,13 @@ config PCA9551_I2C_ADDR
help
The I2C address of the PCA9551 LED controller.
config RESET
bool "Enable support for reset drivers"
config SYSRESET
bool "Enable support for system reset drivers"
depends on DM
help
Enable reset drivers which can be used to reset the CPU or board.
Each driver can provide a reset method which will be called to
effect a reset. The uclass will try all available drivers when
Enable system reset drivers which can be used to reset the CPU or
board. Each driver can provide a reset method which will be called
to effect a reset. The uclass will try all available drivers when
reset_walk() is called.
config WINBOND_W83627
......
......@@ -27,7 +27,7 @@ obj-$(CONFIG_MXS_OCOTP) += mxs_ocotp.o
obj-$(CONFIG_NS87308) += ns87308.o
obj-$(CONFIG_PDSP188x) += pdsp188x.o
obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
obj-$(CONFIG_SANDBOX) += reset_sandbox.o
obj-$(CONFIG_SANDBOX) += sysreset_sandbox.o
ifdef CONFIG_DM_I2C
obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o
endif
......@@ -40,7 +40,7 @@ obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
obj-$(CONFIG_RESET) += reset-uclass.o
obj-$(CONFIG_SYSRESET) += sysreset-uclass.o
obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o
obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
obj-$(CONFIG_QFW) += qfw.o
......@@ -6,7 +6,7 @@
*/
#include <common.h>
#include <reset.h>
#include <sysreset.h>
#include <dm.h>
#include <errno.h>
#include <regmap.h>
......@@ -15,9 +15,9 @@
#include <dm/root.h>
#include <linux/err.h>
int reset_request(struct udevice *dev, enum reset_t type)
int sysreset_request(struct udevice *dev, enum sysreset_t type)
{
struct reset_ops *ops = reset_get_ops(dev);
struct sysreset_ops *ops = sysreset_get_ops(dev);
if (!ops->request)
return -ENOSYS;
......@@ -25,16 +25,16 @@ int reset_request(struct udevice *dev, enum reset_t type)
return ops->request(dev, type);
}
int reset_walk(enum reset_t type)
int sysreset_walk(enum sysreset_t type)
{
struct udevice *dev;
int ret = -ENOSYS;
while (ret != -EINPROGRESS && type < RESET_COUNT) {
for (uclass_first_device(UCLASS_RESET, &dev);
while (ret != -EINPROGRESS && type < SYSRESET_COUNT) {
for (uclass_first_device(UCLASS_SYSRESET, &dev);
dev;
uclass_next_device(&dev)) {
ret = reset_request(dev, type);
ret = sysreset_request(dev, type);
if (ret == -EINPROGRESS)
break;
}
......@@ -44,38 +44,38 @@ int reset_walk(enum reset_t type)
return ret;
}
void reset_walk_halt(enum reset_t type)
void sysreset_walk_halt(enum sysreset_t type)
{
int ret;
ret = reset_walk(type);
ret = sysreset_walk(type);
/* Wait for the reset to take effect */
if (ret == -EINPROGRESS)
mdelay(100);
/* Still no reset? Give up */
printf("Reset not supported on this platform\n");
printf("System reset not supported on this platform\n");
hang();
}
/**
* reset_cpu() - calls reset_walk(RESET_WARM)
* reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
*/
void reset_cpu(ulong addr)
{
reset_walk_halt(RESET_WARM);
sysreset_walk_halt(SYSRESET_WARM);
}
int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
reset_walk_halt(RESET_WARM);
sysreset_walk_halt(SYSRESET_WARM);
return 0;
}
UCLASS_DRIVER(reset) = {
.id = UCLASS_RESET,
.name = "reset",
UCLASS_DRIVER(sysreset) = {
.id = UCLASS_SYSRESET,
.name = "sysreset",
};
......@@ -8,30 +8,31 @@
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <reset.h>
#include <sysreset.h>
#include <asm/state.h>
#include <asm/test.h>
DECLARE_GLOBAL_DATA_PTR;
static int sandbox_warm_reset_request(struct udevice *dev, enum reset_t type)
static int sandbox_warm_sysreset_request(struct udevice *dev,
enum sysreset_t type)
{
struct sandbox_state *state = state_get_current();
switch (type) {
case RESET_WARM:
state->last_reset = type;
case SYSRESET_WARM:
state->last_sysreset = type;
break;
default:
return -ENOSYS;
}
if (!state->reset_allowed[type])
if (!state->sysreset_allowed[type])
return -EACCES;
return -EINPROGRESS;
}
static int sandbox_reset_request(struct udevice *dev, enum reset_t type)
static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
struct sandbox_state *state = state_get_current();
......@@ -44,57 +45,57 @@ static int sandbox_reset_request(struct udevice *dev, enum reset_t type)
return -ENODEV;
switch (type) {
case RESET_COLD:
state->last_reset = type;
case SYSRESET_COLD:
state->last_sysreset = type;
break;
case RESET_POWER:
state->last_reset = type;
if (!state->reset_allowed[type])
case SYSRESET_POWER:
state->last_sysreset = type;
if (!state->sysreset_allowed[type])
return -EACCES;
sandbox_exit();
break;
default:
return -ENOSYS;
}
if (!state->reset_allowed[type])
if (!state->sysreset_allowed[type])
return -EACCES;
return -EINPROGRESS;
}
static struct reset_ops sandbox_reset_ops = {
.request = sandbox_reset_request,
static struct sysreset_ops sandbox_sysreset_ops = {
.request = sandbox_sysreset_request,
};
static const struct udevice_id sandbox_reset_ids[] = {
static const struct udevice_id sandbox_sysreset_ids[] = {
{ .compatible = "sandbox,reset" },
{ }
};
U_BOOT_DRIVER(reset_sandbox) = {
.name = "reset_sandbox",
.id = UCLASS_RESET,
.of_match = sandbox_reset_ids,
.ops = &sandbox_reset_ops,
U_BOOT_DRIVER(sysreset_sandbox) = {
.name = "sysreset_sandbox",
.id = UCLASS_SYSRESET,
.of_match = sandbox_sysreset_ids,
.ops = &sandbox_sysreset_ops,
};
static struct reset_ops sandbox_warm_reset_ops = {
.request = sandbox_warm_reset_request,
static struct sysreset_ops sandbox_warm_sysreset_ops = {
.request = sandbox_warm_sysreset_request,
};
static const struct udevice_id sandbox_warm_reset_ids[] = {
static const struct udevice_id sandbox_warm_sysreset_ids[] = {
{ .compatible = "sandbox,warm-reset" },
{ }
};
U_BOOT_DRIVER(warm_reset_sandbox) = {
.name = "warm_reset_sandbox",
.id = UCLASS_RESET,
.of_match = sandbox_warm_reset_ids,
.ops = &sandbox_warm_reset_ops,
U_BOOT_DRIVER(warm_sysreset_sandbox) = {
.name = "warm_sysreset_sandbox",
.id = UCLASS_SYSRESET,
.of_match = sandbox_warm_sysreset_ids,
.ops = &sandbox_warm_sysreset_ops,
};
/* This is here in case we don't have a device tree */
U_BOOT_DEVICE(reset_sandbox_non_fdt) = {
.name = "reset_sandbox",
U_BOOT_DEVICE(sysreset_sandbox_non_fdt) = {
.name = "sysreset_sandbox",
};
......@@ -61,7 +61,6 @@ enum uclass_id {
UCLASS_PWM, /* Pulse-width modulator */
UCLASS_PWRSEQ, /* Power sequence device */
UCLASS_REGULATOR, /* Regulator device */
UCLASS_RESET, /* Reset device */
UCLASS_REMOTEPROC, /* Remote Processor device */
UCLASS_RTC, /* Real time clock device */
UCLASS_SERIAL, /* Serial UART */
......@@ -70,6 +69,7 @@ enum uclass_id {
UCLASS_SPI_FLASH, /* SPI flash */
UCLASS_SPI_GENERIC, /* Generic SPI flash target */
UCLASS_SYSCON, /* System configuration device */
UCLASS_SYSRESET, /* System reset device */
UCLASS_THERMAL, /* Thermal sensor */
UCLASS_TIMER, /* Timer device */
UCLASS_TPM, /* Trusted Platform Module TIS interface */
......
......@@ -5,20 +5,20 @@
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __RESET_H
#define __RESET_H
#ifndef __SYSRESET_H
#define __SYSRESET_H
enum reset_t {
RESET_WARM, /* Reset CPU, keep GPIOs active */
RESET_COLD, /* Reset CPU and GPIOs */
RESET_POWER, /* Reset PMIC (remove and restore power) */
enum sysreset_t {
SYSRESET_WARM, /* Reset CPU, keep GPIOs active */
SYSRESET_COLD, /* Reset CPU and GPIOs */
SYSRESET_POWER, /* Reset PMIC (remove and restore power) */
RESET_COUNT,
SYSRESET_COUNT,
};
struct reset_ops {
struct sysreset_ops {
/**
* request() - request a reset of the given type
* request() - request a sysreset of the given type
*
* Note that this function may return before the reset takes effect.
*
......@@ -28,24 +28,24 @@ struct reset_ops {
* by this device, 0 if the reset has already happened
* (in which case this method will not actually return)
*/
int (*request)(struct udevice *dev, enum reset_t type);
int (*request)(struct udevice *dev, enum sysreset_t type);
};
#define reset_get_ops(dev) ((struct reset_ops *)(dev)->driver->ops)
#define sysreset_get_ops(dev) ((struct sysreset_ops *)(dev)->driver->ops)
/**
* reset_request() - request a reset
* sysreset_request() - request a sysreset
*
* @type: Reset type to request
* @return 0 if OK, -EPROTONOSUPPORT if not supported by this device
*/
int reset_request(struct udevice *dev, enum reset_t type);
int sysreset_request(struct udevice *dev, enum sysreset_t type);
/**
* reset_walk() - cause a reset
* sysreset_walk() - cause a system reset
*
* This works through the available reset devices until it finds one that can
* perform a reset. If the provided reset type is not available, the next one
* This works through the available sysreset devices until it finds one that can
* perform a reset. If the provided sysreset type is not available, the next one
* will be tried.
*
* If this function fails to reset, it will display a message and halt
......@@ -53,18 +53,18 @@ int reset_request(struct udevice *dev, enum reset_t type);
* @type: Reset type to request
* @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available
*/
int reset_walk(enum reset_t type);
int sysreset_walk(enum sysreset_t type);
/**
* reset_walk_halt() - try to reset, otherwise halt
* sysreset_walk_halt() - try to reset, otherwise halt
*
* This calls reset_walk(). If it returns, indicating that reset is not
* This calls sysreset_walk(). If it returns, indicating that reset is not
* supported, it prints a message and halts.
*/
void reset_walk_halt(enum reset_t type);
void sysreset_walk_halt(enum sysreset_t type);
/**
* reset_cpu() - calls reset_walk(RESET_WARM)
* reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
*/
void reset_cpu(ulong addr);
......
......@@ -26,7 +26,7 @@ obj-$(CONFIG_DM_PCI) += pci.o
obj-$(CONFIG_RAM) += ram.o
obj-y += regmap.o
obj-$(CONFIG_REMOTEPROC) += remoteproc.o
obj-$(CONFIG_RESET) += reset.o
obj-$(CONFIG_SYSRESET) += sysreset.o
obj-$(CONFIG_DM_RTC) += rtc.o
obj-$(CONFIG_DM_SPI_FLASH) += sf.o
obj-$(CONFIG_DM_SPI) += spi.o
......
/*
* Copyright (C) 2015 Google, Inc
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <reset.h>
#include <asm/state.h>
#include <asm/test.h>
#include <dm/test.h>
#include <test/ut.h>
/* Test that we can use particular reset devices */
static int dm_test_reset_base(struct unit_test_state *uts)
{
struct sandbox_state *state = state_get_current();
struct udevice *dev;
/* Device 0 is the platform data device - it should never respond */
ut_assertok(uclass_get_device(UCLASS_RESET, 0, &dev));
ut_asserteq(-ENODEV, reset_request(dev, RESET_WARM));
ut_asserteq(-ENODEV, reset_request(dev, RESET_COLD));
ut_asserteq(-ENODEV, reset_request(dev, RESET_POWER));
/* Device 1 is the warm reset device */
ut_assertok(uclass_get_device(UCLASS_RESET, 1, &dev));
ut_asserteq(-EACCES, reset_request(dev, RESET_WARM));
ut_asserteq(-ENOSYS, reset_request(dev, RESET_COLD));
ut_asserteq(-ENOSYS, reset_request(dev, RESET_POWER));
state->reset_allowed[RESET_WARM] = true;
ut_asserteq(-EINPROGRESS, reset_request(dev, RESET_WARM));
state->reset_allowed[RESET_WARM] = false;
/* Device 2 is the cold reset device */
ut_assertok(uclass_get_device(UCLASS_RESET, 2, &dev));
ut_asserteq(-ENOSYS, reset_request(dev, RESET_WARM));
ut_asserteq(-EACCES, reset_request(dev, RESET_COLD));
state->reset_allowed[RESET_POWER] = false;
ut_asserteq(-EACCES, reset_request(dev, RESET_POWER));
state->reset_allowed[RESET_POWER] = true;
return 0;
}
DM_TEST(dm_test_reset_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
/* Test that we can walk through the reset devices */
static int dm_test_reset_walk(struct unit_test_state *uts)
{
struct sandbox_state *state = state_get_current();
/* If we generate a power reset, we will exit sandbox! */
state->reset_allowed[RESET_POWER] = false;
ut_asserteq(-EACCES, reset_walk(RESET_WARM));
ut_asserteq(-EACCES, reset_walk(RESET_COLD));
ut_asserteq(-EACCES, reset_walk(RESET_POWER));
/*
* Enable cold reset - this should make cold reset work, plus a warm
* reset should be promoted to cold, since this is the next step
* along.
*/
state->reset_allowed[RESET_COLD] = true;
ut_asserteq(-EINPROGRESS, reset_walk(RESET_WARM));
ut_asserteq(-EINPROGRESS, reset_walk(RESET_COLD));
ut_asserteq(-EACCES, reset_walk(RESET_POWER));
state->reset_allowed[RESET_COLD] = false;
state->reset_allowed[RESET_POWER] = true;
return 0;
}
DM_TEST(dm_test_reset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
/*
* Copyright (C) 2015 Google, Inc
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <sysreset.h>
#include <asm/state.h>
#include <asm/test.h>
#include <dm/test.h>
#include <test/ut.h>
/* Test that we can use particular sysreset devices */
static int dm_test_sysreset_base(struct unit_test_state *uts)
{
struct sandbox_state *state = state_get_current();
struct udevice *dev;
/* Device 0 is the platform data device - it should never respond */
ut_assertok(uclass_get_device(UCLASS_SYSRESET, 0, &dev));
ut_asserteq(-ENODEV, sysreset_request(dev, SYSRESET_WARM));
ut_asserteq(-ENODEV, sysreset_request(dev, SYSRESET_COLD));
ut_asserteq(-ENODEV, sysreset_request(dev, SYSRESET_POWER));
/* Device 1 is the warm sysreset device */
ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
ut_asserteq(-EACCES