aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2014-01-10 03:03:35 -0500
committerMax Filippov <jcmvbkbc@gmail.com>2014-01-14 15:28:11 -0500
commit9ed82c6866e2ab671935a75ea454047e8bddb177 (patch)
tree821e8d51935476350c2c5ab308931c7efc00676e
parent58f60c222e8d4503a4be654cbd6d4e190dc1a7d8 (diff)
xtensa: implement ndelay
Proper ndelay implementation allows for faster IO rate with drivers that use ndelay to access their device registers, as otherwise ndelay is emulated with udelay. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-rw-r--r--arch/xtensa/include/asm/delay.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/xtensa/include/asm/delay.h b/arch/xtensa/include/asm/delay.h
index 69ba4629bed0..24304b39a5c7 100644
--- a/arch/xtensa/include/asm/delay.h
+++ b/arch/xtensa/include/asm/delay.h
@@ -29,8 +29,10 @@ static inline void __delay(unsigned long loops)
29 29
30/* Undefined function to get compile-time error */ 30/* Undefined function to get compile-time error */
31void __bad_udelay(void); 31void __bad_udelay(void);
32void __bad_ndelay(void);
32 33
33#define __MAX_UDELAY 30000 34#define __MAX_UDELAY 30000
35#define __MAX_NDELAY 30000
34 36
35static inline void __udelay(unsigned long usecs) 37static inline void __udelay(unsigned long usecs)
36{ 38{
@@ -50,4 +52,24 @@ static inline void udelay(unsigned long usec)
50 __udelay(usec); 52 __udelay(usec);
51} 53}
52 54
55static inline void __ndelay(unsigned long nsec)
56{
57 /*
58 * Inner shift makes sure multiplication doesn't overflow
59 * for legitimate nsec values
60 */
61 unsigned long cycles = (nsec * (ccount_freq >> 15)) >> 15;
62 __delay(cycles);
63}
64
65#define ndelay(n) ndelay(n)
66
67static inline void ndelay(unsigned long nsec)
68{
69 if (__builtin_constant_p(nsec) && nsec >= __MAX_NDELAY)
70 __bad_ndelay();
71 else
72 __ndelay(nsec);
73}
74
53#endif 75#endif