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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* <rc/cpu.h>
*
* @brief Control CPU scaling governer
*
* Functions to read and set the current CPU scaling function. This is not
* specific to the beaglebone and should work on any linux system, however since
* the beaglebone has a single cpu core, this only changes the govenor for one
* core.
*
* @author James Strawson
* @date 3/7/2018
*
* @addtogroup CPU
* @{
*/
#ifndef RC_CPU_H
#define RC_CPU_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* available CPU governors
*/
typedef enum rc_governor_t{
RC_GOV_POWERSAVE, ///< Sets CPU to slowest speed
RC_GOV_PERFORMANCE, ///< Sets CPU to fastest speed
RC_GOV_ONDEMAND, ///< Default automatic scaling
RC_GOV_SCHEDUTIL, ///< Like ONDEMAND but newer algorithm
RC_GOV_CONSERVATIVE ///< Automatically scales the cpu but still tries to save power
} rc_governor_t;
/**
* @brief Sets the CPU governor. See rc_governor_t
*
* This is the equivalent to running 'cpufreq-set -g {governor}' from the
* command line but can be called in your C program instead.
*
* @param[in] gov Desired governor
*
* @return 0 on success, -1 on failure.
*/
int rc_cpu_set_governor(rc_governor_t gov);
/**
* @brief Returns the current clock speed of the Beaglebone's Sitara
* processor in the form of the provided enumerated type. It will never return
* the FREQ_ONDEMAND value as the intention of this function is to see the clock
* speed as set by either the user or the ondemand governor itself.
*
* @return frequency in hz
*/
int rc_cpu_get_freq(void);
/**
* @brief Prints the current frequency to the screen. For example "600mhz".
*
* @return 0 on success or -1 on failure.
*/
int rc_cpu_print_freq(void);
#ifdef __cplusplus
}
#endif
#endif // RC_CPU_H
/** @} end group CPU */