rockchip: sysreset: merge into one common driver
authorKever Yang <kever.yang@rock-chips.com>
Fri, 3 Nov 2017 07:16:12 +0000 (15:16 +0800)
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tue, 21 Nov 2017 22:57:23 +0000 (23:57 +0100)
Use a common driver for all Rockchip SOC instead of one for each SoC.
Use driver_data for reg offset.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
arch/arm/include/asm/arch-rockchip/clock.h
drivers/sysreset/sysreset_rk3036.c [deleted file]
drivers/sysreset/sysreset_rk3188.c [deleted file]
drivers/sysreset/sysreset_rk322x.c [deleted file]
drivers/sysreset/sysreset_rk3288.c [deleted file]
drivers/sysreset/sysreset_rk3328.c [deleted file]
drivers/sysreset/sysreset_rk3368.c [deleted file]
drivers/sysreset/sysreset_rk3399.c [deleted file]
drivers/sysreset/sysreset_rockchip.c [new file with mode: 0644]
drivers/sysreset/sysreset_rv1108.c [deleted file]

index 641df58ac258b00730fdda72312c36ba03cc55a3..736b2603fdadea83a42e193874c73c4c0ae26049 100644 (file)
@@ -39,6 +39,11 @@ static inline int rk_pll_id(enum rk_clk_id clk_id)
        return clk_id - 1;
 }
 
