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: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Simon Glass
parent
6f82fac2f2
commit
1163625898
@@ -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
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Google, Inc
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <reset.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)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
|
||||
switch (type) {
|
||||
case RESET_WARM:
|
||||
state->last_reset = type;
|
||||
break;
|
||||
default:
|
||||
return -ENOSYS;
|
||||
}
|
||||
if (!state->reset_allowed[type])
|
||||
return -EACCES;
|
||||
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
||||
static int sandbox_reset_request(struct udevice *dev, enum reset_t type)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
|
||||
/*
|
||||
* If we have a device tree, the device we created from platform data
|
||||
* (see the U_BOOT_DEVICE() declaration below) should not do anything.
|
||||
* If we are that device, return an error.
|
||||
*/
|
||||
if (state->fdt_fname && dev->of_offset == -1)
|
||||
return -ENODEV;
|
||||
|
||||
switch (type) {
|
||||
case RESET_COLD:
|
||||
state->last_reset = type;
|
||||
break;
|
||||
case RESET_POWER:
|
||||
state->last_reset = type;
|
||||
if (!state->reset_allowed[type])
|
||||
return -EACCES;
|
||||
sandbox_exit();
|
||||
break;
|
||||
default:
|
||||
return -ENOSYS;
|
||||
}
|
||||
if (!state->reset_allowed[type])
|
||||
return -EACCES;
|
||||
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
||||
static struct reset_ops sandbox_reset_ops = {
|
||||
.request = sandbox_reset_request,
|
||||
};
|
||||
|
||||
static const struct udevice_id sandbox_reset_ids[] = {
|
||||
{ .compatible = "sandbox,reset" },
|
||||
{ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(reset_sandbox) = {
|
||||
.name = "reset_sandbox",
|
||||
.id = UCLASS_RESET,
|
||||
.of_match = sandbox_reset_ids,
|
||||
.ops = &sandbox_reset_ops,
|
||||
};
|
||||
|
||||
static struct reset_ops sandbox_warm_reset_ops = {
|
||||
.request = sandbox_warm_reset_request,
|
||||
};
|
||||
|
||||
static const struct udevice_id sandbox_warm_reset_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,
|
||||
};
|
||||
|
||||
/* This is here in case we don't have a device tree */
|
||||
U_BOOT_DEVICE(reset_sandbox_non_fdt) = {
|
||||
.name = "reset_sandbox",
|
||||
};
|
||||
@@ -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",
|
||||
};
|
||||
101
drivers/misc/sysreset_sandbox.c
Normal file
101
drivers/misc/sysreset_sandbox.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Google, Inc
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <sysreset.h>
|
||||
#include <asm/state.h>
|
||||
#include <asm/test.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
static int sandbox_warm_sysreset_request(struct udevice *dev,
|
||||
enum sysreset_t type)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
|
||||
switch (type) {
|
||||
case SYSRESET_WARM:
|
||||
state->last_sysreset = type;
|
||||
break;
|
||||
default:
|
||||
return -ENOSYS;
|
||||
}
|
||||
if (!state->sysreset_allowed[type])
|
||||
return -EACCES;
|
||||
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
||||
static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
|
||||
/*
|
||||
* If we have a device tree, the device we created from platform data
|
||||
* (see the U_BOOT_DEVICE() declaration below) should not do anything.
|
||||
* If we are that device, return an error.
|
||||
*/
|
||||
if (state->fdt_fname && dev->of_offset == -1)
|
||||
return -ENODEV;
|
||||
|
||||
switch (type) {
|
||||
case SYSRESET_COLD:
|
||||
state->last_sysreset = type;
|
||||
break;
|
||||
case SYSRESET_POWER:
|
||||
state->last_sysreset = type;
|
||||
if (!state->sysreset_allowed[type])
|
||||
return -EACCES;
|
||||
sandbox_exit();
|
||||
break;
|
||||
default:
|
||||
return -ENOSYS;
|
||||
}
|
||||
if (!state->sysreset_allowed[type])
|
||||
return -EACCES;
|
||||
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
||||
static struct sysreset_ops sandbox_sysreset_ops = {
|
||||
.request = sandbox_sysreset_request,
|
||||
};
|
||||
|
||||
static const struct udevice_id sandbox_sysreset_ids[] = {
|
||||
{ .compatible = "sandbox,reset" },
|
||||
{ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(sysreset_sandbox) = {
|
||||
.name = "sysreset_sandbox",
|
||||
.id = UCLASS_SYSRESET,
|
||||
.of_match = sandbox_sysreset_ids,
|
||||
.ops = &sandbox_sysreset_ops,
|
||||
};
|
||||
|
||||
static struct sysreset_ops sandbox_warm_sysreset_ops = {
|
||||
.request = sandbox_warm_sysreset_request,
|
||||
};
|
||||
|
||||
static const struct udevice_id sandbox_warm_sysreset_ids[] = {
|
||||
{ .compatible = "sandbox,warm-reset" },
|
||||
{ }
|
||||
};
|
||||
|
||||
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(sysreset_sandbox_non_fdt) = {
|
||||
.name = "sysreset_sandbox",
|
||||
};
|
||||
Reference in New Issue
Block a user