diff options
Diffstat (limited to 'arch/arm/mach-u300/timer.c')
-rw-r--r-- | arch/arm/mach-u300/timer.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/arch/arm/mach-u300/timer.c b/arch/arm/mach-u300/timer.c index 3fc4472719be..18d7fa0603c2 100644 --- a/arch/arm/mach-u300/timer.c +++ b/arch/arm/mach-u300/timer.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * Author: Linus Walleij <linus.walleij@stericsson.com> | 9 | * Author: Linus Walleij <linus.walleij@stericsson.com> |
10 | */ | 10 | */ |
11 | #include <linux/interrupt.h> | 11 | #include <linux/interrupt.h> |
12 | #include <linux/sched.h> | ||
12 | #include <linux/time.h> | 13 | #include <linux/time.h> |
13 | #include <linux/timex.h> | 14 | #include <linux/timex.h> |
14 | #include <linux/clockchips.h> | 15 | #include <linux/clockchips.h> |
@@ -21,6 +22,7 @@ | |||
21 | #include <mach/hardware.h> | 22 | #include <mach/hardware.h> |
22 | 23 | ||
23 | /* Generic stuff */ | 24 | /* Generic stuff */ |
25 | #include <asm/sched_clock.h> | ||
24 | #include <asm/mach/map.h> | 26 | #include <asm/mach/map.h> |
25 | #include <asm/mach/time.h> | 27 | #include <asm/mach/time.h> |
26 | #include <asm/mach/irq.h> | 28 | #include <asm/mach/irq.h> |
@@ -331,20 +333,6 @@ static struct irqaction u300_timer_irq = { | |||
331 | .handler = u300_timer_interrupt, | 333 | .handler = u300_timer_interrupt, |
332 | }; | 334 | }; |
333 | 335 | ||
334 | /* Use general purpose timer 2 as clock source */ | ||
335 | static cycle_t u300_get_cycles(struct clocksource *cs) | ||
336 | { | ||
337 | return (cycles_t) readl(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC); | ||
338 | } | ||
339 | |||
340 | static struct clocksource clocksource_u300_1mhz = { | ||
341 | .name = "GPT2", | ||
342 | .rating = 300, /* Reasonably fast and accurate clock source */ | ||
343 | .read = u300_get_cycles, | ||
344 | .mask = CLOCKSOURCE_MASK(32), /* 32 bits */ | ||
345 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
346 | }; | ||
347 | |||
348 | /* | 336 | /* |
349 | * Override the global weak sched_clock symbol with this | 337 | * Override the global weak sched_clock symbol with this |
350 | * local implementation which uses the clocksource to get some | 338 | * local implementation which uses the clocksource to get some |
@@ -352,12 +340,18 @@ static struct clocksource clocksource_u300_1mhz = { | |||
352 | * this wraps around for now, since it is just a relative time | 340 | * this wraps around for now, since it is just a relative time |
353 | * stamp. (Inspired by OMAP implementation.) | 341 | * stamp. (Inspired by OMAP implementation.) |
354 | */ | 342 | */ |
343 | static DEFINE_CLOCK_DATA(cd); | ||
344 | |||
355 | unsigned long long notrace sched_clock(void) | 345 | unsigned long long notrace sched_clock(void) |
356 | { | 346 | { |
357 | return clocksource_cyc2ns(clocksource_u300_1mhz.read( | 347 | u32 cyc = readl(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC); |
358 | &clocksource_u300_1mhz), | 348 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); |
359 | clocksource_u300_1mhz.mult, | 349 | } |
360 | clocksource_u300_1mhz.shift); | 350 | |
351 | static void notrace u300_update_sched_clock(void) | ||
352 | { | ||
353 | u32 cyc = readl(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC); | ||
354 | update_sched_clock(&cd, cyc, (u32)~0); | ||
361 | } | 355 | } |
362 | 356 | ||
363 | 357 | ||
@@ -375,6 +369,8 @@ static void __init u300_timer_init(void) | |||
375 | clk_enable(clk); | 369 | clk_enable(clk); |
376 | rate = clk_get_rate(clk); | 370 | rate = clk_get_rate(clk); |
377 | 371 | ||
372 | init_sched_clock(&cd, u300_update_sched_clock, 32, rate); | ||
373 | |||
378 | /* | 374 | /* |
379 | * Disable the "OS" and "DD" timers - these are designed for Symbian! | 375 | * Disable the "OS" and "DD" timers - these are designed for Symbian! |
380 | * Example usage in cnh1601578 cpu subsystem pd_timer_app.c | 376 | * Example usage in cnh1601578 cpu subsystem pd_timer_app.c |
@@ -412,11 +408,10 @@ static void __init u300_timer_init(void) | |||
412 | writel(U300_TIMER_APP_EGPT2_TIMER_ENABLE, | 408 | writel(U300_TIMER_APP_EGPT2_TIMER_ENABLE, |
413 | U300_TIMER_APP_VBASE + U300_TIMER_APP_EGPT2); | 409 | U300_TIMER_APP_VBASE + U300_TIMER_APP_EGPT2); |
414 | 410 | ||
415 | clocksource_calc_mult_shift(&clocksource_u300_1mhz, | 411 | /* Use general purpose timer 2 as clock source */ |
416 | rate, APPTIMER_MIN_RANGE); | 412 | if (clocksource_mmio_init(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC, |
417 | if (clocksource_register(&clocksource_u300_1mhz)) | 413 | "GPT2", rate, 300, 32, clocksource_mmio_readl_up)) |
418 | printk(KERN_ERR "timer: failed to initialize clock " | 414 | pr_err("timer: failed to initialize U300 clock source\n"); |
419 | "source %s\n", clocksource_u300_1mhz.name); | ||
420 | 415 | ||
421 | clockevents_calc_mult_shift(&clockevent_u300_1mhz, | 416 | clockevents_calc_mult_shift(&clockevent_u300_1mhz, |
422 | rate, APPTIMER_MIN_RANGE); | 417 | rate, APPTIMER_MIN_RANGE); |