Fix IP22 timer calibration.
[linux-2.6/linux-mips.git] / include / asm-mips / delay.h
blob751757079ee017ab3476504714cbea6b705e5d6a
1 /*
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
4 * for more details.
6 * Copyright (C) 1994 by Waldorf Electronics
7 * Copyright (C) 1995 - 1998, 2001 by Ralf Baechle
8 */
9 #ifndef _ASM_DELAY_H
10 #define _ASM_DELAY_H
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__ (
21 ".set\tnoreorder\n"
22 "1:\tbnez\t%0,1b\n\t"
23 "subu\t%0,1\n\t"
24 ".set\treorder"
25 :"=r" (loops)
26 :"0" (loops));
30 * Division by multiplication: you don't have to worry about
31 * loss of precision.
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
37 * a constant)
39 extern __inline__ void __udelay(unsigned long usecs, unsigned long lpj)
41 unsigned long lo;
44 * Excessive precission? Probably ...
46 usecs *= (unsigned long) (((0x8000000000000000ULL / (500000 / HZ)) +
47 0x80000000ULL) >> 32);
48 __asm__("multu\t%2,%3"
49 :"=h" (usecs), "=l" (lo)
50 :"r" (usecs),"r" (lpj));
51 __delay(usecs);
54 #ifdef CONFIG_SMP
55 #define __udelay_val cpu_data[smp_processor_id()].udelay_val
56 #else
57 #define __udelay_val loops_per_jiffy
58 #endif
60 #define udelay(usecs) __udelay((usecs),__udelay_val)
62 #endif /* _ASM_DELAY_H */