aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cpufreq.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cpufreq.h')
-rw-r--r--include/linux/cpufreq.h75
1 files changed, 60 insertions, 15 deletions
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index fcabc42d66ab..5bd6ab9b0c27 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 */
@@ -180,13 +194,6 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
180struct cpufreq_driver { 194struct cpufreq_driver {
181 char name[CPUFREQ_NAME_LEN]; 195 char name[CPUFREQ_NAME_LEN];
182 u8 flags; 196 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 197
191 /* needed by all drivers */ 198 /* needed by all drivers */
192 int (*init) (struct cpufreq_policy *policy); 199 int (*init) (struct cpufreq_policy *policy);
@@ -194,9 +201,11 @@ struct cpufreq_driver {
194 201
195 /* define one out of two */ 202 /* define one out of two */
196 int (*setpolicy) (struct cpufreq_policy *policy); 203 int (*setpolicy) (struct cpufreq_policy *policy);
197 int (*target) (struct cpufreq_policy *policy, 204 int (*target) (struct cpufreq_policy *policy, /* Deprecated */
198 unsigned int target_freq, 205 unsigned int target_freq,
199 unsigned int relation); 206 unsigned int relation);
207 int (*target_index) (struct cpufreq_policy *policy,
208 unsigned int index);
200 209
201 /* should be defined, if possible */ 210 /* should be defined, if possible */
202 unsigned int (*get) (unsigned int cpu); 211 unsigned int (*get) (unsigned int cpu);
@@ -211,13 +220,29 @@ struct cpufreq_driver {
211}; 220};
212 221
213/* flags */ 222/* flags */
214#define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if 223#define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
215 * all ->init() calls failed */ 224 all ->init() calls failed */
216#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel 225#define CPUFREQ_CONST_LOOPS (1 << 1) /* loops_per_jiffy or other
217 * "constants" aren't affected by 226 kernel "constants" aren't
218 * frequency transitions */ 227 affected by frequency
219#define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed 228 transitions */
220 * mismatches */ 229#define CPUFREQ_PM_NO_WARN (1 << 2) /* don't warn on suspend/resume
230 speed mismatches */
231
232/*
233 * This should be set by platforms having multiple clock-domains, i.e.
234 * supporting multiple policies. With this sysfs directories of governor would
235 * be created in cpu/cpu<num>/cpufreq/ directory and so they can use the same
236 * governor with different tunables for different clusters.
237 */
238#define CPUFREQ_HAVE_GOVERNOR_PER_POLICY (1 << 3)
239
240/*
241 * Driver will do POSTCHANGE notifications from outside of their ->target()
242 * routine and so must set cpufreq_driver->flags with this flag, so that core
243 * can handle them specially.
244 */
245#define CPUFREQ_ASYNC_NOTIFICATION (1 << 4)
221 246
222int cpufreq_register_driver(struct cpufreq_driver *driver_data); 247int cpufreq_register_driver(struct cpufreq_driver *driver_data);
223int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); 248int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
@@ -240,6 +265,13 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
240 return; 265 return;
241} 266}
242 267
268static inline void
269cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
270{
271 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
272 policy->cpuinfo.max_freq);
273}
274
243/********************************************************************* 275/*********************************************************************
244 * CPUFREQ NOTIFIER INTERFACE * 276 * CPUFREQ NOTIFIER INTERFACE *
245 *********************************************************************/ 277 *********************************************************************/
@@ -392,6 +424,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
392 424
393int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, 425int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
394 struct cpufreq_frequency_table *table); 426 struct cpufreq_frequency_table *table);
427int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy);
395 428
396int cpufreq_frequency_table_target(struct cpufreq_policy *policy, 429int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
397 struct cpufreq_frequency_table *table, 430 struct cpufreq_frequency_table *table,
@@ -407,8 +440,20 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
407 440
408/* the following are really really optional */ 441/* the following are really really optional */
409extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; 442extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
443extern struct freq_attr *cpufreq_generic_attr[];
410void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, 444void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
411 unsigned int cpu); 445 unsigned int cpu);
412void cpufreq_frequency_table_put_attr(unsigned int cpu); 446void cpufreq_frequency_table_put_attr(unsigned int cpu);
447int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
448 struct cpufreq_frequency_table *table);
449
450int cpufreq_generic_init(struct cpufreq_policy *policy,
451 struct cpufreq_frequency_table *table,
452 unsigned int transition_latency);
453static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)
454{
455 cpufreq_frequency_table_put_attr(policy->cpu);
456 return 0;
457}
413 458
414#endif /* _LINUX_CPUFREQ_H */ 459#endif /* _LINUX_CPUFREQ_H */