Import 2.3.12pre3
[davej-history.git] / include / asm-mips / delay.h
blob42d16646b5e1ebb12207cee2ee637a5863e3135f
1 /* $Id: delay.h,v 1.2 1999/01/04 16:09:20 ralf Exp $
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
7 * Copyright (C) 1994 by Waldorf Electronics
8 * Copyright (C) 1995 - 1998 by Ralf Baechle
9 */
10 #ifndef __ASM_MIPS_DELAY_H
11 #define __ASM_MIPS_DELAY_H
13 extern __inline__ void __delay(int loops)
15 __asm__ __volatile__ (
16 ".set\tnoreorder\n"
17 "1:\tbnez\t%0,1b\n\t"
18 "subu\t%0,1\n\t"
19 ".set\treorder"
20 :"=r" (loops)
21 :"0" (loops));
25 * division by multiplication: you don't have to worry about
26 * loss of precision.
28 * Use only for very small delays ( < 1 msec). Should probably use a
29 * lookup table, really, as the multiplications take much too long with
30 * short delays. This is a "reasonable" implementation, though (and the
31 * first constant multiplications gets optimized away if the delay is
32 * a constant)
34 extern __inline__ void __udelay(unsigned long usecs, unsigned long lps)
36 usecs *= 0x000010c6; /* 2**32 / 1000000 */
37 __asm__("multu\t%0,%2\n\t"
38 "mfhi\t%0"
39 :"=r" (usecs)
40 :"0" (usecs),"r" (lps));
41 __delay(usecs);
44 #ifdef __SMP__
45 #define __udelay_val cpu_data[smp_processor_id()].udelay_val
46 #else
47 #define __udelay_val loops_per_sec
48 #endif
50 #define udelay(usecs) __udelay((usecs),__udelay_val)
52 #endif /* __ASM_MIPS_DELAY_H */