File: delay.h

package info (click to toggle)
coreboot 25.09%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 217,084 kB
  • sloc: ansic: 1,685,313; sh: 15,803; python: 11,200; perl: 10,186; asm: 8,519; makefile: 5,179; cpp: 4,724; pascal: 2,327; ada: 1,985; yacc: 1,264; lex: 731; sed: 75; ruby: 5; lisp: 5; awk: 4
file content (54 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* SPDX-License-Identifier: BSD-3-Clause */

#ifndef LIBPAYLOAD_DELAY_H
#define LIBPAYLOAD_DELAY_H

#include <stdint.h>

#define NSECS_PER_SEC 1000000000
#define USECS_PER_SEC 1000000
#define MSECS_PER_SEC 1000
#define NSECS_PER_MSEC (NSECS_PER_SEC / MSECS_PER_SEC)
#define NSECS_PER_USEC (NSECS_PER_SEC / USECS_PER_SEC)
#define USECS_PER_MSEC (USECS_PER_SEC / MSECS_PER_SEC)

unsigned int get_cpu_speed(void);

/**
 * Delay for a specified number of nanoseconds.
 *
 * @param ns Number of nanoseconds to delay for.
 */
void ndelay(uint64_t n);

/**
 * Delay for a specified number of microseconds.
 *
 * @param us Number of microseconds to delay for.
 */
static inline void udelay(unsigned int us)
{
	ndelay((uint64_t)us * NSECS_PER_USEC);
}

/**
 * Delay for a specified number of milliseconds.
 *
 * @param ms Number of milliseconds to delay for.
 */
static inline void mdelay(unsigned int ms)
{
	ndelay((uint64_t)ms * NSECS_PER_MSEC);
}

/**
 * Delay for a specified number of seconds.
 *
 * @param s Number of seconds to delay for.
 */
static inline void delay(unsigned int s)
{
	ndelay((uint64_t)s * NSECS_PER_SEC);
}

#endif /* LIBPAYLOAD_DELAY_H */