Debian Codegraph @

payloads/libpayload/include/delay.h

raw symbols SCIP
1 /* SPDX-License-Identifier: BSD-3-Clause */
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 * Delay for a specified number of nanoseconds.
19 *
20 * @param ns Number of nanoseconds to delay for.
21 */
22 void ndelay(uint64_t n);
23
24 /**
25 * Delay for a specified number of microseconds.
26 *
27 * @param us Number of microseconds to delay for.
28 */
29 static inline void udelay(unsigned int us)
30 {
31 ndelay((uint64_t)us * NSECS_PER_USEC);
32 }
33
34 /**
35 * Delay for a specified number of milliseconds.
36 *
37 * @param ms Number of milliseconds to delay for.
38 */
39 static inline void mdelay(unsigned int ms)
40 {
41 ndelay((uint64_t)ms * NSECS_PER_MSEC);
42 }
43
44 /**
45 * Delay for a specified number of seconds.
46 *
47 * @param s Number of seconds to delay for.
48 */
49 static inline void delay(unsigned int s)
50 {
51 ndelay((uint64_t)s * NSECS_PER_SEC);
52 }
53
54 #endif /* LIBPAYLOAD_DELAY_H */