Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
cpufreq.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/notifier.h>
#include <linux/cpufreq.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/cpu.h>
#include <linux/completion.h>
#include <linux/mutex.h>
#include <linux/syscore_ops.h>
#include <trace/events/power.h>

Go to the source code of this file.


#define lock_policy_rwsem(mode, cpu)
#define show_one(file_name, object)
#define store_one(file_name, object)
#define to_policy(k)   container_of(k, struct cpufreq_policy, kobj)
#define to_attr(a)   container_of(a, struct freq_attr, attr)


 lock_policy_rwsem (read, cpu)
 lock_policy_rwsem (write, cpu)
 pure_initcall (init_cpufreq_transition_notifier_list)
int cpufreq_disabled (void)
void disable_cpufreq (void)
struct cpufreq_policycpufreq_cpu_get (unsigned int cpu)
 EXPORT_SYMBOL_GPL (cpufreq_cpu_get)
void cpufreq_cpu_put (struct cpufreq_policy *data)
 EXPORT_SYMBOL_GPL (cpufreq_cpu_put)
void cpufreq_notify_transition (struct cpufreq_freqs *freqs, unsigned int state)
 EXPORT_SYMBOL_GPL (cpufreq_notify_transition)
 show_one (cpuinfo_min_freq, cpuinfo.min_freq)
 show_one (cpuinfo_max_freq, cpuinfo.max_freq)
 show_one (cpuinfo_transition_latency, cpuinfo.transition_latency)
 show_one (scaling_min_freq, min)
 show_one (scaling_max_freq, max)
 show_one (scaling_cur_freq, cur)
 store_one (scaling_min_freq, min)
 store_one (scaling_max_freq, max)
 cpufreq_freq_attr_ro_perm (cpuinfo_cur_freq, 0400)
 cpufreq_freq_attr_ro (cpuinfo_min_freq)
 cpufreq_freq_attr_ro (cpuinfo_max_freq)
 cpufreq_freq_attr_ro (cpuinfo_transition_latency)
 cpufreq_freq_attr_ro (scaling_available_governors)
 cpufreq_freq_attr_ro (scaling_driver)
 cpufreq_freq_attr_ro (scaling_cur_freq)
 cpufreq_freq_attr_ro (bios_limit)
 cpufreq_freq_attr_ro (related_cpus)
 cpufreq_freq_attr_ro (affected_cpus)
 cpufreq_freq_attr_rw (scaling_min_freq)
 cpufreq_freq_attr_rw (scaling_max_freq)
 cpufreq_freq_attr_rw (scaling_governor)
 cpufreq_freq_attr_rw (scaling_setspeed)
 EXPORT_SYMBOL (cpufreq_global_kobject)
unsigned int cpufreq_quick_get (unsigned int cpu)
 EXPORT_SYMBOL (cpufreq_quick_get)
unsigned int cpufreq_quick_get_max (unsigned int cpu)
 EXPORT_SYMBOL (cpufreq_quick_get_max)
unsigned int cpufreq_get (unsigned int cpu)
 EXPORT_SYMBOL (cpufreq_get)
int cpufreq_register_notifier (struct notifier_block *nb, unsigned int list)
 EXPORT_SYMBOL (cpufreq_register_notifier)
int cpufreq_unregister_notifier (struct notifier_block *nb, unsigned int list)
 EXPORT_SYMBOL (cpufreq_unregister_notifier)
int __cpufreq_driver_target (struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation)
 EXPORT_SYMBOL_GPL (__cpufreq_driver_target)
int cpufreq_driver_target (struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation)
 EXPORT_SYMBOL_GPL (cpufreq_driver_target)
int __cpufreq_driver_getavg (struct cpufreq_policy *policy, unsigned int cpu)
 EXPORT_SYMBOL_GPL (__cpufreq_driver_getavg)
int cpufreq_register_governor (struct cpufreq_governor *governor)
 EXPORT_SYMBOL_GPL (cpufreq_register_governor)
void cpufreq_unregister_governor (struct cpufreq_governor *governor)
 EXPORT_SYMBOL_GPL (cpufreq_unregister_governor)
int cpufreq_get_policy (struct cpufreq_policy *policy, unsigned int cpu)
 EXPORT_SYMBOL (cpufreq_get_policy)
int cpufreq_update_policy (unsigned int cpu)
 EXPORT_SYMBOL (cpufreq_update_policy)
int cpufreq_register_driver (struct cpufreq_driver *driver_data)
 EXPORT_SYMBOL_GPL (cpufreq_register_driver)
int cpufreq_unregister_driver (struct cpufreq_driver *driver)
 EXPORT_SYMBOL_GPL (cpufreq_unregister_driver)
 core_initcall (cpufreq_core_init)


