Linux Kernel
3.7.1
|
#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 opp * | opp_find_freq_exact (struct device *dev, unsigned long freq, bool available) |
struct opp * | opp_find_freq_ceil (struct device *dev, unsigned long *freq) |
struct opp * | opp_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_head * | opp_get_notifier (struct device *dev) |
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.
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.
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.
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.
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.
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.
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.
|
read |
opp_get_notifier() - find notifier_head of the device with opp : device pointer used to lookup device OPPs.
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.
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.