Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191786
b: refs/heads/master
c: 2a84751
h: refs/heads/master
v: v3
  • Loading branch information
Linus Walleij authored and Russell King committed May 13, 2010
1 parent 819c8a0 commit 77909e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: af7dc2281fd3cedc04cb51bcc0887cdaf65c3fcc
refs/heads/master: 2a847513cdecd517f7efc06296c539c3a936cf98
28 changes: 27 additions & 1 deletion trunk/arch/arm/plat-nomadik/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@

void __iomem *mtu_base; /* ssigned by machine code */

/*
* Kernel assumes that sched_clock can be called early
* but the MTU may not yet be initialized.
*/
static cycle_t nmdk_read_timer_dummy(struct clocksource *cs)
{
return 0;
}

/* clocksource: MTU decrements, so we negate the value being read. */
static cycle_t nmdk_read_timer(struct clocksource *cs)
{
Expand All @@ -29,12 +38,27 @@ static cycle_t nmdk_read_timer(struct clocksource *cs)
static struct clocksource nmdk_clksrc = {
.name = "mtu_0",
.rating = 200,
.read = nmdk_read_timer,
.read = nmdk_read_timer_dummy,
.mask = CLOCKSOURCE_MASK(32),
.shift = 20,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

/*
* Override the global weak sched_clock symbol with this
* local implementation which uses the clocksource to get some
* better resolution when scheduling the kernel. We accept that
* this wraps around for now, since it is just a relative time
* stamp. (Inspired by OMAP implementation.)
*/
unsigned long long notrace sched_clock(void)
{
return clocksource_cyc2ns(nmdk_clksrc.read(
&nmdk_clksrc),
nmdk_clksrc.mult,
nmdk_clksrc.shift);
}

/* Clockevent device: use one-shot mode */
static void nmdk_clkevt_mode(enum clock_event_mode mode,
struct clock_event_device *dev)
Expand Down Expand Up @@ -121,6 +145,8 @@ void __init nmdk_timer_init(void)
writel(cr | MTU_CRn_ENA, mtu_base + MTU_CR(0));

nmdk_clksrc.mult = clocksource_hz2mult(rate, nmdk_clksrc.shift);
/* Now the scheduling clock is ready */
nmdk_clksrc.read = nmdk_read_timer;

if (clocksource_register(&nmdk_clksrc))
pr_err("timer: failed to initialize clock source %s\n",
Expand Down

0 comments on commit 77909e1

Please sign in to comment.