Skip to content

Commit a00713b

Browse files
aasinclaircarlescufi
authored andcommitted
drivers: regulator: Added initial voltage configuration
The regulator driver has a configured min/max range that is used to limit set values, and to initialise the regulator. A new init value has been added, so that the startup voltage can be higher than the lowest permitted value. Signed-off-by: Andy Sinclair <[email protected]>
1 parent 2380710 commit a00713b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

drivers/regulator/regulator_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ int regulator_common_init(const struct device *dev, bool is_enabled)
2828
}
2929
}
3030

31+
if (config->init_uv > INT32_MIN) {
32+
ret = regulator_set_voltage(dev, config->init_uv, config->init_uv);
33+
if (ret < 0) {
34+
return ret;
35+
}
36+
}
37+
3138
/* If we have valid range values, we try to match them before enabling */
3239
if ((config->min_uv > INT32_MIN) || (config->max_uv < INT32_MAX)) {
3340

dts/bindings/regulator/regulator.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ properties:
1515
type: string
1616
description: A string used as a descriptive name for regulator outputs
1717

18+
regulator-init-microvolt:
19+
type: int
20+
description: Voltage set during initialisation
21+
1822
regulator-min-microvolt:
1923
type: int
2024
description: smallest voltage consumers may set

include/zephyr/drivers/regulator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ struct regulator_common_config {
123123
int32_t min_uv;
124124
/** Maximum allowed voltage, in microvolts. */
125125
int32_t max_uv;
126+
/** Initial voltage, in microvolts. */
127+
int32_t init_uv;
126128
/** Minimum allowed current, in microamps. */
127129
int32_t min_ua;
128130
/** Maximum allowed current, in microamps. */
@@ -148,6 +150,8 @@ struct regulator_common_config {
148150
INT32_MIN), \
149151
.max_uv = DT_PROP_OR(node_id, regulator_max_microvolt, \
150152
INT32_MAX), \
153+
.init_uv = DT_PROP_OR(node_id, regulator_init_microvolt, \
154+
INT32_MIN), \
151155
.min_ua = DT_PROP_OR(node_id, regulator_min_microamp, \
152156
INT32_MIN), \
153157
.max_ua = DT_PROP_OR(node_id, regulator_max_microamp, \

0 commit comments

Comments
 (0)