drivers/sysreset: group sysreset drivers
authorMax Filippov <jcmvbkbc@gmail.com>
Sun, 7 Aug 2016 05:53:00 +0000 (08:53 +0300)
committerTom Rini <trini@konsulko.com>
Fri, 12 Aug 2016 13:22:17 +0000 (09:22 -0400)
Create drivers/sysreset and move sysreset-uclass and all sysreset
drivers there.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
22 files changed:
arch/arm/mach-rockchip/rk3036/Makefile
arch/arm/mach-rockchip/rk3036/reset_rk3036.c [deleted file]
arch/arm/mach-rockchip/rk3288/Makefile
arch/arm/mach-rockchip/rk3288/reset_rk3288.c [deleted file]
arch/arm/mach-rockchip/rk3399/Makefile
arch/arm/mach-rockchip/rk3399/reset_rk3399.c [deleted file]
arch/arm/mach-snapdragon/Makefile
arch/arm/mach-snapdragon/reset.c [deleted file]
drivers/Kconfig
drivers/Makefile
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/sysreset-uclass.c [deleted file]
drivers/misc/sysreset_sandbox.c [deleted file]
drivers/sysreset/Kconfig [new file with mode: 0644]
drivers/sysreset/Makefile [new file with mode: 0644]
drivers/sysreset/sysreset-uclass.c [new file with mode: 0644]
drivers/sysreset/sysreset_rk3036.c [new file with mode: 0644]
drivers/sysreset/sysreset_rk3288.c [new file with mode: 0644]
drivers/sysreset/sysreset_rk3399.c [new file with mode: 0644]
drivers/sysreset/sysreset_sandbox.c [new file with mode: 0644]
drivers/sysreset/sysreset_snapdragon.c [new file with mode: 0644]

index 6095777b8fcf2b1b1d1ec3dfc4c78566fabe2648..916a7a43784cdc854d4ab1c54cbe40a025c38799 100644 (file)
@@ -5,7 +5,6 @@
 #
 
 ifndef CONFIG_SPL_BUILD
-obj-y += reset_rk3036.o
 obj-y += syscon_rk3036.o
 endif
 
diff --git a/arch/arm/mach-rockchip/rk3036/reset_rk3036.c b/arch/arm/mach-rockchip/rk3036/reset_rk3036.c
deleted file mode 100644 (file)
index b3d2113..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * (C) Copyright 2015 Rockchip Electronics Co., Ltd
- *
- * SPDX-License-Identifier:     GPL-2.0+
- */
-
-#include <common.h>
-#include <dm.h>
-#include <errno.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_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 SYSRESET_WARM:
-               writel(0xeca8, &cru->cru_glb_srst_snd_value);
-               break;
-       case SYSRESET_COLD:
-               writel(0xfdb9, &cru->cru_glb_srst_fst_value);
-               break;
-       default:
-               return -EPROTONOSUPPORT;
-       }
-
-       return -EINPROGRESS;
-}
-
-static struct sysreset_ops rk3036_sysreset = {
-       .request        = rk3036_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rk3036) = {
-       .name   = "rk3036_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rk3036_sysreset,
-};
index 82b00a1b01254593e6d4e0387367082c9ac84766..5ec3f0d7e2bad0f288b5feef9ab511733bc8f793 100644 (file)
@@ -5,6 +5,5 @@
 #
 
 obj-y += clk_rk3288.o
-obj-y += reset_rk3288.o
 obj-y += sdram_rk3288.o
 obj-y += syscon_rk3288.o
diff --git a/arch/arm/mach-rockchip/rk3288/reset_rk3288.c b/arch/arm/mach-rockchip/rk3288/reset_rk3288.c
deleted file mode 100644 (file)
index 0aad1c2..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * (C) Copyright 2015 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0
- */
-
-#include <common.h>
-#include <dm.h>
-#include <errno.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_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 SYSRESET_WARM:
-               rk_clrreg(&cru->cru_mode_con, 0xffff);
-               writel(0xeca8, &cru->cru_glb_srst_snd_value);
-               break;
-       case SYSRESET_COLD:
-               rk_clrreg(&cru->cru_mode_con, 0xffff);
-               writel(0xfdb9, &cru->cru_glb_srst_fst_value);
-               break;
-       default:
-               return -EPROTONOSUPPORT;
-       }
-
-       return -EINPROGRESS;
-}
-
-static struct sysreset_ops rk3288_sysreset = {
-       .request        = rk3288_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rk3288) = {
-       .name   = "rk3288_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rk3288_sysreset,
-};
index 3ca20284ef976387ce55d0194167f6d8dccdc0bf..607f9c96129844c61d888f39908040f30cba8f66 100644 (file)
@@ -5,5 +5,4 @@
 #
 
 obj-y += rk3399.o
