From: Matthias Kaehlcke Date: Tue, 9 Mar 2010 21:13:33 +0000 (+0100) Subject: ep93xx timer: Fix resolution of get_ticks() X-Git-Tag: v2010.09-rc1~28^2~7^2~18^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dea86bb9aa663d726a6e6c1cf5c464c3ae351da9;p=u-boot ep93xx timer: Fix resolution of get_ticks() ep93xx timer: Make get_ticks() return a value in CONFIG_SYS_HZ resolution, as announced by get_tbclk() Signed-off-by: Matthias Kaehlcke --- diff --git a/cpu/arm920t/ep93xx/timer.c b/cpu/arm920t/ep93xx/timer.c index bc4ec8fcd4..31304b7f97 100644 --- a/cpu/arm920t/ep93xx/timer.c +++ b/cpu/arm920t/ep93xx/timer.c @@ -69,7 +69,7 @@ static inline unsigned long read_timer(void) } /* - * timer without interrupts + * Get the number of ticks (in CONFIG_SYS_HZ resolution) */ unsigned long long get_ticks(void) { @@ -83,12 +83,12 @@ unsigned long long get_ticks(void) timer.last_update = now; - return timer.ticks; + return clk_to_systicks(timer.ticks); } unsigned long get_timer_masked(void) { - return clk_to_systicks(get_ticks()); + return get_ticks(); } unsigned long get_timer(unsigned long base) @@ -109,10 +109,13 @@ void reset_timer(void) void __udelay(unsigned long usec) { - const unsigned long target = get_ticks() + usecs_to_ticks(usec); + /* read the timer and update timer.ticks */ + get_ticks(); - while (get_ticks() < target) - /* noop */; + const unsigned long long target = timer.ticks + usecs_to_ticks(usec); + + while (timer.ticks < target) + get_ticks(); } int timer_init(void)