1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #ifndef LIBPAYLOAD_DELAY_H
4 #define LIBPAYLOAD_DELAY_H
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)
15 unsigned int get_cpu_speed(void);
17 void arch_ndelay(uint64_t n
);
20 * Delay for a specified number of nanoseconds.
22 * @param ns Number of nanoseconds to delay for.
24 static inline void ndelay(unsigned int ns
)
26 arch_ndelay((uint64_t)ns
);
30 * Delay for a specified number of microseconds.
32 * @param us Number of microseconds to delay for.
34 static inline void udelay(unsigned int us
)
36 arch_ndelay((uint64_t)us
* NSECS_PER_USEC
);
40 * Delay for a specified number of milliseconds.
42 * @param ms Number of milliseconds to delay for.
44 static inline void mdelay(unsigned int ms
)
46 arch_ndelay((uint64_t)ms
* NSECS_PER_MSEC
);
50 * Delay for a specified number of seconds.
52 * @param s Number of seconds to delay for.
54 static inline void delay(unsigned int s
)
56 arch_ndelay((uint64_t)s
* NSECS_PER_SEC
);
59 #endif /* LIBPAYLOAD_DELAY_H */