Skip to contentSkip to conversation

ARM: OMAP: fix OMAP1 clockevent support for hrtimers

PATCH In review Kevin Hilman 2 participants 2 messages Oct 18, 2007 – Oct 22, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: OMAP: fix OMAP1 clockevent support for hrtimers

One-shot mode was broken in MPU-timer support for OMAP1 due to a typo.

Also, ensure timer is stopped before changing the auto-reload flag. The TRM says changing the AR flag when timer is running is undefined.

---
 arch/arm/mach-omap1/time.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm/mach-omap1/time.c +10 -2
Index: dev/arch/arm/mach-omap1/time.c
===================================================================
@@ -132,13 +132,20 @@ static inline void omap_mpu_timer_start(
 	timer->cntl = timerflags;
 }
 
+static inline void omap_mpu_timer_stop(int nr)
+{
+	volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
+
+	timer->cntl &= ~MPU_TIMER_ST;
+}
+
 /*
  * ---------------------------------------------------------------------------
  * MPU timer 1 ... count down to zero, interrupt, reload
  * ---------------------------------------------------------------------------
  */
 static int omap_mpu_set_next_event(unsigned long cycles,
-				    struct clock_event_device *evt)
+				   struct clock_event_device *evt)
 {
 	omap_mpu_timer_start(0, cycles, 0);
 	return 0;
@@ -152,6 +159,7 @@ static void omap_mpu_set_mode(enum clock
 		omap_mpu_set_autoreset(0);
 		break;
 	case CLOCK_EVT_MODE_ONESHOT:
+		omap_mpu_timer_stop(0);
 		omap_mpu_remove_autoreset(0);
 		break;
 	case CLOCK_EVT_MODE_UNUSED:
@@ -163,7 +171,7 @@ static void omap_mpu_set_mode(enum clock
 
 static struct clock_event_device clockevent_mpu_timer1 = {
 	.name		= "mpu_timer1",
-	.features       = CLOCK_EVT_FEAT_PERIODIC, CLOCK_EVT_FEAT_ONESHOT,
+	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 	.shift		= 32,
 	.set_next_event	= omap_mpu_set_next_event,
 	.set_mode	= omap_mpu_set_mode,

--

reviewer
#1 lore raw
Quoted 47 lines · Kevin Hilman

One-shot mode was broken in MPU-timer support for OMAP1 due to a typo.

Also, ensure timer is stopped before changing the auto-reload flag. The TRM says changing the AR flag when timer is running is undefined.

---
 arch/arm/mach-omap1/time.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Index: dev/arch/arm/mach-omap1/time.c
===================================================================

arch/arm/mach-omap1/time.c +9 -1
@@ -132,13 +132,20 @@ static inline void omap_mpu_timer_start(
 	timer->cntl = timerflags;
 }
 
+static inline void omap_mpu_timer_stop(int nr)
+{
+	volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
+
+	timer->cntl &= ~MPU_TIMER_ST;
+}
+
 /*
  * ---------------------------------------------------------------------------
  * MPU timer 1 ... count down to zero, interrupt, reload
  * ---------------------------------------------------------------------------
  */
 static int omap_mpu_set_next_event(unsigned long cycles,
-				    struct clock_event_device *evt)
+				   struct clock_event_device *evt)
 {
 	omap_mpu_timer_start(0, cycles, 0);
 	return 0;
@@ -152,6 +159,7 @@ static void omap_mpu_set_mode(enum clock
 		omap_mpu_set_autoreset(0);
 		break;
 	case CLOCK_EVT_MODE_ONESHOT:
+		omap_mpu_timer_stop(0);
 		omap_mpu_remove_autoreset(0);
 		break;
 	case CLOCK_EVT_MODE_UNUSED:

arch/arm/mach-omap1/time.c static void omap_mpu_set_mode(enum clock · line 177

Quoted 8 lines
arch/arm/mach-omap1/time.c +1 -1
@@ -163,7 +171,7 @@ static void omap_mpu_set_mode(enum clock
 
 static struct clock_event_device clockevent_mpu_timer1 = {
 	.name		= "mpu_timer1",
-	.features       = CLOCK_EVT_FEAT_PERIODIC, CLOCK_EVT_FEAT_ONESHOT,
+	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 	.shift		= 32,
 	.set_next_event	= omap_mpu_set_next_event,
 	.set_mode	= omap_mpu_set_mode,

Pushing today.

Tony