diff options
author | Prashant Gaikwad <pgaikwad@nvidia.com> | 2013-01-04 02:00:52 -0500 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-01-24 14:09:28 -0500 |
commit | f2f6c2556dcc432e50003bc8fa4d62d95906f149 (patch) | |
tree | b0ffefa1b14c1c9a0435adbd81753cca9b6fed97 | |
parent | 4cfe54e57910b59444d34a05284db27df416f20b (diff) |
clk: add common of_clk_init() function
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>
-rw-r--r-- | drivers/clk/clk-fixed-rate.c | 1 | ||||
-rw-r--r-- | drivers/clk/clk.c | 9 | ||||
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 10 | ||||
-rw-r--r-- | include/linux/clk-provider.h | 6 |
4 files changed, 26 insertions, 0 deletions
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c index a53b53be3d65..dc58fbd8516f 100644 --- a/drivers/clk/clk-fixed-rate.c +++ b/drivers/clk/clk-fixed-rate.c | |||
@@ -101,4 +101,5 @@ void of_fixed_clk_setup(struct device_node *node) | |||
101 | of_clk_add_provider(node, of_clk_src_simple_get, clk); | 101 | of_clk_add_provider(node, of_clk_src_simple_get, clk); |
102 | } | 102 | } |
103 | EXPORT_SYMBOL_GPL(of_fixed_clk_setup); | 103 | EXPORT_SYMBOL_GPL(of_fixed_clk_setup); |
104 | CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup); | ||
104 | #endif | 105 | #endif |
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index ad2ac94fede8..fabbfe1a9253 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/init.h> | ||
21 | 22 | ||
22 | static DEFINE_SPINLOCK(enable_lock); | 23 | static DEFINE_SPINLOCK(enable_lock); |
23 | static DEFINE_MUTEX(prepare_lock); | 24 | static DEFINE_MUTEX(prepare_lock); |
@@ -1803,6 +1804,11 @@ struct of_clk_provider { | |||
1803 | void *data; | 1804 | void *data; |
1804 | }; | 1805 | }; |
1805 | 1806 | ||
1807 | extern struct of_device_id __clk_of_table[]; | ||
1808 | |||
1809 | static const struct of_device_id __clk_of_table_sentinel | ||
1810 | __used __section(__clk_of_table_end); | ||
1811 | |||
1806 | static LIST_HEAD(of_clk_providers); | 1812 | static LIST_HEAD(of_clk_providers); |
1807 | static DEFINE_MUTEX(of_clk_lock); | 1813 | static DEFINE_MUTEX(of_clk_lock); |
1808 | 1814 | ||
@@ -1931,6 +1937,9 @@ void __init of_clk_init(const struct of_device_id *matches) | |||
1931 | { | 1937 | { |
1932 | struct device_node *np; | 1938 | struct device_node *np; |
1933 | 1939 | ||
1940 | if (!matches) | ||
1941 | matches = __clk_of_table; | ||
1942 | |||
1934 | for_each_matching_node(np, matches) { | 1943 | for_each_matching_node(np, matches) { |
1935 | const struct of_device_id *match = of_match_node(matches, np); | 1944 | const struct of_device_id *match = of_match_node(matches, np); |
1936 | of_clk_init_cb_t clk_init_cb = match->data; | 1945 | of_clk_init_cb_t clk_init_cb = match->data; |
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index d1ea7ce0b4cb..c1fe60ad1540 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -150,6 +150,15 @@ | |||
150 | #endif | 150 | #endif |
151 | 151 | ||
152 | 152 | ||
153 | #ifdef CONFIG_COMMON_CLK | ||
154 | #define CLK_OF_TABLES() . = ALIGN(8); \ | ||
155 | VMLINUX_SYMBOL(__clk_of_table) = .; \ | ||
156 | *(__clk_of_table) \ | ||
157 | *(__clk_of_table_end) | ||
158 | #else | ||
159 | #define CLK_OF_TABLES() | ||
160 | #endif | ||
161 | |||
153 | #define KERNEL_DTB() \ | 162 | #define KERNEL_DTB() \ |
154 | STRUCT_ALIGN(); \ | 163 | STRUCT_ALIGN(); \ |
155 | VMLINUX_SYMBOL(__dtb_start) = .; \ | 164 | VMLINUX_SYMBOL(__dtb_start) = .; \ |
@@ -493,6 +502,7 @@ | |||
493 | DEV_DISCARD(init.rodata) \ | 502 | DEV_DISCARD(init.rodata) \ |
494 | CPU_DISCARD(init.rodata) \ | 503 | CPU_DISCARD(init.rodata) \ |
495 | MEM_DISCARD(init.rodata) \ | 504 | MEM_DISCARD(init.rodata) \ |
505 | CLK_OF_TABLES() \ | ||
496 | KERNEL_DTB() | 506 | KERNEL_DTB() |
497 | 507 | ||
498 | #define INIT_TEXT \ | 508 | #define INIT_TEXT \ |
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 4989b8a7bed1..7f197d7addb0 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h | |||
@@ -379,7 +379,13 @@ struct clk_onecell_data { | |||
379 | }; | 379 | }; |
380 | struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); | 380 | struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); |
381 | const char *of_clk_get_parent_name(struct device_node *np, int index); | 381 | const char *of_clk_get_parent_name(struct device_node *np, int index); |
382 | |||
382 | void of_clk_init(const struct of_device_id *matches); | 383 | void of_clk_init(const struct of_device_id *matches); |
383 | 384 | ||
385 | #define CLK_OF_DECLARE(name, compat, fn) \ | ||
386 | static const struct of_device_id __clk_of_table_##name \ | ||
387 | __used __section(__clk_of_table) \ | ||
388 | = { .compatible = compat, .data = fn }; | ||
389 | |||
384 | #endif /* CONFIG_COMMON_CLK */ | 390 | #endif /* CONFIG_COMMON_CLK */ |
385 | #endif /* CLK_PROVIDER_H */ | 391 | #endif /* CLK_PROVIDER_H */ |