linux-mips
[Top] [All Lists]

[PATCH 2.5] udelay

To: linux-mips@linux-mips.org
Subject: [PATCH 2.5] udelay
From: Vivien Chappelier <vivienc@nerim.net>
Date: Sat, 21 Dec 2002 19:11:40 +0100 (CET)
Cc: Ralf Baechle <ralf@oss.sgi.com>, Ilya Volynets <ilya@theilya.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Hi,

        The HZ constant has changed in 2.5 and udelay doesn't work
properly anymore. Here's a patch to fix it. I checked the first multiply
is still optimized out during compilation if the delay is constant. It's
for mips64, but mips32 needs it as well.

Vivien.

--- include/asm-mips64/delay.h  2002-12-11 20:44:20.000000000 +0100
+++ include/asm-mips64/delay.h  2002-12-21 18:48:12.000000000 +0100
@@ -41,11 +41,10 @@
 {
        unsigned long lo;
 
-#if (HZ == 100)
-       usecs *= 0x00068db8bac710cbUL;          /* 2**64 / (1000000 / HZ) */
-#elif (HZ == 128)
-       usecs *= 0x0008637bd05af6c6UL;          /* 2**64 / (1000000 / HZ) */
-#endif
+/* HZ * 2**64 / 1000000 */
+#define __UDELAY_FIXED64_HZ_1000000 (0x8000000000000000UL / (500000 / HZ)) 
+
+       usecs *= __UDELAY_FIXED64_HZ_1000000;
        __asm__("dmultu\t%2,%3"
                :"=h" (usecs), "=l" (lo)
                :"r" (usecs),"r" (lpj));


<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 2.5] udelay, Vivien Chappelier <=