+struct sysreset_reg {
+       unsigned int glb_srst_fst_value;
+       unsigned int glb_srst_snd_value;
+};
+
 /**
  * clk_get_divisor() - Calculate the required clock divisior
  *
diff --git a/drivers/sysreset/sysreset_rk3036.c b/drivers/sysreset/sysreset_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,
-};
diff --git a/drivers/sysreset/sysreset_rk3188.c b/drivers/sysreset/sysreset_rk3188.c
deleted file mode 100644 (file)
index 053a634..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * (C) Copyright 2015 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0
- */
-
-#include <common.h>
-#include <dm.h>
-#include <errno.h>
-#include <syscon.h>
-#include <sysreset.h>
-#include <asm/io.h>
-#include <asm/arch/clock.h>
-#include <asm/arch/cru_rk3188.h>
-#include <asm/arch/grf_rk3188.h>
-#include <asm/arch/hardware.h>
-#include <linux/err.h>
-
-int rk3188_sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       struct rk3188_cru *cru = rockchip_get_cru();
-       struct rk3188_grf *grf;
-
-       if (IS_ERR(cru))
-               return PTR_ERR(cru);
-       switch (type) {
-       case SYSRESET_WARM:
-               grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
-               if (IS_ERR(grf))
-                       return -EPROTONOSUPPORT;
-
-               /*
-                * warm-reset keeps the remap value,
-                * so make sure it's disabled.
-                */
-               rk_clrsetreg(&grf->soc_con0,
-                       NOC_REMAP_MASK << NOC_REMAP_SHIFT,
-                       0 << NOC_REMAP_SHIFT);
-
-               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 rk3188_sysreset = {
-       .request        = rk3188_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rk3188) = {
-       .name   = "rk3188_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rk3188_sysreset,
-};
diff --git a/drivers/sysreset/sysreset_rk322x.c b/drivers/sysreset/sysreset_rk322x.c
deleted file mode 100644 (file)
index 5fce79b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * (C) Copyright 2017 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_rk322x.h>
-#include <asm/arch/hardware.h>
-#include <linux/err.h>
-
-int rk322x_sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       struct rk322x_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 rk322x_sysreset = {
-       .request        = rk322x_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rk322x) = {
-       .name   = "rk322x_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rk322x_sysreset,
-};
diff --git a/drivers/sysreset/sysreset_rk3288.c b/drivers/sysreset/sysreset_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,
-};
diff --git a/drivers/sysreset/sysreset_rk3328.c b/drivers/sysreset/sysreset_rk3328.c
deleted file mode 100644 (file)
index 7b9af09..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/arch/clock.h>
-#include <asm/arch/cru_rk3328.h>
-#include <asm/arch/hardware.h>
-#include <asm/io.h>
-#include <linux/err.h>
-
-int rk3328_sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       struct rk3328_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 rk3328_sysreset = {
-       .request        = rk3328_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rk3328) = {
-       .name   = "rk3328_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rk3328_sysreset,
-};
diff --git a/drivers/sysreset/sysreset_rk3368.c b/drivers/sysreset/sysreset_rk3368.c
deleted file mode 100644 (file)
index de62921..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * (C) Copyright 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_rk3368.h>
-#include <asm/arch/hardware.h>
-#include <linux/err.h>
-
-static void rk3368_pll_enter_slow_mode(struct rk3368_cru *cru)
-{
-       struct rk3368_pll *pll;
-       int i;
-
-       for (i = 0; i < 6; i++) {
-               pll = &cru->pll[i];
-               rk_clrreg(&pll->con3, PLL_MODE_MASK);
-       }
-}
-
-static int rk3368_sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       struct rk3368_cru *cru = rockchip_get_cru();
-
-       if (IS_ERR(cru))
-               return PTR_ERR(cru);
-       switch (type) {
-       case SYSRESET_WARM:
-               rk3368_pll_enter_slow_mode(cru);
-               rk_clrsetreg(&cru->glb_rst_con, PMU_GLB_SRST_CTRL_MASK,
-                            PMU_RST_BY_SND_GLB_SRST << PMU_GLB_SRST_CTRL_SHIFT);
-               writel(0xeca8, &cru->glb_srst_snd_val);
-               break;
-       case SYSRESET_COLD:
-               rk3368_pll_enter_slow_mode(cru);
-               rk_clrsetreg(&cru->glb_rst_con, PMU_GLB_SRST_CTRL_MASK,
-                            PMU_RST_BY_FST_GLB_SRST << PMU_GLB_SRST_CTRL_SHIFT);
-               writel(0xfdb9, &cru->glb_srst_fst_val);
-               break;
-       default:
-               return -EPROTONOSUPPORT;
-       }
-
-       return -EINPROGRESS;
-}
-
-static struct sysreset_ops rk3368_sysreset = {
-       .request        = rk3368_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rk3368) = {
-       .name   = "rk3368_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rk3368_sysreset,
-};
diff --git a/drivers/sysreset/sysreset_rk3399.c b/drivers/sysreset/sysreset_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,
-};
diff --git a/drivers/sysreset/sysreset_rockchip.c b/drivers/sysreset/sysreset_rockchip.c
new file mode 100644 (file)
index 0000000..894975f
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2017 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_rk3328.h>
+#include <asm/arch/hardware.h>
+#include <linux/err.h>
+
+int rockchip_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+       struct sysreset_reg *offset = dev_get_priv(dev);
+       unsigned long cru_base = (unsigned long)rockchip_get_cru();
+
+       if (IS_ERR_VALUE(cru_base))
+               return (int)cru_base;
+
+       switch (type) {
+       case SYSRESET_WARM:
+               writel(0xeca8, cru_base + offset->glb_srst_snd_value);
+               break;
+       case SYSRESET_COLD:
+               writel(0xfdb9, cru_base + offset->glb_srst_fst_value);
+               break;
+       default:
+               return -EPROTONOSUPPORT;
+       }
+
+       return -EINPROGRESS;
+}
+
+static struct sysreset_ops rockchip_sysreset = {
+       .request        = rockchip_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_rockchip) = {
+       .name   = "rockchip_sysreset",
+       .id     = UCLASS_SYSRESET,
+       .ops    = &rockchip_sysreset,
+};
diff --git a/drivers/sysreset/sysreset_rv1108.c b/drivers/sysreset/sysreset_rv1108.c
deleted file mode 100644 (file)
index 9d8e9f7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * (C) Copyright 2015 Rockchip Electronics Co., Ltd
- * Author: Andy Yan <andy.yan@rock-chips.com>
- * 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_rv1108.h>
-#include <asm/arch/hardware.h>
-#include <linux/err.h>
-
-int rv1108_sysreset_request(struct udevice *dev, enum sysreset_t type)
-{
-       struct rv1108_cru *cru = rockchip_get_cru();
-
-       if (IS_ERR(cru))
-               return PTR_ERR(cru);
-
-       switch (type) {
-       case SYSRESET_WARM:
-               writel(0xeca8, &cru->glb_srst_snd_val);
-               break;
-       case SYSRESET_COLD:
-               writel(0xfdb9, &cru->glb_srst_fst_val);
-               break;
-       default:
-               return -EPROTONOSUPPORT;
-       }
-
-       return -EINPROGRESS;
-}
-
-static struct sysreset_ops rv1108_sysreset = {
-       .request        = rv1108_sysreset_request,
-};
-
-U_BOOT_DRIVER(sysreset_rv1108) = {
-       .name   = "rv1108_sysreset",
-       .id     = UCLASS_SYSRESET,
-       .ops    = &rv1108_sysreset,
-};