]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ARM: 6153/1: nomadik MTU to use dynamic shift and mult assignment
authorLinus Walleij <linus.walleij@stericsson.com>
Tue, 1 Jun 2010 07:26:49 +0000 (08:26 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 16 Jun 2010 21:29:31 +0000 (22:29 +0100)
This removes the hard-coded shift values for the MTU timer, since
the different platforms using this has very different running
frequencies doing this dynamically is a better idea. Also take
this opportunity to make a more through shutdown of the MTU
clockevent when requested.

Acked-by: Alessandro Rubini <rubini@unipv.it>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/plat-nomadik/include/plat/mtu.h
arch/arm/plat-nomadik/timer.c

index 42c907258b14a04e34622d1ca99c638c5827631f..65704a3d42410890b044fd499cfba2ceaf067b9c 100644 (file)
@@ -1,6 +1,12 @@
 #ifndef __PLAT_MTU_H
 #define __PLAT_MTU_H
 
+/*
+ * Guaranteed runtime conversion range in seconds for
+ * the clocksource and clockevent.
+ */
+#define MTU_MIN_RANGE 4
+
 /* should be set by the platform code */
 extern void __iomem *mtu_base;
 
index 08aaa4a7f65fe0e868b1a8cbfa8dd80d73209cec..ea3ca86c52836ba1ec9fe780da9c1629db91723f 100644 (file)
@@ -42,7 +42,6 @@ static struct clocksource nmdk_clksrc = {
        .rating         = 200,
        .read           = nmdk_read_timer_dummy,
        .mask           = CLOCKSOURCE_MASK(32),
-       .shift          = 20,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -82,6 +81,12 @@ static void nmdk_clkevt_mode(enum clock_event_mode mode,
        case CLOCK_EVT_MODE_UNUSED:
                /* disable irq */
                writel(0, mtu_base + MTU_IMSC);
+               /* disable timer */
+               cr = readl(mtu_base + MTU_CR(1));
+               cr &= ~MTU_CRn_ENA;
+               writel(cr, mtu_base + MTU_CR(1));
+               /* load some high default value */
+               writel(0xffffffff, mtu_base + MTU_LR(1));
                break;
        case CLOCK_EVT_MODE_RESUME:
                break;
@@ -98,7 +103,6 @@ static int nmdk_clkevt_next(unsigned long evt, struct clock_event_device *ev)
 static struct clock_event_device nmdk_clkevt = {
        .name           = "mtu_1",
        .features       = CLOCK_EVT_FEAT_ONESHOT,
-       .shift          = 32,
        .rating         = 200,
        .set_mode       = nmdk_clkevt_mode,
        .set_next_event = nmdk_clkevt_next,
@@ -151,6 +155,7 @@ void __init nmdk_timer_init(void)
        } else {
                cr |= MTU_CRn_PRESCALE_1;
        }
+       clocksource_calc_mult_shift(&nmdk_clksrc, rate, MTU_MIN_RANGE);
 
        /* Timer 0 is the free running clocksource */
        writel(cr, mtu_base + MTU_CR(0));
@@ -158,7 +163,6 @@ void __init nmdk_timer_init(void)
        writel(0, mtu_base + MTU_BGLR(0));
        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;
 
@@ -175,8 +179,10 @@ void __init nmdk_timer_init(void)
        } else {
                cr |= MTU_CRn_PRESCALE_1;
        }
+       clockevents_calc_mult_shift(&nmdk_clkevt, rate, MTU_MIN_RANGE);
+
        writel(cr | MTU_CRn_ONESHOT, mtu_base + MTU_CR(1)); /* off, currently */
-       nmdk_clkevt.mult = div_sc(rate, NSEC_PER_SEC, nmdk_clkevt.shift);
+
        nmdk_clkevt.max_delta_ns =
                clockevent_delta2ns(0xffffffff, &nmdk_clkevt);
        nmdk_clkevt.min_delta_ns =