Zephyr Project API 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Regulator Interface

Regulator Interface. More...

Modules

 ADP5360 Devicetree helpers.
 
 AXP192 Devicetree helpers.
 
 Devicetree helpers
 
 MAX20335 Devicetree helpers.
 
 NPM1100 Devicetree helpers.
 
 NPM1300 Devicetree helpers.
 
 NPM6001 Devicetree helpers.
 
 Regulator Parent Interface
 Regulator Parent Interface.
 
 Silabs DCDC devicetree helpers.
 
 nRF5X regulator devicetree helpers.
 

Typedefs

typedef uint8_t regulator_dvs_state_t
 Opaque type to store regulator DVS states.
 
typedef uint8_t regulator_mode_t
 Opaque type to store regulator modes.
 
typedef uint8_t regulator_error_flags_t
 Opaque bit map for regulator error flags (see REGULATOR_ERRORS)
 

Functions

int regulator_enable (const struct device *dev)
 Enable a regulator.
 
bool regulator_is_enabled (const struct device *dev)
 Check if a regulator is enabled.
 
int regulator_disable (const struct device *dev)
 Disable a regulator.
 
static unsigned int regulator_count_voltages (const struct device *dev)
 Obtain the number of supported voltage levels.
 
static int regulator_list_voltage (const struct device *dev, unsigned int idx, int32_t *volt_uv)
 Obtain the value of a voltage given an index.
 
bool regulator_is_supported_voltage (const struct device *dev, int32_t min_uv, int32_t max_uv)
 Check if a voltage within a window is supported.
 
int regulator_set_voltage (const struct device *dev, int32_t min_uv, int32_t max_uv)
 Set the output voltage.
 
static int regulator_get_voltage (const struct device *dev, int32_t *volt_uv)
 Obtain output voltage.
 
static unsigned int regulator_count_current_limits (const struct device *dev)
 Obtain the number of supported current limit levels.
 
static int regulator_list_current_limit (const struct device *dev, unsigned int idx, int32_t *current_ua)
 Obtain the value of a current limit given an index.
 
int regulator_set_current_limit (const struct device *dev, int32_t min_ua, int32_t max_ua)
 Set output current limit.
 
static int regulator_get_current_limit (const struct device *dev, int32_t *curr_ua)
 Get output current limit.
 
int regulator_set_mode (const struct device *dev, regulator_mode_t mode)
 Set mode.
 
static int regulator_get_mode (const struct device *dev, regulator_mode_t *mode)
 Get mode.
 
static int regulator_set_active_discharge (const struct device *dev, bool active_discharge)
 Set active discharge setting.
 
static int regulator_get_active_discharge (const struct device *dev, bool *active_discharge)
 Get active discharge setting.
 
static int regulator_get_error_flags (const struct device *dev, regulator_error_flags_t *flags)
 Get active error flags.
 

Regulator error flags.

#define REGULATOR_ERROR_OVER_VOLTAGE   BIT(0)
 Voltage is too high.
 
#define REGULATOR_ERROR_OVER_CURRENT   BIT(1)
 Current is too high.
 
#define REGULATOR_ERROR_OVER_TEMP   BIT(2)
 Temperature is too high.
 

Detailed Description

Regulator Interface.

Since
2.4
Version
0.1.0

Macro Definition Documentation

◆ REGULATOR_ERROR_OVER_CURRENT

#define REGULATOR_ERROR_OVER_CURRENT   BIT(1)

#include <include/zephyr/drivers/regulator.h>

Current is too high.

◆ REGULATOR_ERROR_OVER_TEMP

#define REGULATOR_ERROR_OVER_TEMP   BIT(2)

#include <include/zephyr/drivers/regulator.h>

Temperature is too high.

◆ REGULATOR_ERROR_OVER_VOLTAGE

#define REGULATOR_ERROR_OVER_VOLTAGE   BIT(0)

#include <include/zephyr/drivers/regulator.h>

Voltage is too high.

Typedef Documentation

◆ regulator_dvs_state_t

#include <include/zephyr/drivers/regulator.h>

Opaque type to store regulator DVS states.

◆ regulator_error_flags_t

#include <include/zephyr/drivers/regulator.h>

Opaque bit map for regulator error flags (see REGULATOR_ERRORS)

◆ regulator_mode_t

#include <include/zephyr/drivers/regulator.h>

Opaque type to store regulator modes.

Function Documentation

◆ regulator_count_current_limits()

static unsigned int regulator_count_current_limits ( const struct device dev)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Obtain the number of supported current limit levels.

Each current limit level supported by a regulator gets an index, starting from zero. The total number of supported current limit levels can be used together with regulator_list_current_limit() to list all supported current limit levels.

Parameters
devRegulator device instance.
Returns
Number of supported current limits.

◆ regulator_count_voltages()

static unsigned int regulator_count_voltages ( const struct device dev)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Obtain the number of supported voltage levels.

Each voltage level supported by a regulator gets an index, starting from zero. The total number of supported voltage levels can be used together with regulator_list_voltage() to list all supported voltage levels.

Parameters
devRegulator device instance.
Returns
Number of supported voltages.

◆ regulator_disable()

int regulator_disable ( const struct device dev)

#include <include/zephyr/drivers/regulator.h>

Disable a regulator.

Release a regulator after a previous regulator_enable() completed successfully. Regulators that are always on, or configured in devicetree with regulator-always-on will always stay enabled, and so this function will always succeed.

This must be invoked at most once for each successful regulator_enable().

Parameters
devRegulator device instance.
Return values
0If regulator has been successfully disabled.
-errnoNegative errno in case of failure.
-ENOTSUPIf regulator disablement can not be controlled.

◆ regulator_enable()

int regulator_enable ( const struct device dev)

