This source file includes following definitions.
- __delay
- __udelay
1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef _ASM_MICROBLAZE_DELAY_H
14 #define _ASM_MICROBLAZE_DELAY_H
15
16 #include <linux/param.h>
17
18 static inline void __delay(unsigned long loops)
19 {
20 asm volatile ("# __delay \n\t" \
21 "1: addi %0, %0, -1\t\n" \
22 "bneid %0, 1b \t\n" \
23 "nop \t\n"
24 : "=r" (loops)
25 : "0" (loops));
26 }
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 #define __MAX_UDELAY (226050910UL/HZ)
42 #define __MAX_NDELAY (4294967295UL/HZ)
43
44 extern unsigned long loops_per_jiffy;
45
46 static inline void __udelay(unsigned int x)
47 {
48
49 unsigned long long tmp =
50 (unsigned long long)x * (unsigned long long)loops_per_jiffy \
51 * 226LL;
52 unsigned loops = tmp >> 32;
53
54
55
56
57
58 __delay(loops);
59 }
60
61 extern void __bad_udelay(void);
62 extern void __bad_ndelay(void);
63
64 #define udelay(n) \
65 ({ \
66 if (__builtin_constant_p(n)) { \
67 if ((n) / __MAX_UDELAY >= 1) \
68 __bad_udelay(); \
69 else \
70 __udelay((n) * (19 * HZ)); \
71 } else { \
72 __udelay((n) * (19 * HZ)); \
73 } \
74 })
75
76 #define ndelay(n) \
77 ({ \
78 if (__builtin_constant_p(n)) { \
79 if ((n) / __MAX_NDELAY >= 1) \
80 __bad_ndelay(); \
81 else \
82 __udelay((n) * HZ); \
83 } else { \
84 __udelay((n) * HZ); \
85 } \
86 })
87
88 #define muldiv(a, b, c) (((a)*(b))/(c))
89
90 #endif