API reference¶
Due to limitations of the kernel documentation framework and the
existing layout of the source code the entire regulator API is
documented here.
-
struct pre_voltage_change_data¶
Data sent with PRE_VOLTAGE_CHANGE event
Definition:
struct pre_voltage_change_data {
unsigned long old_uV;
unsigned long min_uV;
unsigned long max_uV;
};
Members
old_uVCurrent voltage before change.
min_uVMin voltage we’ll change to.
max_uVMax voltage we’ll change to.
-
struct regulator_bulk_data¶
Data used for bulk regulator operations.
Definition:
struct regulator_bulk_data {
const char *supply;
struct regulator *consumer;
int init_load_uA;
};
Members
supplyThe name of the supply. Initialised by the user before
using the bulk regulator APIs.
consumerThe regulator consumer for the supply. This will be managed
by the bulk API.
init_load_uAAfter getting the regulator, regulator_set_load() will be
called with this load. Initialised by the user before
using the bulk regulator APIs.
Description
The regulator APIs provide a series of regulator_bulk_() API calls as
a convenience to consumers which require multiple supplies. This
structure is used to manage data for these calls.
-
struct regulator_state¶
regulator state during low power system states
Definition:
struct regulator_state {
int uV;
int min_uV;
int max_uV;
unsigned int mode;
int enabled;
bool changeable;
};
Members
uVDefault operating voltage during suspend, it can be adjusted
among <min_uV, max_uV>.
min_uVMinimum suspend voltage may be set.
max_uVMaximum suspend voltage may be set.
modeOperating mode during suspend.
enabledoperations during suspend.
- DO_NOTHING_IN_SUSPEND
- DISABLE_IN_SUSPEND
- ENABLE_IN_SUSPEND
changeableIs this state can be switched between enabled/disabled,
Description
This describes a regulators state during a system wide low power
state. One of enabled or disabled must be set for the
configuration to be applied.
-
struct regulation_constraints¶
regulator operating constraints.
Definition:
struct regulation_constraints {
const char *name;
int min_uV;
int max_uV;
int uV_offset;
int min_uA;
int max_uA;
int ilim_uA;
int pw_budget_mW;
int system_load;
u32 *max_spread;
int max_uV_step;
unsigned int valid_modes_mask;
unsigned int valid_ops_mask;
int input_uV;
struct regulator_state state_disk;
struct regulator_state state_mem;
struct regulator_state state_standby;
struct notification_limit over_curr_limits;
struct notification_limit over_voltage_limits;
struct notification_limit under_voltage_limits;
struct notification_limit temp_limits;
suspend_state_t initial_state;
unsigned int initial_mode;
unsigned int ramp_delay;
unsigned int settling_time;
unsigned int settling_time_up;
unsigned int settling_time_down;
unsigned int enable_time;
unsigned int uv_less_critical_window_ms;
unsigned int active_discharge;
unsigned always_on:1;
unsigned boot_on:1;
unsigned apply_uV:1;
unsigned ramp_disable:1;
unsigned soft_start:1;
unsigned pull_down:1;
unsigned system_critical:1;
unsigned over_current_protection:1;
unsigned over_current_detection:1;
unsigned over_voltage_detection:1;
unsigned under_voltage_detection:1;
unsigned over_temp_detection:1;
};
Members
nameDescriptive name for the constraints, used for display purposes.
min_uVSmallest voltage consumers may set.
max_uVLargest voltage consumers may set.
uV_offsetOffset applied to voltages from consumer to compensate for
voltage drops.
min_uASmallest current consumers may set.
max_uALargest current consumers may set.
ilim_uAMaximum input current.
pw_budget_mWPower budget for the regulator in mW.
system_loadLoad that isn’t captured by any consumer requests.
max_spreadMax possible spread between coupled regulators
max_uV_stepMax possible step change in voltage
valid_modes_maskMask of modes which may be configured by consumers.
valid_ops_maskOperations which may be performed by consumers.
input_uVInput voltage for regulator when supplied by another regulator.
state_diskState for regulator when system is suspended in disk mode.
state_memState for regulator when system is suspended in mem mode.
state_standbyState for regulator when system is suspended in standby
mode.
over_curr_limitsLimits for acting on over current.
over_voltage_limitsLimits for acting on over voltage.
under_voltage_limitsLimits for acting on under voltage.
temp_limitsLimits for acting on over temperature.
initial_stateSuspend state to set by default.
initial_modeMode to set at startup.
ramp_delayTime to settle down after voltage change (unit: uV/us)
settling_timeTime to settle down after voltage change when voltage
change is non-linear (unit: microseconds).
settling_time_upTime to settle down after voltage increase when voltage
change is non-linear (unit: microseconds).
settling_time_downTime to settle down after voltage decrease when
voltage change is non-linear (unit: microseconds).
enable_timeTurn-on time of the rails (unit: microseconds)
uv_less_critical_window_msSpecifies the time window (in milliseconds)
following a critical under-voltage (UV) event
during which less critical actions can be
safely carried out by the system (for example
logging). After this time window more critical
actions should be done (for example prevent
HW damage).
active_dischargeEnable/disable active discharge. The enum
regulator_active_discharge values are used for
initialisation.
always_onSet if the regulator should never be disabled.
boot_onSet if the regulator is enabled when the system is initially
started. If the regulator is not enabled by the hardware or
bootloader then it will be enabled when the constraints are
applied.
apply_uVApply the voltage constraint when initialising.
ramp_disableDisable ramp delay when initialising or when setting voltage.
soft_startEnable soft start so that voltage ramps slowly.
pull_downEnable pull down when regulator is disabled.
system_criticalSet if the regulator is critical to system stability or
functionality.
over_current_protectionAuto disable on over current event.
over_current_detectionConfigure over current limits.
over_voltage_detectionConfigure over voltage limits.
under_voltage_detectionConfigure under voltage limits.
over_temp_detectionConfigure over temperature limits.
Description
This struct describes regulator and board/machine specific constraints.
-
struct regulator_consumer_supply¶
supply -> device mapping
Definition:
struct regulator_consumer_supply {
const char *dev_name;
const char *supply;
};
Members
dev_nameResult of dev_name() for the consumer.
supplyName for the supply.
Description
This maps a supply name to a device. Use of dev_name allows support for
buses which make struct device available late such as I2C.
-
struct regulator_init_data¶
regulator platform initialisation data.
Definition:
struct regulator_init_data {
const char *supply_regulator;
struct regulation_constraints constraints;
int num_consumer_supplies;
struct regulator_consumer_supply *consumer_supplies;
void *driver_data;
};
Members
supply_regulatorParent regulator. Specified using the regulator name
as it appears in the name field in sysfs, which can
be explicitly set using the constraints field ‘name’.
constraintsConstraints. These must be specified for the regulator to
be usable.
num_consumer_suppliesNumber of consumer device supplies.
consumer_suppliesConsumer device supply configuration.
driver_dataData passed to regulator_init.
Description
Initialisation constraints, our supply and consumers supplies.
-
struct regulator_ops¶
regulator operations.
Definition:
struct regulator_ops {
int (*list_voltage) (struct regulator_dev *, unsigned selector);
int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV, unsigned *selector);
int (*map_voltage)(struct regulator_dev *, int min_uV, int max_uV);
int (*set_voltage_sel) (struct regulator_dev *, unsigned selector);
int (*get_voltage) (struct regulator_dev *);
int (*get_voltage_sel) (struct regulator_dev *);
int (*set_current_limit) (struct regulator_dev *, int min_uA, int max_uA);
int (*get_current_limit) (struct regulator_dev *);
int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
int (*set_over_current_protection)(struct regulator_dev *, int lim_uA, int severity, bool enable);
int (*set_over_voltage_protection)(struct regulator_dev *, int lim_uV, int severity, bool enable);
int (*set_under_voltage_protection)(struct regulator_dev *, int lim_uV, int severity, bool enable);
int (*set_thermal_protection)(struct regulator_dev *, int lim, int severity, bool enable);
int (*set_active_discharge)(struct regulator_dev *, bool enable);
int (*enable) (struct regulator_dev *);
int (*disable) (struct regulator_dev *);
int (*is_enabled) (struct regulator_dev *);
int (*set_mode) (struct regulator_dev *, unsigned int mode);
unsigned int (*get_mode) (struct regulator_dev *);
int (*get_error_flags)(struct regulator_dev *, unsigned int *flags);
int (*enable_time) (struct regulator_dev *);
int (*set_ramp_delay) (struct regulator_dev *, int ramp_delay);
int (*set_voltage_time) (struct regulator_dev *, int old_uV, int new_uV);
int (*set_voltage_time_sel) (struct regulator_dev *, unsigned int old_selector, unsigned int new_selector);
int (*set_soft_start) (struct regulator_dev *);
int (*get_status)(struct regulator_dev *);
unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV, int output_uV, int load_uA);
int (*set_load)(struct regulator_dev *, int load_uA);
int (*set_bypass)(struct regulator_dev *dev, bool enable);
int (*get_bypass)(struct regulator_dev *dev, bool *enable);
int (*set_suspend_voltage) (struct regulator_dev *, int uV);
int (*set_suspend_enable) (struct regulator_dev *);
int (*set_suspend_disable) (struct regulator_dev *);
int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
int (*resume)(struct regulator_dev *rdev);
int (*set_pull_down) (struct regulator_dev *);
};
Members
list_voltageReturn one of the supported voltages, in microvolts; zero
if the selector indicates a voltage that is unusable on this system;
or negative errno. Selectors range from zero to one less than
regulator_desc.n_voltages. Voltages may be reported in any order.
set_voltageSet the voltage for the regulator within the range specified.
The driver should select the voltage closest to min_uV.
map_voltageConvert a voltage into a selector
set_voltage_selSet the voltage for the regulator using the specified
selector.
get_voltageReturn the currently configured voltage for the regulator;
return -ENOTRECOVERABLE if regulator can’t be read at
bootup and hasn’t been set yet.
get_voltage_selReturn the currently configured voltage selector for the
regulator; return -ENOTRECOVERABLE if regulator can’t
be read at bootup and hasn’t been set yet.
set_current_limitConfigure a limit for a current-limited regulator.
The driver should select the current closest to max_uA.
get_current_limitGet the configured limit for a current-limited regulator.
set_input_current_limitConfigure an input limit.
set_over_current_protectionSupport enabling of and setting limits for over
current situation detection. Detection can be configured for three
levels of severity.
set_over_voltage_protectionSupport enabling of and setting limits for over
voltage situation detection. Detection can be configured for same
severities as over current protection. Units of uV.
set_under_voltage_protectionSupport enabling of and setting limits for
under voltage situation detection. Detection can be configured for same
severities as over current protection. Units of uV.
set_thermal_protectionSupport enabling of and setting limits for over
temperature situation detection.Detection can be configured for same
severities as over current protection. Units of degree Kelvin.
set_active_dischargeSet active discharge enable/disable of regulators.
enableConfigure the regulator as enabled.
disableConfigure the regulator as disabled.
is_enabledReturn 1 if the regulator is enabled, 0 if not.
May also return negative errno.
set_modeSet the configured operating mode for the regulator.
get_modeGet the configured operating mode for the regulator.
get_error_flagsGet the current error(s) for the regulator.
enable_timeTime taken for the regulator voltage output voltage to
stabilise after being enabled, in microseconds.
set_ramp_delaySet the ramp delay for the regulator. The driver should
select ramp delay equal to or less than(closest) ramp_delay.
set_voltage_timeTime taken for the regulator voltage output voltage
to stabilise after being set to a new value, in microseconds.
The function receives the from and to voltage as input, it
should return the worst case.
set_voltage_time_selTime taken for the regulator voltage output voltage
to stabilise after being set to a new value, in microseconds.
The function receives the from and to voltage selector as
input, it should return the worst case.
set_soft_startEnable soft start for the regulator.
get_statusReturn actual (not as-configured) status of regulator, as a
REGULATOR_STATUS value (or negative errno)
get_optimum_modeGet the most efficient operating mode for the regulator
when running with the specified parameters.
set_loadSet the load for the regulator.
set_bypassSet the regulator in bypass mode.
get_bypassGet the regulator bypass mode state.
set_suspend_voltageSet the voltage for the regulator when the system
is suspended.
set_suspend_enableMark the regulator as enabled when the system is
suspended.
set_suspend_disableMark the regulator as disabled when the system is
suspended.
set_suspend_modeSet the operating mode for the regulator when the
system is suspended.
resumeResume operation of suspended regulator.
set_pull_downConfigure the regulator to pull down when the regulator
is disabled.
Description
This struct describes regulator operations which can be implemented by
regulator chip drivers.
-
struct regulator_desc¶
Static regulator descriptor
Definition:
struct regulator_desc {
const char *name;
const char *supply_name;
const char *of_match;
bool of_match_full_name;
const char *regulators_node;
int (*of_parse_cb)(struct device_node *, const struct regulator_desc *, struct regulator_config *);
int (*init_cb)(struct regulator_dev *, struct regulator_config *);
int id;
unsigned int continuous_voltage_range:1;
unsigned n_voltages;
unsigned int n_current_limits;
const struct regulator_ops *ops;
int irq;
enum regulator_type type;
struct module *owner;
unsigned int min_uV;
unsigned int uV_step;
unsigned int linear_min_sel;
int fixed_uV;
unsigned int ramp_delay;
int min_dropout_uV;
const struct linear_range *linear_ranges;
const unsigned int *linear_range_selectors_bitfield;
int n_linear_ranges;
const unsigned int *volt_table;
const unsigned int *curr_table;
unsigned int vsel_range_reg;
unsigned int vsel_range_mask;
bool range_applied_by_vsel;
unsigned int vsel_reg;
unsigned int vsel_mask;
unsigned int vsel_step;
unsigned int csel_reg;
unsigned int csel_mask;
unsigned int apply_reg;
unsigned int apply_bit;
unsigned int enable_reg;
unsigned int enable_mask;
unsigned int enable_val;
unsigned int disable_val;
bool enable_is_inverted;
unsigned int bypass_reg;
unsigned int bypass_mask;
unsigned int bypass_val_on;
unsigned int bypass_val_off;
unsigned int active_discharge_on;
unsigned int active_discharge_off;
unsigned int active_discharge_mask;
unsigned int active_discharge_reg;
unsigned int soft_start_reg;
unsigned int soft_start_mask;
unsigned int soft_start_val_on;
unsigned int pull_down_reg;
unsigned int pull_down_mask;
unsigned int pull_down_val_on;
unsigned int ramp_reg;
unsigned int ramp_mask;
const unsigned int *ramp_delay_table;
unsigned int n_ramp_values;
unsigned int enable_time;
unsigned int off_on_delay;
unsigned int poll_enabled_time;
unsigned int (*of_map_mode)(unsigned int mode);
};
Members
nameIdentifying name for the regulator.
supply_nameIdentifying the regulator supply
of_matchName used to identify regulator in DT.
of_match_full_nameA flag to indicate that the of_match string, if
present, should be matched against the node full_name.
regulators_nodeName of node containing regulator definitions in DT.
of_parse_cbOptional callback called only if of_match is present.
Will be called for each regulator parsed from DT, during
init_data parsing.
The regulator_config passed as argument to the callback will
be a copy of config passed to regulator_register, valid only
for this particular call. Callback may freely change the
config but it cannot store it for later usage.
Callback should return 0 on success or negative ERRNO
indicating failure.
init_cbOptional callback called after the parsing of init_data.
Allows the regulator to perform runtime init if necessary,
such as synching the regulator and the parsed constraints.
Callback should return 0 on success or negative ERRNO
indicating failure.
idNumerical identifier for the regulator.
continuous_voltage_rangeIndicates if the regulator can set any
voltage within constrains range.
n_voltagesNumber of selectors available for ops.list_voltage().
n_current_limitsNumber of selectors available for current limits
opsRegulator operations table.
irqInterrupt number for the regulator.
typeIndicates if the regulator is a voltage or current regulator.
ownerModule providing the regulator, used for refcounting.
min_uVVoltage given by the lowest selector (if linear mapping)
uV_stepVoltage increase with each selector (if linear mapping)
linear_min_selMinimal selector for starting linear mapping
fixed_uVFixed voltage of rails.
ramp_delayTime to settle down after voltage change (unit: uV/us)
min_dropout_uVThe minimum dropout voltage this regulator can handle
linear_rangesA constant table of possible voltage ranges.
linear_range_selectors_bitfieldA constant table of voltage range
selectors as bitfield values. If
pickable ranges are used each range
must have corresponding selector here.
n_linear_rangesNumber of entries in the linear_ranges (and in
linear_range_selectors_bitfield if used) table(s).
volt_tableVoltage mapping table (if table based mapping)
curr_tableCurrent limit mapping table (if table based mapping)
vsel_range_regRegister for range selector when using pickable ranges
and regulator_map_*_voltage_*_pickable functions.
vsel_range_maskMask for register bitfield used for range selector
range_applied_by_vselA flag to indicate that changes to vsel_range_reg
are only effective after vsel_reg is written
vsel_regRegister for selector when using regulator_map_*_voltage_*
vsel_maskMask for register bitfield used for selector
vsel_stepSpecify the resolution of selector stepping when setting
voltage. If 0, then no stepping is done (requested selector is
set directly), if >0 then the regulator API will ramp the
voltage up/down gradually each time increasing/decreasing the
selector by the specified step value.
csel_regRegister for current limit selector using regmap set_current_limit
csel_maskMask for register bitfield used for current limit selector
apply_regRegister for initiate voltage change on the output when
using regulator_set_voltage_sel_regmap
apply_bitRegister bitfield used for initiate voltage change on the
output when using regulator_set_voltage_sel_regmap
enable_regRegister for control when using regmap enable/disable ops
enable_maskMask for control when using regmap enable/disable ops
enable_valEnabling value for control when using regmap enable/disable ops
disable_valDisabling value for control when using regmap enable/disable ops
enable_is_invertedA flag to indicate set enable_mask bits to disable
when using regulator_enable_regmap and friends APIs.
bypass_regRegister for control when using regmap set_bypass
bypass_maskMask for control when using regmap set_bypass
bypass_val_onEnabling value for control when using regmap set_bypass
bypass_val_offDisabling value for control when using regmap set_bypass
active_discharge_onDisabling value for control when using regmap
set_active_discharge
active_discharge_offEnabling value for control when using regmap
set_active_discharge
active_discharge_maskMask for control when using regmap
set_active_discharge
active_discharge_regRegister for control when using regmap
set_active_discharge
soft_start_regRegister for control when using regmap set_soft_start
soft_start_maskMask for control when using regmap set_soft_start
soft_start_val_onEnabling value for control when using regmap
set_soft_start
pull_down_regRegister for control when using regmap set_pull_down
pull_down_maskMask for control when using regmap set_pull_down
pull_down_val_onEnabling value for control when using regmap
set_pull_down
ramp_regRegister for controlling the regulator ramp-rate.
ramp_maskBitmask for the ramp-rate control register.
ramp_delay_tableTable for mapping the regulator ramp-rate values. Values
should be given in units of V/S (uV/uS). See the
regulator_set_ramp_delay_regmap().
n_ramp_valuesnumber of elements at ramp_delay_table.
enable_timeTime taken for initial enable of regulator (in uS).
off_on_delayguard time (in uS), before re-enabling a regulator
poll_enabled_timeThe polling interval (in uS) to use while checking that
the regulator was actually enabled. Max up to enable_time.
of_map_modeMaps a hardware mode defined in a DeviceTree to a standard mode
Description
Each regulator registered with the core is described with a
structure of this type and a struct regulator_config. This
structure contains the non-varying parts of the regulator
description.
-
struct regulator_config¶
Dynamic regulator descriptor
Definition:
struct regulator_config {
struct device *dev;
const struct regulator_init_data *init_data;
void *driver_data;
struct device_node *of_node;
struct regmap *regmap;
struct gpio_desc *ena_gpiod;
};
Members
devstruct device for the regulator
init_dataplatform provided init data, passed through by driver
driver_dataprivate regulator data
of_nodeOpenFirmware node to parse for device tree bindings (may be
NULL).
regmapregmap to use for core regmap helpers if dev_get_regmap() is
insufficient.
ena_gpiodGPIO controlling regulator enable.
Description
Each regulator registered with the core is described with a
structure of this type and a struct regulator_desc. This structure
contains the runtime variable parts of the regulator description.
-
struct regulator_err_state¶
regulator error/notification status
Definition:
struct regulator_err_state {
struct regulator_dev *rdev;
unsigned long notifs;
unsigned long errors;
int possible_errs;
};
Members
rdevRegulator which status the struct indicates.
notifsEvents which have occurred on the regulator.
errorsErrors which are active on the regulator.
possible_errsErrors which can be signaled (by given IRQ).
-
struct regulator_irq_data¶
regulator error/notification status data
Definition:
struct regulator_irq_data {
struct regulator_err_state *states;
int num_states;
void *data;
long opaque;
};
Members
statesStatus structs for each of the associated regulators.
num_statesAmount of associated regulators.
dataDriver data pointer given at regulator_irq_desc.
opaqueValue storage for IC driver. Core does not update this. ICs
may want to store status register value here at map_event and
compare contents at ‘renable’ callback to see if new problems
have been added to status. If that is the case it may be
desirable to return REGULATOR_ERROR_CLEARED and not
REGULATOR_ERROR_ON to allow IRQ fire again and to generate
notifications also for the new issues.
Description
This structure is passed to ‘map_event’ and ‘renable’ callbacks for
reporting regulator status to core.
-
struct regulator_irq_desc¶
notification sender for IRQ based events.
Definition:
struct regulator_irq_desc {
const char *name;
int fatal_cnt;
int reread_ms;
int irq_off_ms;
bool skip_off;
bool high_prio;
void *data;
int (*die)(struct regulator_irq_data *rid);
int (*map_event)(int irq, struct regulator_irq_data *rid, unsigned long *dev_mask);
int (*renable)(struct regulator_irq_data *rid);
};
Members
nameThe visible name for the IRQ
fatal_cntIf this IRQ is used to signal HW damaging condition it may be
best to shut-down regulator(s) or reboot the SOC if error
handling is repeatedly failing. If fatal_cnt is given the IRQ
handling is aborted if it fails for fatal_cnt times and die()
callback (if populated) is called. If die() is not populated
poweroff for the system is attempted in order to prevent any
further damage.
reread_msThe time which is waited before attempting to re-read status
at the worker if IC reading fails. Immediate re-read is done
if time is not specified.
irq_off_msThe time which IRQ is kept disabled before re-evaluating the
status for devices which keep IRQ disabled for duration of the
error. If this is not given the IRQ is left enabled and renable
is not called.
skip_offIf set to true the IRQ handler will attempt to check if any of
the associated regulators are enabled prior to taking other
actions. If no regulators are enabled and this is set to true
a spurious IRQ is assumed and IRQ_NONE is returned.
high_prioBoolean to indicate that high priority WQ should be used.
dataDriver private data pointer which will be passed as such to
the renable, map_event and die callbacks in regulator_irq_data.
dieProtection callback. If IC status reading or recovery actions
fail fatal_cnt times this callback is called or system is
powered off. This callback should implement a final protection
attempt like disabling the regulator. If protection succeeded
die() may return 0. If anything else is returned the core
assumes final protection failed and attempts to perform a
poweroff as a last resort.
map_eventDriver callback to map IRQ status into regulator devices with
events / errors. NOTE: callback MUST initialize both the
errors and notifs for all rdevs which it signals having
active events as core does not clean the map data.
REGULATOR_FAILED_RETRY can be returned to indicate that the
status reading from IC failed. If this is repeated for
fatal_cnt times the core will call die() callback or power-off
the system as a last resort to protect the HW.
renableOptional callback to check status (if HW supports that) before
re-enabling IRQ. If implemented this should clear the error
flags so that errors fetched by regulator_get_error_flags()
are updated. If callback is not implemented then errors are
assumed to be cleared and IRQ is re-enabled.
REGULATOR_FAILED_RETRY can be returned to
indicate that the status reading from IC failed. If this is
repeated for ‘fatal_cnt’ times the core will call die()
callback or if die() is not populated then attempt to power-off
the system as a last resort to protect the HW.
Returning zero indicates that the problem in HW has been solved
and IRQ will be re-enabled. Returning REGULATOR_ERROR_ON
indicates the error condition is still active and keeps IRQ
disabled. Please note that returning REGULATOR_ERROR_ON does
not retrigger evaluating what events are active or resending
notifications. If this is needed you probably want to return
zero and allow IRQ to retrigger causing events to be
re-evaluated and re-sent.
Description
This structure is used for registering regulator IRQ notification helper.
-
struct regulator *regulator_get(struct device *dev, const char *id)¶
lookup and obtain a reference to a regulator.
Parameters
struct device *devdevice for regulator “consumer”
const char *idSupply name or regulator ID.
Description
Use of supply names configured via set_consumer_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.
Return
Pointer to a struct regulator corresponding to the regulator
producer, or an ERR_PTR() encoded negative error number.
-
struct regulator *regulator_get_exclusive(struct device *dev, const char *id)¶
obtain exclusive access to a regulator.
Parameters
struct device *devdevice for regulator “consumer”
const char *idSupply name or regulator ID.
Description
Other consumers will be unable to obtain this regulator while 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 set_consumer_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.
Return
Pointer to a struct regulator corresponding to the regulator
producer, or an ERR_PTR() encoded negative error number.
-
struct regulator *regulator_get_optional(struct device *dev, const char *id)¶
obtain optional access to a regulator.
Parameters
struct device *devdevice for regulator “consumer”
const char *idSupply name or regulator ID.
Description
This is intended for use by consumers for devices which can have
some supplies unconnected in normal use, such as some MMC devices.
It can allow the regulator core to provide stub supplies for other
supplies requested using normal regulator_get() calls without
disrupting the operation of drivers that can handle absent
supplies.
Use of supply names configured via set_consumer_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.
Return
Pointer to a struct regulator corresponding to the regulator
producer, or an ERR_PTR() encoded negative error number.
-
void regulator_put(struct regulator *regulator)¶
“free” the regulator source
Parameters
struct regulator *regulatorregulator source
Note
drivers must ensure that all regulator_enable calls made on this
regulator source are balanced by regulator_disable calls prior to calling
this function.
-
int regulator_register_supply_alias(struct device *dev, const char *id, struct device *alias_dev, const char *alias_id)¶
Provide device alias for supply lookup
Parameters
struct device *devdevice that will be given as the regulator “consumer”
const char *idSupply name or regulator ID
struct device *alias_devdevice that should be used to lookup the supply
const char *alias_idSupply name or regulator ID that should be used to lookup the
supply
Description
All lookups for id on dev will instead be conducted for alias_id on
alias_dev.
Return
0 on success or a negative error number on failure.
-
void regulator_unregister_supply_alias(struct device *dev, const char *id)¶
Remove device alias
Parameters
struct device *devdevice that will be given as the regulator “consumer”
const char *idSupply name or regulator ID
Description
Remove a lookup alias if one exists for id on dev.
-
int regulator_bulk_register_supply_alias(struct device *dev, const char *const *id, struct device *alias_dev, const char *const *alias_id, int num_id)¶
register multiple aliases
Parameters
struct device *devdevice that will be given as the regulator “consumer”
const char *const *idList of supply names or regulator IDs
struct device *alias_devdevice that should be used to lookup the supply
const char *const *alias_idList of supply names or regulator IDs that should be used to
lookup the supply
int num_idNumber of aliases to register
Description
This helper function allows drivers to register several supply
aliases in one operation. If any of the aliases cannot be
registered any aliases that were registered will be removed
before returning to the caller.
Return
0 on success or a negative error number on failure.
-
void regulator_bulk_unregister_supply_alias(struct device *dev, const char *const *id, int num_id)¶
unregister multiple aliases
Parameters
struct device *devdevice that will be given as the regulator “consumer”
const char *const *idList of supply names or regulator IDs
int num_idNumber of aliases to unregister
Description
This helper function allows drivers to unregister several supply
aliases in one operation.
-
int regulator_enable(struct regulator *regulator)¶
enable regulator output
Parameters
struct regulator *regulatorregulator source
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_disable(struct regulator *regulator)¶
disable regulator output
Parameters
struct regulator *regulatorregulator source
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_force_disable(struct regulator *regulator)¶
force disable regulator output
Parameters
struct regulator *regulatorregulator source
Description
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).
Return
0 on success or a negative error number on failure.
-
int regulator_disable_deferred(struct regulator *regulator, int ms)¶
disable regulator output with delay
Parameters
struct regulator *regulatorregulator source
int msmilliseconds until the regulator is disabled
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_is_enabled(struct regulator *regulator)¶
is the regulator output enabled
Parameters
struct regulator *regulatorregulator source
Description
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.
Return
Positive if the regulator driver backing the source/client
has requested that the device be enabled, zero if it hasn’t,
else a negative error number.
-
int regulator_count_voltages(struct regulator *regulator)¶
count regulator_list_voltage() selectors
Parameters
struct regulator *regulatorregulator source
Return
Number of selectors for regulator, or negative error number.
Description
Selectors are numbered starting at zero, and typically correspond to
bitfields in hardware registers.
-
int regulator_list_voltage(struct regulator *regulator, unsigned selector)¶
enumerate supported voltages
Parameters
struct regulator *regulatorregulator source
unsigned selectoridentify voltage to list
Context
can sleep
Return
Voltage for selector that can be passed to regulator_set_voltage(),
0 if selector can’t be used on this system, or a negative error
number on failure.
-
struct regmap *regulator_get_regmap(struct regulator *regulator)¶
get the regulator’s register map
Parameters
struct regulator *regulatorregulator source
Return
Pointer to the struct regmap for regulator, or ERR_PTR()
encoded -EOPNOTSUPP if regulator doesn’t use regmap.
-
int regulator_get_hardware_vsel_register(struct regulator *regulator, unsigned *vsel_reg, unsigned *vsel_mask)¶
get the HW voltage selector register
Parameters
struct regulator *regulatorregulator source
unsigned *vsel_regvoltage selector register, output parameter
unsigned *vsel_maskmask for voltage selector bitfield, output parameter
Description
Returns the hardware register offset and bitmask used for setting the
regulator voltage. This might be useful when configuring voltage-scaling
hardware or firmware that can make I2C requests behind the kernel’s back,
for example.
On success, the output parameters vsel_reg and vsel_mask are filled in
and 0 is returned, otherwise a negative error number is returned.
Return
0 on success, or -EOPNOTSUPP if the regulator does not support
voltage selectors.
-
int regulator_list_hardware_vsel(struct regulator *regulator, unsigned selector)¶
get the HW-specific register value for a selector
Parameters
struct regulator *regulatorregulator source
unsigned selectoridentify voltage to list
Description
Converts the selector to a hardware-specific voltage selector that can be
directly written to the regulator registers. The address of the voltage
register can be determined by calling regulator_get_hardware_vsel_register.
Return
0 on success, -EINVAL if the selector is outside the supported
range, or -EOPNOTSUPP if the regulator does not support voltage
selectors.
-
int regulator_hardware_enable(struct regulator *regulator, bool enable)¶
access the HW for enable/disable regulator
Parameters
struct regulator *regulatorregulator source
bool enabletrue for enable, false for disable
Description
Request that the regulator be enabled/disabled with the regulator output at
the predefined voltage or current value.
Return
0 on success or a negative error number on failure.
-
unsigned int regulator_get_linear_step(struct regulator *regulator)¶
return the voltage step size between VSEL values
Parameters
struct regulator *regulatorregulator source
Return
The voltage step size between VSEL values for linear regulators,
or 0 if the regulator isn’t a linear regulator.
-
int regulator_is_supported_voltage(struct regulator *regulator, int min_uV, int max_uV)¶
check if a voltage range can be supported
Parameters
struct regulator *regulatorRegulator to check.
int min_uVMinimum required voltage in uV.
int max_uVMaximum required voltage in uV.
Return
1 if the voltage range is supported, 0 if not, or a negative error
number if regulator’s voltage can’t be changed and voltage readback
failed.
-
int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)¶
set regulator output voltage
Parameters
struct regulator *regulatorregulator source
int min_uVMinimum required voltage in uV
int max_uVMaximum acceptable voltage in uV
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_set_voltage_time(struct regulator *regulator, int old_uV, int new_uV)¶
get raise/fall time
Parameters
struct regulator *regulatorregulator source
int old_uVstarting voltage in microvolts
int new_uVtarget voltage in microvolts
Description
Provided with the starting and ending voltage, this function attempts to
calculate the time in microseconds required to rise or fall to this new
voltage.
Return
ramp time in microseconds, or a negative error number if calculation failed.
-
int regulator_set_voltage_time_sel(struct regulator_dev *rdev, unsigned int old_selector, unsigned int new_selector)¶
get raise/fall time
Parameters
struct regulator_dev *rdevregulator source device
unsigned int old_selectorselector for starting voltage
unsigned int new_selectorselector for target voltage
Description
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.
Return
ramp time in microseconds, or a negative error number if calculation failed.
-
int regulator_sync_voltage(struct regulator *regulator)¶
re-apply last regulator output voltage
Parameters
struct regulator *regulatorregulator source
Description
Re-apply the last configured voltage. This is intended to be used
where some external control source the consumer is cooperating with
has caused the configured voltage to change.
Return
0 on success or a negative error number on failure.
-
int regulator_get_voltage(struct regulator *regulator)¶
get regulator output voltage
Parameters
struct regulator *regulatorregulator source
Return
Current regulator voltage in uV, or a negative error number on failure.
NOTE
If the regulator is disabled it will return the voltage value. This
function should not be used to determine regulator state.
-
int regulator_set_current_limit(struct regulator *regulator, int min_uA, int max_uA)¶
set regulator output current limit
Parameters
struct regulator *regulatorregulator source
int min_uAMinimum supported current in uA
int max_uAMaximum supported current in uA
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_get_current_limit(struct regulator *regulator)¶
get regulator output current
Parameters
struct regulator *regulatorregulator source
Return
Current supplied by the specified current sink in uA,
or a negative error number on failure.
NOTE
If the regulator is disabled it will return the current value. This
function should not be used to determine regulator state.
-
int regulator_get_unclaimed_power_budget(struct regulator *regulator)¶
get regulator unclaimed power budget
Parameters
struct regulator *regulatorregulator source
Return
Unclaimed power budget of the regulator in mW.
-
int regulator_request_power_budget(struct regulator *regulator, unsigned int pw_req)¶
request power budget on a regulator
Parameters
struct regulator *regulatorregulator source
unsigned int pw_reqPower requested
Return
0 on success or a negative error number on failure.
-
void regulator_free_power_budget(struct regulator *regulator, unsigned int pw)¶
free power budget on a regulator
Parameters
struct regulator *regulatorregulator source
unsigned int pwPower to be released.
Return
Power budget of the regulator in mW.
-
int regulator_set_mode(struct regulator *regulator, unsigned int mode)¶
set regulator operating mode
Parameters
struct regulator *regulatorregulator source
unsigned int modeoperating mode - one of the REGULATOR_MODE constants
Description
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.
Return
0 on success or a negative error number on failure.
-
unsigned int regulator_get_mode(struct regulator *regulator)¶
get regulator operating mode
Parameters
struct regulator *regulatorregulator source
Description
Get the current regulator operating mode.
Return
Current operating mode as REGULATOR_MODE_* values,
or a negative error number on failure.
-
int regulator_get_error_flags(struct regulator *regulator, unsigned int *flags)¶
get regulator error information
Parameters
struct regulator *regulatorregulator source
unsigned int *flagspointer to store error flags
Description
Get the current regulator error information.
Return
0 on success or a negative error number on failure.
-
int regulator_set_load(struct regulator *regulator, int uA_load)¶
set regulator load
Parameters
struct regulator *regulatorregulator source
int uA_loadload current
Description
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.
NOTE
when a regulator consumer requests to have a regulator
disabled then any load that consumer requested no longer counts
toward the total requested load. If the regulator is re-enabled
then the previously requested load will start counting again.
If a regulator is an always-on regulator then an individual consumer’s
load will still be removed if that consumer is fully disabled.
Return
0 on success or a negative error number on failure.
-
int regulator_allow_bypass(struct regulator *regulator, bool enable)¶
allow the regulator to go into bypass mode
Parameters
struct regulator *regulatorRegulator to configure
bool enableenable or disable bypass mode
Description
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.
Return
0 on success or if changing bypass is not possible, or
a negative error number on failure.
-
int regulator_register_notifier(struct regulator *regulator, struct notifier_block *nb)¶
register regulator event notifier
Parameters
struct regulator *regulatorregulator source
struct notifier_block *nbnotifier block
Description
Register notifier block to receive regulator events.
Return
0 on success or a negative error number on failure.
-
int regulator_unregister_notifier(struct regulator *regulator, struct notifier_block *nb)¶
unregister regulator event notifier
Parameters
struct regulator *regulatorregulator source
struct notifier_block *nbnotifier block
Description
Unregister regulator event notifier block.
Return
0 on success or a negative error number on failure.
-
int regulator_bulk_get(struct device *dev, int num_consumers, struct regulator_bulk_data *consumers)¶
get multiple regulator consumers
Parameters
struct device *devDevice to supply
int num_consumersNumber of consumers to register
struct regulator_bulk_data *consumersConfiguration of consumers; clients are stored here.
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_bulk_enable(int num_consumers, struct regulator_bulk_data *consumers)¶
enable multiple regulator consumers
Parameters
int num_consumersNumber of consumers
struct regulator_bulk_data *consumersConsumer data; clients are stored here.
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_bulk_disable(int num_consumers, struct regulator_bulk_data *consumers)¶
disable multiple regulator consumers
Parameters
int num_consumersNumber of consumers
struct regulator_bulk_data *consumersConsumer data; clients are stored here.
Description
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.
Return
0 on success or a negative error number on failure.
-
int regulator_bulk_force_disable(int num_consumers, struct regulator_bulk_data *consumers)¶
force disable multiple regulator consumers
Parameters
int num_consumersNumber of consumers
struct regulator_bulk_data *consumersConsumer data; clients are stored here.
Description
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.
Return
0 on success or a negative error number on failure.
-
void regulator_bulk_free(int num_consumers, struct regulator_bulk_data *consumers)¶
free multiple regulator consumers
Parameters
int num_consumersNumber of consumers
struct regulator_bulk_data *consumersConsumer data; clients are stored here.
Description
This convenience API allows consumers to free multiple regulator
clients in a single API call.
-
int regulator_notifier_call_chain(struct regulator_dev *rdev, unsigned long event, void *data)¶
call regulator event notifier
Parameters
struct regulator_dev *rdevregulator source
unsigned long eventnotifier block
void *datacallback-specific data.
Description
Called by regulator drivers to notify clients a regulator event has
occurred.
Return
NOTIFY_DONE.
-
int regulator_mode_to_status(unsigned int mode)¶
convert a regulator mode into a status
Parameters
unsigned int modeMode to convert
Description
Convert a regulator mode into a status.
Return
REGULATOR_STATUS_* value corresponding to given mode.
-
struct regulator_dev *regulator_register(struct device *dev, const struct regulator_desc *regulator_desc, const struct regulator_config *cfg)¶
register regulator
Parameters
struct device *devthe device that drive the regulator
const struct regulator_desc *regulator_descregulator to register
const struct regulator_config *cfgruntime configuration for regulator
Description
Called by regulator drivers to register a regulator.
Return
Pointer to a valid struct regulator_dev on success or
an ERR_PTR() encoded negative error number on failure.
-
void regulator_unregister(struct regulator_dev *rdev)¶
unregister regulator
Parameters
struct regulator_dev *rdevregulator to unregister
Description
Called by regulator drivers to unregister a regulator.
-
void regulator_has_full_constraints(void)¶
the system has fully specified constraints
Parameters
voidno arguments
Description
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.
-
void *rdev_get_drvdata(struct regulator_dev *rdev)¶
get rdev regulator driver data
Parameters
struct regulator_dev *rdevregulator
Description
Get rdev regulator driver private data. This call can be used in the
regulator driver context.
Return
Pointer to regulator driver private data.
-
void *regulator_get_drvdata(struct regulator *regulator)¶
get regulator driver data
Parameters
struct regulator *regulatorregulator
Description
Get regulator driver private data. This call can be used in the consumer
driver context when non API regulator specific functions need to be called.
Return
Pointer to regulator driver private data.
-
void regulator_set_drvdata(struct regulator *regulator, void *data)¶
set regulator driver data
Parameters
struct regulator *regulatorregulator
void *datadata
-
int rdev_get_id(struct regulator_dev *rdev)¶
get regulator ID
Parameters
struct regulator_dev *rdevregulator
Return
Regulator ID for rdev.