kvm tools, setup: Create private directory
[linux-2.6/next.git] / arch / unicore32 / include / asm / delay.h
blob164ae61cd6f7b1e42043fd4fff79f41154f72de0
1 /*
2 * linux/arch/unicore32/include/asm/delay.h
4 * Code specific to PKUnity SoC and UniCore ISA
6 * Copyright (C) 2001-2010 GUAN Xue-tao
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Delay routines, using a pre-computed "loops_per_second" value.
14 #ifndef __UNICORE_DELAY_H__
15 #define __UNICORE_DELAY_H__
17 #include <asm/param.h> /* HZ */
19 extern void __delay(int loops);
22 * This function intentionally does not exist; if you see references to
23 * it, it means that you're calling udelay() with an out of range value.
25 * With currently imposed limits, this means that we support a max delay
26 * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
28 extern void __bad_udelay(void);
31 * division by multiplication: you don't have to worry about
32 * loss of precision.
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
38 * a constant)
40 extern void __udelay(unsigned long usecs);
41 extern void __const_udelay(unsigned long);
43 #define MAX_UDELAY_MS 2
45 #define udelay(n) \
46 (__builtin_constant_p(n) ? \
47 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
48 __const_udelay((n) * ((2199023U*HZ)>>11))) : \
49 __udelay(n))
51 #endif /* __UNICORE_DELAY_H__ */