Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.17-rc2 212 lines 5.4 kB view raw
1/* 2 * cpufreq.h - definitions for libcpufreq 3 * 4 * Copyright (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de> 5 * 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. 9 * 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. 14 */ 15 16#ifndef __CPUPOWER_CPUFREQ_H__ 17#define __CPUPOWER_CPUFREQ_H__ 18 19struct cpufreq_policy { 20 unsigned long min; 21 unsigned long max; 22 char *governor; 23}; 24 25struct cpufreq_available_governors { 26 char *governor; 27 struct cpufreq_available_governors *next; 28 struct cpufreq_available_governors *first; 29}; 30 31struct cpufreq_available_frequencies { 32 unsigned long frequency; 33 struct cpufreq_available_frequencies *next; 34 struct cpufreq_available_frequencies *first; 35}; 36 37 38struct cpufreq_affected_cpus { 39 unsigned int cpu; 40 struct cpufreq_affected_cpus *next; 41 struct cpufreq_affected_cpus *first; 42}; 43 44struct cpufreq_stats { 45 unsigned long frequency; 46 unsigned long long time_in_state; 47 struct cpufreq_stats *next; 48 struct cpufreq_stats *first; 49}; 50 51 52 53#ifdef __cplusplus 54extern "C" { 55#endif 56 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. 61 * 62 * returns 0 on failure, else frequency in kHz. 63 */ 64 65unsigned long cpufreq_get_freq_kernel(unsigned int cpu); 66 67unsigned long cpufreq_get_freq_hardware(unsigned int cpu); 68 69#define cpufreq_get(cpu) cpufreq_get_freq_kernel(cpu); 70 71 72/* determine CPU transition latency 73 * 74 * returns 0 on failure, else transition latency in 10^(-9) s = nanoseconds 75 */ 76unsigned long cpufreq_get_transition_latency(unsigned int cpu); 77 78 79/* determine hardware CPU frequency limits 80 * 81 * These may be limited further by thermal, energy or other 82 * considerations by cpufreq policy notifiers in the kernel. 83 */ 84 85int cpufreq_get_hardware_limits(unsigned int cpu, 86 unsigned long *min, 87 unsigned long *max); 88 89 90/* determine CPUfreq driver used 91 * 92 * Remember to call cpufreq_put_driver when no longer needed 93 * to avoid memory leakage, please. 94 */ 95 96char *cpufreq_get_driver(unsigned int cpu); 97 98void cpufreq_put_driver(char *ptr); 99 100 101/* determine CPUfreq policy currently used 102 * 103 * Remember to call cpufreq_put_policy when no longer needed 104 * to avoid memory leakage, please. 105 */ 106 107 108struct cpufreq_policy *cpufreq_get_policy(unsigned int cpu); 109 110void cpufreq_put_policy(struct cpufreq_policy *policy); 111 112 113/* determine CPUfreq governors currently available 114 * 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. 118 */ 119 120 121struct cpufreq_available_governors 122*cpufreq_get_available_governors(unsigned int cpu); 123 124void cpufreq_put_available_governors( 125 struct cpufreq_available_governors *first); 126 127 128/* determine CPU frequency states available 129 * 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. 133 */ 134 135struct cpufreq_available_frequencies 136*cpufreq_get_available_frequencies(unsigned int cpu); 137 138void cpufreq_put_available_frequencies( 139 struct cpufreq_available_frequencies *first); 140 141 142/* determine affected CPUs 143 * 144 * Remember to call cpufreq_put_affected_cpus when no longer needed 145 * to avoid memory leakage, please. 146 */ 147 148struct cpufreq_affected_cpus *cpufreq_get_affected_cpus(unsigned 149 int cpu); 150 151void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *first); 152 153 154/* determine related CPUs 155 * 156 * Remember to call cpufreq_put_related_cpus when no longer needed 157 * to avoid memory leakage, please. 158 */ 159 160struct cpufreq_affected_cpus *cpufreq_get_related_cpus(unsigned 161 int cpu); 162 163void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *first); 164 165 166/* determine stats for cpufreq subsystem 167 * 168 * This is not available in all kernel versions or configurations. 169 */ 170 171struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu, 172 unsigned long long *total_time); 173 174void cpufreq_put_stats(struct cpufreq_stats *stats); 175 176unsigned long cpufreq_get_transitions(unsigned int cpu); 177 178 179/* set new cpufreq policy 180 * 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. 183 */ 184 185int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy); 186 187 188/* modify a policy by only changing min/max freq or governor 189 * 190 * Does not check whether result is what was intended. 191 */ 192 193int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq); 194int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq); 195int cpufreq_modify_policy_governor(unsigned int cpu, char *governor); 196 197 198/* set a specific frequency 199 * 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. 203 */ 204 205int cpufreq_set_frequency(unsigned int cpu, 206 unsigned long target_frequency); 207 208#ifdef __cplusplus 209} 210#endif 211 212#endif /* _CPUFREQ_H */