Zephyr Project API  3.3.0
A Scalable Open Source RTOS
Regulator Interface

Regulator Interface. More...

Modules

 NPM1100 Devicetree helpers.
 
 NPM6001 Devicetree helpers.
 
 Regulator Parent Interface
 Regulator Parent Interface.
 

Typedefs

typedef uint8_t regulator_dvs_state_t
 
typedef uint8_t regulator_mode_t
 
typedef uint8_t regulator_error_flags_t
 

Functions

int regulator_enable (const struct device *dev)
 Enable a regulator. More...
 
bool regulator_is_enabled (const struct device *dev)
 Check if a regulator is enabled. More...
 
int regulator_disable (const struct device *dev)
 Disable a regulator. More...
 
static unsigned int regulator_count_voltages (const struct device *dev)
 Obtain the number of supported voltage levels. More...
 
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. More...
 
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. More...
 
int regulator_set_voltage (const struct device *dev, int32_t min_uv, int32_t max_uv)
 Set the output voltage. More...
 
static int regulator_get_voltage (const struct device *dev, int32_t *volt_uv)
 Obtain output voltage. More...
 
int regulator_set_current_limit (const struct device *dev, int32_t min_ua, int32_t max_ua)
 Set output current limit. More...
 
static int regulator_get_current_limit (const struct device *dev, int32_t *curr_ua)
 Get output current limit. More...
 
int regulator_set_mode (const struct device *dev, regulator_mode_t mode)
 Set mode. More...
 
static int regulator_get_mode (const struct device *dev, regulator_mode_t *mode)
 Get mode. More...
 
static int regulator_get_error_flags (const struct device *dev, regulator_error_flags_t *flags)
 Get active error flags. More...
 

Regulator error flags.

#define REGULATOR_ERROR_OVER_VOLTAGE   BIT(0)
 
#define REGULATOR_ERROR_OVER_CURRENT   BIT(1)
 
#define REGULATOR_ERROR_OVER_TEMP   BIT(2)
 

Detailed Description

Regulator Interface.

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_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.

◆ 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.

◆ 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_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_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.