#include <include/zephyr/drivers/regulator.h>

Enable a regulator.

Reference-counted request that a regulator be turned on. A regulator is considered "on" when it has reached a stable/usable state. Regulators that are always on, or configured in devicetree with regulator-always-on will always stay enabled, and so this function will always succeed.

Parameters
devRegulator device instance
Return values
0If regulator has been successfully enabled.
-errnoNegative errno in case of failure.
-ENOTSUPIf regulator enablement can not be controlled.

◆ regulator_get_active_discharge()

static int regulator_get_active_discharge ( const struct device dev,
bool active_discharge 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Get active discharge setting.

Parameters
devRegulator device instance.
[out]active_dischargeWhere active discharge will be stored.
Return values
0If successful.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_get_current_limit()

static int regulator_get_current_limit ( const struct device dev,
int32_t curr_ua 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Get output current limit.

Parameters
devRegulator device instance.
[out]curr_uaWhere output current limit will be stored.
Return values
0If successful.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_get_error_flags()

static int regulator_get_error_flags ( const struct device dev,
regulator_error_flags_t flags 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Get active error flags.

Parameters
devRegulator device instance.
[out]flagsWhere error flags will be stored.
Return values
0If successful.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_get_mode()

static int regulator_get_mode ( const struct device dev,
regulator_mode_t mode 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Get mode.

Parameters
devRegulator device instance.
[out]modeWhere mode will be stored.
Return values
0If successful.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_get_voltage()

static int regulator_get_voltage ( const struct device dev,
int32_t volt_uv 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Obtain output voltage.

Parameters
devRegulator device instance.
[out]volt_uvWhere configured output voltage will be stored.
Return values
0If successful
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_is_enabled()

bool regulator_is_enabled ( const struct device dev)

#include <include/zephyr/drivers/regulator.h>

Check if a regulator is enabled.

Parameters
devRegulator device instance.
Return values
trueIf regulator is enabled.
falseIf regulator is disabled.

◆ regulator_is_supported_voltage()

bool regulator_is_supported_voltage ( const struct device dev,
int32_t  min_uv,
int32_t  max_uv 
)

#include <include/zephyr/drivers/regulator.h>

Check if a voltage within a window is supported.

Parameters
devRegulator device instance.
min_uvMinimum voltage in microvolts.
max_uvmaximum voltage in microvolts.
Return values
trueIf voltage is supported.
falseIf voltage is not supported.

◆ regulator_list_current_limit()

static int regulator_list_current_limit ( const struct device dev,
unsigned int  idx,
int32_t current_ua 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Obtain the value of a current limit given an index.

Each current limit level supported by a regulator gets an index, starting from zero. Together with regulator_count_current_limits(), this function can be used to iterate over all supported current limits.

Parameters
devRegulator device instance.
idxCurrent index.
[out]current_uaWhere current for the given index will be stored, in microamps.
Return values
0If index corresponds to a supported current limit.
-EINVALIf index does not correspond to a supported current limit.

◆ regulator_list_voltage()

static int regulator_list_voltage ( const struct device dev,
unsigned int  idx,
int32_t volt_uv 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Obtain the value of a voltage given an index.

Each voltage level supported by a regulator gets an index, starting from zero. Together with regulator_count_voltages(), this function can be used to iterate over all supported voltages.

Parameters
devRegulator device instance.
idxVoltage index.
[out]volt_uvWhere voltage for the given index will be stored, in microvolts.
Return values
0If index corresponds to a supported voltage.
-EINVALIf index does not correspond to a supported voltage.

◆ regulator_set_active_discharge()

static int regulator_set_active_discharge ( const struct device dev,
bool  active_discharge 
)
inlinestatic

#include <include/zephyr/drivers/regulator.h>

Set active discharge setting.

Parameters
devRegulator device instance.
active_dischargeActive discharge enable or disable.
Return values
0If successful.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_set_current_limit()

int regulator_set_current_limit ( const struct device dev,
int32_t  min_ua,
int32_t  max_ua 
)

#include <include/zephyr/drivers/regulator.h>

Set output current limit.

The output current limit will be configured to the closest supported output current limit. regulator_get_current_limit() can be used to obtain the actual configured current limit. Current may be limited using current-min-microamp and/or current-max-microamp in Devicetree.

Parameters
devRegulator device instance.
min_uaMinimum acceptable current limit in microamps.
max_uaMaximum acceptable current limit in microamps.
Return values
0If successful.
-EINVALIf the given current limit window is not valid.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_set_mode()

int regulator_set_mode ( const struct device dev,
regulator_mode_t  mode 
)

#include <include/zephyr/drivers/regulator.h>

Set mode.

Regulators can support multiple modes in order to permit different voltage configuration or better power savings. This API will apply a mode for the regulator. Allowed modes may be limited using regulator-allowed-modes devicetree property.

Parameters
devRegulator device instance.
modeMode to select for this regulator.
Return values
0If successful.
-ENOTSUPIf mode is not supported.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.

◆ regulator_set_voltage()

int regulator_set_voltage ( const struct device dev,
int32_t  min_uv,
int32_t  max_uv 
)

#include <include/zephyr/drivers/regulator.h>

Set the output voltage.

The output voltage will be configured to the closest supported output voltage. regulator_get_voltage() can be used to obtain the actual configured voltage. The voltage will be applied to the active or selected mode. Output voltage may be limited using regulator-min-microvolt and/or regulator-max-microvolt in devicetree.

Parameters
devRegulator device instance.
min_uvMinimum acceptable voltage in microvolts.
max_uvMaximum acceptable voltage in microvolts.
Return values
0If successful.
-EINVALIf the given voltage window is not valid.
-ENOSYSIf function is not implemented.
-errnoIn case of any other error.