]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/arm/mach-omap2/timer-gp.c
Merge tag 'v2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[mv-sheeva.git] / arch / arm / mach-omap2 / timer-gp.c
index e13c29eecf2b54d3cdf17cdff24ea18c8f2f7ee9..0fc550e7e4825a04093a4e1980b1bd169f8cd893 100644 (file)
 #include <asm/mach/time.h>
 #include <plat/dmtimer.h>
 #include <asm/localtimer.h>
+#include <asm/sched_clock.h>
 
 #include "timer-gp.h"
 
+#include <plat/common.h>
+
 /* MAX_GPTIMER_ID: number of GPTIMERs on the chip */
 #define MAX_GPTIMER_ID         12
 
@@ -176,14 +179,19 @@ static void __init omap2_gp_clockevent_init(void)
 /* 
  * When 32k-timer is enabled, don't use GPTimer for clocksource
  * instead, just leave default clocksource which uses the 32k
- * sync counter.  See clocksource setup in see plat-omap/common.c. 
+ * sync counter.  See clocksource setup in plat-omap/counter_32k.c
  */
 
-static inline void __init omap2_gp_clocksource_init(void) {}
+static void __init omap2_gp_clocksource_init(void)
+{
+       omap_init_clocksource_32k();
+}
+
 #else
 /*
  * clocksource
  */
+static DEFINE_CLOCK_DATA(cd);
 static struct omap_dm_timer *gpt_clocksource;
 static cycle_t clocksource_read_cycles(struct clocksource *cs)
 {
@@ -195,15 +203,23 @@ static struct clocksource clocksource_gpt = {
        .rating         = 300,
        .read           = clocksource_read_cycles,
        .mask           = CLOCKSOURCE_MASK(32),
-       .shift          = 24,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+static void notrace dmtimer_update_sched_clock(void)
+{
+       u32 cyc;
+
+       cyc = omap_dm_timer_read_counter(gpt_clocksource);
+
+       update_sched_clock(&cd, cyc, (u32)~0);
+}
+
 /* Setup free-running counter for clocksource */
 static void __init omap2_gp_clocksource_init(void)
 {
        static struct omap_dm_timer *gpt;
-       u32 tick_rate, tick_period;
+       u32 tick_rate;
        static char err1[] __initdata = KERN_ERR
                "%s: failed to request dm-timer\n";
        static char err2[] __initdata = KERN_ERR
@@ -216,13 +232,12 @@ static void __init omap2_gp_clocksource_init(void)
 
        omap_dm_timer_set_source(gpt, OMAP_TIMER_SRC_SYS_CLK);
        tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gpt));
-       tick_period = (tick_rate / HZ) - 1;
 
        omap_dm_timer_set_load_start(gpt, 1, 0);
 
-       clocksource_gpt.mult =
-               clocksource_khz2mult(tick_rate/1000, clocksource_gpt.shift);
-       if (clocksource_register(&clocksource_gpt))
+       init_sched_clock(&cd, dmtimer_update_sched_clock, 32, tick_rate);
+
+       if (clocksource_register_hz(&clocksource_gpt, tick_rate))
                printk(err2, clocksource_gpt.name);
 }
 #endif