Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
delay.h
Go to the documentation of this file.
1 /*
2  * linux/arch/unicore32/include/asm/delay.h
3  *
4  * Code specific to PKUnity SoC and UniCore ISA
5  *
6  * Copyright (C) 2001-2010 GUAN Xue-tao
7  *
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.
11  *
12  * Delay routines, using a pre-computed "loops_per_second" value.
13  */
14 #ifndef __UNICORE_DELAY_H__
15 #define __UNICORE_DELAY_H__
16 
17 #include <asm/param.h> /* HZ */
18 
19 extern void __delay(int loops);
20 
21 /*
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.
24  *
25  * With currently imposed limits, this means that we support a max delay
26  * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
27  */
28 extern void __bad_udelay(void);
29 
30 /*
31  * division by multiplication: you don't have to worry about
32  * loss of precision.
33  *
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)
39  */
40 extern void __udelay(unsigned long usecs);
41 extern void __const_udelay(unsigned long);
42 
43 #define MAX_UDELAY_MS 2
44 
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))
50 
51 #endif /* __UNICORE_DELAY_H__ */
52