[PATCH 2/2] clk: fixed-factor: add DT init function

Antony Pavlov antonynpavlov at gmail.com
Fri Apr 25 00:57:47 PDT 2014


Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 drivers/clk/clk-fixed-factor.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index cb531b1..40b63d6 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -92,3 +92,39 @@ struct clk *clk_fixed_factor(const char *name,
 
 	return &f->clk;
 }
+
+#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+/**
+ * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock
+ */
+static int of_fixed_factor_clk_setup(struct device_node *node)
+{
+	struct clk *clk;
+	const char *clk_name = node->name;
+	const char *parent_name;
+	u32 div, mult;
+
+	if (of_property_read_u32(node, "clock-div", &div)) {
+		pr_err("%s Fixed factor clock <%s> must have a clock-div property\n",
+			__func__, node->name);
+		return -EINVAL;
+	}
+
+	if (of_property_read_u32(node, "clock-mult", &mult)) {
+		pr_err("%s Fixed factor clock <%s> must have a clock-mult property\n",
+			__func__, node->name);
+		return -EINVAL;
+	}
+
+	of_property_read_string(node, "clock-output-names", &clk_name);
+	parent_name = of_clk_get_parent_name(node, 0);
+
+	clk = clk_fixed_factor(clk_name, parent_name, mult, div, 0);
+	if (IS_ERR(clk))
+		return IS_ERR(clk);
+
+	return of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
+		of_fixed_factor_clk_setup);
+#endif
-- 
1.9.0




More information about the barebox mailing list