[U-Boot] [PATCH] Rename reset to sysreset

Stephen Warren swarren at wwwdotorg.org
Thu May 12 20:03:35 CEST 2016


From: Stephen Warren <swarren at nvidia.com>

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 at nvidia.com>
---
 arch/arm/lib/Makefile                              |  2 +-
 arch/arm/mach-rockchip/rk3036/reset_rk3036.c       | 20 +++---
 arch/arm/mach-rockchip/rk3288/reset_rk3288.c       | 20 +++---
 arch/arm/mach-snapdragon/reset.c                   | 18 ++---
 arch/sandbox/cpu/state.c                           |  4 +-
 arch/sandbox/include/asm/state.h                   |  6 +-
 configs/chromebook_jerry_defconfig                 |  2 +-
 configs/dragonboard410c_defconfig                  |  2 +-
 configs/evb-rk3036_defconfig                       |  2 +-
 configs/firefly-rk3288_defconfig                   |  2 +-
 configs/kylin-rk3036_defconfig                     |  2 +-
 configs/rock2_defconfig                            |  2 +-
 configs/sandbox_defconfig                          |  2 +-
 drivers/clk/clk_rk3036.c                           |  2 +-
 drivers/clk/clk_rk3288.c                           |  2 +-
 drivers/misc/Kconfig                               | 10 +--
 drivers/misc/Makefile                              |  4 +-
 drivers/misc/{reset-uclass.c => sysreset-uclass.c} | 32 ++++-----
 .../misc/{reset_sandbox.c => sysreset_sandbox.c}   | 61 +++++++++--------
 include/dm/uclass-id.h                             |  2 +-
 include/{reset.h => sysreset.h}                    | 42 ++++++------
 test/dm/Makefile                                   |  2 +-
 test/dm/{reset.c => sysreset.c}                    | 80 +++++++++++-----------
 23 files changed, 161 insertions(+), 160 deletions(-)
 rename drivers/misc/{reset-uclass.c => sysreset-uclass.c} (55%)
 rename drivers/misc/{reset_sandbox.c => sysreset_sandbox.c} (46%)
 rename include/{reset.h => sysreset.h} (47%)
 rename test/dm/{reset.c => sysreset.c} (16%)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 7a0fb5862e1b..b535dbef49a2 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -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
 
diff --git a/arch/arm/mach-rockchip/rk3036/reset_rk3036.c b/arch/arm/mach-rockchip/rk3036/reset_rk3036.c
index fefb568f7aef..b3d211323992 100644
--- a/arch/arm/mach-rockchip/rk3036/reset_rk3036.c
+++ b/arch/arm/mach-rockchip/rk3036/reset_rk3036.c
@@ -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,
 };
diff --git a/arch/arm/mach-rockchip/rk3288/reset_rk3288.c b/arch/arm/mach-rockchip/rk3288/reset_rk3288.c
index bf7540a5d24d..0aad1c216013 100644
--- a/arch/arm/mach-rockchip/rk3288/reset_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/reset_rk3288.c
@@ -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,
 };
diff --git a/arch/arm/mach-snapdragon/reset.c b/arch/arm/mach-snapdragon/reset.c
index 2627eec18154..a6cabfb8b012 100644
--- a/arch/arm/mach-snapdragon/reset.c
+++ b/arch/arm/mach-snapdragon/reset.c
@@ -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,
 };
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index d2a7dc9b450f..2b4dbd341ff3 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -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:
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 11856c2fede6..149f28d8732f 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -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 */
diff --git a/configs/chromebook_jerry_defconfig b/configs/chromebook_jerry_defconfig
index 25ead92778cc..d5bc5153b1b1 100644
--- a/configs/chromebook_jerry_defconfig
+++ b/configs/chromebook_jerry_defconfig
@@ -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
diff --git a/configs/dragonboard410c_defconfig b/configs/dragonboard410c_defconfig
index 2566ded58a44..37c5ea7761c9 100644
--- a/configs/dragonboard410c_defconfig
+++ b/configs/dragonboard410c_defconfig
@@ -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
diff --git a/configs/evb-rk3036_defconfig b/configs/evb-rk3036_defconfig
index 4dd458624342..9894fffcca20 100644
--- a/configs/evb-rk3036_defconfig
+++ b/configs/evb-rk3036_defconfig
@@ -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
diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig
index 0995f9b329fe..0cbc5398488d 100644
--- a/configs/firefly-rk3288_defconfig
+++ b/configs/firefly-rk3288_defconfig
@@ -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
diff --git a/configs/kylin-rk3036_defconfig b/configs/kylin-rk3036_defconfig
index 50fbe654bf63..0ff6c6b9a4ac 100644
--- a/configs/kylin-rk3036_defconfig
+++ b/configs/kylin-rk3036_defconfig
@@ -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
diff --git a/configs/rock2_defconfig b/configs/rock2_defconfig
index fd32fb521eb6..3e16b805caa8 100644
--- a/configs/rock2_defconfig
+++ b/configs/rock2_defconfig
@@ -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
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index afdf4a3ba715..9ad570c7fc49 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -95,7 +95,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
diff --git a/drivers/clk/clk_rk3036.c b/drivers/clk/clk_rk3036.c
index bd5f22a753a4..7ec65bdff029 100644
--- a/drivers/clk/clk_rk3036.c
+++ b/drivers/clk/clk_rk3036.c
@@ -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);
 
