]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: timer-sp: add sched_clock support
authorRob Herring <rob.herring@calxeda.com>
Mon, 12 Dec 2011 21:29:08 +0000 (15:29 -0600)
committerRob Herring <rob.herring@calxeda.com>
Fri, 10 Feb 2012 04:42:55 +0000 (22:42 -0600)
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 <rob.herring@calxeda.com>
arch/arm/Kconfig
arch/arm/common/timer-sp.c
arch/arm/include/asm/hardware/timer-sp.h

index a48aecc17eacc2e3d3f5cf4b0ff4183f29b33440..448802296cb3e17e96c5a69270c18f91201b6ba8 100644 (file)
@@ -1127,6 +1127,7 @@ config PLAT_VERSATILE
 config ARM_TIMER_SP804
        bool
        select CLKSRC_MMIO
+       select HAVE_SCHED_CLOCK
 
 source arch/arm/mm/Kconfig
 
index 8794a34eae61d87b34d433dc1266c555c7687fca..df13a3ffff3514b703584483d1b43a9cb12d3953 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 
+#include <asm/sched_clock.h>
 #include <asm/hardware/arm_timer.h>
 
 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);
+       }
 }
 
 
index 4384d81eee79d4f456589541d8ea957ca598d50a..2dd9d3f83f2963282ad5c593b94aebbc59df421a 100644 (file)
@@ -1,2 +1,15 @@
-void sp804_clocksource_init(void __iomem *, const char *);
+void __sp804_clocksource_and_sched_clock_init(void __iomem *,
+                                             const char *, int);
+
+static inline void sp804_clocksource_init(void __iomem *base, const char *name)
+{
+       __sp804_clocksource_and_sched_clock_init(base, name, 0);
+}
+
+static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base,
+                                                         const char *name)
+{
+       __sp804_clocksource_and_sched_clock_init(base, name, 1);
+}
+
 void sp804_clockevents_init(void __iomem *, unsigned int, const char *);