diff options
author | David Hendricks <dhendrix@chromium.org> | 2013-05-02 14:23:51 -0700 |
---|---|---|
committer | Ronald G. Minnich <rminnich@gmail.com> | 2013-05-05 00:18:48 +0200 |
commit | 0bb875be5e575b6eceb081d1a92da467b87aa96b (patch) | |
tree | acb7e0664c1297d95eff2f279c66711e72c4432c /src/cpu/samsung/exynos5-common/timer.c | |
parent | c2f177737bb2ae1836b3badeb90daf6bdcc2134f (diff) | |
download | coreboot-0bb875be5e575b6eceb081d1a92da467b87aa96b.tar.xz |
exynos5/5250: Update timer call sites to use monotonic timer API
This goes thru various call sites where we used timer_us() and updates
them to use the new monotonic timer API.
udelay() changed substantially and now gracefully handles wraparound.
Change-Id: Ie2cc86a4125cf0de12837fd7d337a11aed25715c
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: http://review.coreboot.org/3176
Reviewed-by: Aaron Durbin <adurbin@google.com>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/cpu/samsung/exynos5-common/timer.c')
-rw-r--r-- | src/cpu/samsung/exynos5-common/timer.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/cpu/samsung/exynos5-common/timer.c b/src/cpu/samsung/exynos5-common/timer.c index ca15501bb7..c8e419a57c 100644 --- a/src/cpu/samsung/exynos5-common/timer.c +++ b/src/cpu/samsung/exynos5-common/timer.c @@ -25,7 +25,7 @@ #include <common.h> #include <arch/io.h> -#include <time.h> +#include <timer.h> #include <console/console.h> #include <cpu/samsung/exynos5-common/pwm.h> #include <cpu/samsung/exynos5-common/clk.h> @@ -121,16 +121,23 @@ unsigned long timer_get_us(void) /* delay x useconds */ void udelay(unsigned long usec) { - unsigned long start; - - start = timer_us(); - if ((start + usec) < start){ - printk(BIOS_EMERG, "udelay: %08lx is impossibly large\n", - usec); - usec = 1000000; + struct mono_time current, end; + + timer_monotonic_get(¤t); + end = current; + mono_time_add_usecs(&end, usec); + + if (mono_time_after(¤t, &end)) { + printk(BIOS_EMERG, "udelay: 0x%08lx is impossibly large\n", + usec); + /* There's not much we can do if usec is too big. Use a long, + * paranoid delay value and hope for the best... */ + end = current; + mono_time_add_usecs(&end, USECS_PER_SEC); } - while ((timer_us() - start) < usec) - ; + + while (mono_time_before(¤t, &end)) + timer_monotonic_get(¤t); } /* |