Linux Kernel
3.7.1
|
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/async.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/suspend.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/module.h>
#include <trace/events/regulator.h>
#include "dummy.h"
Go to the source code of this file.
Data Structures | |
struct | regulator_map |
struct | regulator |
Macros | |
#define | CREATE_TRACE_POINTS |
#define | rdev_crit(rdev, fmt,...) pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) |
#define | rdev_err(rdev, fmt,...) pr_err("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) |
#define | rdev_warn(rdev, fmt,...) pr_warn("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) |
#define | rdev_info(rdev, fmt,...) pr_info("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) |
#define | rdev_dbg(rdev, fmt,...) pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) |
#define | REG_STR_SIZE 64 |
core_initcall | ( | regulator_init | ) |
int devm_regulator_bulk_get | ( | struct device * | dev, |
int | num_consumers, | ||
struct regulator_bulk_data * | consumers | ||
) |
devm_regulator_bulk_get - managed get multiple regulator consumers
: Device to supply : Number of consumers to register : Configuration of consumers; clients are stored here.
This helper function allows drivers to get several regulator consumers in one operation with management, the regulators will automatically be freed when the device is unbound. If any of the regulators cannot be acquired then any regulators that were allocated will be freed before returning to the caller.
devm_regulator_get - Resource managed regulator_get() : device for regulator "consumer" : Supply name or regulator ID.
Managed regulator_get(). Regulators returned from this function are automatically regulator_put() on driver detach. See regulator_get() for more information.
devm_regulator_put - Resource managed regulator_put() : regulator to free
Deallocate a regulator allocated with devm_regulator_get(). Normally this function will not need to be called and the resource management code will ensure that the resource is freed.
EXPORT_SYMBOL_GPL | ( | regulator_get | ) |
EXPORT_SYMBOL_GPL | ( | devm_regulator_get | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_exclusive | ) |
EXPORT_SYMBOL_GPL | ( | regulator_put | ) |
EXPORT_SYMBOL_GPL | ( | devm_regulator_put | ) |
EXPORT_SYMBOL_GPL | ( | regulator_enable | ) |
EXPORT_SYMBOL_GPL | ( | regulator_disable | ) |
EXPORT_SYMBOL_GPL | ( | regulator_force_disable | ) |
EXPORT_SYMBOL_GPL | ( | regulator_disable_deferred | ) |
EXPORT_SYMBOL_GPL | ( | regulator_is_enabled_regmap | ) |
EXPORT_SYMBOL_GPL | ( | regulator_enable_regmap | ) |
EXPORT_SYMBOL_GPL | ( | regulator_disable_regmap | ) |
EXPORT_SYMBOL_GPL | ( | regulator_is_enabled | ) |
EXPORT_SYMBOL_GPL | ( | regulator_count_voltages | ) |
EXPORT_SYMBOL_GPL | ( | regulator_list_voltage_linear | ) |
EXPORT_SYMBOL_GPL | ( | regulator_list_voltage_table | ) |
EXPORT_SYMBOL_GPL | ( | regulator_list_voltage | ) |
EXPORT_SYMBOL_GPL | ( | regulator_is_supported_voltage | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_voltage_sel_regmap | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_voltage_sel_regmap | ) |
EXPORT_SYMBOL_GPL | ( | regulator_map_voltage_iterate | ) |
EXPORT_SYMBOL_GPL | ( | regulator_map_voltage_linear | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_voltage | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_voltage_time | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_voltage_time_sel | ) |
EXPORT_SYMBOL_GPL | ( | regulator_sync_voltage | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_voltage | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_current_limit | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_current_limit | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_mode | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_mode | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_optimum_mode | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_bypass_regmap | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_bypass_regmap | ) |
EXPORT_SYMBOL_GPL | ( | regulator_allow_bypass | ) |
EXPORT_SYMBOL_GPL | ( | regulator_register_notifier | ) |
EXPORT_SYMBOL_GPL | ( | regulator_unregister_notifier | ) |
EXPORT_SYMBOL_GPL | ( | regulator_bulk_get | ) |
EXPORT_SYMBOL_GPL | ( | devm_regulator_bulk_get | ) |
EXPORT_SYMBOL_GPL | ( | regulator_bulk_enable | ) |
EXPORT_SYMBOL_GPL | ( | regulator_bulk_disable | ) |
EXPORT_SYMBOL_GPL | ( | regulator_bulk_force_disable | ) |
EXPORT_SYMBOL_GPL | ( | regulator_bulk_free | ) |
EXPORT_SYMBOL_GPL | ( | regulator_notifier_call_chain | ) |
EXPORT_SYMBOL_GPL | ( | regulator_mode_to_status | ) |
EXPORT_SYMBOL_GPL | ( | regulator_register | ) |
EXPORT_SYMBOL_GPL | ( | regulator_unregister | ) |
EXPORT_SYMBOL_GPL | ( | regulator_suspend_prepare | ) |
EXPORT_SYMBOL_GPL | ( | regulator_suspend_finish | ) |
EXPORT_SYMBOL_GPL | ( | regulator_has_full_constraints | ) |
EXPORT_SYMBOL_GPL | ( | regulator_use_dummy_regulator | ) |
EXPORT_SYMBOL_GPL | ( | rdev_get_drvdata | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_drvdata | ) |
EXPORT_SYMBOL_GPL | ( | regulator_set_drvdata | ) |
EXPORT_SYMBOL_GPL | ( | rdev_get_id | ) |
EXPORT_SYMBOL_GPL | ( | rdev_get_dev | ) |
EXPORT_SYMBOL_GPL | ( | regulator_get_init_drvdata | ) |
late_initcall | ( | regulator_init_complete | ) |
|
read |
void* rdev_get_drvdata | ( | struct regulator_dev * | rdev | ) |
int rdev_get_id | ( | struct regulator_dev * | rdev | ) |
regulator_allow_bypass - allow the regulator to go into bypass mode
: Regulator to configure : enable or disable bypass mode
Allow the regulator to go into bypass mode if all other consumers for the regulator also enable bypass mode and the machine constraints allow this. Bypass mode means that the regulator is simply passing the input directly to the output with no regulation.
int regulator_bulk_disable | ( | int | num_consumers, |
struct regulator_bulk_data * | consumers | ||
) |
regulator_bulk_disable - disable multiple regulator consumers
: Number of consumers : Consumer data; clients are stored here.
This convenience API allows consumers to disable multiple regulator clients in a single API call. If any consumers cannot be disabled then any others that were disabled will be enabled again prior to return.
int regulator_bulk_enable | ( | int | num_consumers, |
struct regulator_bulk_data * | consumers | ||
) |
regulator_bulk_enable - enable multiple regulator consumers
: Number of consumers : Consumer data; clients are stored here.
This convenience API allows consumers to enable multiple regulator clients in a single API call. If any consumers cannot be enabled then any others that were enabled will be disabled again prior to return.
int regulator_bulk_force_disable | ( | int | num_consumers, |
struct regulator_bulk_data * | consumers | ||
) |
regulator_bulk_force_disable - force disable multiple regulator consumers
: Number of consumers : Consumer data; clients are stored here.
This convenience API allows consumers to forcibly disable multiple regulator clients in a single API call. NOTE: This should be used for situations when device damage will likely occur if the regulators are not disabled (e.g. over temp). Although regulator_force_disable function call for some consumers can return error numbers, the function is called for all consumers.
void regulator_bulk_free | ( | int | num_consumers, |
struct regulator_bulk_data * | consumers | ||
) |
int regulator_bulk_get | ( | struct device * | dev, |
int | num_consumers, | ||
struct regulator_bulk_data * | consumers | ||
) |
regulator_bulk_get - get multiple regulator consumers
: Device to supply : Number of consumers to register : Configuration of consumers; clients are stored here.
This helper function allows drivers to get several regulator consumers in one operation. If any of the regulators cannot be acquired then any regulators that were allocated will be freed before returning to the caller.
regulator_count_voltages - count regulator_list_voltage() selectors : regulator source
Returns number of selectors, or negative errno. Selectors are numbered starting at zero, and typically correspond to bitfields in hardware registers.
regulator_disable - disable regulator output : regulator source
Disable the regulator output voltage or current. Calls to regulator_enable() must be balanced with calls to regulator_disable().
NOTE: this will only disable the regulator output if no other consumer devices have it enabled, the regulator device supports disabling and machine constraints permit this operation.
regulator_disable_deferred - disable regulator output with delay : regulator source : miliseconds until the regulator is disabled
Execute regulator_disable() on the regulator after a delay. This is intended for use with devices that require some time to quiesce.
NOTE: this will only disable the regulator output if no other consumer devices have it enabled, the regulator device supports disabling and machine constraints permit this operation.
int regulator_disable_regmap | ( | struct regulator_dev * | rdev | ) |
regulator_enable - enable regulator output : regulator source
Request that the regulator be enabled with the regulator output at the predefined voltage or current value. Calls to regulator_enable() must be balanced with calls to regulator_disable().
NOTE: the output value can be set by other drivers, boot loader or may be hardwired in the regulator.
int regulator_enable_regmap | ( | struct regulator_dev * | rdev | ) |
regulator_force_disable - force disable regulator output : regulator source
Forcibly disable the regulator output voltage or current. NOTE: this will disable the regulator output even if other consumer devices have it enabled. This should be used for situations when device damage will likely occur if the regulator is not disabled (e.g. over temp).
regulator_get - lookup and obtain a reference to a regulator. : device for regulator "consumer" : Supply name or regulator ID.
Returns a struct regulator corresponding to the regulator producer, or IS_ERR() condition containing errno.
Use of supply names configured via regulator_set_device_supply() is strongly encouraged. It is recommended that the supply name used should match the name used for the supply and/or the relevant device pins in the datasheet.
int regulator_get_bypass_regmap | ( | struct regulator_dev * | rdev, |
bool * | enable | ||
) |
regulator_get_bypass_regmap - Default get_bypass() using regmap
: device to operate on. : current state.
regulator_get_exclusive - obtain exclusive access to a regulator. : device for regulator "consumer" : Supply name or regulator ID.
Returns a struct regulator corresponding to the regulator producer, or IS_ERR() condition containing errno. Other consumers will be unable to obtain this reference is held and the use count for the regulator will be initialised to reflect the current state of the regulator.
This is intended for use by consumers which cannot tolerate shared use of the regulator such as those which need to force the regulator off for correct operation of the hardware they are controlling.
Use of supply names configured via regulator_set_device_supply() is strongly encouraged. It is recommended that the supply name used should match the name used for the supply and/or the relevant device pins in the datasheet.
void* regulator_get_init_drvdata | ( | struct regulator_init_data * | reg_init_data | ) |
int regulator_get_voltage_sel_regmap | ( | struct regulator_dev * | rdev | ) |
regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap users
: regulator to operate on
Regulators that use regmap for their register I/O can set the vsel_reg and vsel_mask fields in their descriptor and then use this as their get_voltage_vsel operation, saving some code.
regulator_has_full_constraints - the system has fully specified constraints
Calling this function will cause the regulator API to disable all regulators which have a zero use count and don't have an always_on constraint in a late_initcall.
The intention is that this will become the default behaviour in a future kernel release so users are encouraged to use this facility now.
regulator_is_enabled - is the regulator output enabled : regulator source
Returns positive if the regulator driver backing the source/client has requested that the device be enabled, zero if it hasn't, else a negative errno code.
Note that the device backing this regulator handle can have multiple users, so it might be enabled even if regulator_enable() was never called for this particular source.
int regulator_is_enabled_regmap | ( | struct regulator_dev * | rdev | ) |
regulator_is_enabled_regmap - standard is_enabled() for regmap users
: regulator to operate on
Regulators that use regmap for their register I/O can set the enable_reg and enable_mask fields in their descriptor and then use this as their is_enabled operation, saving some code.
int regulator_list_voltage_linear | ( | struct regulator_dev * | rdev, |
unsigned int | selector | ||
) |
regulator_list_voltage_linear - List voltages with simple calculation
: Regulator device : Selector to convert into a voltage
Regulators with a simple linear mapping between voltages and selectors can set min_uV and uV_step in the regulator descriptor and then use this function as their list_voltage() operation,
int regulator_list_voltage_table | ( | struct regulator_dev * | rdev, |
unsigned int | selector | ||
) |
regulator_list_voltage_table - List voltages with table based mapping
: Regulator device : Selector to convert into a voltage
Regulators with table based mapping between voltages and selectors can set volt_table in the regulator descriptor and then use this function as their list_voltage() operation.
int regulator_map_voltage_iterate | ( | struct regulator_dev * | rdev, |
int | min_uV, | ||
int | max_uV | ||
) |
regulator_map_voltage_iterate - map_voltage() based on list_voltage()
: Regulator to operate on : Lower bound for voltage : Upper bound for voltage
Drivers implementing set_voltage_sel() and list_voltage() can use this as their map_voltage() operation. It will find a suitable voltage by calling list_voltage() until it gets something in bounds for the requested voltages.
int regulator_map_voltage_linear | ( | struct regulator_dev * | rdev, |
int | min_uV, | ||
int | max_uV | ||
) |
regulator_map_voltage_linear - map_voltage() for simple linear mappings
: Regulator to operate on : Lower bound for voltage : Upper bound for voltage
Drivers providing min_uV and uV_step in their regulator_desc can use this as their map_voltage() operation.
int regulator_notifier_call_chain | ( | struct regulator_dev * | rdev, |
unsigned long | event, | ||
void * | data | ||
) |
regulator_notifier_call_chain - call regulator event notifier : regulator source : notifier block : callback-specific data.
Called by regulator drivers to notify clients a regulator event has occurred. We also notify regulator clients downstream. Note lock must be held by caller.
|
read |
int regulator_register_notifier | ( | struct regulator * | regulator, |
struct notifier_block * | nb | ||
) |
int regulator_set_bypass_regmap | ( | struct regulator_dev * | rdev, |
bool | enable | ||
) |
regulator_set_bypass_regmap - Default set_bypass() using regmap
: device to operate on. : state to set.
regulator_set_current_limit - set regulator output current limit : regulator source : Minimuum supported current in uA : Maximum supported current in uA
Sets current sink to the desired output current. This can be set during any regulator state. IOW, regulator can be disabled or enabled.
If the regulator is enabled then the current will change to the new value immediately otherwise if the regulator is disabled the regulator will output at the new current when enabled.
NOTE: Regulator system constraints must be set for this regulator before calling this function otherwise this call will fail.
regulator_set_mode - set regulator operating mode : regulator source : operating mode - one of the REGULATOR_MODE constants
Set regulator operating mode to increase regulator efficiency or improve regulation performance.
NOTE: Regulator system constraints must be set for this regulator before calling this function otherwise this call will fail.
regulator_set_optimum_mode - set regulator optimum operating mode : regulator source : load current
Notifies the regulator core of a new device load. This is then used by DRMS (if enabled by constraints) to set the most efficient regulator operating mode for the new regulator loading.
Consumer devices notify their supply regulator of the maximum power they will require (can be taken from device datasheet in the power consumption tables) when they change operational status and hence power state. Examples of operational state changes that can affect power consumption are :-
o Device is opened / closed. o Device I/O is about to begin or has just finished. o Device is idling in between work.
This information is also exported via sysfs to userspace.
DRMS will sum the total requested load on the regulator and change to the most efficient operating mode if platform constraints allow.
Returns the new regulator mode or error.
regulator_set_voltage - set regulator output voltage : regulator source : Minimum required voltage in uV : Maximum acceptable voltage in uV
Sets a voltage regulator to the desired output voltage. This can be set during any regulator state. IOW, regulator can be disabled or enabled.
If the regulator is enabled then the voltage will change to the new value immediately otherwise if the regulator is disabled the regulator will output at the new voltage when enabled.
NOTE: If the regulator is shared between several devices then the lowest request voltage that meets the system constraints will be used. Regulator system constraints must be set for this regulator before calling this function otherwise this call will fail.
int regulator_set_voltage_sel_regmap | ( | struct regulator_dev * | rdev, |
unsigned | sel | ||
) |
regulator_set_voltage_sel_regmap - standard set_voltage_sel for regmap users
: regulator to operate on : Selector to set
Regulators that use regmap for their register I/O can set the vsel_reg and vsel_mask fields in their descriptor and then use this as their set_voltage_vsel operation, saving some code.
int regulator_set_voltage_time_sel | ( | struct regulator_dev * | rdev, |
unsigned int | old_selector, | ||
unsigned int | new_selector | ||
) |
regulator_set_voltage_time_sel - get raise/fall time : regulator source device : selector for starting voltage : selector for target voltage
Provided with the starting and target voltage selectors, this function returns time in microseconds required to rise or fall to this new voltage
Drivers providing ramp_delay in regulation_constraints can use this as their set_voltage_time_sel() operation.
int regulator_suspend_prepare | ( | suspend_state_t | state | ) |
void regulator_unregister | ( | struct regulator_dev * | rdev | ) |
int regulator_unregister_notifier | ( | struct regulator * | regulator, |
struct notifier_block * | nb | ||
) |
regulator_use_dummy_regulator - Provide a dummy regulator when none is found
Calling this function will cause the regulator API to provide a dummy regulator to consumers if no physical regulator is found, allowing most consumers to proceed as though a regulator were configured. This allows systems such as those with software controllable regulators for the CPU core only to be brought up more readily.