Rename reset to sysreset
authorStephen Warren <swarren@nvidia.com>
Thu, 12 May 2016 18:03:35 +0000 (12:03 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 27 May 2016 02:48:31 +0000 (20:48 -0600)
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>
27 files changed:
arch/arm/lib/Makefile
arch/arm/mach-rockchip/rk3036/reset_rk3036.c
arch/arm/mach-rockchip/rk3288/reset_rk3288.c
arch/arm/mach-snapdragon/reset.c
arch/sandbox/cpu/state.c
arch/sandbox/include/asm/state.h
configs/chromebook_jerry_defconfig
configs/dragonboard410c_defconfig
configs/evb-rk3036_defconfig
configs/firefly-rk3288_defconfig
configs/kylin-rk3036_defconfig
configs/rock2_defconfig
configs/sandbox_defconfig
configs/sandbox_noblk_defconfig
drivers/clk/clk_rk3036.c
drivers/clk/clk_rk3288.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/reset_sandbox.c [deleted file]
drivers/misc/sysreset-uclass.c [moved from drivers/misc/reset-uclass.c with 55% similarity]
drivers/misc/sysreset_sandbox.c [new file with mode: 0644]
include/dm/uclass-id.h
include/reset.h [deleted file]
include/sysreset.h [new file with mode: 0644]
test/dm/Makefile
test/dm/reset.c [deleted file]
test/dm/sysreset.c [new file with mode: 0644]

index 7a0fb58..b535dbe 100644 (file)
@@ -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
 
index fefb568..b3d2113 100644 (file)
@@ -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,
 };
index bf7540a..0aad1c2 100644 (file)
@@ -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,
 };
index 2627eec..a6cabfb 100644 (file)
@@ -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,
 };
index d2a7dc9..2b4dbd3 100644 (file)
@@ -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:
index 11856c2..149f28d 100644 (file)
@@ -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 */
index 25ead92..d5bc515 100644 (file)
@@ -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
index 2566ded..37c5ea7 100644 (file)
@@ -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
index 4dd4586..9894fff 100644 (file)
@@ -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
index 0995f9b..0cbc539 100644 (file)
@@ -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
index 50fbe65..0ff6c6b 100644 (file)
@@ -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
index fd32fb5..3e16b80 100644 (file)
@@ -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
index 9e4a92d..6e30c5d 100644 (file)
@@ -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
index 93167c2..60c7339 100644 (file)
@@ -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
index bd5f22a..7ec65bd 100644 (file)
@@ -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);
 
index 2a85e93..e763a1c 100644 (file)
@@ -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);
 
index c40f6b5..2373037 100644 (file)
@@ -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
index 98704f2..066639b 100644 (file)
@@ -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
diff --git a/drivers/misc/reset_sandbox.c b/drivers/misc/reset_sandbox.c
deleted file mode 100644 (file)
index 2691bb0..0000000
+++ /dev/null
@@ -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",
-};
similarity index 55%
rename from drivers/misc/reset-uclass.c
rename to drivers/misc/sysreset-uclass.c
index fdb5c6f..e41efca 100644 (file)
@@ -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/sysreset_sandbox.c b/drivers/misc/sysreset_sandbox.c
new file mode 100644 (file)
index 0000000..7ae7f38
--- /dev/null
@@ -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",
+};
index a5cf6e2..f9ff45e 100644 (file)
@@ -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/reset.h
deleted file mode 100644 (file)
index 383761e..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2015 Google, Inc
- * Written by Simon Glass <sjg@chromium.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __RESET_H
-#define __RESET_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) */
-
-       RESET_COUNT,
-};
-
-struct reset_ops {
-       /**
-        * request() - request a reset of the given type
-        *
-        * Note that this function may return before the reset takes effect.
-        *
-        * @type:       Reset type to request
-        * @return -EINPROGRESS if the reset has been started and
-        *              will complete soon, -EPROTONOSUPPORT if not supported
-        *              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);
-};
-
-#define reset_get_ops(dev)        ((struct reset_ops *)(dev)->driver->ops)
-
-/**
- * reset_request() - request a reset
- *
- * @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);
-
-/**
- * reset_walk() - cause a 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
- * will be tried.
- *
- * If this function fails to reset, it will display a message and halt
- *
- * @type:      Reset type to request
- * @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available
- */
-int reset_walk(enum reset_t type);
-
-/**
- * reset_walk_halt() - try to reset, otherwise halt
- *
- * This calls reset_walk(). If it returns, indicating that reset is not
- * supported, it prints a message and halts.
- */
-void reset_walk_halt(enum reset_t type);
-
-/**
- * reset_cpu() - calls reset_walk(RESET_WARM)
- */
-void reset_cpu(ulong addr);
-
-#endif
diff --git a/include/sysreset.h b/include/sysreset.h
new file mode 100644 (file)
index 0000000..393c7be
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __SYSRESET_H
+#define __SYSRESET_H
+
+enum sysreset_t {
+       SYSRESET_WARM,  /* Reset CPU, keep GPIOs active */
+       SYSRESET_COLD,  /* Reset CPU and GPIOs */
+       SYSRESET_POWER, /* Reset PMIC (remove and restore power) */
+
+       SYSRESET_COUNT,
+};
+
+struct sysreset_ops {
+       /**
+        * request() - request a sysreset of the given type
+        *
+        * Note that this function may return before the reset takes effect.
+        *
+        * @type:       Reset type to request
+        * @return -EINPROGRESS if the reset has been started and
+        *              will complete soon, -EPROTONOSUPPORT if not supported
+        *              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 sysreset_t type);
+};
+
+#define sysreset_get_ops(dev)        ((struct sysreset_ops *)(dev)->driver->ops)
+
+/**
+ * sysreset_request() - request a sysreset
+ *
+ * @type:      Reset type to request
+ * @return 0 if OK, -EPROTONOSUPPORT if not supported by this device
+ */
+int sysreset_request(struct udevice *dev, enum sysreset_t type);
+
+/**
+ * sysreset_walk() - cause a system reset
+ *
+ * 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
+ *
+ * @type:      Reset type to request
+ * @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available
+ */
+int sysreset_walk(enum sysreset_t type);
+
+/**
+ * sysreset_walk_halt() - try to reset, otherwise halt
+ *
+ * This calls sysreset_walk(). If it returns, indicating that reset is not
+ * supported, it prints a message and halts.
+ */
+void sysreset_walk_halt(enum sysreset_t type);
+
+/**
+ * reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
+ */
+void reset_cpu(ulong addr);
+
+#endif
index 9a11ae0..fd781e8 100644 (file)
@@ -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/reset.c
deleted file mode 100644 (file)
index 5d53f25..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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);
diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c
new file mode 100644 (file)
index 0000000..5e94c07
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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, sysreset_request(dev, SYSRESET_WARM));
+       ut_asserteq(-ENOSYS, sysreset_request(dev, SYSRESET_COLD));
+       ut_asserteq(-ENOSYS, sysreset_request(dev, SYSRESET_POWER));
+
+       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 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_sysreset_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* 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 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 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->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_sysreset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);