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 <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2022-10-13 13:11:20 -05:00 committed by Carles Cufí
commit 842ee0acf3
4 changed files with 23 additions and 4 deletions

View file

@ -191,6 +191,7 @@ arduino_serial: &flexcomm12 {
enable-val = <PCA9420_MODECFG_2_SW1_EN_VAL>; enable-val = <PCA9420_MODECFG_2_SW1_EN_VAL>;
min-uV = <500000>; min-uV = <500000>;
max-uV = <1800000>; max-uV = <1800000>;
regulator-boot-on;
}; };
pca9420_sw2: sw2_buck { pca9420_sw2: sw2_buck {
@ -207,6 +208,7 @@ arduino_serial: &flexcomm12 {
enable-val = <PCA9420_MODECFG_2_SW2_EN_VAL>; enable-val = <PCA9420_MODECFG_2_SW2_EN_VAL>;
min-uV = <1500000>; min-uV = <1500000>;
max-uV = <3300000>; max-uV = <3300000>;
regulator-boot-on;
}; };
pca9420_ldo1: ldo1_reg { pca9420_ldo1: ldo1_reg {
@ -223,6 +225,7 @@ arduino_serial: &flexcomm12 {
enable-val = <PCA9420_MODECFG_2_LDO1_EN_VAL>; enable-val = <PCA9420_MODECFG_2_LDO1_EN_VAL>;
min-uV = <1700000>; min-uV = <1700000>;
max-uV = <1900000>; max-uV = <1900000>;
regulator-boot-on;
}; };
pca9420_ldo2: ldo2_reg { pca9420_ldo2: ldo2_reg {
@ -239,6 +242,7 @@ arduino_serial: &flexcomm12 {
enable-val = <PCA9420_MODECFG_2_LDO2_EN_VAL>; enable-val = <PCA9420_MODECFG_2_LDO2_EN_VAL>;
min-uV = <1500000>; min-uV = <1500000>;
max-uV = <3300000>; max-uV = <3300000>;
regulator-boot-on;
}; };

View file

@ -265,6 +265,7 @@ i2s1: &flexcomm3 {
enable-val = <PCA9420_MODECFG_2_SW1_EN_VAL>; enable-val = <PCA9420_MODECFG_2_SW1_EN_VAL>;
min-uV = <500000>; min-uV = <500000>;
max-uV = <1800000>; max-uV = <1800000>;
regulator-boot-on;
}; };
pca9420_sw2: sw2_buck { pca9420_sw2: sw2_buck {
@ -281,6 +282,7 @@ i2s1: &flexcomm3 {
enable-val = <PCA9420_MODECFG_2_SW2_EN_VAL>; enable-val = <PCA9420_MODECFG_2_SW2_EN_VAL>;
min-uV = <1500000>; min-uV = <1500000>;
max-uV = <3300000>; max-uV = <3300000>;
regulator-boot-on;
}; };
pca9420_ldo1: ldo1_reg { pca9420_ldo1: ldo1_reg {
@ -297,6 +299,7 @@ i2s1: &flexcomm3 {
enable-val = <PCA9420_MODECFG_2_LDO1_EN_VAL>; enable-val = <PCA9420_MODECFG_2_LDO1_EN_VAL>;
min-uV = <1700000>; min-uV = <1700000>;
max-uV = <1900000>; max-uV = <1900000>;
regulator-boot-on;
}; };
pca9420_ldo2: ldo2_reg { pca9420_ldo2: ldo2_reg {
@ -313,6 +316,7 @@ i2s1: &flexcomm3 {
enable-val = <PCA9420_MODECFG_2_LDO2_EN_VAL>; enable-val = <PCA9420_MODECFG_2_LDO2_EN_VAL>;
min-uV = <1500000>; min-uV = <1500000>;
max-uV = <3300000>; max-uV = <3300000>;
regulator-boot-on;
}; };

View file

@ -53,6 +53,7 @@ struct regulator_config {
uint8_t enable_mask; uint8_t enable_mask;
uint8_t enable_val; uint8_t enable_val;
bool enable_inverted; bool enable_inverted;
bool boot_on;
uint8_t ilim_reg; uint8_t ilim_reg;
uint8_t ilim_mask; uint8_t ilim_mask;
struct i2c_dt_spec i2c; struct i2c_dt_spec i2c;
@ -502,6 +503,7 @@ static int pmic_reg_init(const struct device *dev)
{ {
const struct regulator_config *config = dev->config; const struct regulator_config *config = dev->config;
struct regulator_data *data = dev->data; struct regulator_data *data = dev->data;
int rc = 0;
/* Cast the voltage array set at compile time to the voltage range /* Cast the voltage array set at compile time to the voltage range
* struct * struct
@ -513,10 +515,13 @@ static int pmic_reg_init(const struct device *dev)
if (!device_is_ready(config->i2c.bus)) { if (!device_is_ready(config->i2c.bus)) {
return -ENODEV; return -ENODEV;
} }
if (config->initial_mode) { if (config->boot_on) {
return regulator_set_mode(dev, config->initial_mode); rc = enable_regulator(dev, NULL);
} }
return 0; if (config->initial_mode) {
rc = regulator_set_mode(dev, config->initial_mode);
}
return rc;
} }
@ -554,6 +559,7 @@ static const struct regulator_driver_api api = {
.ilim_reg = DT_PROP_OR(node, ilim_reg, 0), \ .ilim_reg = DT_PROP_OR(node, ilim_reg, 0), \
.ilim_mask = DT_PROP_OR(node, ilim_mask, 0), \ .ilim_mask = DT_PROP_OR(node, ilim_mask, 0), \
.enable_inverted = DT_PROP(node, enable_inverted), \ .enable_inverted = DT_PROP(node, enable_inverted), \
.boot_on = DT_PROP_OR(node, regulator_boot_on, false), \
.num_modes = ARRAY_SIZE(pmic_reg_##ord##_allowed_modes), \ .num_modes = ARRAY_SIZE(pmic_reg_##ord##_allowed_modes), \
.initial_mode = DT_PROP_OR(DT_PARENT(node), regulator_initial_mode, 0), \ .initial_mode = DT_PROP_OR(DT_PARENT(node), regulator_initial_mode, 0), \
.i2c = I2C_DT_SPEC_GET(DT_PARENT(node)), \ .i2c = I2C_DT_SPEC_GET(DT_PARENT(node)), \

View file

@ -3,10 +3,11 @@
description: PMIC controlled regulator description: PMIC controlled regulator
include: regulator.yaml
compatible: "regulator-pmic" compatible: "regulator-pmic"
include: base.yaml
properties: properties:
regulator-initial-mode: regulator-initial-mode:
type: int type: int
@ -38,6 +39,10 @@ properties:
to the modesel-reg. to the modesel-reg.
child-binding: child-binding:
include:
- name: regulator.yaml
property-allowlist:
- regulator-boot-on
description: Voltage output of PMIC controller regulator description: Voltage output of PMIC controller regulator
properties: properties:
voltage-range: voltage-range: