patch-2.2.18 linux/include/asm-ppc/delay.h
Next file: linux/include/asm-ppc/dma.h
Previous file: linux/include/asm-ppc/backlight.h
Back to the patch index
Back to the overall index
- Lines: 58
- Date:
Wed Nov 8 23:00:35 2000
- Orig file:
v2.2.17/include/asm-ppc/delay.h
- Orig date:
Fri Apr 21 12:46:49 2000
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/include/asm-ppc/delay.h linux/include/asm-ppc/delay.h
@@ -1,6 +1,8 @@
#ifndef _PPC_DELAY_H
#define _PPC_DELAY_H
+#include <asm/param.h>
+
/*
* Copyright 1996, Paul Mackerras.
*
@@ -10,7 +12,10 @@
* 2 of the License, or (at your option) any later version.
*/
-extern unsigned long loops_per_sec;
+extern unsigned long loops_per_jiffy;
+
+/* maximum permitted argument to udelay */
+#define __MAX_UDELAY 1000000
extern __inline__ void __delay(unsigned int loops)
{
@@ -19,15 +24,30 @@
"r" (loops) : "ctr");
}
-extern __inline__ void udelay(unsigned long usecs)
+/* 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) */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)