Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm: zynq: Move timer to clocksource interface

Use clocksource timer initialization.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

+21 -26
+1 -1
arch/arm/mach-zynq/common.c
··· 78 78 79 79 xilinx_zynq_clocks_init(slcr); 80 80 81 - xttcps_timer_init(); 81 + clocksource_of_init(); 82 82 } 83 83 84 84 /**
-2
arch/arm/mach-zynq/common.h
··· 17 17 #ifndef __MACH_ZYNQ_COMMON_H__ 18 18 #define __MACH_ZYNQ_COMMON_H__ 19 19 20 - void __init xttcps_timer_init(void); 21 - 22 20 #endif
+20 -23
arch/arm/mach-zynq/timer.c
··· 22 22 #include <linux/of_irq.h> 23 23 #include <linux/slab.h> 24 24 #include <linux/clk-provider.h> 25 - #include "common.h" 26 25 27 26 /* 28 27 * This driver configures the 2 16-bit count-up timers as follows: ··· 259 260 ttccs->xttc.clk = clk; 260 261 261 262 err = clk_prepare_enable(ttccs->xttc.clk); 262 - if (WARN_ON(err)) 263 + if (WARN_ON(err)) { 264 + kfree(ttccs); 263 265 return; 266 + } 264 267 265 268 ttccs->xttc.clk_rate_change_nb.notifier_call = 266 269 xttcps_rate_change_clocksource_cb; ··· 291 290 292 291 err = clocksource_register_hz(&ttccs->cs, 293 292 clk_get_rate(ttccs->xttc.clk) / PRESCALE); 294 - if (WARN_ON(err)) 293 + if (WARN_ON(err)) { 294 + kfree(ttccs); 295 295 return; 296 - 296 + } 297 297 } 298 298 299 299 static int xttcps_rate_change_clockevent_cb(struct notifier_block *nb, ··· 343 341 ttcce->xttc.clk = clk; 344 342 345 343 err = clk_prepare_enable(ttcce->xttc.clk); 346 - if (WARN_ON(err)) 344 + if (WARN_ON(err)) { 345 + kfree(ttcce); 347 346 return; 347 + } 348 348 349 349 ttcce->xttc.clk_rate_change_nb.notifier_call = 350 350 xttcps_rate_change_clockevent_cb; ··· 377 373 err = request_irq(irq, xttcps_clock_event_interrupt, 378 374 IRQF_DISABLED | IRQF_TIMER, 379 375 ttcce->ce.name, ttcce); 380 - if (WARN_ON(err)) 376 + if (WARN_ON(err)) { 377 + kfree(ttcce); 381 378 return; 379 + } 382 380 383 381 clockevents_config_and_register(&ttcce->ce, 384 382 clk_get_rate(ttcce->xttc.clk) / PRESCALE, 1, 0xfffe); ··· 392 386 * Initializes the timer hardware and register the clock source and clock event 393 387 * timers with Linux kernal timer framework 394 388 */ 395 - static void __init xttcps_timer_init_of(struct device_node *timer) 389 + static void __init xttcps_timer_init(struct device_node *timer) 396 390 { 397 391 unsigned int irq; 398 392 void __iomem *timer_baseaddr; 399 393 struct clk *clk; 394 + static int initialized; 395 + 396 + if (initialized) 397 + return; 398 + 399 + initialized = 1; 400 400 401 401 /* 402 402 * Get the 1st Triple Timer Counter (TTC) block from the device tree ··· 433 421 pr_info("%s #0 at %p, irq=%d\n", timer->name, timer_baseaddr, irq); 434 422 } 435 423 436 - void __init xttcps_timer_init(void) 437 - { 438 - const char * const timer_list[] = { 439 - "cdns,ttc", 440 - NULL 441 - }; 442 - struct device_node *timer; 443 - 444 - timer = of_find_compatible_node(NULL, NULL, timer_list[0]); 445 - if (!timer) { 446 - pr_err("ERROR: no compatible timer found\n"); 447 - BUG(); 448 - } 449 - 450 - xttcps_timer_init_of(timer); 451 - } 424 + CLOCKSOURCE_OF_DECLARE(ttc, "cdns,ttc", xttcps_timer_init);