[U-Boot] [PATCH v2 2/2] rockchip: clk: bind reset driver

Kever Yang kever.yang at rock-chips.com
Tue Nov 28 07:02:29 UTC 2017


From: Elaine Zhang <zhangqing at rock-chips.com>

Bind rockchip reset to clock-controller with rockchip_reset_bind().

Signed-off-by: Elaine Zhang <zhangqing at rock-chips.com>
Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
---

Changes in v2:
- use rockchip_reset_bind() to bind reset driver.

 arch/arm/include/asm/arch-rockchip/clock.h | 10 ++++++++++
 drivers/clk/rockchip/clk_rk3036.c          |  6 ++++++
 drivers/clk/rockchip/clk_rk3188.c          |  6 ++++++
 drivers/clk/rockchip/clk_rk322x.c          |  6 ++++++
 drivers/clk/rockchip/clk_rk3288.c          |  6 ++++++
 drivers/clk/rockchip/clk_rk3328.c          |  6 ++++++
 drivers/clk/rockchip/clk_rk3368.c          |  6 ++++++
 drivers/clk/rockchip/clk_rk3399.c          | 19 +++++++++++++++++++
 drivers/clk/rockchip/clk_rv1108.c          |  6 ++++++
 9 files changed, 71 insertions(+)

diff --git a/arch/arm/include/asm/arch-rockchip/clock.h b/arch/arm/include/asm/arch-rockchip/clock.h
index 736b260..5264111 100644
--- a/arch/arm/include/asm/arch-rockchip/clock.h
+++ b/arch/arm/include/asm/arch-rockchip/clock.h
@@ -85,4 +85,14 @@ void rk3288_clk_configure_cpu(struct rk3288_cru *cru, struct rk3288_grf *grf);
 
 int rockchip_get_clk(struct udevice **devp);
 
+/*
+ * rockchip_reset_bind() - Bind soft reset device as child of clock device
+ *
+ * @pdev: clock udevice
+ * @reg_offset: the first offset in cru for softreset registers
+ * @reg_number: the reg numbers of softreset registers
+ * @return 0 success, or error value
+ */
+int rockchip_reset_bind(struct udevice *pdev, u32 reg_offset, u32 reg_number);
+
 #endif
diff --git a/drivers/clk/rockchip/clk_rk3036.c b/drivers/clk/rockchip/clk_rk3036.c
index 280ebb9..a718a08 100644
--- a/drivers/clk/rockchip/clk_rk3036.c
+++ b/drivers/clk/rockchip/clk_rk3036.c
@@ -332,6 +332,7 @@ static int rk3036_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -347,6 +348,11 @@ static int rk3036_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk3036_cru, cru_softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 9);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return 0;
 }
 
diff --git a/drivers/clk/rockchip/clk_rk3188.c b/drivers/clk/rockchip/clk_rk3188.c
index fca6899..6f24538 100644
--- a/drivers/clk/rockchip/clk_rk3188.c
+++ b/drivers/clk/rockchip/clk_rk3188.c
@@ -575,6 +575,7 @@ static int rk3188_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -590,6 +591,11 @@ static int rk3188_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk3188_cru, cru_softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 9);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return 0;
 }
 
diff --git a/drivers/clk/rockchip/clk_rk322x.c b/drivers/clk/rockchip/clk_rk322x.c
index ff52b55..1fc4e9e 100644
--- a/drivers/clk/rockchip/clk_rk322x.c
+++ b/drivers/clk/rockchip/clk_rk322x.c
@@ -387,6 +387,7 @@ static int rk322x_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -402,6 +403,11 @@ static int rk322x_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk322x_cru, cru_softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 9);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return 0;
 }
 
diff --git a/drivers/clk/rockchip/clk_rk3288.c b/drivers/clk/rockchip/clk_rk3288.c
index ac53239..e456bd0 100644
--- a/drivers/clk/rockchip/clk_rk3288.c
+++ b/drivers/clk/rockchip/clk_rk3288.c
@@ -861,6 +861,7 @@ static int rk3288_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -876,6 +877,11 @@ static int rk3288_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk3288_cru, cru_softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 12);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return 0;
 }
 
diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c
index 4d522a7..8563c72 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -599,6 +599,7 @@ static int rk3328_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -614,6 +615,11 @@ static int rk3328_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk3328_cru, softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 12);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return ret;
 }
 
diff --git a/drivers/clk/rockchip/clk_rk3368.c b/drivers/clk/rockchip/clk_rk3368.c
index bfeef39..c9449ed 100644
--- a/drivers/clk/rockchip/clk_rk3368.c
+++ b/drivers/clk/rockchip/clk_rk3368.c
@@ -528,6 +528,7 @@ static int rk3368_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -543,6 +544,11 @@ static int rk3368_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk3368_cru, softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 15);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return ret;
 }
 
diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c
index 2e85ac7..97d2fcc 100644
--- a/drivers/clk/rockchip/clk_rk3399.c
+++ b/drivers/clk/rockchip/clk_rk3399.c
@@ -1031,6 +1031,7 @@ static int rk3399_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -1046,6 +1047,11 @@ static int rk3399_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk3399_cru, softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 21);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return 0;
 }
 
@@ -1221,6 +1227,18 @@ static int rk3399_pmuclk_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int rk3399_pmuclk_bind(struct udevice *dev)
+{
+	int ret = 0;
+
+	offset = offsetof(struct rk3399_pmucru, pmucru_softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 2);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
+	return 0;
+}
+
 static const struct udevice_id rk3399_pmuclk_ids[] = {
 	{ .compatible = "rockchip,rk3399-pmucru" },
 	{ }
@@ -1234,6 +1252,7 @@ U_BOOT_DRIVER(rockchip_rk3399_pmuclk) = {
 	.ofdata_to_platdata = rk3399_pmuclk_ofdata_to_platdata,
 	.ops		= &rk3399_pmuclk_ops,
 	.probe		= rk3399_pmuclk_probe,
+	.bind		= rk3399_pmuclk_bind,
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 	.platdata_auto_alloc_size = sizeof(struct rk3399_pmuclk_plat),
 #endif
diff --git a/drivers/clk/rockchip/clk_rv1108.c b/drivers/clk/rockchip/clk_rv1108.c
index a119548..0f0a18f 100644
--- a/drivers/clk/rockchip/clk_rv1108.c
+++ b/drivers/clk/rockchip/clk_rv1108.c
@@ -225,6 +225,7 @@ static int rv1108_clk_bind(struct udevice *dev)
 	int ret;
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
+	u32 offset;
 
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
@@ -240,6 +241,11 @@ static int rv1108_clk_bind(struct udevice *dev)
 		sys_child->priv = priv;
 	}
 
+	offset = offsetof(struct rk3368_cru, softrst_con[0]);
+	ret = rockchip_reset_bind(dev, offset, 13);
+	if (ret)
+		debug("Warning: software reset driver bind faile\n");
+
 	return 0;
 }
 
-- 
1.9.1



More information about the U-Boot mailing list