patch-2.4.1 linux/include/asm-ppc/delay.h
Next file: linux/include/asm-ppc/dma.h
Previous file: linux/include/asm-i386/system.h
Back to the patch index
Back to the overall index
- Lines: 61
- Date:
Mon Jan 22 15:41:15 2001
- Orig file:
v2.4.0/linux/include/asm-ppc/delay.h
- Orig date:
Sat Nov 11 18:23:10 2000
diff -u --recursive --new-file v2.4.0/linux/include/asm-ppc/delay.h linux/include/asm-ppc/delay.h
@@ -2,6 +2,8 @@
#ifndef _PPC_DELAY_H
#define _PPC_DELAY_H
+#include <asm/param.h>
+
/*
* Copyright 1996, Paul Mackerras.
*
@@ -11,25 +13,38 @@
* 2 of the License, or (at your option) any later version.
*/
-extern unsigned long loops_per_sec;
+extern unsigned long loops_per_jiffy;
-extern __inline__ void __delay(unsigned int loops)
-{
- if (loops != 0)
- __asm__ __volatile__("mtctr %0; 1: bdnz 1b" : :
- "r" (loops) : "ctr");
-}
+/* maximum permitted argument to udelay */
+#define __MAX_UDELAY 1000000
-extern __inline__ void udelay(unsigned long usecs)
+extern void __delay(unsigned int loops);
+
+/* N.B. the `secs' parameter here is a fixed-point number with
+ the binary point to the left of the most-significant bit. */
+extern __inline__ void __const_udelay(unsigned int secs)
{
- unsigned long loops;
+ unsigned int loops;
- /* compute (usecs * 2^32 / 10^6) * loops_per_sec / 2^32 */
- usecs *= 0x10c6; /* 2^32 / 10^6 */
__asm__("mulhwu %0,%1,%2" : "=r" (loops) :
- "r" (usecs), "r" (loops_per_sec));
- __delay(loops);
+ "r" (secs), "r" (loops_per_jiffy));
+ __delay(loops * HZ);
}
+
+/*
+ * note that 4294 == 2^32 / 10^6, multiplying by 4294 converts from
+ * microseconds to a 32-bit fixed-point number of seconds.
+ */
+extern __inline__ void __udelay(unsigned int usecs)
+{
+ __const_udelay(usecs * 4294);
+}
+
+extern void __bad_udelay(void); /* deliberately undefined */
+
+#define udelay(n) (__builtin_constant_p(n)? \
+ ((n) > __MAX_UDELAY? __bad_udelay(): __const_udelay((n) * 4294u)) : \
+ __udelay(n))
#endif /* defined(_PPC_DELAY_H) */
#endif /* __KERNEL__ */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)