Skip to content

Commit

Permalink
ARM: timer-sp: add sched_clock support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rob Herring committed Feb 10, 2012
1 parent d65b4e9 commit a7bf616
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ config PLAT_VERSATILE
config ARM_TIMER_SP804
bool
select CLKSRC_MMIO
select HAVE_SCHED_CLOCK

source arch/arm/mm/Kconfig

Expand Down
17 changes: 16 additions & 1 deletion arch/arm/common/timer-sp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand All @@ -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);
}
}


Expand Down
15 changes: 14 additions & 1 deletion arch/arm/include/asm/hardware/timer-sp.h
Original file line number Diff line number Diff line change
@@ -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 *);

0 comments on commit a7bf616

Please sign in to comment.