public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V3] Nomadik: fix reset_timer()
@ 2009-11-06  8:12 Alessandro Rubini
  0 siblings, 0 replies; only message in thread
From: Alessandro Rubini @ 2009-11-06  8:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

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.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---

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(-)

diff --git a/cpu/arm926ejs/nomadik/timer.c b/cpu/arm926ejs/nomadik/timer.c
index 16067c9..991752d 100644
--- a/cpu/arm926ejs/nomadik/timer.c
+++ b/cpu/arm926ejs/nomadik/timer.c
@@ -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)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-11-06  8:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-06  8:12 [U-Boot] [PATCH V3] Nomadik: fix reset_timer() Alessandro Rubini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox