aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinyu Chen <xinyu.chen@freescale.com>2010-03-24 10:18:23 +0800
committerXinyu Chen <xinyu.chen@freescale.com>2010-03-26 09:48:18 +0800
commitc68afebba8ce224668788a77dedde660abfad830 (patch)
tree37fe10861402be9ca6804c7351bd3b0b2033c5b8
parent1b07ae665ef8afc6e3450398fd9fbb0a81395c69 (diff)
downloadlinux-linaro-c68afebba8ce224668788a77dedde660abfad830.tar.gz
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>
-rw-r--r--arch/arm/plat-mxc/time.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index fbf86e42c3f..c958688ba24 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);