From: Tony Lindgren Date: Tue, 16 Aug 2005 12:00:09 +0000 (-0700) Subject: ARM: OMAP: Add sched_clock() for 32k timer X-Git-Tag: v2.6.13-omap1~22 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=85049d4c9c497778614a9b49172d08262bca98ee;p=linux-2.6-omap-h63xx.git ARM: OMAP: Add sched_clock() for 32k timer Add sched_clock() for 32k timer --- diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c index d540539c9bb..e36b58c5052 100644 --- a/arch/arm/mach-omap1/time.c +++ b/arch/arm/mach-omap1/time.c @@ -296,13 +296,22 @@ static inline void omap_32k_timer_stop(void) } /* - * Rounds down to nearest usec + * Rounds down to nearest usec. Note that this will overflow for larger values. */ static inline unsigned long omap_32k_ticks_to_usecs(unsigned long ticks_32k) { return (ticks_32k * 5*5*5*5*5*5) >> 9; } +/* + * Rounds down to nearest nsec. + */ +static inline unsigned long long +omap_32k_ticks_to_nsecs(unsigned long ticks_32k) +{ + return (unsigned long long) ticks_32k * 1000 * 5*5*5*5*5*5 >> 9; +} + static unsigned long omap_32k_last_tick = 0; /* @@ -314,6 +323,15 @@ static unsigned long omap_32k_timer_gettimeoffset(void) return omap_32k_ticks_to_usecs(now - omap_32k_last_tick); } +/* + * Returns current time from boot in nsecs. It's OK for this to wrap + * around for now, as it's just a relative time stamp. + */ +unsigned long long sched_clock(void) +{ + return omap_32k_ticks_to_nsecs(omap_32k_sync_timer_read()); +} + /* * Timer interrupt for 32KHz timer. When dynamic tick is enabled, this * function is also called from other interrupts to remove latency