Skip to content

Commit 842ee0a

Browse files
danieldegrassecarlescufi
authored andcommitted
drivers: regulator: support regulator-boot-on for PMIC driver
Add support for regulator-boot-on to PMIC driver. Many PMIC devices will be enabled at boot, so this property allows the regulator framework to correctly track their state. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent f10ec43 commit 842ee0a

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

boards/arm/mimxrt595_evk/mimxrt595_evk_cm33.dts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ arduino_serial: &flexcomm12 {
191191
enable-val = <PCA9420_MODECFG_2_SW1_EN_VAL>;
192192
min-uV = <500000>;
193193
max-uV = <1800000>;
194+
regulator-boot-on;
194195
};
195196

196197
pca9420_sw2: sw2_buck {
@@ -207,6 +208,7 @@ arduino_serial: &flexcomm12 {
207208
enable-val = <PCA9420_MODECFG_2_SW2_EN_VAL>;
208209
min-uV = <1500000>;
209210
max-uV = <3300000>;
211+
regulator-boot-on;
210212
};
211213

212214
pca9420_ldo1: ldo1_reg {
@@ -223,6 +225,7 @@ arduino_serial: &flexcomm12 {
223225
enable-val = <PCA9420_MODECFG_2_LDO1_EN_VAL>;
224226
min-uV = <1700000>;
225227
max-uV = <1900000>;
228+
regulator-boot-on;
226229
};
227230

228231
pca9420_ldo2: ldo2_reg {
@@ -239,6 +242,7 @@ arduino_serial: &flexcomm12 {
239242
enable-val = <PCA9420_MODECFG_2_LDO2_EN_VAL>;
240243
min-uV = <1500000>;
241244
max-uV = <3300000>;
245+
regulator-boot-on;
242246
};
243247

244248

boards/arm/mimxrt685_evk/mimxrt685_evk_cm33.dts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ i2s1: &flexcomm3 {
265265
enable-val = <PCA9420_MODECFG_2_SW1_EN_VAL>;
266266
min-uV = <500000>;
267267
max-uV = <1800000>;
268+
regulator-boot-on;
268269
};
269270

270271
pca9420_sw2: sw2_buck {
@@ -281,6 +282,7 @@ i2s1: &flexcomm3 {
281282
enable-val = <PCA9420_MODECFG_2_SW2_EN_VAL>;
282283
min-uV = <1500000>;
283284
max-uV = <3300000>;
285+
regulator-boot-on;
284286
};
285287

286288
pca9420_ldo1: ldo1_reg {
@@ -297,6 +299,7 @@ i2s1: &flexcomm3 {
297299
enable-val = <PCA9420_MODECFG_2_LDO1_EN_VAL>;
298300
min-uV = <1700000>;
299301
max-uV = <1900000>;
302+
regulator-boot-on;
300303
};
301304

302305
pca9420_ldo2: ldo2_reg {
@@ -313,6 +316,7 @@ i2s1: &flexcomm3 {
313316
enable-val = <PCA9420_MODECFG_2_LDO2_EN_VAL>;
314317
min-uV = <1500000>;
315318
max-uV = <3300000>;
319+
regulator-boot-on;
316320
};
317321

318322

drivers/regulator/regulator_pmic.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct regulator_config {
5353
uint8_t enable_mask;
5454
uint8_t enable_val;
5555
bool enable_inverted;
56+
bool boot_on;
5657
uint8_t ilim_reg;
5758
uint8_t ilim_mask;
5859
struct i2c_dt_spec i2c;
@@ -502,6 +503,7 @@ static int pmic_reg_init(const struct device *dev)
502503
{
503504
const struct regulator_config *config = dev->config;
504505
struct regulator_data *data = dev->data;
506+
int rc = 0;
505507

506508
/* Cast the voltage array set at compile time to the voltage range
507509
* struct
@@ -513,10 +515,13 @@ static int pmic_reg_init(const struct device *dev)
513515
if (!device_is_ready(config->i2c.bus)) {
514516
return -ENODEV;
515517
}
518+
if (config->boot_on) {
519+
rc = enable_regulator(dev, NULL);
520+
}
516521
if (config->initial_mode) {
517-
return regulator_set_mode(dev, config->initial_mode);
522+
rc = regulator_set_mode(dev, config->initial_mode);
518523
}
519-
return 0;
524+
return rc;
520525
}
521526

522527

@@ -554,6 +559,7 @@ static const struct regulator_driver_api api = {
554559
.ilim_reg = DT_PROP_OR(node, ilim_reg, 0), \
555560
.ilim_mask = DT_PROP_OR(node, ilim_mask, 0), \
556561
.enable_inverted = DT_PROP(node, enable_inverted), \
562+
.boot_on = DT_PROP_OR(node, regulator_boot_on, false), \
557563
.num_modes = ARRAY_SIZE(pmic_reg_##ord##_allowed_modes), \
558564
.initial_mode = DT_PROP_OR(DT_PARENT(node), regulator_initial_mode, 0), \
559565
.i2c = I2C_DT_SPEC_GET(DT_PARENT(node)), \

dts/bindings/regulator/regulator-pmic.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
description: PMIC controlled regulator
55

6-
include: regulator.yaml
76

87
compatible: "regulator-pmic"
98

9+
include: base.yaml
10+
1011
properties:
1112
regulator-initial-mode:
1213
type: int
@@ -38,6 +39,10 @@ properties:
3839
to the modesel-reg.
3940
4041
child-binding:
42+
include:
43+
- name: regulator.yaml
44+
property-allowlist:
45+
- regulator-boot-on
4146
description: Voltage output of PMIC controller regulator
4247
properties:
4348
voltage-range:

0 commit comments

Comments
 (0)