diff options
Diffstat (limited to 'arch/arm/mach-zynq/timer.c')
-rw-r--r-- | arch/arm/mach-zynq/timer.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/arch/arm/mach-zynq/timer.c b/arch/arm/mach-zynq/timer.c index 82357d94a0e0..ab5b839e22f0 100644 --- a/arch/arm/mach-zynq/timer.c +++ b/arch/arm/mach-zynq/timer.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/of_irq.h> | 22 | #include <linux/of_irq.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/clk-provider.h> | 24 | #include <linux/clk-provider.h> |
25 | #include "common.h" | ||
26 | 25 | ||
27 | /* | 26 | /* |
28 | * This driver configures the 2 16-bit count-up timers as follows: | 27 | * This driver configures the 2 16-bit count-up timers as follows: |
@@ -260,8 +259,10 @@ static void __init xttc_setup_clocksource(struct clk *clk, void __iomem *base) | |||
260 | ttccs->xttc.clk = clk; | 259 | ttccs->xttc.clk = clk; |
261 | 260 | ||
262 | err = clk_prepare_enable(ttccs->xttc.clk); | 261 | err = clk_prepare_enable(ttccs->xttc.clk); |
263 | if (WARN_ON(err)) | 262 | if (WARN_ON(err)) { |
263 | kfree(ttccs); | ||
264 | return; | 264 | return; |
265 | } | ||
265 | 266 | ||
266 | ttccs->xttc.clk_rate_change_nb.notifier_call = | 267 | ttccs->xttc.clk_rate_change_nb.notifier_call = |
267 | xttcps_rate_change_clocksource_cb; | 268 | xttcps_rate_change_clocksource_cb; |
@@ -290,9 +291,10 @@ static void __init xttc_setup_clocksource(struct clk *clk, void __iomem *base) | |||
290 | 291 | ||
291 | err = clocksource_register_hz(&ttccs->cs, | 292 | err = clocksource_register_hz(&ttccs->cs, |
292 | clk_get_rate(ttccs->xttc.clk) / PRESCALE); | 293 | clk_get_rate(ttccs->xttc.clk) / PRESCALE); |
293 | if (WARN_ON(err)) | 294 | if (WARN_ON(err)) { |
295 | kfree(ttccs); | ||
294 | return; | 296 | return; |
295 | 297 | } | |
296 | } | 298 | } |
297 | 299 | ||
298 | static int xttcps_rate_change_clockevent_cb(struct notifier_block *nb, | 300 | static int xttcps_rate_change_clockevent_cb(struct notifier_block *nb, |
@@ -341,8 +343,10 @@ static void __init xttc_setup_clockevent(struct clk *clk, | |||
341 | ttcce->xttc.clk = clk; | 343 | ttcce->xttc.clk = clk; |
342 | 344 | ||
343 | err = clk_prepare_enable(ttcce->xttc.clk); | 345 | err = clk_prepare_enable(ttcce->xttc.clk); |
344 | if (WARN_ON(err)) | 346 | if (WARN_ON(err)) { |
347 | kfree(ttcce); | ||
345 | return; | 348 | return; |
349 | } | ||
346 | 350 | ||
347 | ttcce->xttc.clk_rate_change_nb.notifier_call = | 351 | ttcce->xttc.clk_rate_change_nb.notifier_call = |
348 | xttcps_rate_change_clockevent_cb; | 352 | xttcps_rate_change_clockevent_cb; |
@@ -373,8 +377,10 @@ static void __init xttc_setup_clockevent(struct clk *clk, | |||
373 | err = request_irq(irq, xttcps_clock_event_interrupt, | 377 | err = request_irq(irq, xttcps_clock_event_interrupt, |
374 | IRQF_DISABLED | IRQF_TIMER, | 378 | IRQF_DISABLED | IRQF_TIMER, |
375 | ttcce->ce.name, ttcce); | 379 | ttcce->ce.name, ttcce); |
376 | if (WARN_ON(err)) | 380 | if (WARN_ON(err)) { |
381 | kfree(ttcce); | ||
377 | return; | 382 | return; |
383 | } | ||
378 | 384 | ||
379 | clockevents_config_and_register(&ttcce->ce, | 385 | clockevents_config_and_register(&ttcce->ce, |
380 | clk_get_rate(ttcce->xttc.clk) / PRESCALE, 1, 0xfffe); | 386 | clk_get_rate(ttcce->xttc.clk) / PRESCALE, 1, 0xfffe); |
@@ -386,11 +392,17 @@ static void __init xttc_setup_clockevent(struct clk *clk, | |||
386 | * Initializes the timer hardware and register the clock source and clock event | 392 | * Initializes the timer hardware and register the clock source and clock event |
387 | * timers with Linux kernal timer framework | 393 | * timers with Linux kernal timer framework |
388 | */ | 394 | */ |
389 | static void __init xttcps_timer_init_of(struct device_node *timer) | 395 | static void __init xttcps_timer_init(struct device_node *timer) |
390 | { | 396 | { |
391 | unsigned int irq; | 397 | unsigned int irq; |
392 | void __iomem *timer_baseaddr; | 398 | void __iomem *timer_baseaddr; |
393 | struct clk *clk; | 399 | struct clk *clk; |
400 | static int initialized; | ||
401 | |||
402 | if (initialized) | ||
403 | return; | ||
404 | |||
405 | initialized = 1; | ||
394 | 406 | ||
395 | /* | 407 | /* |
396 | * Get the 1st Triple Timer Counter (TTC) block from the device tree | 408 | * Get the 1st Triple Timer Counter (TTC) block from the device tree |
@@ -421,19 +433,4 @@ static void __init xttcps_timer_init_of(struct device_node *timer) | |||
421 | pr_info("%s #0 at %p, irq=%d\n", timer->name, timer_baseaddr, irq); | 433 | pr_info("%s #0 at %p, irq=%d\n", timer->name, timer_baseaddr, irq); |
422 | } | 434 | } |
423 | 435 | ||
424 | void __init xttcps_timer_init(void) | 436 | CLOCKSOURCE_OF_DECLARE(ttc, "cdns,ttc", xttcps_timer_init); |
425 | { | ||
426 | const char * const timer_list[] = { | ||
427 | "cdns,ttc", | ||
428 | NULL | ||
429 | }; | ||
430 | struct device_node *timer; | ||
431 | |||
432 | timer = of_find_compatible_node(NULL, NULL, timer_list[0]); | ||
433 | if (!timer) { | ||
434 | pr_err("ERROR: no compatible timer found\n"); | ||
435 | BUG(); | ||
436 | } | ||
437 | |||
438 | xttcps_timer_init_of(timer); | ||
439 | } | ||