Skip to contentSkip to conversation

Blackfin: fix timer_init()/timer_reset()

PATCH New Mike Frysinger 1 participant 1 message May 19, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Blackfin: fix timer_init()/timer_reset()

From: Graf Yang <[email protected]>

The timer_init() function was not using the right csync instruction, nor was it doing it right after disabling the core timer.

The timer_reset() function would reset the timestamp, but not the actual timer, so there was a common edge case where get_timer() return a jump of one timestamp (couple milliseconds) right after resetting. This caused many functions to improperly timeout right away.

---
 cpu/blackfin/interrupts.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
cpu/blackfin/interrupts.c +3 -2
index d4dd636..bf6fb4b 100644
@@ -95,11 +95,12 @@ void udelay(unsigned long usec)
 int timer_init(void)
 {
 	*pTCNTL = 0x1;
+	CSYNC();
 	*pTSCALE = 0x0;
 	*pTCOUNT = MAX_TIM_LOAD;
 	*pTPERIOD = MAX_TIM_LOAD;
 	*pTCNTL = 0x7;
-	asm("CSYNC;");
+	CSYNC();
 
 	timestamp = 0;
 	last_time = 0;
@@ -151,5 +152,5 @@ ulong get_timer(ulong base)
 
 void reset_timer(void)
 {
-	timestamp = 0;
+	timer_init();
 }
Signature · 1 line
1.6.3.1