]> git.karo-electronics.de Git - linux-beck.git/commitdiff
clk: add common of_clk_init() function
authorPrashant Gaikwad <pgaikwad@nvidia.com>
Fri, 4 Jan 2013 07:00:52 +0000 (12:30 +0530)
committerMike Turquette <mturquette@linaro.org>
Thu, 24 Jan 2013 19:09:28 +0000 (11:09 -0800)
Modify of_clk_init function so that it will determine which
driver to initialize based on device tree instead of each driver
registering to it.

Based on a similar patch for drivers/irqchip by Thomas Petazzoni and
drivers/clocksource by Stephen Warren.

Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Tested-by: Tony Prisk <linux@prisktech.co.nz>
Tested-by: Pawel Moll <pawel.moll@arm.com>
Tested-by: Rob Herring <rob.herring@calxeda.com>
Tested-by: Josh Cartwright <josh.cartwright@ni.com>
Reviewed-by: Josh Cartwright <josh.cartwright@ni.com>
Acked-by: Maxime Ripard <maxime.ripard@anandra.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
[mturquette@linaro.org: merge conflict from missing CLKSRC_OF_TABLES()]

Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clk-fixed-rate.c
drivers/clk/clk.c
include/asm-generic/vmlinux.lds.h
include/linux/clk-provider.h

index a53b53be3d65cc04efd5c0c545b89249ed14ddce..dc58fbd8516f6e377472e962f3090cf06b299a8d 100644 (file)
@@ -101,4 +101,5 @@ void of_fixed_clk_setup(struct device_node *node)
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
 }
 EXPORT_SYMBOL_GPL(of_fixed_clk_setup);
+CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup);
 #endif
index ad2ac94fede842ded7f3912ecfa1c7014dce7206..fabbfe1a9253bc017840ec69c89244e461b31737 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/device.h>
+#include <linux/init.h>
 
 static DEFINE_SPINLOCK(enable_lock);
 static DEFINE_MUTEX(prepare_lock);
@@ -1803,6 +1804,11 @@ struct of_clk_provider {
        void *data;
 };
 
+extern struct of_device_id __clk_of_table[];
+
+static const struct of_device_id __clk_of_table_sentinel
+       __used __section(__clk_of_table_end);
+
 static LIST_HEAD(of_clk_providers);
 static DEFINE_MUTEX(of_clk_lock);
 
@@ -1931,6 +1937,9 @@ void __init of_clk_init(const struct of_device_id *matches)
 {
        struct device_node *np;
 
+       if (!matches)
+               matches = __clk_of_table;
+
        for_each_matching_node(np, matches) {
                const struct of_device_id *match = of_match_node(matches, np);
                of_clk_init_cb_t clk_init_cb = match->data;
index d1ea7ce0b4cb95c9e61935aefbcb09c12f49bdbc..c1fe60ad1540a0f922458cda1a6609c51de2c42e 100644 (file)
 #endif
 
 
+#ifdef CONFIG_COMMON_CLK
+#define CLK_OF_TABLES() . = ALIGN(8);                          \
+                       VMLINUX_SYMBOL(__clk_of_table) = .;     \
+                       *(__clk_of_table)                       \
+                       *(__clk_of_table_end)
+#else
+#define CLK_OF_TABLES()
+#endif
+
 #define KERNEL_DTB()                                                   \
        STRUCT_ALIGN();                                                 \
        VMLINUX_SYMBOL(__dtb_start) = .;                                \
        DEV_DISCARD(init.rodata)                                        \
        CPU_DISCARD(init.rodata)                                        \
        MEM_DISCARD(init.rodata)                                        \
+       CLK_OF_TABLES()                                                 \
        KERNEL_DTB()
 
 #define INIT_TEXT                                                      \
index 4989b8a7bed1703659c8f9a3fd7d955b5c6f6ffb..7f197d7addb0be18141a66ad225135b9b0730b24 100644 (file)
@@ -379,7 +379,13 @@ struct clk_onecell_data {
 };
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
+
 void of_clk_init(const struct of_device_id *matches);
 
+#define CLK_OF_DECLARE(name, compat, fn)                       \
+       static const struct of_device_id __clk_of_table_##name  \
+               __used __section(__clk_of_table)                \
+               = { .compatible = compat, .data = fn };
+
 #endif /* CONFIG_COMMON_CLK */
 #endif /* CLK_PROVIDER_H */