drivers: regulator: common: Added regulator-boot-off

Added regulator-boot-off option to common regulator driver.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
This commit is contained in:
Andy Sinclair 2024-02-21 11:21:43 +00:00 committed by Anas Nashif
commit 977fc0c2ad
3 changed files with 14 additions and 1 deletions

View file

@ -90,6 +90,9 @@ int regulator_common_init(const struct device *dev, bool is_enabled)
if (is_enabled) {
data->refcnt++;
if ((config->flags & REGULATOR_BOOT_OFF) != 0U) {
return regulator_disable(dev);
}
} else if ((config->flags & REGULATOR_INIT_ENABLED) != 0U) {
ret = api->enable(dev);
if (ret < 0) {

View file

@ -61,6 +61,11 @@ properties:
This property is intended to only be used for regulators where
software cannot read the state of the regulator.
regulator-boot-off:
type: boolean
description: |
Regulator should be disabled on boot.
regulator-allow-bypass:
type: boolean
description: allow the regulator to go into bypass mode

View file

@ -141,6 +141,8 @@ __subsystem struct regulator_driver_api {
/** Regulator active discharge get bits */
#define REGULATOR_ACTIVE_DISCHARGE_GET_BITS(x) \
(((x) & REGULATOR_ACTIVE_DISCHARGE_MASK) >> REGULATOR_ACTIVE_DISCHARGE_POS)
/** Indicates regulator must be initialized OFF */
#define REGULATOR_BOOT_OFF BIT(4)
/** @} */
@ -212,7 +214,9 @@ struct regulator_common_config {
REGULATOR_BOOT_ON) | \
(REGULATOR_ACTIVE_DISCHARGE_SET_BITS( \
DT_PROP_OR(node_id, regulator_active_discharge, \
REGULATOR_ACTIVE_DISCHARGE_DEFAULT)))), \
REGULATOR_ACTIVE_DISCHARGE_DEFAULT))) | \
(DT_PROP_OR(node_id, regulator_boot_off, 0U) * \
REGULATOR_BOOT_OFF)), \
}
/**
@ -254,6 +258,7 @@ void regulator_common_data_init(const struct device *dev);
*
* - Automatically enable the regulator if it is set to `regulator-boot-on`
* or `regulator-always-on` and increase its usage count.
* - Automatically disable the regulator if it is set to `regulator-boot-off`.
* - Configure the regulator mode if `regulator-initial-mode` is set.
* - Ensure regulator voltage is set to a valid range.
*