Skip to contentSkip to conversation

Nomadik: fix reset_timer()

PATCH Superseded Alessandro Rubini 1 participant 1 message Nov 6, 2009

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Nomadik: fix reset_timer()

From: Alessandro Rubini <[email protected]>

Previous code was failing when reading back the timer less than 400us after resetting it. This lead nand operations to incorrectly timeout any now and then. This changes READ_TIMER from negation to subtraction, so after writing 0 to reset it, an immediate read is correctly reported as 0 elapsed ticks.

---

This is an alternative to V2, which is being posted at the same time. I prefer this approach to that one, as it fixes the problem without switching subsequent code to negative logic.

 cpu/arm926ejs/nomadik/timer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
cpu/arm926ejs/nomadik/timer.c +2 -2
index 16067c9..991752d 100644
@@ -34,8 +34,8 @@
 #define TICKS_PER_HZ		(TIMER_CLOCK / CONFIG_SYS_HZ)
 #define TICKS_TO_HZ(x)		((x) / TICKS_PER_HZ)
 
-/* macro to read the 32 bit timer: since it decrements, we invert read value */
-#define READ_TIMER() (~readl(CONFIG_SYS_TIMERBASE + MTU_VAL(0)))
+/* macro to read the decrementing 32 bit timer as an increasing count */
+#define READ_TIMER() (0 - readl(CONFIG_SYS_TIMERBASE + MTU_VAL(0)))
 
 /* Configure a free-running, auto-wrap counter with no prescaler */
 int timer_init(void)
Signature · 1 line
1.6.0.2