struct kobjectcpufreq_global_kobject

Macro Definition Documentation

#define lock_policy_rwsem (   mode,
static int lock_policy_rwsem_##mode \
(int cpu) \
{ \
int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \
BUG_ON(policy_cpu == -1); \
down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \
if (unlikely(!cpu_online(cpu))) { \
up_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \
return -1; \
} \
return 0; \

Definition at line 70 of file cpufreq.c.

#define show_one (   file_name,
static ssize_t show_##file_name \
(struct cpufreq_policy *policy, char *buf) \
{ \
return sprintf(buf, "%u\n", policy->object); \

cpufreq_per_cpu_attr_read() / show_#file_name() - print out cpufreq information

Write out information from cpufreq_driver->policy[cpu]; object must be "unsigned int".

Definition at line 381 of file cpufreq.c.

#define store_one (   file_name,
static ssize_t store_##file_name \
(struct cpufreq_policy *policy, const char *buf, size_t count) \
{ \
unsigned int ret = -EINVAL; \
struct cpufreq_policy new_policy; \
ret = cpufreq_get_policy(&new_policy, policy->cpu); \
if (ret) \
return -EINVAL; \
ret = sscanf(buf, "%u", &new_policy.object); \
if (ret != 1) \
return -EINVAL; \
ret = __cpufreq_set_policy(policy, &new_policy); \
policy->user_policy.object = policy->object; \
return ret ? ret : count; \

cpufreq_per_cpu_attr_write() / store_#file_name() - sysfs write access

Definition at line 401 of file cpufreq.c.

#define to_attr (   a)    container_of(a, struct freq_attr, attr)

Definition at line 632 of file cpufreq.c.

#define to_policy (   k)    container_of(k, struct cpufreq_policy, kobj)

Definition at line 631 of file cpufreq.c.

Function Documentation

int __cpufreq_driver_getavg ( struct cpufreq_policy policy,
unsigned int  cpu 

Definition at line 1508 of file cpufreq.c.

int __cpufreq_driver_target ( struct cpufreq_policy policy,
unsigned int  target_freq,
unsigned int  relation 

Definition at line 1466 of file cpufreq.c.

core_initcall ( cpufreq_core_init  )
struct cpufreq_policy* cpufreq_cpu_get ( unsigned int  cpu)

Definition at line 179 of file cpufreq.c.

void cpufreq_cpu_put ( struct cpufreq_policy data)

Definition at line 197 of file cpufreq.c.

int cpufreq_disabled ( void  )

Definition at line 130 of file cpufreq.c.

int cpufreq_driver_target ( struct cpufreq_policy policy,
unsigned int  target_freq,
unsigned int  relation 

Definition at line 1484 of file cpufreq.c.

cpufreq_freq_attr_ro ( cpuinfo_min_freq  )
cpufreq_freq_attr_ro ( cpuinfo_max_freq  )
cpufreq_freq_attr_ro ( cpuinfo_transition_latency  )
cpufreq_freq_attr_ro ( scaling_available_governors  )
cpufreq_freq_attr_ro ( scaling_driver  )
cpufreq_freq_attr_ro ( scaling_cur_freq  )
cpufreq_freq_attr_ro ( bios_limit  )
cpufreq_freq_attr_ro ( related_cpus  )
cpufreq_freq_attr_ro ( affected_cpus  )
cpufreq_freq_attr_ro_perm ( cpuinfo_cur_freq  ,
cpufreq_freq_attr_rw ( scaling_min_freq  )
cpufreq_freq_attr_rw ( scaling_max_freq  )
cpufreq_freq_attr_rw ( scaling_governor  )
cpufreq_freq_attr_rw ( scaling_setspeed  )
unsigned int cpufreq_get ( unsigned int  cpu)

cpufreq_get - get the current CPU frequency (in kHz) : CPU number

Get the CPU current (static) CPU frequency

Definition at line 1279 of file cpufreq.c.

int cpufreq_get_policy ( struct cpufreq_policy policy,
unsigned int  cpu 

cpufreq_get_policy - get the current cpufreq_policy : struct cpufreq_policy into which the current cpufreq_policy is written

Reads the current cpufreq policy.

Definition at line 1641 of file cpufreq.c.

void cpufreq_notify_transition ( struct cpufreq_freqs freqs,
unsigned int  state 

cpufreq_notify_transition - call notifier chain and adjust_jiffies on frequency transition.

This function calls the transition notifiers and the "adjust_jiffies" function. It is called twice on all CPU frequency changes that have external effects.

Definition at line 259 of file cpufreq.c.

unsigned int cpufreq_quick_get ( unsigned int  cpu)

cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur : CPU number

This is the last known freq, without actually getting it from the driver. Return value will be same as what is shown in scaling_cur_freq in sysfs.

Definition at line 1215 of file cpufreq.c.

unsigned int cpufreq_quick_get_max ( unsigned int  cpu)

cpufreq_quick_get_max - get the max reported CPU frequency for this CPU : CPU number

Just return the max possible frequency for a given CPU.

Definition at line 1235 of file cpufreq.c.

int cpufreq_register_driver ( struct cpufreq_driver driver_data)

cpufreq_register_driver - register a CPU Frequency driver : A struct cpufreq_driver containing the values# submitted by the CPU Frequency driver.

Registers a CPU Frequency driver to this core code. This code returns zero on success, -EBUSY when another driver got here first (and isn't unregistered in the meantime).

Definition at line 1849 of file cpufreq.c.

int cpufreq_register_governor ( struct cpufreq_governor governor)

Definition at line 1576 of file cpufreq.c.

int cpufreq_register_notifier ( struct notifier_block nb,
unsigned int  list 

cpufreq_register_notifier - register a driver with cpufreq : notifier function to register : CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER

Add a driver to one of two lists: either a list of drivers that are notified about clock rate changes (once before and once after the transition), or a list of drivers that are notified about changes in cpufreq policy.

This function may sleep, and has the same return conditions as blocking_notifier_chain_register.

Definition at line 1405 of file cpufreq.c.

int cpufreq_unregister_driver ( struct cpufreq_driver driver)

cpufreq_unregister_driver - unregister the current CPUFreq driver

Unregister the current CPUFreq driver. Only call this if you have the right to do so, i.e. if you have succeeded in initialising before! Returns zero if successful, and -EINVAL if the cpufreq_driver is currently not initialised.

Definition at line 1920 of file cpufreq.c.

void cpufreq_unregister_governor ( struct cpufreq_governor governor)

Definition at line 1600 of file cpufreq.c.

int cpufreq_unregister_notifier ( struct notifier_block nb,
unsigned int  list 

cpufreq_unregister_notifier - unregister a driver with cpufreq : notifier block to be unregistered : CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER

Remove a driver from the CPU frequency notifier list.

This function may sleep, and has the same return conditions as blocking_notifier_chain_unregister.

Definition at line 1439 of file cpufreq.c.

int cpufreq_update_policy ( unsigned int  cpu)

cpufreq_update_policy - re-evaluate an existing cpufreq policy : CPU which shall be re-evaluated

Useful for policy notifiers which have different necessities at different times.

Definition at line 1754 of file cpufreq.c.

void disable_cpufreq ( void  )

Definition at line 134 of file cpufreq.c.

EXPORT_SYMBOL ( cpufreq_global_kobject  )
EXPORT_SYMBOL ( cpufreq_quick_get  )
EXPORT_SYMBOL ( cpufreq_quick_get_max  )
EXPORT_SYMBOL ( cpufreq_get  )
EXPORT_SYMBOL ( cpufreq_register_notifier  )
EXPORT_SYMBOL ( cpufreq_unregister_notifier  )
EXPORT_SYMBOL ( cpufreq_get_policy  )
EXPORT_SYMBOL ( cpufreq_update_policy  )
EXPORT_SYMBOL_GPL ( cpufreq_cpu_get  )
EXPORT_SYMBOL_GPL ( cpufreq_cpu_put  )
EXPORT_SYMBOL_GPL ( cpufreq_notify_transition  )
EXPORT_SYMBOL_GPL ( __cpufreq_driver_target  )
EXPORT_SYMBOL_GPL ( cpufreq_driver_target  )
EXPORT_SYMBOL_GPL ( __cpufreq_driver_getavg  )
EXPORT_SYMBOL_GPL ( cpufreq_register_governor  )
EXPORT_SYMBOL_GPL ( cpufreq_unregister_governor  )
EXPORT_SYMBOL_GPL ( cpufreq_register_driver  )
EXPORT_SYMBOL_GPL ( cpufreq_unregister_driver  )
lock_policy_rwsem ( read  ,
lock_policy_rwsem ( write  ,
pure_initcall ( init_cpufreq_transition_notifier_list  )
show_one ( cpuinfo_min_freq  ,
cpuinfo.  min_freq 
show_one ( cpuinfo_max_freq  ,
cpuinfo.  max_freq 
show_one ( cpuinfo_transition_latency  ,
cpuinfo.  transition_latency 
show_one ( scaling_min_freq  ,
show_one ( scaling_max_freq  ,
show_one ( scaling_cur_freq  ,
store_one ( scaling_min_freq  ,
store_one ( scaling_max_freq  ,

Variable Documentation

struct kobject* cpufreq_global_kobject

Definition at line 628 of file cpufreq.c.