diff options
Diffstat (limited to 'include/linux/cpufreq.h')
-rw-r--r-- | include/linux/cpufreq.h | 83 |
1 files changed, 68 insertions, 15 deletions
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index fcabc42d66ab..dc196bbcf227 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -85,6 +85,20 @@ struct cpufreq_policy { | |||
85 | struct list_head policy_list; | 85 | struct list_head policy_list; |
86 | struct kobject kobj; | 86 | struct kobject kobj; |
87 | struct completion kobj_unregister; | 87 | struct completion kobj_unregister; |
88 | |||
89 | /* | ||
90 | * The rules for this semaphore: | ||
91 | * - Any routine that wants to read from the policy structure will | ||
92 | * do a down_read on this semaphore. | ||
93 | * - Any routine that will write to the policy structure and/or may take away | ||
94 | * the policy altogether (eg. CPU hotplug), will hold this lock in write | ||
95 | * mode before doing so. | ||
96 | * | ||
97 | * Additional rules: | ||
98 | * - Lock should not be held across | ||
99 | * __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); | ||
100 | */ | ||
101 | struct rw_semaphore rwsem; | ||
88 | }; | 102 | }; |
89 | 103 | ||
90 | /* Only for ACPI */ | 104 | /* Only for ACPI */ |
@@ -93,8 +107,16 @@ struct cpufreq_policy { | |||
93 | #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ | 107 | #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ |
94 | #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ | 108 | #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ |
95 | 109 | ||
110 | #ifdef CONFIG_CPU_FREQ | ||
96 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); | 111 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); |
97 | void cpufreq_cpu_put(struct cpufreq_policy *policy); | 112 | void cpufreq_cpu_put(struct cpufreq_policy *policy); |
113 | #else | ||
114 | static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) | ||
115 | { | ||
116 | return NULL; | ||
117 | } | ||
118 | static inline void cpufreq_cpu_put(struct cpufreq_policy *policy) { } | ||
119 | #endif | ||
98 | 120 | ||
99 | static inline bool policy_is_shared(struct cpufreq_policy *policy) | 121 | static inline bool policy_is_shared(struct cpufreq_policy *policy) |
100 | { | 122 | { |
@@ -180,13 +202,6 @@ __ATTR(_name, 0644, show_##_name, store_##_name) | |||
180 | struct cpufreq_driver { | 202 | struct cpufreq_driver { |
181 | char name[CPUFREQ_NAME_LEN]; | 203 | char name[CPUFREQ_NAME_LEN]; |
182 | u8 flags; | 204 | u8 flags; |
183 | /* | ||
184 | * This should be set by platforms having multiple clock-domains, i.e. | ||
185 | * supporting multiple policies. With this sysfs directories of governor | ||
186 | * would be created in cpu/cpu<num>/cpufreq/ directory and so they can | ||
187 | * use the same governor with different tunables for different clusters. | ||
188 | */ | ||
189 | bool have_governor_per_policy; | ||
190 | 205 | ||
191 | /* needed by all drivers */ | 206 | /* needed by all drivers */ |
192 | int (*init) (struct cpufreq_policy *policy); | 207 | int (*init) (struct cpufreq_policy *policy); |
@@ -194,9 +209,11 @@ struct cpufreq_driver { | |||
194 | 209 | ||
195 | /* define one out of two */ | 210 | /* define one out of two */ |
196 | int (*setpolicy) (struct cpufreq_policy *policy); | 211 | int (*setpolicy) (struct cpufreq_policy *policy); |
197 | int (*target) (struct cpufreq_policy *policy, | 212 | int (*target) (struct cpufreq_policy *policy, /* Deprecated */ |
198 | unsigned int target_freq, | 213 | unsigned int target_freq, |
199 | unsigned int relation); | 214 | unsigned int relation); |
215 | int (*target_index) (struct cpufreq_policy *policy, | ||
216 | unsigned int index); | ||
200 | 217 | ||
201 | /* should be defined, if possible */ | 218 | /* should be defined, if possible */ |
202 | unsigned int (*get) (unsigned int cpu); | 219 | unsigned int (*get) (unsigned int cpu); |
@@ -211,13 +228,29 @@ struct cpufreq_driver { | |||
211 | }; | 228 | }; |
212 | 229 | ||
213 | /* flags */ | 230 | /* flags */ |
214 | #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if | 231 | #define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if |
215 | * all ->init() calls failed */ | 232 | all ->init() calls failed */ |
216 | #define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel | 233 | #define CPUFREQ_CONST_LOOPS (1 << 1) /* loops_per_jiffy or other |
217 | * "constants" aren't affected by | 234 | kernel "constants" aren't |
218 | * frequency transitions */ | 235 | affected by frequency |
219 | #define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed | 236 | transitions */ |
220 | * mismatches */ | 237 | #define CPUFREQ_PM_NO_WARN (1 << 2) /* don't warn on suspend/resume |
238 | speed mismatches */ | ||
239 | |||
240 | /* | ||
241 | * This should be set by platforms having multiple clock-domains, i.e. | ||
242 | * supporting multiple policies. With this sysfs directories of governor would | ||
243 | * be created in cpu/cpu<num>/cpufreq/ directory and so they can use the same | ||
244 | * governor with different tunables for different clusters. | ||
245 | */ | ||
246 | #define CPUFREQ_HAVE_GOVERNOR_PER_POLICY (1 << 3) | ||
247 | |||
248 | /* | ||
249 | * Driver will do POSTCHANGE notifications from outside of their ->target() | ||
250 | * routine and so must set cpufreq_driver->flags with this flag, so that core | ||
251 | * can handle them specially. | ||
252 | */ | ||
253 | #define CPUFREQ_ASYNC_NOTIFICATION (1 << 4) | ||
221 | 254 | ||
222 | int cpufreq_register_driver(struct cpufreq_driver *driver_data); | 255 | int cpufreq_register_driver(struct cpufreq_driver *driver_data); |
223 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); | 256 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); |
@@ -240,6 +273,13 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, | |||
240 | return; | 273 | return; |
241 | } | 274 | } |
242 | 275 | ||
276 | static inline void | ||
277 | cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy) | ||
278 | { | ||
279 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | ||
280 | policy->cpuinfo.max_freq); | ||
281 | } | ||
282 | |||
243 | /********************************************************************* | 283 | /********************************************************************* |
244 | * CPUFREQ NOTIFIER INTERFACE * | 284 | * CPUFREQ NOTIFIER INTERFACE * |
245 | *********************************************************************/ | 285 | *********************************************************************/ |
@@ -392,6 +432,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | |||
392 | 432 | ||
393 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | 433 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, |
394 | struct cpufreq_frequency_table *table); | 434 | struct cpufreq_frequency_table *table); |
435 | int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy); | ||
395 | 436 | ||
396 | int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | 437 | int cpufreq_frequency_table_target(struct cpufreq_policy *policy, |
397 | struct cpufreq_frequency_table *table, | 438 | struct cpufreq_frequency_table *table, |
@@ -407,8 +448,20 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu); | |||
407 | 448 | ||
408 | /* the following are really really optional */ | 449 | /* the following are really really optional */ |
409 | extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; | 450 | extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; |
451 | extern struct freq_attr *cpufreq_generic_attr[]; | ||
410 | void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, | 452 | void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, |
411 | unsigned int cpu); | 453 | unsigned int cpu); |
412 | void cpufreq_frequency_table_put_attr(unsigned int cpu); | 454 | void cpufreq_frequency_table_put_attr(unsigned int cpu); |
455 | int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, | ||
456 | struct cpufreq_frequency_table *table); | ||
457 | |||
458 | int cpufreq_generic_init(struct cpufreq_policy *policy, | ||
459 | struct cpufreq_frequency_table *table, | ||
460 | unsigned int transition_latency); | ||
461 | static inline int cpufreq_generic_exit(struct cpufreq_policy *policy) | ||
462 | { | ||
463 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
464 | return 0; | ||
465 | } | ||
413 | 466 | ||
414 | #endif /* _LINUX_CPUFREQ_H */ | 467 | #endif /* _LINUX_CPUFREQ_H */ |