diff options
-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; |