[U-Boot] [PATCH v2 23/55] dm: clk: Add support for of-platdata

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


Add support for this feature in the core clock code.

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

Changes in v2: None

 drivers/clk/clk-uclass.c     | 20 ++++++++++++++++++++
 drivers/clk/clk_fixed_rate.c |  2 ++
 include/clk.h                |  4 ++++
 3 files changed, 26 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index b483c1e..efe2d4e 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <dt-structs.h>
 #include <errno.h>
 #include <dm/lists.h>
 #include <dm/root.h>
@@ -65,6 +66,22 @@ ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate)
 }
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+# if CONFIG_IS_ENABLED(OF_PLATDATA)
+int clk_get_by_index_platdata(struct udevice *dev, int index,
+			      struct phandle_2_cell *cells,
+			      struct udevice **clk_devp)
+{
+	int ret;
+
+	if (index != 0)
+		return -ENOSYS;
+	assert(*clk_devp);
+	ret = uclass_get_device(UCLASS_CLK, 0, clk_devp);
+	if (ret)
+		return ret;
+	return cells[0].id;
+}
+# else
 int clk_get_by_index(struct udevice *dev, int index, struct udevice **clk_devp)
 {
 	int ret;
@@ -104,6 +121,9 @@ int clk_get_by_index(struct udevice *dev, int index, struct udevice **clk_devp)
 	return args.args_count > 0 ? args.args[0] : 0;
 #endif
 }
+# endif /* OF_PLATDATA */
+#else
+
 #endif
 
 UCLASS_DRIVER(clk) = {
diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c
index 8beda9c..8c3fb8f 100644
--- a/drivers/clk/clk_fixed_rate.c
+++ b/drivers/clk/clk_fixed_rate.c
@@ -33,9 +33,11 @@ const struct clk_ops clk_fixed_rate_ops = {
 
 static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	to_clk_fixed_rate(dev)->fixed_rate =
 				fdtdec_get_int(gd->fdt_blob, dev->of_offset,
 					       "clock-frequency", 0);
+#endif
 
 	return 0;
 }
diff --git a/include/clk.h b/include/clk.h
index ca20c3d..e4d23be 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -120,6 +120,10 @@ ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
  *		argument after the clock node phandle. If there is no arguemnt,
  *		returns 0. Return -ve error code on any error
  */
+struct phandle_2_cell;
+int clk_get_by_index_platdata(struct udevice *dev, int index,
+			      struct phandle_2_cell *cells,
+			      struct udevice **clk_devp);
 int clk_get_by_index(struct udevice *dev, int index, struct udevice **clk_devp);
 #else
 static inline int clk_get_by_index(struct udevice *dev, int index,
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list