Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / tools / power / cpupower / lib / cpufreq.h
blob60beaf5ed2ea4da7d69850de8719a67097c3e6e6
1 /*
2 * cpufreq.h - definitions for libcpufreq
4 * Copyright (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef __CPUPOWER_CPUFREQ_H__
17 #define __CPUPOWER_CPUFREQ_H__
19 struct cpufreq_policy {
20 unsigned long min;
21 unsigned long max;
22 char *governor;
25 struct cpufreq_available_governors {
26 char *governor;
27 struct cpufreq_available_governors *next;
28 struct cpufreq_available_governors *first;
31 struct cpufreq_available_frequencies {
32 unsigned long frequency;
33 struct cpufreq_available_frequencies *next;
34 struct cpufreq_available_frequencies *first;
38 struct cpufreq_affected_cpus {
39 unsigned int cpu;
40 struct cpufreq_affected_cpus *next;
41 struct cpufreq_affected_cpus *first;
44 struct cpufreq_stats {
45 unsigned long frequency;
46 unsigned long long time_in_state;
47 struct cpufreq_stats *next;
48 struct cpufreq_stats *first;
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
57 /* determine current CPU frequency
58 * - _kernel variant means kernel's opinion of CPU frequency
59 * - _hardware variant means actual hardware CPU frequency,
60 * which is only available to root.
62 * returns 0 on failure, else frequency in kHz.
65 unsigned long cpufreq_get_freq_kernel(unsigned int cpu);
67 unsigned long cpufreq_get_freq_hardware(unsigned int cpu);
69 #define cpufreq_get(cpu) cpufreq_get_freq_kernel(cpu);
72 /* determine CPU transition latency
74 * returns 0 on failure, else transition latency in 10^(-9) s = nanoseconds
76 unsigned long cpufreq_get_transition_latency(unsigned int cpu);
79 /* determine hardware CPU frequency limits
81 * These may be limited further by thermal, energy or other
82 * considerations by cpufreq policy notifiers in the kernel.
85 int cpufreq_get_hardware_limits(unsigned int cpu,
86 unsigned long *min,
87 unsigned long *max);
90 /* determine CPUfreq driver used
92 * Remember to call cpufreq_put_driver when no longer needed
93 * to avoid memory leakage, please.
96 char *cpufreq_get_driver(unsigned int cpu);
98 void cpufreq_put_driver(char *ptr);
101 /* determine CPUfreq policy currently used
103 * Remember to call cpufreq_put_policy when no longer needed
104 * to avoid memory leakage, please.
108 struct cpufreq_policy *cpufreq_get_policy(unsigned int cpu);
110 void cpufreq_put_policy(struct cpufreq_policy *policy);
113 /* determine CPUfreq governors currently available
115 * may be modified by modprobe'ing or rmmod'ing other governors. Please
116 * free allocated memory by calling cpufreq_put_available_governors
117 * after use.
121 struct cpufreq_available_governors
122 *cpufreq_get_available_governors(unsigned int cpu);
124 void cpufreq_put_available_governors(
125 struct cpufreq_available_governors *first);
128 /* determine CPU frequency states available
130 * Only present on _some_ ->target() cpufreq drivers. For information purposes
131 * only. Please free allocated memory by calling
132 * cpufreq_put_available_frequencies after use.
135 struct cpufreq_available_frequencies
136 *cpufreq_get_available_frequencies(unsigned int cpu);
138 void cpufreq_put_available_frequencies(
139 struct cpufreq_available_frequencies *first);
142 /* determine affected CPUs
144 * Remember to call cpufreq_put_affected_cpus when no longer needed
145 * to avoid memory leakage, please.
148 struct cpufreq_affected_cpus *cpufreq_get_affected_cpus(unsigned
149 int cpu);
151 void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *first);
154 /* determine related CPUs
156 * Remember to call cpufreq_put_related_cpus when no longer needed
157 * to avoid memory leakage, please.
160 struct cpufreq_affected_cpus *cpufreq_get_related_cpus(unsigned
161 int cpu);
163 void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *first);
166 /* determine stats for cpufreq subsystem
168 * This is not available in all kernel versions or configurations.
171 struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu,
172 unsigned long long *total_time);
174 void cpufreq_put_stats(struct cpufreq_stats *stats);
176 unsigned long cpufreq_get_transitions(unsigned int cpu);
179 /* set new cpufreq policy
181 * Tries to set the passed policy as new policy as close as possible,
182 * but results may differ depending e.g. on governors being available.
185 int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy);
188 /* modify a policy by only changing min/max freq or governor
190 * Does not check whether result is what was intended.
193 int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq);
194 int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq);
195 int cpufreq_modify_policy_governor(unsigned int cpu, char *governor);
198 /* set a specific frequency
200 * Does only work if userspace governor can be used and no external
201 * interference (other calls to this function or to set/modify_policy)
202 * occurs. Also does not work on ->range() cpufreq drivers.
205 int cpufreq_set_frequency(unsigned int cpu,
206 unsigned long target_frequency);
208 #ifdef __cplusplus
210 #endif
212 #endif /* _CPUFREQ_H */