aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorKevin Hilman <khilman@mvista.com>2007-11-13 02:24:03 -0500
committerTony Lindgren <tony@atomide.com>2008-04-14 12:57:12 -0400
commitf258b0c6fa6ca653c7f4e6e2846dbb7ed3af3446 (patch)
treea5c89a4c4506ca87f99d4fd155633296302d0215 /arch/arm
parent5a3a388fbefac3705dfcde16c93fc81e6fd9378f (diff)
ARM: OMAP: Timer32K: Move 32k-based sched_clock() to common code
Since 32k timer code is moving to OMAP1 specific dir, move the 32k-based sched_clock() into common code where it is based on the 32k sync counter and can be used even when using MPU timer. While moving, change the ticks-to-nsecs conversion to use the helper functions provided by clocksource.h. Also removed the unused ticks_to_usec, leaving only ticks_to_nsec. Signed-off-by: Kevin Hilman <khilman@mvista.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/plat-omap/common.c17
-rw-r--r--arch/arm/plat-omap/timer32k.c26
2 files changed, 17 insertions, 26 deletions
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 4f0f9c4e938e..7f1cae16cfad 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -193,6 +193,23 @@ static struct clocksource clocksource_32k = {
193 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 193 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
194}; 194};
195 195
196/*
197 * Rounds down to nearest nsec.
198 */
199unsigned long long omap_32k_ticks_to_nsecs(unsigned long ticks_32k)
200{
201 return cyc2ns(&clocksource_32k, ticks_32k);
202}
203
204/*
205 * Returns current time from boot in nsecs. It's OK for this to wrap
206 * around for now, as it's just a relative time stamp.
207 */
208unsigned long long sched_clock(void)
209{
210 return omap_32k_ticks_to_nsecs(omap_32k_read());
211}
212
196static int __init omap_init_clocksource_32k(void) 213static int __init omap_init_clocksource_32k(void)
197{ 214{
198 static char err[] __initdata = KERN_ERR 215 static char err[] __initdata = KERN_ERR
diff --git a/arch/arm/plat-omap/timer32k.c b/arch/arm/plat-omap/timer32k.c
index ce034dc59d41..1f7365f5df24 100644
--- a/arch/arm/plat-omap/timer32k.c
+++ b/arch/arm/plat-omap/timer32k.c
@@ -153,32 +153,6 @@ static inline unsigned long omap_32k_sync_timer_read(void)
153 return omap_readl(TIMER_32K_SYNCHRONIZED); 153 return omap_readl(TIMER_32K_SYNCHRONIZED);
154} 154}
155 155
156/*
157 * Rounds down to nearest usec. Note that this will overflow for larger values.
158 */
159static inline unsigned long omap_32k_ticks_to_usecs(unsigned long ticks_32k)
160{
161 return (ticks_32k * 5*5*5*5*5*5) >> 9;
162}
163
164/*
165 * Rounds down to nearest nsec.
166 */
167static inline unsigned long long
168omap_32k_ticks_to_nsecs(unsigned long ticks_32k)
169{
170 return (unsigned long long) ticks_32k * 1000 * 5*5*5*5*5*5 >> 9;
171}
172
173/*
174 * Returns current time from boot in nsecs. It's OK for this to wrap
175 * around for now, as it's just a relative time stamp.
176 */
177unsigned long long sched_clock(void)
178{
179 return omap_32k_ticks_to_nsecs(omap_32k_sync_timer_read());
180}
181
182static irqreturn_t omap_32k_timer_interrupt(int irq, void *dev_id) 156static irqreturn_t omap_32k_timer_interrupt(int irq, void *dev_id)
183{ 157{
184 struct clock_event_device *evt = &clockevent_32k_timer; 158 struct clock_event_device *evt = &clockevent_32k_timer;