Skip to contentSkip to conversation

ARM: arch timer: Set the TVAL before timer is enabled

PATCH In review Rohit Vaswani 2 participants 2 messages Jun 21, 2013 – Jun 24, 2013

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

PATCH 1/1 ARM: arch timer: Set the TVAL before timer is enabled

On some hardware, the timer deasserts the interrupt when a new TVAL is written only when the enable bit is cleared. Hence explicitly disable the timer and then program the TVAL followed by enabling the timer.
If this order is not followed, there are chances that you would not receive any timer interrupts.
This is done as suggested in https://lkml.org/lkml/2012/8/11/39

---
 drivers/clocksource/arm_arch_timer.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/clocksource/arm_arch_timer.c +3 -2
index a2b2541..05ba0c2 100644
@@ -103,9 +103,10 @@ static inline void set_next_event(const int access, unsigned long evt)
 {
 	unsigned long ctrl;
 	ctrl = arch_timer_reg_read(access, ARCH_TIMER_REG_CTRL);
-	ctrl |= ARCH_TIMER_CTRL_ENABLE;
-	ctrl &= ~ARCH_TIMER_CTRL_IT_MASK;
+	ctrl &= ~(ARCH_TIMER_CTRL_ENABLE | ARCH_TIMER_CTRL_IT_MASK);
+	arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl);
 	arch_timer_reg_write(access, ARCH_TIMER_REG_TVAL, evt);
+	ctrl |= ARCH_TIMER_CTRL_ENABLE;
 	arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl);
 }
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Rohit Vaswani

On some hardware, the timer deasserts the interrupt when a new TVAL is written only when the enable bit is cleared. Hence explicitly disable the timer and then program the TVAL followed by enabling the timer.
If this order is not followed, there are chances that you would not receive any timer interrupts.
This is done as suggested in https://lkml.org/lkml/2012/8/11/39

---
 drivers/clocksource/arm_arch_timer.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/clocksource/arm_arch_timer.c +0 -0
index a2b2541..05ba0c2 100644
@@ -103,9 +103,10 @@ static inline void set_next_event(const int access, unsigned long evt)
 {

drivers/clocksource/arm_arch_timer.c static inline void set_next_event(const int access, unsigned long evt) · line 111

Quoted 10 lines
drivers/clocksource/arm_arch_timer.c +3 -2
 	unsigned long ctrl;
 	ctrl = arch_timer_reg_read(access, ARCH_TIMER_REG_CTRL);
-	ctrl |= ARCH_TIMER_CTRL_ENABLE;
-	ctrl &= ~ARCH_TIMER_CTRL_IT_MASK;
+	ctrl &= ~(ARCH_TIMER_CTRL_ENABLE | ARCH_TIMER_CTRL_IT_MASK);
+	arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl);
 	arch_timer_reg_write(access, ARCH_TIMER_REG_TVAL, evt);
+	ctrl |= ARCH_TIMER_CTRL_ENABLE;
 	arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl);
 }

Maybe that would deserve a comment in the code so people don't get the idea it can be reordered to save the extra write?

Other than that, and FWIW:

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...