-obj-y += reset_rk3399.o
 obj-y += syscon_rk3399.o
diff --git a/arch/arm/mach-rockchip/rk3399/reset_rk3399.c b/arch/arm/mach-rockchip/rk3399/reset_rk3399.c
deleted file mode 100644 (file)
index 9a55546..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * (C) Copyright 2016 Rockchip Electronics Co., Ltd
- *
- * SPDX-License-Identifier:    GPL-2.0
- */
-
-#include <common.h>
-#include <dm.h>
-#include <errno.h>
-#include <sysreset.h>
-#include <asm/io.h>
-#include <asm/arch/clock.h>
-#include <asm/arch/cru_rk3399.h>
-#include <asm/arch/hardware.h>
-#include <linux/err.h>
-
-int rk3399_sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       struct rk3399_cru *cru = rockchip_get_cru();
-
-       if (IS_ERR(cru))
-               return PTR_ERR(cru);
-       switch (type) {
-       case SYSRESET_WARM:
-               writel(0xeca8, &cru->glb_srst_snd_value);
-               break;
-       case SYSRESET_COLD:
-               writel(0xfdb9, &cru->glb_srst_fst_value);
-               break;
-       default:
-               return -EPROTONOSUPPORT;
-       }
-
-       return -EINPROGRESS;
-}
-
-static struct sysreset_ops rk3399_sysreset = {
-       .request        = rk3399_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rk3399) = {
-       .name   = "rk3399_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rk3399_sysreset,
-};
index 4735844b752d5da0c31ce84c4b13b79496762a94..d82a04dda60769e2a0a32df7b80f201e547a465b 100644 (file)
@@ -6,4 +6,3 @@
 
 obj-y += clock-apq8016.o
 obj-y += sysmap-apq8016.o
-obj-y += reset.o
diff --git a/arch/arm/mach-snapdragon/reset.c b/arch/arm/mach-snapdragon/reset.c
deleted file mode 100644 (file)
index a6cabfb..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Qualcomm APQ8016 reset controller driver
- *
- * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <dm.h>
-#include <errno.h>
-#include <sysreset.h>
-#include <asm/io.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static int msm_sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       phys_addr_t addr = dev_get_addr(dev);
-       if (!addr)
-               return -EINVAL;
-       writel(0, addr);
-       return -EINPROGRESS;
-}
-
-static struct sysreset_ops msm_sysreset_ops = {
-       .request        = msm_sysreset_request,
-};
-
-static const struct udevice_id msm_sysreset_ids[] = {
-       { .compatible = "qcom,pshold" },
-       { }
-};
-
-U_BOOT_DRIVER(msm_reset) = {
-       .name           = "msm_sysreset",
-       .id             = UCLASS_SYSRESET,
-       .of_match       = msm_sysreset_ids,
-       .ops            = &msm_sysreset_ops,
-};
index f6003a0a593ab1052ccf8ce51450a9e32d0347e6..4f84469955529ab449af1021080421d5faad6487 100644 (file)
@@ -68,6 +68,8 @@ source "drivers/spi/Kconfig"
 
 source "drivers/spmi/Kconfig"
 
+source "drivers/sysreset/Kconfig"
+
 source "drivers/thermal/Kconfig"
 
 source "drivers/timer/Kconfig"
index ad5cbae7caa565dfc0ec0fd7cc18148a3677afef..7861d346036c50ff421fed4db2cd4ed66aebfe16 100644 (file)
@@ -22,7 +22,7 @@ obj-$(CONFIG_SPL_SERIAL_SUPPORT) += serial/
 obj-$(CONFIG_SPL_SPI_SUPPORT) += spi/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/
-obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/
+obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/ sysreset/
 obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
 obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
@@ -59,6 +59,7 @@ obj-$(CONFIG_X86) += pch/
 obj-y += rtc/
 obj-y += sound/
 obj-y += spmi/
+obj-y += sysreset/
 obj-y += timer/
 obj-y += tpm/
 obj-y += twserial/
index b84e351da7cf86c7c29ef7bed32afc99f7520053..80c15581b927aef604c3510e8d296d889e63da9f 100644 (file)
@@ -121,15 +121,6 @@ config PCA9551_I2C_ADDR
        help
          The I2C address of the PCA9551 LED controller.
 
-config SYSRESET
-       bool "Enable support for system reset drivers"
-       depends on DM
-       help
-         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
        bool "Enable Winbond Super I/O driver"
        help
