Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
opp.c File Reference
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/cpufreq.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
#include <linux/opp.h>
#include <linux/of.h>

Go to the source code of this file.

Data Structures

struct  opp
 
struct  device_opp
 

Functions

unsigned long opp_get_voltage (struct opp *opp)
 
unsigned long opp_get_freq (struct opp *opp)
 
int opp_get_opp_count (struct device *dev)
 
struct oppopp_find_freq_exact (struct device *dev, unsigned long freq, bool available)
 
struct oppopp_find_freq_ceil (struct device *dev, unsigned long *freq)
 
struct oppopp_find_freq_floor (struct device *dev, unsigned long *freq)
 
int opp_add (struct device *dev, unsigned long freq, unsigned long u_volt)
 
int opp_enable (struct device *dev, unsigned long freq)
 
int opp_disable (struct device *dev, unsigned long freq)
 
struct srcu_notifier_headopp_get_notifier (struct device *dev)
 

Function Documentation

int opp_add ( struct device dev,
unsigned long  freq,
unsigned long  u_volt 
)

opp_add() - Add an OPP table from a table definitions : device for which we do this operation : Frequency in Hz for this OPP : Voltage in uVolts for this OPP

This function adds an opp definition to the opp list and returns status. The opp is made available by default and it can be controlled using opp_enable/disable functions.

Locking: The internal device_opp and opp structures are RCU protected. Hence this function internally uses RCU updater strategy with mutex locks to keep the integrity of the internal data structures. Callers should ensure that this function is NOT called under RCU protection or in contexts where mutex cannot be locked.

Definition at line 376 of file opp.c.

int opp_disable ( struct device dev,
unsigned long  freq 
)

opp_disable() - Disable a specific OPP : device for which we do this operation : OPP frequency to disable

Disables a provided opp. If the operation is valid, this returns 0, else the corresponding error value. It is meant to be a temporary control by users to make this OPP not available until the circumstances are right to make it available again (with a call to opp_enable).

Locking: The internal device_opp and opp structures are RCU protected. Hence this function indirectly uses RCU and mutex locks to keep the integrity of the internal data structures. Callers should ensure that this function is NOT called under RCU protection or in contexts where mutex locking or synchronize_rcu() blocking calls cannot be used.

Definition at line 572 of file opp.c.

int opp_enable ( struct device dev,
unsigned long  freq 
)

opp_enable() - Enable a specific OPP : device for which we do this operation : OPP frequency to enable

Enables a provided opp. If the operation is valid, this returns 0, else the corresponding error value. It is meant to be used for users an OPP available after being temporarily made unavailable with opp_disable.

Locking: The internal device_opp and opp structures are RCU protected. Hence this function indirectly uses RCU and mutex locks to keep the integrity of the internal data structures. Callers should ensure that this function is NOT called under RCU protection or in contexts where mutex locking or synchronize_rcu() blocking calls cannot be used.

Definition at line 551 of file opp.c.

struct opp* opp_find_freq_ceil ( struct device dev,
unsigned long freq 
)
read

opp_find_freq_ceil() - Search for an rounded ceil freq : device for which we do this operation : Start frequency

Search for the matching ceil available OPP from a starting freq for a device.

Returns matching *opp and refreshes *freq accordingly, else returns ERR_PTR in case of error and should be handled using IS_ERR.

Locking: This function must be called under rcu_read_lock(). opp is a rcu protected pointer. The reason for the same is that the opp pointer which is returned will remain valid for use with opp_get_{voltage, freq} only while under the locked area. The pointer returned must be used prior to unlocking with rcu_read_unlock() to maintain the integrity of the pointer.

Definition at line 289 of file opp.c.

struct opp* opp_find_freq_exact ( struct device dev,
unsigned long  freq,
bool  available 
)
read

opp_find_freq_exact() - search for an exact frequency : device for which we do this operation : frequency to search for : true/false - match for available opp

Searches for exact match in the opp list and returns pointer to the matching opp if found, else returns ERR_PTR in case of error and should be handled using IS_ERR.

Note: available is a modifier for the search. if available=true, then the match is for exact matching frequency and is available in the stored OPP table. if false, the match is for exact frequency which is not available.

This provides a mechanism to enable an opp which is not available currently or the opposite as well.

Locking: This function must be called under rcu_read_lock(). opp is a rcu protected pointer. The reason for the same is that the opp pointer which is returned will remain valid for use with opp_get_{voltage, freq} only while under the locked area. The pointer returned must be used prior to unlocking with rcu_read_unlock() to maintain the integrity of the pointer.

Definition at line 248 of file opp.c.

struct opp* opp_find_freq_floor ( struct device dev,
unsigned long freq 
)
read

opp_find_freq_floor() - Search for a rounded floor freq : device for which we do this operation : Start frequency

Search for the matching floor available OPP from a starting freq for a device.

Returns matching *opp and refreshes *freq accordingly, else returns ERR_PTR in case of error and should be handled using IS_ERR.

Locking: This function must be called under rcu_read_lock(). opp is a rcu protected pointer. The reason for the same is that the opp pointer which is returned will remain valid for use with opp_get_{voltage, freq} only while under the locked area. The pointer returned must be used prior to unlocking with rcu_read_unlock() to maintain the integrity of the pointer.

Definition at line 331 of file opp.c.

unsigned long opp_get_freq ( struct opp opp)

opp_get_freq() - Gets the frequency corresponding to an available opp : opp for which frequency has to be returned for

Return frequency in hertz corresponding to the opp, else return 0

Locking: This function must be called under rcu_read_lock(). opp is a rcu protected pointer. This means that opp which could have been fetched by opp_find_freq_{exact,ceil,floor} functions is valid as long as we are under RCU lock. The pointer returned by the opp_find_freq family must be used in the same section as the usage of this function with the pointer prior to unlocking with rcu_read_unlock() to maintain the integrity of the pointer.

Definition at line 179 of file opp.c.

struct srcu_notifier_head* opp_get_notifier ( struct device dev)
read

opp_get_notifier() - find notifier_head of the device with opp : device pointer used to lookup device OPPs.

Definition at line 669 of file opp.c.

int opp_get_opp_count ( struct device dev)

opp_get_opp_count() - Get number of opps available in the opp list : device for which we do this operation

This function returns the number of available opps if there are any, else returns 0 if none or the corresponding error value.

Locking: This function must be called under rcu_read_lock(). This function internally references two RCU protected structures: device_opp and opp which are safe as long as we are under a common RCU locked section.

Definition at line 204 of file opp.c.

unsigned long opp_get_voltage ( struct opp opp)

opp_get_voltage() - Gets the voltage corresponding to an available opp : opp for which voltage has to be returned for

Return voltage in micro volt corresponding to the opp, else return 0

Locking: This function must be called under rcu_read_lock(). opp is a rcu protected pointer. This means that opp which could have been fetched by opp_find_freq_{exact,ceil,floor} functions is valid as long as we are under RCU lock. The pointer returned by the opp_find_freq family must be used in the same section as the usage of this function with the pointer prior to unlocking with rcu_read_unlock() to maintain the integrity of the pointer.

Definition at line 150 of file opp.c.