[ARM] 4012/1: Clocksource for pxa

Add a clocksource driver for pxa2xx systems

Signed-off-by: Luotao Fu <lfu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Sascha Hauer and committed by Russell King c80204e5 da2c12a2

+23 -22
+23 -22
arch/arm/mach-pxa/time.c
··· 18 18 #include <linux/signal.h> 19 19 #include <linux/errno.h> 20 20 #include <linux/sched.h> 21 + #include <linux/clocksource.h> 21 22 22 23 #include <asm/system.h> 23 24 #include <asm/hardware.h> ··· 47 46 } 48 47 RCNR = current_time; 49 48 return 0; 50 - } 51 - 52 - /* IRQs are disabled before entering here from do_gettimeofday() */ 53 - static unsigned long pxa_gettimeoffset (void) 54 - { 55 - long ticks_to_match, elapsed, usec; 56 - 57 - /* Get ticks before next timer match */ 58 - ticks_to_match = OSMR0 - OSCR; 59 - 60 - /* We need elapsed ticks since last match */ 61 - elapsed = LATCH - ticks_to_match; 62 - 63 - /* don't get fooled by the workaround in pxa_timer_interrupt() */ 64 - if (elapsed <= 0) 65 - return 0; 66 - 67 - /* Now convert them to usec */ 68 - usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH; 69 - 70 - return usec; 71 49 } 72 50 73 51 #ifdef CONFIG_NO_IDLE_HZ ··· 101 121 .handler = pxa_timer_interrupt, 102 122 }; 103 123 124 + cycle_t pxa_get_cycles(void) 125 + { 126 + return OSCR; 127 + } 128 + 129 + static struct clocksource clocksource_pxa = { 130 + .name = "pxa_timer", 131 + .rating = 200, 132 + .read = pxa_get_cycles, 133 + .mask = CLOCKSOURCE_MASK(32), 134 + .shift = 20, 135 + .is_continuous = 1, 136 + }; 137 + 104 138 static void __init pxa_timer_init(void) 105 139 { 106 140 struct timespec tv; ··· 133 139 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */ 134 140 OSMR0 = OSCR + LATCH; /* set initial match */ 135 141 local_irq_restore(flags); 142 + 143 + /* on PXA OSCR runs continiously and is not written to, so we can use it 144 + * as clock source directly. 145 + */ 146 + clocksource_pxa.mult = 147 + clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_pxa.shift); 148 + clocksource_register(&clocksource_pxa); 149 + 136 150 } 137 151 138 152 #ifdef CONFIG_NO_IDLE_HZ ··· 213 211 .init = pxa_timer_init, 214 212 .suspend = pxa_timer_suspend, 215 213 .resume = pxa_timer_resume, 216 - .offset = pxa_gettimeoffset, 217 214 #ifdef CONFIG_NO_IDLE_HZ 218 215 .dyn_tick = &pxa_dyn_tick, 219 216 #endif