Skip to content

Commit

Permalink
msm: timer: Support sched_clock()
Browse files Browse the repository at this point in the history
Now that sched_clock is mandatory on ARM it's simple to add
sched_clock support to the MSM timer code. Add it so that we get
more accurate sched_clock output than the jiffies based version
that's provided by default.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
  • Loading branch information
Stephen Boyd authored and Marc Zyngier committed Feb 24, 2012
1 parent 6905a65 commit f8e56c4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions arch/arm/mach-msm/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <asm/mach/time.h>
#include <asm/hardware/gic.h>
#include <asm/localtimer.h>
#include <asm/sched_clock.h>

#include <mach/msm_iomap.h>
#include <mach/cpu.h>
Expand Down Expand Up @@ -105,12 +106,12 @@ static union {

static void __iomem *source_base;

static cycle_t msm_read_timer_count(struct clocksource *cs)
static notrace cycle_t msm_read_timer_count(struct clocksource *cs)
{
return readl_relaxed(source_base + TIMER_COUNT_VAL);
}

static cycle_t msm_read_timer_count_shift(struct clocksource *cs)
static notrace cycle_t msm_read_timer_count_shift(struct clocksource *cs)
{
/*
* Shift timer count down by a constant due to unreliable lower bits
Expand All @@ -127,6 +128,11 @@ static struct clocksource msm_clocksource = {
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

static notrace u32 msm_sched_clock_read(void)
{
return msm_clocksource.read(&msm_clocksource);
}

static void __init msm_timer_init(void)
{
struct clock_event_device *ce = &msm_clockevent;
Expand Down Expand Up @@ -189,6 +195,8 @@ static void __init msm_timer_init(void)
res = clocksource_register_hz(cs, dgt_hz);
if (res)
pr_err("clocksource_register failed\n");
setup_sched_clock(msm_sched_clock_read,
cpu_is_msm7x01() ? 32 - MSM_DGT_SHIFT : 32, dgt_hz);
}

#ifdef CONFIG_LOCAL_TIMERS
Expand Down

0 comments on commit f8e56c4

Please sign in to comment.