From: Graf Yang Date: Tue, 19 May 2009 08:40:08 +0000 (-0400) Subject: Blackfin: fix timer_init()/timer_reset() X-Git-Tag: v2009.06-rc3~28^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ec01481ddc4cf302c7f6d760b776ca94819ec21e;p=u-boot Blackfin: fix timer_init()/timer_reset() 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. Signed-off-by: Graf Yang Signed-off-by: Mike Frysinger --- diff --git a/cpu/blackfin/interrupts.c b/cpu/blackfin/interrupts.c index d4dd636101..bf6fb4b4cf 100644 --- a/cpu/blackfin/interrupts.c +++ b/cpu/blackfin/interrupts.c @@ -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(); }