2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1994 by Waldorf Electronics
7 * Copyright (C) 1995 - 2000 by Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
13 #include <linux/config.h>
14 #include <asm/param.h>
16 extern unsigned long loops_per_jiffy;
18 extern __inline__ void
19 __delay(unsigned long loops)
21 __asm__ __volatile__ (
31 * Division by multiplication: you don't have to worry about
34 * Use only for very small delays ( < 1 msec). Should probably use a
35 * lookup table, really, as the multiplications take much too long with
36 * short delays. This is a "reasonable" implementation, though (and the
37 * first constant multiplications gets optimized away if the delay is
40 extern __inline__ void __udelay(unsigned long usecs, unsigned long lpj)
45 usecs *= 0x00068db8bac710cbUL; /* 2**64 / (1000000 / HZ) */
47 usecs *= 0x0008637bd05af6c6UL; /* 2**64 / (1000000 / HZ) */
49 __asm__("dmultu\t%2,%3"
50 :"=h" (usecs), "=l" (lo)
51 :"r" (usecs),"r" (lpj));
56 #define __udelay_val cpu_data[smp_processor_id()].udelay_val
58 #define __udelay_val loops_per_jiffy
61 #define udelay(usecs) __udelay((usecs),__udelay_val)
63 #endif /* _ASM_DELAY_H */