[U-Boot-Users] [PATCH 2/3][MIPS] lib_mips/time.c: Fix udelay
Shinya Kuribayashi
skuribay at ruby.dti.ne.jp
Sat May 24 14:59:51 CEST 2008
What we have to do is just to wait for given micro-seconds. No need to
take into account current time, get_timer and CFG_HZ.
Signed-off-by: Shinya Kuribayashi <skuribay at ruby.dti.ne.jp>
---
lib_mips/time.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib_mips/time.c b/lib_mips/time.c
index f03f023..154d792 100644
--- a/lib_mips/time.c
+++ b/lib_mips/time.c
@@ -51,13 +51,13 @@ void set_timer(ulong t)
write_32bit_cp0_register(CP0_COUNT, t);
}
-void udelay (unsigned long usec)
+void udelay(unsigned long usec)
{
ulong tmo;
- ulong start = get_timer(0);
+ unsigned int start = read_32bit_cp0_register(CP0_COUNT);
- tmo = usec * (CFG_HZ / 1000000);
- while ((ulong)((read_32bit_cp0_register(CP0_COUNT) - start)) < tmo)
+ tmo = start + (usec * (CONFIG_MIPS_TIMER_FREQ / 1000000));
+ while ((ulong)(tmo - read_32bit_cp0_register(CP0_COUNT)) < 0x7fffffff)
/*NOP*/;
}
More information about the U-Boot
mailing list