| 1 |
|
| 2 |
|
| 3 |
#ifndef LIBPAYLOAD_DELAY_H |
| 4 |
#define LIBPAYLOAD_DELAY_H |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
|
| 8 |
#define NSECS_PER_SEC 1000000000 |
| 9 |
#define USECS_PER_SEC 1000000 |
| 10 |
#define MSECS_PER_SEC 1000 |
| 11 |
#define NSECS_PER_MSEC (NSECS_PER_SEC / MSECS_PER_SEC) |
| 12 |
#define NSECS_PER_USEC (NSECS_PER_SEC / USECS_PER_SEC) |
| 13 |
#define USECS_PER_MSEC (USECS_PER_SEC / MSECS_PER_SEC) |
| 14 |
|
| 15 |
unsigned int get_cpu_speed(void); |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
void ndelay(uint64_t n); |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
static inline void udelay(unsigned int us) |
| 30 |
{ |
| 31 |
ndelay((uint64_t)us * NSECS_PER_USEC); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
static inline void mdelay(unsigned int ms) |
| 40 |
{ |
| 41 |
ndelay((uint64_t)ms * NSECS_PER_MSEC); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
static inline void delay(unsigned int s) |
| 50 |
{ |
| 51 |
ndelay((uint64_t)s * NSECS_PER_SEC); |
| 52 |
} |
| 53 |
|
| 54 |
#endif |