diff options
Diffstat (limited to 'arch/arm/plat-spear/time.c')
-rw-r--r-- | arch/arm/plat-spear/time.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/arch/arm/plat-spear/time.c b/arch/arm/plat-spear/time.c index 1c94989d725f..03321af5de9f 100644 --- a/arch/arm/plat-spear/time.c +++ b/arch/arm/plat-spear/time.c | |||
@@ -15,14 +15,15 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/ioport.h> | ||
18 | #include <linux/io.h> | 19 | #include <linux/io.h> |
19 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/of_irq.h> | ||
22 | #include <linux/of_address.h> | ||
20 | #include <linux/time.h> | 23 | #include <linux/time.h> |
21 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
22 | #include <asm/mach/time.h> | 25 | #include <asm/mach/time.h> |
23 | #include <mach/generic.h> | 26 | #include <mach/generic.h> |
24 | #include <mach/hardware.h> | ||
25 | #include <mach/irqs.h> | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * We would use TIMER0 and TIMER1 as clockevent and clocksource. | 29 | * We would use TIMER0 and TIMER1 as clockevent and clocksource. |
@@ -175,7 +176,7 @@ static struct irqaction spear_timer_irq = { | |||
175 | .handler = spear_timer_interrupt | 176 | .handler = spear_timer_interrupt |
176 | }; | 177 | }; |
177 | 178 | ||
178 | static void __init spear_clockevent_init(void) | 179 | static void __init spear_clockevent_init(int irq) |
179 | { | 180 | { |
180 | u32 tick_rate; | 181 | u32 tick_rate; |
181 | 182 | ||
@@ -195,22 +196,35 @@ static void __init spear_clockevent_init(void) | |||
195 | 196 | ||
196 | clockevents_register_device(&clkevt); | 197 | clockevents_register_device(&clkevt); |
197 | 198 | ||
198 | setup_irq(SPEAR_GPT0_CHAN0_IRQ, &spear_timer_irq); | 199 | setup_irq(irq, &spear_timer_irq); |
199 | } | 200 | } |
200 | 201 | ||
201 | void __init spear_setup_timer(void) | 202 | const static struct of_device_id timer_of_match[] __initconst = { |
203 | { .compatible = "st,spear-timer", }, | ||
204 | { }, | ||
205 | }; | ||
206 | |||
207 | void __init spear_setup_of_timer(void) | ||
202 | { | 208 | { |
203 | int ret; | 209 | struct device_node *np; |
210 | int irq, ret; | ||
211 | |||
212 | np = of_find_matching_node(NULL, timer_of_match); | ||
213 | if (!np) { | ||
214 | pr_err("%s: No timer passed via DT\n", __func__); | ||
215 | return; | ||
216 | } | ||
204 | 217 | ||
205 | if (!request_mem_region(SPEAR_GPT0_BASE, SZ_1K, "gpt0")) { | 218 | irq = irq_of_parse_and_map(np, 0); |
206 | pr_err("%s:cannot get IO addr\n", __func__); | 219 | if (!irq) { |
220 | pr_err("%s: No irq passed for timer via DT\n", __func__); | ||
207 | return; | 221 | return; |
208 | } | 222 | } |
209 | 223 | ||
210 | gpt_base = (void __iomem *)ioremap(SPEAR_GPT0_BASE, SZ_1K); | 224 | gpt_base = of_iomap(np, 0); |
211 | if (!gpt_base) { | 225 | if (!gpt_base) { |
212 | pr_err("%s:ioremap failed for gpt\n", __func__); | 226 | pr_err("%s: of iomap failed\n", __func__); |
213 | goto err_mem; | 227 | return; |
214 | } | 228 | } |
215 | 229 | ||
216 | gpt_clk = clk_get_sys("gpt0", NULL); | 230 | gpt_clk = clk_get_sys("gpt0", NULL); |
@@ -225,7 +239,7 @@ void __init spear_setup_timer(void) | |||
225 | goto err_prepare_enable_clk; | 239 | goto err_prepare_enable_clk; |
226 | } | 240 | } |
227 | 241 | ||
228 | spear_clockevent_init(); | 242 | spear_clockevent_init(irq); |
229 | spear_clocksource_init(); | 243 | spear_clocksource_init(); |
230 | 244 | ||
231 | return; | 245 | return; |
@@ -234,6 +248,4 @@ err_prepare_enable_clk: | |||
234 | clk_put(gpt_clk); | 248 | clk_put(gpt_clk); |
235 | err_iomap: | 249 | err_iomap: |
236 | iounmap(gpt_base); | 250 | iounmap(gpt_base); |
237 | err_mem: | ||
238 | release_mem_region(SPEAR_GPT0_BASE, SZ_1K); | ||
239 | } | 251 | } |