提交 7ce83018 编写于 作者: R Russell King

ARM: pxa: convert sched_clock() to use new infrastructure

Convert pxa to use the new sched_clock() infrastructure for extending
32bit counters to full 64-bit nanoseconds.
Tested-by: NEric Miao <eric.y.miao@gmail.com>
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 28bb7bc6
...@@ -593,6 +593,7 @@ config ARCH_PXA ...@@ -593,6 +593,7 @@ config ARCH_PXA
select COMMON_CLKDEV select COMMON_CLKDEV
select ARCH_REQUIRE_GPIOLIB select ARCH_REQUIRE_GPIOLIB
select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS
select HAVE_SCHED_CLOCK
select TICK_ONESHOT select TICK_ONESHOT
select PLAT_PXA select PLAT_PXA
select SPARSE_IRQ select SPARSE_IRQ
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/clockchips.h> #include <linux/clockchips.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/cnt32_to_63.h>
#include <asm/div64.h> #include <asm/div64.h>
#include <asm/mach/irq.h> #include <asm/mach/irq.h>
#include <asm/mach/time.h> #include <asm/mach/time.h>
#include <asm/sched_clock.h>
#include <mach/regs-ost.h> #include <mach/regs-ost.h>
/* /*
...@@ -32,29 +32,18 @@ ...@@ -32,29 +32,18 @@
* long as there is always less than 582 seconds between successive * long as there is always less than 582 seconds between successive
* calls to sched_clock() which should always be the case in practice. * calls to sched_clock() which should always be the case in practice.
*/ */
static DEFINE_CLOCK_DATA(cd);
#define OSCR2NS_SCALE_FACTOR 10 unsigned long long notrace sched_clock(void)
static unsigned long oscr2ns_scale;
static void __init set_oscr2ns_scale(unsigned long oscr_rate)
{ {
unsigned long long v = 1000000000ULL << OSCR2NS_SCALE_FACTOR; u32 cyc = OSCR;
do_div(v, oscr_rate); return cyc_to_sched_clock(&cd, cyc, (u32)~0);
oscr2ns_scale = v;
/*
* We want an even value to automatically clear the top bit
* returned by cnt32_to_63() without an additional run time
* instruction. So if the LSB is 1 then round it up.
*/
if (oscr2ns_scale & 1)
oscr2ns_scale++;
} }
unsigned long long notrace sched_clock(void) static void notrace pxa_update_sched_clock(void)
{ {
unsigned long long v = cnt32_to_63(OSCR); u32 cyc = OSCR;
return (v * oscr2ns_scale) >> OSCR2NS_SCALE_FACTOR; update_sched_clock(&cd, cyc, (u32)~0);
} }
...@@ -144,7 +133,7 @@ static void __init pxa_timer_init(void) ...@@ -144,7 +133,7 @@ static void __init pxa_timer_init(void)
OIER = 0; OIER = 0;
OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3;
set_oscr2ns_scale(clock_tick_rate); init_sched_clock(&cd, pxa_update_sched_clock, 32, clock_tick_rate);
ckevt_pxa_osmr0.mult = ckevt_pxa_osmr0.mult =
div_sc(clock_tick_rate, NSEC_PER_SEC, ckevt_pxa_osmr0.shift); div_sc(clock_tick_rate, NSEC_PER_SEC, ckevt_pxa_osmr0.shift);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册