diff options
| author | Michal Simek <michal.simek@xilinx.com> | 2013-03-20 05:24:59 -0400 |
|---|---|---|
| committer | Michal Simek <michal.simek@xilinx.com> | 2013-04-04 03:09:10 -0400 |
| commit | c5263bb8b7944f1e34b36b5ea8a9119fc48a31ae (patch) | |
| tree | 650ec881b4d9516263a1ea58dc5f0cceaeb6d9d1 | |
| parent | e932900a3279b5dbb6d8f43c7b369003620e137c (diff) | |
arm: zynq: Move timer to clocksource interface
Use clocksource timer initialization.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
| -rw-r--r-- | arch/arm/mach-zynq/common.c | 2 | ||||
| -rw-r--r-- | arch/arm/mach-zynq/common.h | 2 | ||||
| -rw-r--r-- | arch/arm/mach-zynq/timer.c | 43 |
3 files changed, 21 insertions, 26 deletions
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c index 76493b050beb..68e0907de5d0 100644 --- a/arch/arm/mach-zynq/common.c +++ b/arch/arm/mach-zynq/common.c | |||
| @@ -78,7 +78,7 @@ static void __init xilinx_zynq_timer_init(void) | |||
| 78 | 78 | ||
| 79 | xilinx_zynq_clocks_init(slcr); | 79 | xilinx_zynq_clocks_init(slcr); |
| 80 | 80 | ||
| 81 | xttcps_timer_init(); | 81 | clocksource_of_init(); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | /** | 84 | /** |
diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h index 8b4dbbaa01cf..5050bb10bb12 100644 --- a/arch/arm/mach-zynq/common.h +++ b/arch/arm/mach-zynq/common.h | |||
| @@ -17,6 +17,4 @@ | |||
| 17 | #ifndef __MACH_ZYNQ_COMMON_H__ | 17 | #ifndef __MACH_ZYNQ_COMMON_H__ |
| 18 | #define __MACH_ZYNQ_COMMON_H__ | 18 | #define __MACH_ZYNQ_COMMON_H__ |
| 19 | 19 | ||
| 20 | void __init xttcps_timer_init(void); | ||
| 21 | |||
| 22 | #endif | 20 | #endif |
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 | } | ||
