Skip to content

Commit f71ddc7

Browse files
aasinclaircvinayak
authored andcommitted
[nrf fromtree] drivers: regulator: common: Added regulator-boot-off
Added regulator-boot-off option to common regulator driver. Signed-off-by: Andy Sinclair <[email protected]> (cherry picked from commit a14abeb)
1 parent 54b4e40 commit f71ddc7

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

drivers/regulator/regulator_common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ int regulator_common_init(const struct device *dev, bool is_enabled)
9090

9191
if (is_enabled) {
9292
data->refcnt++;
93+
if ((config->flags & REGULATOR_BOOT_OFF) != 0U) {
94+
return regulator_disable(dev);
95+
}
9396
} else if ((config->flags & REGULATOR_INIT_ENABLED) != 0U) {
9497
ret = api->enable(dev);
9598
if (ret < 0) {

dts/bindings/regulator/regulator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ properties:
6161
This property is intended to only be used for regulators where
6262
software cannot read the state of the regulator.
6363
64+
regulator-boot-off:
65+
type: boolean
66+
description: |
67+
Regulator should be disabled on boot.
68+
6469
regulator-allow-bypass:
6570
type: boolean
6671
description: allow the regulator to go into bypass mode

include/zephyr/drivers/regulator.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ __subsystem struct regulator_driver_api {
141141
/** Regulator active discharge get bits */
142142
#define REGULATOR_ACTIVE_DISCHARGE_GET_BITS(x) \
143143
(((x) & REGULATOR_ACTIVE_DISCHARGE_MASK) >> REGULATOR_ACTIVE_DISCHARGE_POS)
144+
/** Indicates regulator must be initialized OFF */
145+
#define REGULATOR_BOOT_OFF BIT(4)
144146

145147
/** @} */
146148

@@ -212,7 +214,9 @@ struct regulator_common_config {
212214
REGULATOR_BOOT_ON) | \
213215
(REGULATOR_ACTIVE_DISCHARGE_SET_BITS( \
214216
DT_PROP_OR(node_id, regulator_active_discharge, \
215-
REGULATOR_ACTIVE_DISCHARGE_DEFAULT)))), \
217+
REGULATOR_ACTIVE_DISCHARGE_DEFAULT))) | \
218+
(DT_PROP_OR(node_id, regulator_boot_off, 0U) * \
219+
REGULATOR_BOOT_OFF)), \
216220
}
217221

218222
/**
@@ -254,6 +258,7 @@ void regulator_common_data_init(const struct device *dev);
254258
*
255259
* - Automatically enable the regulator if it is set to `regulator-boot-on`
256260
* or `regulator-always-on` and increase its usage count.
261+
* - Automatically disable the regulator if it is set to `regulator-boot-off`.
257262
* - Configure the regulator mode if `regulator-initial-mode` is set.
258263
* - Ensure regulator voltage is set to a valid range.
259264
*

0 commit comments

Comments
 (0)