diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2013-09-04 07:58:11 -0400 |
---|---|---|
committer | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2013-09-29 15:08:54 -0400 |
commit | f9e4a18de7398bc615f9d45250bdaf31eafc5af6 (patch) | |
tree | e4ec4e062a4fc961494deb6f5d9ec3f5bd548c3b /drivers/clk | |
parent | be0804513a506de96925f9ed1aa8dc1facd4c180 (diff) |
clk: vt8500: parse pmc_base from clock driver
Currently, clock providers for vt8500 depend on machine_init providing
pmc_base address before calling of_clk_init. With upcoming arch-wide
.time_init calling of_clk_init, we should make clock providers independent
of mach code. This adds a pmc_base parsing helper to current clock provider
that gets called if there is no pmc_base set, yet.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Acked-by: Tony Prisk <linux@prisktech.co.nz>
Acked-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk-vt8500.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c index 82306f5fb9c2..39fe72aab1e5 100644 --- a/drivers/clk/clk-vt8500.c +++ b/drivers/clk/clk-vt8500.c | |||
@@ -15,11 +15,14 @@ | |||
15 | 15 | ||
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/of.h> | 17 | #include <linux/of.h> |
18 | #include <linux/of_address.h> | ||
18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
19 | #include <linux/bitops.h> | 20 | #include <linux/bitops.h> |
20 | #include <linux/clkdev.h> | 21 | #include <linux/clkdev.h> |
21 | #include <linux/clk-provider.h> | 22 | #include <linux/clk-provider.h> |
22 | 23 | ||
24 | #define LEGACY_PMC_BASE 0xD8130000 | ||
25 | |||
23 | /* All clocks share the same lock as none can be changed concurrently */ | 26 | /* All clocks share the same lock as none can be changed concurrently */ |
24 | static DEFINE_SPINLOCK(_lock); | 27 | static DEFINE_SPINLOCK(_lock); |
25 | 28 | ||
@@ -53,6 +56,21 @@ struct clk_pll { | |||
53 | 56 | ||
54 | static void __iomem *pmc_base; | 57 | static void __iomem *pmc_base; |
55 | 58 | ||
59 | static __init void vtwm_set_pmc_base(void) | ||
60 | { | ||
61 | struct device_node *np = | ||
62 | of_find_compatible_node(NULL, NULL, "via,vt8500-pmc"); | ||
63 | |||
64 | if (np) | ||
65 | pmc_base = of_iomap(np, 0); | ||
66 | else | ||
67 | pmc_base = ioremap(LEGACY_PMC_BASE, 0x1000); | ||
68 | of_node_put(np); | ||
69 | |||
70 | if (!pmc_base) | ||
71 | pr_err("%s:of_iomap(pmc) failed\n", __func__); | ||
72 | } | ||
73 | |||
56 | #define to_clk_device(_hw) container_of(_hw, struct clk_device, hw) | 74 | #define to_clk_device(_hw) container_of(_hw, struct clk_device, hw) |
57 | 75 | ||
58 | #define VT8500_PMC_BUSY_MASK 0x18 | 76 | #define VT8500_PMC_BUSY_MASK 0x18 |
@@ -222,6 +240,9 @@ static __init void vtwm_device_clk_init(struct device_node *node) | |||
222 | int rc; | 240 | int rc; |
223 | int clk_init_flags = 0; | 241 | int clk_init_flags = 0; |
224 | 242 | ||
243 | if (!pmc_base) | ||
244 | vtwm_set_pmc_base(); | ||
245 | |||
225 | dev_clk = kzalloc(sizeof(*dev_clk), GFP_KERNEL); | 246 | dev_clk = kzalloc(sizeof(*dev_clk), GFP_KERNEL); |
226 | if (WARN_ON(!dev_clk)) | 247 | if (WARN_ON(!dev_clk)) |
227 | return; | 248 | return; |
@@ -636,6 +657,9 @@ static __init void vtwm_pll_clk_init(struct device_node *node, int pll_type) | |||
636 | struct clk_init_data init; | 657 | struct clk_init_data init; |
637 | int rc; | 658 | int rc; |
638 | 659 | ||
660 | if (!pmc_base) | ||
661 | vtwm_set_pmc_base(); | ||
662 | |||
639 | rc = of_property_read_u32(node, "reg", ®); | 663 | rc = of_property_read_u32(node, "reg", ®); |
640 | if (WARN_ON(rc)) | 664 | if (WARN_ON(rc)) |
641 | return; | 665 | return; |