diff options
-rw-r--r-- | arch/arm/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-pxa/time.c | 29 |
2 files changed, 10 insertions, 20 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 0208e1e9ed79..23035d65252c 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -593,6 +593,7 @@ config ARCH_PXA | |||
593 | select COMMON_CLKDEV | 593 | select COMMON_CLKDEV |
594 | select ARCH_REQUIRE_GPIOLIB | 594 | select ARCH_REQUIRE_GPIOLIB |
595 | select GENERIC_CLOCKEVENTS | 595 | select GENERIC_CLOCKEVENTS |
596 | select HAVE_SCHED_CLOCK | ||
596 | select TICK_ONESHOT | 597 | select TICK_ONESHOT |
597 | select PLAT_PXA | 598 | select PLAT_PXA |
598 | select SPARSE_IRQ | 599 | select SPARSE_IRQ |
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c index b8d9dff00ad1..e7f64d9b4f2d 100644 --- a/arch/arm/mach-pxa/time.c +++ b/arch/arm/mach-pxa/time.c | |||
@@ -17,11 +17,11 @@ | |||
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/clockchips.h> | 18 | #include <linux/clockchips.h> |
19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
20 | #include <linux/cnt32_to_63.h> | ||
21 | 20 | ||
22 | #include <asm/div64.h> | 21 | #include <asm/div64.h> |
23 | #include <asm/mach/irq.h> | 22 | #include <asm/mach/irq.h> |
24 | #include <asm/mach/time.h> | 23 | #include <asm/mach/time.h> |
24 | #include <asm/sched_clock.h> | ||
25 | #include <mach/regs-ost.h> | 25 | #include <mach/regs-ost.h> |
26 | 26 | ||
27 | /* | 27 | /* |
@@ -32,29 +32,18 @@ | |||
32 | * long as there is always less than 582 seconds between successive | 32 | * long as there is always less than 582 seconds between successive |
33 | * calls to sched_clock() which should always be the case in practice. | 33 | * calls to sched_clock() which should always be the case in practice. |
34 | */ | 34 | */ |
35 | static DEFINE_CLOCK_DATA(cd); | ||
35 | 36 | ||
36 | #define OSCR2NS_SCALE_FACTOR 10 | 37 | unsigned long long notrace sched_clock(void) |
37 | |||
38 | static unsigned long oscr2ns_scale; | ||
39 | |||
40 | static void __init set_oscr2ns_scale(unsigned long oscr_rate) | ||
41 | { | 38 | { |
42 | unsigned long long v = 1000000000ULL << OSCR2NS_SCALE_FACTOR; | 39 | u32 cyc = OSCR; |
43 | do_div(v, oscr_rate); | 40 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); |
44 | oscr2ns_scale = v; | ||
45 | /* | ||
46 | * We want an even value to automatically clear the top bit | ||
47 | * returned by cnt32_to_63() without an additional run time | ||
48 | * instruction. So if the LSB is 1 then round it up. | ||
49 | */ | ||
50 | if (oscr2ns_scale & 1) | ||
51 | oscr2ns_scale++; | ||
52 | } | 41 | } |
53 | 42 | ||
54 | unsigned long long notrace sched_clock(void) | 43 | static void notrace pxa_update_sched_clock(void) |
55 | { | 44 | { |
56 | unsigned long long v = cnt32_to_63(OSCR); | 45 | u32 cyc = OSCR; |
57 | return (v * oscr2ns_scale) >> OSCR2NS_SCALE_FACTOR; | 46 | update_sched_clock(&cd, cyc, (u32)~0); |
58 | } | 47 | } |
59 | 48 | ||
60 | 49 | ||
@@ -144,7 +133,7 @@ static void __init pxa_timer_init(void) | |||
144 | OIER = 0; | 133 | OIER = 0; |
145 | OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; | 134 | OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; |
146 | 135 | ||
147 | set_oscr2ns_scale(clock_tick_rate); | 136 | init_sched_clock(&cd, pxa_update_sched_clock, 32, clock_tick_rate); |
148 | 137 | ||
149 | ckevt_pxa_osmr0.mult = | 138 | ckevt_pxa_osmr0.mult = |
150 | div_sc(clock_tick_rate, NSEC_PER_SEC, ckevt_pxa_osmr0.shift); | 139 | div_sc(clock_tick_rate, NSEC_PER_SEC, ckevt_pxa_osmr0.shift); |