clk: add DT fixed-clock binding support
authorGrant Likely <grant.likely@secretlab.ca>
Sun, 8 Apr 2012 02:39:39 +0000 (21:39 -0500)
committerMike Turquette <mturquette@linaro.org>
Thu, 12 Jul 2012 00:58:46 +0000 (17:58 -0700)
Add support for DT "fixed-clock" binding to the common fixed rate clock
support.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
[Rob Herring] Rework and move into common clock infrastructure
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clk-fixed-rate.c
include/linux/clk-provider.h

index 7e1464569727b70b4c851b00c9798ffc34fb8d91..f5ec0eebd4d7ce324aa59ae49bdfb03c03ea6daa 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/err.h>
+#include <linux/of.h>
 
 /*
  * DOC: basic fixed-rate clock that cannot gate
@@ -79,3 +80,25 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
 
        return clk;
 }
+
+#ifdef CONFIG_OF
+/**
+ * of_fixed_clk_setup() - Setup function for simple fixed rate clock
+ */
+void __init 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;
+
+       of_property_read_string(node, "clock-output-names", &clk_name);
+
+       clk = clk_register_fixed_rate(NULL, clk_name, NULL, CLK_IS_ROOT, rate);
+       if (clk)
+               of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+EXPORT_SYMBOL_GPL(of_fixed_clk_setup);
+#endif
index 7c9c691102b5ff649b80e4a1565189152e199b39..77335fac943e74b2ca7748ec74665657d828572f 100644 (file)
@@ -172,6 +172,8 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
                const char *parent_name, unsigned long flags,
                unsigned long fixed_rate);
 
+void of_fixed_clk_setup(struct device_node *np);
+
 /**
  * struct clk_gate - gating clock
  *