mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 22:51:42 +00:00
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>
This commit is contained in:
parent
58f60c222e
commit
9ed82c6866
@ -29,8 +29,10 @@ static inline void __delay(unsigned long loops)
|
|||||||
|
|
||||||
/* Undefined function to get compile-time error */
|
/* Undefined function to get compile-time error */
|
||||||
void __bad_udelay(void);
|
void __bad_udelay(void);
|
||||||
|
void __bad_ndelay(void);
|
||||||
|
|
||||||
#define __MAX_UDELAY 30000
|
#define __MAX_UDELAY 30000
|
||||||
|
#define __MAX_NDELAY 30000
|
||||||
|
|
||||||
static inline void __udelay(unsigned long usecs)
|
static inline void __udelay(unsigned long usecs)
|
||||||
{
|
{
|
||||||
@ -50,4 +52,24 @@ static inline void udelay(unsigned long usec)
|
|||||||
__udelay(usec);
|
__udelay(usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void __ndelay(unsigned long nsec)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Inner shift makes sure multiplication doesn't overflow
|
||||||
|
* for legitimate nsec values
|
||||||
|
*/
|
||||||
|
unsigned long cycles = (nsec * (ccount_freq >> 15)) >> 15;
|
||||||
|
__delay(cycles);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ndelay(n) ndelay(n)
|
||||||
|
|
||||||
|
static inline void ndelay(unsigned long nsec)
|
||||||
|
{
|
||||||
|
if (__builtin_constant_p(nsec) && nsec >= __MAX_NDELAY)
|
||||||
|
__bad_ndelay();
|
||||||
|
else
|
||||||
|
__ndelay(nsec);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user