From a7bf61620831c5578e434429bc7fa0fd0219c40c Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 12 Dec 2011 15:29:08 -0600 Subject: ARM: timer-sp: add sched_clock support Add a sched_clock support for the sp804 timer. The clocksource timer can optionally initialize itself as sched_clock timer. Signed-off-by: Rob Herring --- arch/arm/common/timer-sp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c index 8794a34..df13a3f 100644 --- a/arch/arm/common/timer-sp.c +++ b/arch/arm/common/timer-sp.c @@ -26,6 +26,7 @@ #include #include +#include #include static long __init sp804_get_clock_rate(const char *name) @@ -67,7 +68,16 @@ static long __init sp804_get_clock_rate(const char *name) return rate; } -void __init sp804_clocksource_init(void __iomem *base, const char *name) +static void __iomem *sched_clock_base; + +static u32 sp804_read(void) +{ + return ~readl_relaxed(sched_clock_base + TIMER_VALUE); +} + +void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base, + const char *name, + int use_sched_clock) { long rate = sp804_get_clock_rate(name); @@ -83,6 +93,11 @@ void __init sp804_clocksource_init(void __iomem *base, const char *name) clocksource_mmio_init(base + TIMER_VALUE, name, rate, 200, 32, clocksource_mmio_readl_down); + + if (use_sched_clock) { + sched_clock_base = base; + setup_sched_clock(sp804_read, 32, rate); + } } -- cgit v1.1