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>
This commit is contained in:
Xinyu Chen
2010-03-24 10:18:23 +08:00
committed by Matt Sealey
parent 2875d0d86f
commit f4a735b4bc

View File

@@ -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);