From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shinya Kuribayashi Date: Sat, 24 May 2008 21:59:51 +0900 Subject: [U-Boot-Users] [PATCH 2/3][MIPS] lib_mips/time.c: Fix udelay In-Reply-To: <483810E2.7020105@ruby.dti.ne.jp> References: <20080520185822.8B9C86545F@mcmullan-linux.hq.netapp.com> <48339C9D.5040800@necel.com> <20080521153255.GD13959@ld0162-tx32.am.freescale.net> <483810E2.7020105@ruby.dti.ne.jp> Message-ID: <48381147.5060803@ruby.dti.ne.jp> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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*/; }