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 - 1998, 2001 by Ralf Baechle
12 #include <linux/config.h>
13 #include <linux/param.h>
15 extern unsigned long loops_per_jiffy;
17 extern __inline__ void
18 __delay(unsigned long loops)
20 __asm__ __volatile__ (
30 * division by multiplication: you don't have to worry about
33 * Use only for very small delays ( < 1 msec). Should probably use a
34 * lookup table, really, as the multiplications take much too long with
35 * short delays. This is a "reasonable" implementation, though (and the
36 * first constant multiplications gets optimized away if the delay is
39 extern __inline__ void __udelay(unsigned long usecs, unsigned long lpj)
44 usecs *= 0x00068db8; /* 2**32 / (1000000 / HZ) */
46 usecs *= 0x0008637b; /* 2**32 / (1000000 / HZ) */
48 __asm__("multu\t%2,%3"
49 :"=h" (usecs), "=l" (lo)
50 :"r" (usecs),"r" (lpj));
55 #define __udelay_val cpu_data[smp_processor_id()].udelay_val
57 #define __udelay_val loops_per_jiffy
60 #define udelay(usecs) __udelay((usecs),__udelay_val)
62 #endif /* _ASM_DELAY_H */