[U-Boot-Users] [PATCH][BUGFIX] Incorrect handling of AT91RM9200 timer overflow

Anders Larsen alarsen at rea.de
Fri Nov 11 16:56:04 CET 2005


Hi,

the AT91RM9200 timer functions are confusing apples with bananas.

When the (16-bit) timer overflows, we have lost exactly 2^16 counts
(or a multiple thereof, but we currently can't catch that situation),
but get_timer_raw() instead adds the (unrelated) conversion factor
to milliseconds, causing udelay() to potentially return too early.

The patch below fixes this.

Cheers
 Anders

CHANGELOG:
  Fix incorrect handling of at91rm9200 timer overflow in get_timer_raw()
  Patch by Anders Larsen, 11 Nov 2005

Signed-off-by: Anders Larsen <alarsen at rea.de>

---

 cpu/arm920t/at91rm9200/interrupts.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cpu/arm920t/at91rm9200/interrupts.c b/cpu/arm920t/at91rm9200/interrupts.c
index 1054602..68ad58b 100644
--- a/cpu/arm920t/at91rm9200/interrupts.c
+++ b/cpu/arm920t/at91rm9200/interrupts.c
@@ -108,7 +108,7 @@ ulong get_timer_raw (void)
 		timestamp += now - lastinc;
 	} else {
 		/* we have an overflow ... */
-		timestamp += now + TIMER_LOAD_VAL - lastinc;
+		timestamp += now + 0x10000 - lastinc;
 	}
 	lastinc = now;
 





More information about the U-Boot mailing list