diff options
author | Arnd Bergmann <arnd@arndb.de> | 2013-03-19 10:27:22 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2013-03-25 07:29:41 -0400 |
commit | 275786b71d42bb54c03c15197128d7cb05d4dd8b (patch) | |
tree | f617b3c2c278798da79f832f14faa81fa57f2c6c | |
parent | 67bdb28718ae6dbdfbfa541161529acfa0f3c137 (diff) |
ARM: sirf: use clocksource_of infrastructure
This moves the two sirf clocksource drivers to drivers/clocksource
and integrates them into the framework for locating the clock sources
automatically.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Barry Song <Baohua.Song@csr.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/arm/mach-prima2/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-prima2/common.c | 14 | ||||
-rw-r--r-- | arch/arm/mach-prima2/common.h | 3 | ||||
-rw-r--r-- | drivers/clocksource/Makefile | 2 | ||||
-rw-r--r-- | drivers/clocksource/timer-marco.c (renamed from arch/arm/mach-prima2/timer-marco.c) | 25 | ||||
-rw-r--r-- | drivers/clocksource/timer-prima2.c (renamed from arch/arm/mach-prima2/timer-prima2.c) | 38 |
6 files changed, 24 insertions, 60 deletions
diff --git a/arch/arm/mach-prima2/Makefile b/arch/arm/mach-prima2/Makefile index 5fdff7e32290..52ac738881c8 100644 --- a/arch/arm/mach-prima2/Makefile +++ b/arch/arm/mach-prima2/Makefile | |||
@@ -6,5 +6,3 @@ obj-$(CONFIG_CACHE_L2X0) += l2x0.o | |||
6 | obj-$(CONFIG_SUSPEND) += pm.o sleep.o | 6 | obj-$(CONFIG_SUSPEND) += pm.o sleep.o |
7 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o | 7 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o |
8 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o | 8 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o |
9 | obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o | ||
10 | obj-$(CONFIG_ARCH_MARCO) += timer-marco.o | ||
diff --git a/arch/arm/mach-prima2/common.c b/arch/arm/mach-prima2/common.c index 31f43eac1420..4f94cd87972a 100644 --- a/arch/arm/mach-prima2/common.c +++ b/arch/arm/mach-prima2/common.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * Licensed under GPLv2 or later. | 6 | * Licensed under GPLv2 or later. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/clocksource.h> | ||
9 | #include <linux/init.h> | 10 | #include <linux/init.h> |
10 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
11 | #include <linux/irqchip.h> | 12 | #include <linux/irqchip.h> |
@@ -31,6 +32,13 @@ void __init sirfsoc_init_late(void) | |||
31 | sirfsoc_pm_init(); | 32 | sirfsoc_pm_init(); |
32 | } | 33 | } |
33 | 34 | ||
35 | static __init void sirfsoc_init_time(void) | ||
36 | { | ||
37 | /* initialize clocking early, we want to set the OS timer */ | ||
38 | sirfsoc_of_clk_init(); | ||
39 | clocksource_of_init(); | ||
40 | } | ||
41 | |||
34 | static __init void sirfsoc_map_io(void) | 42 | static __init void sirfsoc_map_io(void) |
35 | { | 43 | { |
36 | sirfsoc_map_lluart(); | 44 | sirfsoc_map_lluart(); |
@@ -48,7 +56,7 @@ DT_MACHINE_START(ATLAS6_DT, "Generic ATLAS6 (Flattened Device Tree)") | |||
48 | .nr_irqs = 128, | 56 | .nr_irqs = 128, |
49 | .map_io = sirfsoc_map_io, | 57 | .map_io = sirfsoc_map_io, |
50 | .init_irq = irqchip_init, | 58 | .init_irq = irqchip_init, |
51 | .init_time = sirfsoc_prima2_timer_init, | 59 | .init_time = sirfsoc_init_time, |
52 | .init_machine = sirfsoc_mach_init, | 60 | .init_machine = sirfsoc_mach_init, |
53 | .init_late = sirfsoc_init_late, | 61 | .init_late = sirfsoc_init_late, |
54 | .dt_compat = atlas6_dt_match, | 62 | .dt_compat = atlas6_dt_match, |
@@ -67,7 +75,7 @@ DT_MACHINE_START(PRIMA2_DT, "Generic PRIMA2 (Flattened Device Tree)") | |||
67 | .nr_irqs = 128, | 75 | .nr_irqs = 128, |
68 | .map_io = sirfsoc_map_io, | 76 | .map_io = sirfsoc_map_io, |
69 | .init_irq = irqchip_init, | 77 | .init_irq = irqchip_init, |
70 | .init_time = sirfsoc_prima2_timer_init, | 78 | .init_time = sirfsoc_init_time, |
71 | .dma_zone_size = SZ_256M, | 79 | .dma_zone_size = SZ_256M, |
72 | .init_machine = sirfsoc_mach_init, | 80 | .init_machine = sirfsoc_mach_init, |
73 | .init_late = sirfsoc_init_late, | 81 | .init_late = sirfsoc_init_late, |
@@ -87,7 +95,7 @@ DT_MACHINE_START(MARCO_DT, "Generic MARCO (Flattened Device Tree)") | |||
87 | .smp = smp_ops(sirfsoc_smp_ops), | 95 | .smp = smp_ops(sirfsoc_smp_ops), |
88 | .map_io = sirfsoc_map_io, | 96 | .map_io = sirfsoc_map_io, |
89 | .init_irq = irqchip_init, | 97 | .init_irq = irqchip_init, |
90 | .init_time = sirfsoc_marco_timer_init, | 98 | .init_time = sirfsoc_init_time, |
91 | .init_machine = sirfsoc_mach_init, | 99 | .init_machine = sirfsoc_mach_init, |
92 | .init_late = sirfsoc_init_late, | 100 | .init_late = sirfsoc_init_late, |
93 | .dt_compat = marco_dt_match, | 101 | .dt_compat = marco_dt_match, |
diff --git a/arch/arm/mach-prima2/common.h b/arch/arm/mach-prima2/common.h index b7c26b62e4a7..54262cf063c6 100644 --- a/arch/arm/mach-prima2/common.h +++ b/arch/arm/mach-prima2/common.h | |||
@@ -13,9 +13,6 @@ | |||
13 | #include <asm/mach/time.h> | 13 | #include <asm/mach/time.h> |
14 | #include <asm/exception.h> | 14 | #include <asm/exception.h> |
15 | 15 | ||
16 | extern void sirfsoc_prima2_timer_init(void); | ||
17 | extern void sirfsoc_marco_timer_init(void); | ||
18 | |||
19 | extern struct smp_operations sirfsoc_smp_ops; | 16 | extern struct smp_operations sirfsoc_smp_ops; |
20 | extern void sirfsoc_secondary_startup(void); | 17 | extern void sirfsoc_secondary_startup(void); |
21 | extern void sirfsoc_cpu_die(unsigned int cpu); | 18 | extern void sirfsoc_cpu_die(unsigned int cpu); |
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 4d8283aec5b5..5e2176f9453f 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile | |||
@@ -16,6 +16,8 @@ obj-$(CONFIG_CLKSRC_NOMADIK_MTU) += nomadik-mtu.o | |||
16 | obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o | 16 | obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o |
17 | obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o | 17 | obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o |
18 | obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o | 18 | obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o |
19 | obj-$(CONFIG_ARCH_MARCO) += timer-marco.o | ||
20 | obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o | ||
19 | obj-$(CONFIG_SUNXI_TIMER) += sunxi_timer.o | 21 | obj-$(CONFIG_SUNXI_TIMER) += sunxi_timer.o |
20 | obj-$(CONFIG_ARCH_TEGRA) += tegra20_timer.o | 22 | obj-$(CONFIG_ARCH_TEGRA) += tegra20_timer.o |
21 | obj-$(CONFIG_VT8500_TIMER) += vt8500_timer.o | 23 | obj-$(CONFIG_VT8500_TIMER) += vt8500_timer.o |
diff --git a/arch/arm/mach-prima2/timer-marco.c b/drivers/clocksource/timer-marco.c index f4eea2e97eb0..97738dbf3e3b 100644 --- a/arch/arm/mach-prima2/timer-marco.c +++ b/drivers/clocksource/timer-marco.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include <asm/localtimer.h> | 21 | #include <asm/localtimer.h> |
22 | #include <asm/mach/time.h> | 22 | #include <asm/mach/time.h> |
23 | 23 | ||
24 | #include "common.h" | ||
25 | |||
26 | #define SIRFSOC_TIMER_32COUNTER_0_CTRL 0x0000 | 24 | #define SIRFSOC_TIMER_32COUNTER_0_CTRL 0x0000 |
27 | #define SIRFSOC_TIMER_32COUNTER_1_CTRL 0x0004 | 25 | #define SIRFSOC_TIMER_32COUNTER_1_CTRL 0x0004 |
28 | #define SIRFSOC_TIMER_MATCH_0 0x0018 | 26 | #define SIRFSOC_TIMER_MATCH_0 0x0018 |
@@ -53,7 +51,6 @@ static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { | |||
53 | static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT]; | 51 | static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT]; |
54 | 52 | ||
55 | static void __iomem *sirfsoc_timer_base; | 53 | static void __iomem *sirfsoc_timer_base; |
56 | static void __init sirfsoc_of_timer_map(void); | ||
57 | 54 | ||
58 | /* disable count and interrupt */ | 55 | /* disable count and interrupt */ |
59 | static inline void sirfsoc_timer_count_disable(int idx) | 56 | static inline void sirfsoc_timer_count_disable(int idx) |
@@ -242,15 +239,12 @@ static void __init sirfsoc_clockevent_init(void) | |||
242 | } | 239 | } |
243 | 240 | ||
244 | /* initialize the kernel jiffy timer source */ | 241 | /* initialize the kernel jiffy timer source */ |
245 | void __init sirfsoc_marco_timer_init(void) | 242 | static void __init sirfsoc_marco_timer_init(void) |
246 | { | 243 | { |
247 | unsigned long rate; | 244 | unsigned long rate; |
248 | u32 timer_div; | 245 | u32 timer_div; |
249 | struct clk *clk; | 246 | struct clk *clk; |
250 | 247 | ||
251 | /* initialize clocking early, we want to set the OS timer */ | ||
252 | sirfsoc_of_clk_init(); | ||
253 | |||
254 | /* timer's input clock is io clock */ | 248 | /* timer's input clock is io clock */ |
255 | clk = clk_get_sys("io", NULL); | 249 | clk = clk_get_sys("io", NULL); |
256 | 250 | ||
@@ -260,8 +254,6 @@ void __init sirfsoc_marco_timer_init(void) | |||
260 | BUG_ON(rate < CLOCK_TICK_RATE); | 254 | BUG_ON(rate < CLOCK_TICK_RATE); |
261 | BUG_ON(rate % CLOCK_TICK_RATE); | 255 | BUG_ON(rate % CLOCK_TICK_RATE); |
262 | 256 | ||
263 | sirfsoc_of_timer_map(); | ||
264 | |||
265 | /* Initialize the timer dividers */ | 257 | /* Initialize the timer dividers */ |
266 | timer_div = rate / CLOCK_TICK_RATE - 1; | 258 | timer_div = rate / CLOCK_TICK_RATE - 1; |
267 | writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_CTRL); | 259 | writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_CTRL); |
@@ -286,18 +278,8 @@ void __init sirfsoc_marco_timer_init(void) | |||
286 | sirfsoc_clockevent_init(); | 278 | sirfsoc_clockevent_init(); |
287 | } | 279 | } |
288 | 280 | ||
289 | static struct of_device_id timer_ids[] = { | 281 | static void __init sirfsoc_of_timer_init(struct device_node *np) |
290 | { .compatible = "sirf,marco-tick" }, | ||
291 | {}, | ||
292 | }; | ||
293 | |||
294 | static void __init sirfsoc_of_timer_map(void) | ||
295 | { | 282 | { |
296 | struct device_node *np; | ||
297 | |||
298 | np = of_find_matching_node(NULL, timer_ids); | ||
299 | if (!np) | ||
300 | return; | ||
301 | sirfsoc_timer_base = of_iomap(np, 0); | 283 | sirfsoc_timer_base = of_iomap(np, 0); |
302 | if (!sirfsoc_timer_base) | 284 | if (!sirfsoc_timer_base) |
303 | panic("unable to map timer cpu registers\n"); | 285 | panic("unable to map timer cpu registers\n"); |
@@ -312,5 +294,6 @@ static void __init sirfsoc_of_timer_map(void) | |||
312 | panic("No irq passed for timer1 via DT\n"); | 294 | panic("No irq passed for timer1 via DT\n"); |
313 | #endif | 295 | #endif |
314 | 296 | ||
315 | of_node_put(np); | 297 | sirfsoc_marco_timer_init(); |
316 | } | 298 | } |
299 | CLOCKSOURCE_OF_DECLARE(sirfsoc_marco_timer, "sirf,marco-tick", sirfsoc_of_timer_init ); | ||
diff --git a/arch/arm/mach-prima2/timer-prima2.c b/drivers/clocksource/timer-prima2.c index 982908350b46..760882665d7a 100644 --- a/arch/arm/mach-prima2/timer-prima2.c +++ b/drivers/clocksource/timer-prima2.c | |||
@@ -18,12 +18,9 @@ | |||
18 | #include <linux/of.h> | 18 | #include <linux/of.h> |
19 | #include <linux/of_irq.h> | 19 | #include <linux/of_irq.h> |
20 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
21 | #include <mach/map.h> | ||
22 | #include <asm/sched_clock.h> | 21 | #include <asm/sched_clock.h> |
23 | #include <asm/mach/time.h> | 22 | #include <asm/mach/time.h> |
24 | 23 | ||
25 | #include "common.h" | ||
26 | |||
27 | #define SIRFSOC_TIMER_COUNTER_LO 0x0000 | 24 | #define SIRFSOC_TIMER_COUNTER_LO 0x0000 |
28 | #define SIRFSOC_TIMER_COUNTER_HI 0x0004 | 25 | #define SIRFSOC_TIMER_COUNTER_HI 0x0004 |
29 | #define SIRFSOC_TIMER_MATCH_0 0x0008 | 26 | #define SIRFSOC_TIMER_MATCH_0 0x0008 |
@@ -56,7 +53,6 @@ static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { | |||
56 | static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT]; | 53 | static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT]; |
57 | 54 | ||
58 | static void __iomem *sirfsoc_timer_base; | 55 | static void __iomem *sirfsoc_timer_base; |
59 | static void __init sirfsoc_of_timer_map(void); | ||
60 | 56 | ||
61 | /* timer0 interrupt handler */ | 57 | /* timer0 interrupt handler */ |
62 | static irqreturn_t sirfsoc_timer_interrupt(int irq, void *dev_id) | 58 | static irqreturn_t sirfsoc_timer_interrupt(int irq, void *dev_id) |
@@ -182,14 +178,11 @@ static void __init sirfsoc_clockevent_init(void) | |||
182 | } | 178 | } |
183 | 179 | ||
184 | /* initialize the kernel jiffy timer source */ | 180 | /* initialize the kernel jiffy timer source */ |
185 | void __init sirfsoc_prima2_timer_init(void) | 181 | static void __init sirfsoc_prima2_timer_init(struct device_node *np) |
186 | { | 182 | { |
187 | unsigned long rate; | 183 | unsigned long rate; |
188 | struct clk *clk; | 184 | struct clk *clk; |
189 | 185 | ||
190 | /* initialize clocking early, we want to set the OS timer */ | ||
191 | sirfsoc_of_clk_init(); | ||
192 | |||
193 | /* timer's input clock is io clock */ | 186 | /* timer's input clock is io clock */ |
194 | clk = clk_get_sys("io", NULL); | 187 | clk = clk_get_sys("io", NULL); |
195 | 188 | ||
@@ -200,7 +193,11 @@ void __init sirfsoc_prima2_timer_init(void) | |||
200 | BUG_ON(rate < CLOCK_TICK_RATE); | 193 | BUG_ON(rate < CLOCK_TICK_RATE); |
201 | BUG_ON(rate % CLOCK_TICK_RATE); | 194 | BUG_ON(rate % CLOCK_TICK_RATE); |
202 | 195 | ||
203 | sirfsoc_of_timer_map(); | 196 | sirfsoc_timer_base = of_iomap(np, 0); |
197 | if (!sirfsoc_timer_base) | ||
198 | panic("unable to map timer cpu registers\n"); | ||
199 | |||
200 | sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0); | ||
204 | 201 | ||
205 | writel_relaxed(rate / CLOCK_TICK_RATE / 2 - 1, sirfsoc_timer_base + SIRFSOC_TIMER_DIV); | 202 | writel_relaxed(rate / CLOCK_TICK_RATE / 2 - 1, sirfsoc_timer_base + SIRFSOC_TIMER_DIV); |
206 | writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO); | 203 | writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO); |
@@ -215,25 +212,4 @@ void __init sirfsoc_prima2_timer_init(void) | |||
215 | 212 | ||
216 | sirfsoc_clockevent_init(); | 213 | sirfsoc_clockevent_init(); |
217 | } | 214 | } |
218 | 215 | CLOCKSOURCE_OF_DECLARE(sirfsoc_prima2_timer, "sirf,prima2-tick", sirfsoc_prima2_timer_init); | |
219 | static struct of_device_id timer_ids[] = { | ||
220 | { .compatible = "sirf,prima2-tick" }, | ||
221 | {}, | ||
222 | }; | ||
223 | |||
224 | static void __init sirfsoc_of_timer_map(void) | ||
225 | { | ||
226 | struct device_node *np; | ||
227 | |||
228 | np = of_find_matching_node(NULL, timer_ids); | ||
229 | if (!np) | ||
230 | return; | ||
231 | sirfsoc_timer_base = of_iomap(np, 0); | ||
232 | if (!sirfsoc_timer_base) | ||
233 | panic("unable to map timer cpu registers\n"); | ||
234 | |||
235 | /* Get the interrupts property */ | ||
236 | sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0); | ||
237 | |||
238 | of_node_put(np); | ||
239 | } | ||