[PATCH 5/5] clk: fixed: add DT init function

Sebastian Hesselbarth sebastian.hesselbarth at gmail.com
Sat Nov 9 08:24:21 EST 2013


This adds a DT init function to clk-fixed and corresponding CLK_OF_DECLARE
to put it into the DT clock provider table.
---
Cc: barebox at lists.infradead.org
---
 drivers/clk/clk-fixed.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c
index e5d36b4..3a38865 100644
--- a/drivers/clk/clk-fixed.c
+++ b/drivers/clk/clk-fixed.c
@@ -54,3 +54,26 @@ struct clk *clk_fixed(const char *name, int rate)
 
 	return &fix->clk;
 }
+
+#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+/**
+ * of_fixed_clk_setup() - Setup function for simple fixed rate clock
+ */
+static int of_fixed_clk_setup(struct device_node *node)
+{
+	struct clk *clk;
+	const char *clk_name = node->name;
+	u32 rate;
+
+	if (of_property_read_u32(node, "clock-frequency", &rate))
+		return -EINVAL;
+
+	of_property_read_string(node, "clock-output-names", &clk_name);
+
+	clk = clk_fixed(clk_name, rate);
+	if (IS_ERR(clk))
+		return IS_ERR(clk);
+	return of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup);
+#endif
-- 
1.8.4.rc3




More information about the barebox mailing list