diff options
author | Xinyu Chen <xinyu.chen@freescale.com> | 2010-03-24 10:18:23 +0800 |
---|---|---|
committer | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2010-05-25 11:20:17 +0200 |
commit | e482740f547623eb71fd031e4619a341d47fa33c (patch) | |
tree | b2e950fc90add025983070451a2809ccf5a5a3f2 /arch | |
parent | 576e39e481040bafe1f793bfc54de76fc197e5e1 (diff) |
ENGR00121913 Add sched_clock support to i.mx platform
Add sched_clock() implement for i.mx platform to support nanosecond
resolution time for sched clock used by scheduler.
This case is found by running Android's CTS case: android.os.cts.DebugTest,
which tests the clock_gettime with CLOCK_THREAD_CPUTIME_ID clock,
and needs nanosecond resolution sched clock.
It returns 0 before timer initialize, return GPT counter after that.
Signed-off-by: Xinyu Chen <xinyu.chen@freescale.com>
Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/plat-mxc/time.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c index fbf86e42c3f4..c958688ba243 100644 --- a/arch/arm/plat-mxc/time.c +++ b/arch/arm/plat-mxc/time.c @@ -116,6 +116,18 @@ static struct clocksource clocksource_mxc = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +unsigned long long sched_clock(void) +{ + unsigned long long ret; + + if (!timer_base) + return 0; + + ret = (unsigned long long)clocksource_mxc.read(&clocksource_mxc); + ret = (ret * clocksource_mxc.mult_orig) >> clocksource_mxc.shift; + return ret; +} + static int __init mxc_clocksource_init(struct clk *timer_clk) { unsigned int c = clk_get_rate(timer_clk); |