From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alessandro Rubini Date: Fri, 6 Nov 2009 09:12:12 +0100 Subject: [U-Boot] [PATCH V3] Nomadik: fix reset_timer() Message-ID: <20091106081212.GA11919@mail.gnudd.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Alessandro Rubini 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 Acked-by: Andrea Gallo --- 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