Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <rob.herring@calxeda.com>

+31 -2
+1
arch/arm/Kconfig
··· 1127 1127 config ARM_TIMER_SP804 1128 1128 bool 1129 1129 select CLKSRC_MMIO 1130 + select HAVE_SCHED_CLOCK 1130 1131 1131 1132 source arch/arm/mm/Kconfig 1132 1133
+16 -1
arch/arm/common/timer-sp.c
··· 26 26 #include <linux/irq.h> 27 27 #include <linux/io.h> 28 28 29 + #include <asm/sched_clock.h> 29 30 #include <asm/hardware/arm_timer.h> 30 31 31 32 static long __init sp804_get_clock_rate(const char *name) ··· 68 67 return rate; 69 68 } 70 69 71 - void __init sp804_clocksource_init(void __iomem *base, const char *name) 70 + static void __iomem *sched_clock_base; 71 + 72 + static u32 sp804_read(void) 73 + { 74 + return ~readl_relaxed(sched_clock_base + TIMER_VALUE); 75 + } 76 + 77 + void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base, 78 + const char *name, 79 + int use_sched_clock) 72 80 { 73 81 long rate = sp804_get_clock_rate(name); 74 82 ··· 93 83 94 84 clocksource_mmio_init(base + TIMER_VALUE, name, 95 85 rate, 200, 32, clocksource_mmio_readl_down); 86 + 87 + if (use_sched_clock) { 88 + sched_clock_base = base; 89 + setup_sched_clock(sp804_read, 32, rate); 90 + } 96 91 } 97 92 98 93
+14 -1
arch/arm/include/asm/hardware/timer-sp.h
··· 1 - void sp804_clocksource_init(void __iomem *, const char *); 1 + void __sp804_clocksource_and_sched_clock_init(void __iomem *, 2 + const char *, int); 3 + 4 + static inline void sp804_clocksource_init(void __iomem *base, const char *name) 5 + { 6 + __sp804_clocksource_and_sched_clock_init(base, name, 0); 7 + } 8 + 9 + static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base, 10 + const char *name) 11 + { 12 + __sp804_clocksource_and_sched_clock_init(base, name, 1); 13 + } 14 + 2 15 void sp804_clockevents_init(void __iomem *, unsigned int, const char *);