Skip to contentSkip to conversation

Incorrect handling of AT91RM9200 timer overflow

PATCH New Anders Larsen 2 participants 2 messages Nov 11, 2005 – Nov 22, 2005 Arm/Microchip (AT91) SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Incorrect handling of AT91RM9200 timer overflow

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

---

 cpu/arm920t/at91rm9200/interrupts.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
cpu/arm920t/at91rm9200/interrupts.c +1 -1
index 1054602..68ad58b 100644
@@ -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;
 
#1 lore raw

PATCH 1/1 Incorrect handling of AT91RM9200 timer overflow

Wolfgang,

Quoted 9 lines

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.

Quoted 8 lines

Cheers
Anders

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

Makes sense. Please apply.

--
Steven