aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/counter_32k.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-12-15 16:53:51 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-12-22 17:44:49 -0500
commitdc548fbbd2ecd0fc3b02301d551e5f8e19ae58fd (patch)
treeb96dc2b070c8f3b1835c2ee1fd6bf0e2b13b67f9 /arch/arm/plat-omap/counter_32k.c
parentec05aa139939d9c7b790041a379f0e752b2f1a4d (diff)
ARM: omap: convert sched_clock() to use new infrastructure
Convert omap to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds. Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/plat-omap/counter_32k.c')
-rw-r--r--arch/arm/plat-omap/counter_32k.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index aed301bfa2f9..1b558efbe732 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -18,6 +18,8 @@
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20 20
21#include <asm/sched_clock.h>
22
21#include <plat/common.h> 23#include <plat/common.h>
22#include <plat/board.h> 24#include <plat/board.h>
23 25
@@ -110,10 +112,25 @@ static struct clocksource clocksource_32k = {
110 * Returns current time from boot in nsecs. It's OK for this to wrap 112 * Returns current time from boot in nsecs. It's OK for this to wrap
111 * around for now, as it's just a relative time stamp. 113 * around for now, as it's just a relative time stamp.
112 */ 114 */
115static DEFINE_CLOCK_DATA(cd);
116
117/*
118 * Constants generated by clocks_calc_mult_shift(m, s, 32768, NSEC_PER_SEC, 60).
119 * This gives a resolution of about 30us and a wrap period of about 36hrs.
120 */
121#define SC_MULT 4000000000u
122#define SC_SHIFT 17
123
113unsigned long long notrace sched_clock(void) 124unsigned long long notrace sched_clock(void)
114{ 125{
115 return clocksource_cyc2ns(clocksource_32k.read(&clocksource_32k), 126 u32 cyc = clocksource_32k.read(&clocksource_32k);
116 clocksource_32k.mult, clocksource_32k.shift); 127 return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT);
128}
129
130static void notrace omap_update_sched_clock(void)
131{
132 u32 cyc = clocksource_32k.read(&clocksource_32k);
133 update_sched_clock(&cd, cyc, (u32)~0);
117} 134}
118 135
119/** 136/**
@@ -171,6 +188,9 @@ static int __init omap_init_clocksource_32k(void)
171 188
172 if (clocksource_register_hz(&clocksource_32k, 32768)) 189 if (clocksource_register_hz(&clocksource_32k, 32768))
173 printk(err, clocksource_32k.name); 190 printk(err, clocksource_32k.name);
191
192 init_fixed_sched_clock(&cd, omap_update_sched_clock, 32,
193 32768, SC_MULT, SC_SHIFT);
174 } 194 }
175 return 0; 195 return 0;
176} 196}