Skip to contentSkip to conversation

ARM: OMAP: Add clocksource driver for OMAP

PATCH In review Dirk Behme 2 participants 2 messages Nov 12, 2006 – Nov 13, 2006

Subsystems (3)
lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH 1/1 ARM: OMAP: Add clocksource driver for OMAP

Add clocksource driver for OMAP.

This is an update of

http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=3876/1

from Daniel Walker and Kevin Hilman.

Changes:

- Apply cleanly to recent git (pt_regs change)
- Move clocksource init to extra function. Can be called later by clocksource subsystem
- Remove warning
arch/arm/plat-omap/timer32k.c:216: warning: 'omap_32k_timer_handler' defined but not used if CONFIG_NO_IDLE_HZ isn't set.
- Minor cleanups

Signed-off-by Dirk Behme <dirk.behme_at_gmail.com>
arch/arm/mach-omap1/time.c +37 -23
Index: linux-osk/arch/arm/mach-omap1/time.c
===================================================================
@@ -7,6 +7,7 @@
  * Partial timer rewrite and additional dynamic tick timer support by
  * Tony Lindgen <[email protected]> and
  * Tuukka Tikkanen <[email protected]>
+ * Clocksource infrastructure added by Daniel Walker <[email protected]>
  *
  * MPU timer code based on the older MPU timer code for OMAP
  * Copyright (C) 2000 RidgeRun, Inc.
@@ -39,6 +40,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
+#include <linux/clocksource.h>
 
 #include <asm/system.h>
 #include <asm/hardware.h>
@@ -140,34 +142,13 @@ unsigned long omap_mpu_timer_ticks_to_us
 }
 
 /*
- * Last processed system timer interrupt
- */
-static unsigned long omap_mpu_timer_last = 0;
-
-/*
- * Returns elapsed usecs since last system timer interrupt
- */
-static unsigned long omap_mpu_timer_gettimeoffset(void)
-{
-	unsigned long now = 0 - omap_mpu_timer_read(0);
-	unsigned long elapsed = now - omap_mpu_timer_last;
-
-	return omap_mpu_timer_ticks_to_usecs(elapsed);
-}
-
-/*
  * Elapsed time between interrupts is calculated using timer0.
  * Latency during the interrupt is calculated using timer1.
  * Both timer0 and timer1 are counting at 6MHz (P2 6.5MHz).
  */
 static irqreturn_t omap_mpu_timer_interrupt(int irq, void *dev_id)
 {
-	unsigned long now, latency;
-
 	write_seqlock(&xtime_lock);
-	now = 0 - omap_mpu_timer_read(0);
-	latency = MPU_TICKS_PER_SEC / HZ - omap_mpu_timer_read(1);
-	omap_mpu_timer_last = now - latency;
 	timer_tick();
 	write_sequnlock(&xtime_lock);
 
@@ -181,6 +162,7 @@ static struct irqaction omap_mpu_timer_i
 };
 
 static unsigned long omap_mpu_timer1_overflows;
+
 static irqreturn_t omap_mpu_timer1_interrupt(int irq, void *dev_id)
 {
 	omap_mpu_timer1_overflows++;
@@ -196,7 +178,7 @@ static struct irqaction omap_mpu_timer1_
 static __init void omap_init_mpu_timer(void)
 {
 	set_cyc2ns_scale(MPU_TICKS_PER_SEC / 1000);
-	omap_timer.offset = omap_mpu_timer_gettimeoffset;
+
 	setup_irq(INT_TIMER1, &omap_mpu_timer1_irq);
 	setup_irq(INT_TIMER2, &omap_mpu_timer_irq);
 	omap_mpu_timer_start(0, 0xffffffff);
@@ -220,15 +202,47 @@ unsigned long long sched_clock(void)
 
 /*
  * ---------------------------------------------------------------------------
+ * MPU clocksource
+ * ---------------------------------------------------------------------------
+ */
+static cycle_t mpu_read(void)
+{
+      return ~omap_mpu_timer_read(0);
+}
+
+/*
+ * Clock source structure for the MPU timer.
+ */
+struct clocksource clocksource_mpu = {
+      .name           = "mpu-timer",
+      .rating         = 300,
+      .read           = mpu_read,
+      .mask           = CLOCKSOURCE_MASK(32),
+      .shift          = 24,
+      .is_continuous  = 1,
+};
+
+static __init void omap_init_clocksource(void)
+{
+	clocksource_mpu.mult =
+		clocksource_hz2mult(MPU_TICKS_PER_SEC, clocksource_mpu.shift);
+
+	if (clocksource_register(&clocksource_mpu))
+		printk("omap_init_mpu_timer : Error registering"
+		       " mpu-timer clocksource!\n");
+}
+
+/*
+ * ---------------------------------------------------------------------------
  * Timer initialization
  * ---------------------------------------------------------------------------
  */
 static void __init omap_timer_init(void)
 {
 	omap_init_mpu_timer();
+	omap_init_clocksource();
 }
 
 struct sys_timer omap_timer = {
 	.init		= omap_timer_init,
-	.offset		= NULL,		/* Initialized later */
 };
arch/arm/plat-omap/Kconfig +1 -0
Index: linux-osk/arch/arm/plat-omap/Kconfig
===================================================================
@@ -11,6 +11,7 @@ choice
 
 config ARCH_OMAP1
 	bool "TI OMAP1"
+	select GENERIC_TIME
 
 config ARCH_OMAP2
 	bool "TI OMAP2"
arch/arm/plat-omap/timer32k.c +49 -24

129 lines not on this page · raw message

Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Dirk Behme

Add clocksource driver for OMAP.

This is an update of

http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=3876/1

from Daniel Walker and Kevin Hilman.

Changes:

- Apply cleanly to recent git (pt_regs change)
- Move clocksource init to extra function. Can be called later by clocksource subsystem
- Remove warning
arch/arm/plat-omap/timer32k.c:216: warning: 'omap_32k_timer_handler' defined but not used if CONFIG_NO_IDLE_HZ isn't set.
- Minor cleanups

Quoted 1 line
Signed-off-by Dirk Behme <dirk.behme_at_gmail.com>