diff --git a/drivers/clk/clk_rk3288.c b/drivers/clk/clk_rk3288.c
index 2a85e93a6cc3..e763a1c8e91f 100644
--- a/drivers/clk/clk_rk3288.c
+++ b/drivers/clk/clk_rk3288.c
@@ -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);
 
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index af8667f030c5..48f23e61cf8e 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -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
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 5969d3444413..59c73415139c 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -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,6 +40,6 @@ 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
diff --git a/drivers/misc/reset-uclass.c b/drivers/misc/sysreset-uclass.c
similarity index 55%
rename from drivers/misc/reset-uclass.c
rename to drivers/misc/sysreset-uclass.c
index fdb5c6fcff34..e41efcaca602 100644
--- a/drivers/misc/reset-uclass.c
+++ b/drivers/misc/sysreset-uclass.c
@@ -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",
 };
diff --git a/drivers/misc/reset_sandbox.c b/drivers/misc/sysreset_sandbox.c
similarity index 46%
rename from drivers/misc/reset_sandbox.c
rename to drivers/misc/sysreset_sandbox.c
index 2691bb031a50..7ae7f386ee02 100644
--- a/drivers/misc/reset_sandbox.c
+++ b/drivers/misc/sysreset_sandbox.c
@@ -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",
 };
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index cbf9b2ca2351..45ae9650e3dd 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -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 */
diff --git a/include/reset.h b/include/sysreset.h
similarity index 47%
rename from include/reset.h
rename to include/sysreset.h
index 383761eb1fb0..393c7be3d811 100644
--- a/include/reset.h
+++ b/include/sysreset.h
@@ -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);
 
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 9a11ae0a147a..fd781e82cfe8 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -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
diff --git a/test/dm/reset.c b/test/dm/sysreset.c
similarity index 16%
rename from test/dm/reset.c
rename to test/dm/sysreset.c
index 5d53f252bb5e..5e94c072b658 100644
--- a/test/dm/reset.c
+++ b/test/dm/sysreset.c
@@ -6,69 +6,69 @@
 
 #include <common.h>
 #include <dm.h>
-#include <reset.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 reset devices */
-static int dm_test_reset_base(struct unit_test_state *uts)
+/* 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_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));
+	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 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));
+	/* Device 1 is the warm sysreset device */
+	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
+	ut_asserteq(-EACCES, sysreset_request(dev, SYSRESET_WARM));
+	ut_asserteq(-ENOSYS, sysreset_request(dev, SYSRESET_COLD));
+	ut_asserteq(-ENOSYS, sysreset_request(dev, SYSRESET_POWER));
 
-	state->reset_allowed[RESET_WARM] = true;
-	ut_asserteq(-EINPROGRESS, reset_request(dev, RESET_WARM));
-	state->reset_allowed[RESET_WARM] = false;
+	state->sysreset_allowed[SYSRESET_WARM] = true;
+	ut_asserteq(-EINPROGRESS, sysreset_request(dev, SYSRESET_WARM));
+	state->sysreset_allowed[SYSRESET_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;
+	/* Device 2 is the cold sysreset device */
+	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
+	ut_asserteq(-ENOSYS, sysreset_request(dev, SYSRESET_WARM));
+	ut_asserteq(-EACCES, sysreset_request(dev, SYSRESET_COLD));
+	state->sysreset_allowed[SYSRESET_POWER] = false;
+	ut_asserteq(-EACCES, sysreset_request(dev, SYSRESET_POWER));
+	state->sysreset_allowed[SYSRESET_POWER] = true;
 
 	return 0;
 }
-DM_TEST(dm_test_reset_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sysreset_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)
+/* Test that we can walk through the sysreset devices */
+static int dm_test_sysreset_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));
+	/* If we generate a power sysreset, we will exit sandbox! */
+	state->sysreset_allowed[SYSRESET_POWER] = false;
+	ut_asserteq(-EACCES, sysreset_walk(SYSRESET_WARM));
+	ut_asserteq(-EACCES, sysreset_walk(SYSRESET_COLD));
+	ut_asserteq(-EACCES, sysreset_walk(SYSRESET_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.
+	 * Enable cold system reset - this should make cold system reset work,
+	 * plus a warm system 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;
+	state->sysreset_allowed[SYSRESET_COLD] = true;
+	ut_asserteq(-EINPROGRESS, sysreset_walk(SYSRESET_WARM));
+	ut_asserteq(-EINPROGRESS, sysreset_walk(SYSRESET_COLD));
+	ut_asserteq(-EACCES, sysreset_walk(SYSRESET_POWER));
+	state->sysreset_allowed[SYSRESET_COLD] = false;
+	state->sysreset_allowed[SYSRESET_POWER] = true;
 
 	return 0;
 }
-DM_TEST(dm_test_reset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sysreset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.8.2



More information about the U-Boot mailing list