[U-Boot] [PATCH v2 47/55] rockchip: clk: Update the rk3288 driver to support of-platdata

Simon Glass sjg at chromium.org
Mon Jun 13 07:33:28 CEST 2016


Add support for of-platdata with rk3288. This requires decoding the
of-platdata struct and setting up the devices from that. Also the driver
needs to be renamed to match the string that of-platdata will search for.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

 drivers/clk/clk_rk3288.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/clk_rk3288.c b/drivers/clk/clk_rk3288.c
index 8a62b3d..05912ff 100644
--- a/drivers/clk/clk_rk3288.c
+++ b/drivers/clk/clk_rk3288.c
@@ -7,7 +7,9 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <dt-structs.h>
 #include <errno.h>
+#include <mapmem.h>
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
@@ -22,6 +24,9 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 struct rk3288_clk_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_rockchip_rk3288_cru dtd;
+#endif
 	enum rk_clk_id clk_id;
 };
 
@@ -837,11 +842,13 @@ static struct clk_ops rk3288_clk_ops = {
 
 static int rk3288_clk_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3288_clk_plat *plat = dev_get_platdata(dev);
 	struct rk3288_clk_priv *priv = dev_get_priv(dev);
 
 	if (plat->clk_id == CLK_OSC)
 		priv->cru = (struct rk3288_cru *)dev_get_addr(dev);
+#endif
 
 	return 0;
 }
@@ -861,6 +868,9 @@ static int rk3288_clk_probe(struct udevice *dev)
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 	if (IS_ERR(priv->grf))
 		return PTR_ERR(priv->grf);
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	priv->cru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]);
+#endif
 #ifdef CONFIG_SPL_BUILD
 	rkclk_init(priv->cru, priv->grf);
 #endif
@@ -891,8 +901,8 @@ static int rk3288_clk_bind(struct udevice *dev)
 		struct rk3288_clk_plat *cplat;
 
 		debug("%s %s\n", __func__, clk_name[pll]);
-		ret = device_bind_driver(dev, "clk_rk3288", clk_name[pll],
-					 &child);
+		ret = device_bind_driver(dev, "rockchip_rk3288_cru",
+					 clk_name[pll], &child);
 		if (ret)
 			return ret;
 		cplat = dev_get_platdata(child);
@@ -912,8 +922,8 @@ static const struct udevice_id rk3288_clk_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(clk_rk3288) = {
-	.name		= "clk_rk3288",
+U_BOOT_DRIVER(rockchip_rk3288_cru) = {
+	.name		= "rockchip_rk3288_cru",
 	.id		= UCLASS_CLK,
 	.of_match	= rk3288_clk_ids,
 	.priv_auto_alloc_size = sizeof(struct rk3288_clk_priv),
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list