Optimize andes_clear_page() and andes_copy_page() with prefetch
[linux-2.6/linux-mips.git] / include / asm-mips / delay.h
blob7628fe4a8cdba2d8642f252f9dc30b85aae70877
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_DELAY_H
11 #define _ASM_DELAY_H
13 #include <linux/config.h>
15 extern __inline__ void
16 __delay(unsigned long loops)
18 __asm__ __volatile__ (
19 ".set\tnoreorder\n"
20 "1:\tbnez\t%0,1b\n\t"
21 "subu\t%0,1\n\t"
22 ".set\treorder"
23 :"=r" (loops)
24 :"0" (loops));
28 * division by multiplication: you don't have to worry about
29 * loss of precision.
31 * Use only for very small delays ( < 1 msec). Should probably use a
32 * lookup table, really, as the multiplications take much too long with
33 * short delays. This is a "reasonable" implementation, though (and the
34 * first constant multiplications gets optimized away if the delay is
35 * a constant)
37 extern __inline__ void __udelay(unsigned long usecs, unsigned long lps)
39 unsigned long lo;
41 usecs *= 0x000010c6; /* 2**32 / 1000000 */
42 __asm__("multu\t%2,%3"
43 :"=h" (usecs), "=l" (lo)
44 :"r" (usecs),"r" (lps));
45 __delay(usecs);
48 #ifdef CONFIG_SMP
49 #define __udelay_val cpu_data[smp_processor_id()].udelay_val
50 #else
51 #define __udelay_val loops_per_sec
52 #endif
54 #define udelay(usecs) __udelay((usecs),__udelay_val)
56 #endif /* _ASM_DELAY_H */