]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ARM: 6297/1: move U300 timer to dynamic clock lookup
authorLinus Walleij <linus.walleij@stericsson.com>
Thu, 5 Aug 2010 06:59:54 +0000 (07:59 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 10 Aug 2010 21:10:56 +0000 (22:10 +0100)
This moves the U300 timer code to look up its clock rate from the
clock framework as is apropriate and also switches it over to use
the generic code for *calc_mult_shift() on clock source and clock
event.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-u300/clock.c
arch/arm/mach-u300/timer.c

index 7a94729caff9a87e2576a1b5822b6bb452a70ad1..60acf9e708ae9d655423e46e804f509908642c04 100644 (file)
@@ -1204,10 +1204,14 @@ static struct clk timer_clk = {
        .lock       = __SPIN_LOCK_UNLOCKED(timer_clk.lock),
 };
 
+/*
+ * There is a binary divider in the hardware that divides
+ * the 13MHz PLL by 13 down to 1 MHz.
+ */
 static struct clk app_timer_clk = {
        .name       = "TIMER_APP",
        .parent     = &slow_clk,
-       .rate       = 13000000,
+       .rate       = 1000000,
        .hw_ctrld   = true,
        .reset      = true,
        .res_reg    = U300_SYSCON_VBASE + U300_SYSCON_RSR,
index 01f161831956e9c7dc02445a34845546f17dffdf..3fc4472719be0f05bfeb3823fbe000a7818cf2d5 100644 (file)
@@ -25,6 +25,8 @@
 #include <asm/mach/time.h>
 #include <asm/mach/irq.h>
 
+/* Be able to sleep for atleast 4 seconds (usually more) */
+#define APPTIMER_MIN_RANGE 4
 
 /*
  * APP side special timer registers
@@ -308,8 +310,6 @@ static struct clock_event_device clockevent_u300_1mhz = {
        .name           = "GPT1",
        .rating         = 300, /* Reasonably fast and accurate clock event */
        .features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-       /* 22 calculated using the algorithm in arch/mips/kernel/time.c */
-       .shift          = 22,
        .set_next_event = u300_set_next_event,
        .set_mode       = u300_set_mode,
 };
@@ -342,8 +342,6 @@ static struct clocksource clocksource_u300_1mhz = {
        .rating         = 300, /* Reasonably fast and accurate clock source */
        .read           = u300_get_cycles,
        .mask           = CLOCKSOURCE_MASK(32), /* 32 bits */
-       /* 22 calculated using the algorithm in arch/mips/kernel/time.c */
-       .shift          = 22,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -369,11 +367,13 @@ unsigned long long notrace sched_clock(void)
 static void __init u300_timer_init(void)
 {
        struct clk *clk;
+       unsigned long rate;
 
        /* Clock the interrupt controller */
        clk = clk_get_sys("apptimer", NULL);
        BUG_ON(IS_ERR(clk));
        clk_enable(clk);
+       rate = clk_get_rate(clk);
 
        /*
         * Disable the "OS" and "DD" timers - these are designed for Symbian!
@@ -412,15 +412,14 @@ static void __init u300_timer_init(void)
        writel(U300_TIMER_APP_EGPT2_TIMER_ENABLE,
                U300_TIMER_APP_VBASE + U300_TIMER_APP_EGPT2);
 
-       /* This is a pure microsecond clock source */
-       clocksource_u300_1mhz.mult =
-               clocksource_khz2mult(1000, clocksource_u300_1mhz.shift);
+       clocksource_calc_mult_shift(&clocksource_u300_1mhz,
+                                   rate, APPTIMER_MIN_RANGE);
        if (clocksource_register(&clocksource_u300_1mhz))
                printk(KERN_ERR "timer: failed to initialize clock "
                       "source %s\n", clocksource_u300_1mhz.name);
 
-       clockevent_u300_1mhz.mult =
-               div_sc(1000000, NSEC_PER_SEC, clockevent_u300_1mhz.shift);
+       clockevents_calc_mult_shift(&clockevent_u300_1mhz,
+                                   rate, APPTIMER_MIN_RANGE);
        /* 32bit counter, so 32bits delta is max */
        clockevent_u300_1mhz.max_delta_ns =
                clockevent_delta2ns(0xffffffff, &clockevent_u300_1mhz);