index fff6f0cdf95bc1bf5a821d002cd02658bfd3e68b..af541c6784dafb6bd5655bdc0a072bbd736bfec6 100644 (file)
@@ -27,7 +27,6 @@ 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) += sysreset_sandbox.o
 ifdef CONFIG_DM_I2C
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o
@@ -47,7 +46,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_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/sysreset-uclass.c b/drivers/misc/sysreset-uclass.c
deleted file mode 100644 (file)
index 3566d17..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2015 Google, Inc
- * Written by Simon Glass <sjg@chromium.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <sysreset.h>
-#include <dm.h>
-#include <errno.h>
-#include <regmap.h>
-#include <dm/device-internal.h>
-#include <dm/lists.h>
-#include <dm/root.h>
-#include <linux/err.h>
-
-int sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       struct sysreset_ops *ops = sysreset_get_ops(dev);
-
-       if (!ops->request)
-               return -ENOSYS;
-
-       return ops->request(dev, type);
-}
-
-int sysreset_walk(enum sysreset_t type)
-{
-       struct udevice *dev;
-       int ret = -ENOSYS;
-
-       while (ret != -EINPROGRESS && type < SYSRESET_COUNT) {
-               for (uclass_first_device(UCLASS_SYSRESET, &dev);
-                    dev;
-                    uclass_next_device(&dev)) {
-                       ret = sysreset_request(dev, type);
-                       if (ret == -EINPROGRESS)
-                               break;
-               }
-               type++;
-       }
-
-       return ret;
-}
-
-void sysreset_walk_halt(enum sysreset_t type)
-{
-       int ret;
-
-       ret = sysreset_walk(type);
-
-       /* Wait for the reset to take effect */
-       if (ret == -EINPROGRESS)
-               mdelay(100);
-
-       /* Still no reset? Give up */
-       debug("System reset not supported on this platform\n");
-       hang();
-}
-
-/**
- * reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
- */
-void reset_cpu(ulong addr)
-{
-       sysreset_walk_halt(SYSRESET_WARM);
-}
-
-
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-       sysreset_walk_halt(SYSRESET_WARM);
-
-       return 0;
-}
-
-UCLASS_DRIVER(sysreset) = {
-       .id             = UCLASS_SYSRESET,
-       .name           = "sysreset",
-};
diff --git a/drivers/misc/sysreset_sandbox.c b/drivers/misc/sysreset_sandbox.c
deleted file mode 100644 (file)
index 7ae7f38..0000000
+++ /dev/null
@@ -1,101 +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 <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",
-};
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
new file mode 100644 (file)
index 0000000..05a37b9
--- /dev/null
@@ -0,0 +1,16 @@
+#
+# System reset devices
+#
+
+menu "System reset device drivers"
+
+config SYSRESET
+       bool "Enable support for system reset drivers"
+       depends on DM
+       help
+         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.
+
+endmenu
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
new file mode 100644 (file)
index 0000000..7db1b69
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# (C) Copyright 2016 Cadence Design Systems Inc.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-$(CONFIG_SYSRESET) += sysreset-uclass.o
+
+ifndef CONFIG_SPL_BUILD
+obj-$(CONFIG_ROCKCHIP_RK3036) += sysreset_rk3036.o
+endif
+obj-$(CONFIG_ROCKCHIP_RK3288) += sysreset_rk3288.o
+obj-$(CONFIG_ROCKCHIP_RK3399) += sysreset_rk3399.o
+obj-$(CONFIG_SANDBOX) += sysreset_sandbox.o
+obj-$(CONFIG_ARCH_SNAPDRAGON) += sysreset_snapdragon.o
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
new file mode 100644 (file)
index 0000000..3566d17
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <sysreset.h>
+#include <dm.h>
+#include <errno.h>
+#include <regmap.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/root.h>
+#include <linux/err.h>
+
+int sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+       struct sysreset_ops *ops = sysreset_get_ops(dev);
+
+       if (!ops->request)
+               return -ENOSYS;
+
+       return ops->request(dev, type);
+}
+
+int sysreset_walk(enum sysreset_t type)
+{
+       struct udevice *dev;
+       int ret = -ENOSYS;
+
+       while (ret != -EINPROGRESS && type < SYSRESET_COUNT) {
+               for (uclass_first_device(UCLASS_SYSRESET, &dev);
+                    dev;
+                    uclass_next_device(&dev)) {
+                       ret = sysreset_request(dev, type);
+                       if (ret == -EINPROGRESS)
+                               break;
+               }
+               type++;
+       }
+
+       return ret;
+}
+
+void sysreset_walk_halt(enum sysreset_t type)
+{
+       int ret;
+
+       ret = sysreset_walk(type);
+
+       /* Wait for the reset to take effect */
+       if (ret == -EINPROGRESS)
+               mdelay(100);
+
+       /* Still no reset? Give up */
+       debug("System reset not supported on this platform\n");
+       hang();
+}
+
+/**
+ * reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
+ */
+void reset_cpu(ulong addr)
+{
+       sysreset_walk_halt(SYSRESET_WARM);
+}
+
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       sysreset_walk_halt(SYSRESET_WARM);
+
+       return 0;
+}
+
+UCLASS_DRIVER(sysreset) = {
+       .id             = UCLASS_SYSRESET,
+       .name           = "sysreset",
+};
diff --git a/drivers/sysreset/sysreset_rk3036.c b/drivers/sysreset/sysreset_rk3036.c
new file mode 100644 (file)
index 0000000..b3d2113
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.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_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 SYSRESET_WARM:
+               writel(0xeca8, &cru->cru_glb_srst_snd_value);
+               break;
+       case SYSRESET_COLD:
+               writel(0xfdb9, &cru->cru_glb_srst_fst_value);
+               break;
+       default:
+               return -EPROTONOSUPPORT;
+       }
+
+       return -EINPROGRESS;
+}
+
+static struct sysreset_ops rk3036_sysreset = {
+       .request        = rk3036_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_rk3036) = {
+       .name   = "rk3036_sysreset",
+       .id     = UCLASS_SYSRESET,
+       .ops    = &rk3036_sysreset,
+};
diff --git a/drivers/sysreset/sysreset_rk3288.c b/drivers/sysreset/sysreset_rk3288.c
new file mode 100644 (file)
index 0000000..0aad1c2
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.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_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 SYSRESET_WARM:
+               rk_clrreg(&cru->cru_mode_con, 0xffff);
+               writel(0xeca8, &cru->cru_glb_srst_snd_value);
+               break;
+       case SYSRESET_COLD:
+               rk_clrreg(&cru->cru_mode_con, 0xffff);
+               writel(0xfdb9, &cru->cru_glb_srst_fst_value);
+               break;
+       default:
+               return -EPROTONOSUPPORT;
+       }
+
+       return -EINPROGRESS;
+}
+
+static struct sysreset_ops rk3288_sysreset = {
+       .request        = rk3288_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_rk3288) = {
+       .name   = "rk3288_sysreset",
+       .id     = UCLASS_SYSRESET,
+       .ops    = &rk3288_sysreset,
+};
diff --git a/drivers/sysreset/sysreset_rk3399.c b/drivers/sysreset/sysreset_rk3399.c
new file mode 100644 (file)
index 0000000..9a55546
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <sysreset.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3399.h>
+#include <asm/arch/hardware.h>
+#include <linux/err.h>
+
+int rk3399_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+       struct rk3399_cru *cru = rockchip_get_cru();
+
+       if (IS_ERR(cru))
+               return PTR_ERR(cru);
+       switch (type) {
+       case SYSRESET_WARM:
+               writel(0xeca8, &cru->glb_srst_snd_value);
+               break;
+       case SYSRESET_COLD:
+               writel(0xfdb9, &cru->glb_srst_fst_value);
+               break;
+       default:
+               return -EPROTONOSUPPORT;
+       }
+
+       return -EINPROGRESS;
+}
+
+static struct sysreset_ops rk3399_sysreset = {
+       .request        = rk3399_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_rk3399) = {
+       .name   = "rk3399_sysreset",
+       .id     = UCLASS_SYSRESET,
+       .ops    = &rk3399_sysreset,
+};
diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/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",
+};
diff --git a/drivers/sysreset/sysreset_snapdragon.c b/drivers/sysreset/sysreset_snapdragon.c
new file mode 100644 (file)
index 0000000..a6cabfb
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Qualcomm APQ8016 reset controller driver
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <sysreset.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int msm_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+       phys_addr_t addr = dev_get_addr(dev);
+       if (!addr)
+               return -EINVAL;
+       writel(0, addr);
+       return -EINPROGRESS;
+}
+
+static struct sysreset_ops msm_sysreset_ops = {
+       .request        = msm_sysreset_request,
+};
+
+static const struct udevice_id msm_sysreset_ids[] = {
+       { .compatible = "qcom,pshold" },
+       { }
+};
+
+U_BOOT_DRIVER(msm_reset) = {
+       .name           = "msm_sysreset",
+       .id             = UCLASS_SYSRESET,
+       .of_match       = msm_sysreset_ids,
+       .ops            = &msm_sysreset_ops,
+};