[PATCH RFC 2/2] regulator: da9063: disable monitoring while regulator is off
From: Benjamin Bara
Date: Thu Apr 20 2023 - 06:32:45 EST
From: Benjamin Bara <benjamin.bara@xxxxxxxxxxx>
The PWR_OK state of the da9063 indicates whether all monitored voltages
are within the expected range. When a regulator is disabled without
disabling its voltage monitor before, the PWR_OK state becomes false. On
our board, this invalid state leads to a hard reset.
Therefore, prevent the invalid state by disabling the monitor before the
regulator is disabled.
This still requires to explicitly enable the voltage monitor in the
device tree and has no impact otherwise.
TODO: clarify if a MODE change has impact on the voltage monitor
Signed-off-by: Benjamin Bara <benjamin.bara@xxxxxxxxxxx>
---
drivers/regulator/da9063-regulator.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 82f52a2a031a..0fa320abad93 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -713,14 +713,27 @@ static irqreturn_t da9063_ldo_lim_event(int irq, void *data)
/*
* Probing and Initialisation functions
*/
+
+/* prevent !PWR_OK state by disabling monitoring while regulator is off. */
+static const struct monitoring_constraints da9063_vmon_constraints = {
+ .mon_disable_during_reg_off = 1,
+};
+
static const struct regulator_init_data *da9063_get_regulator_initdata(
const struct da9063_regulators_pdata *regl_pdata, int id)
{
+ struct regulator_init_data *initdata;
+ struct regulation_constraints *reg_constr;
int i;
for (i = 0; i < regl_pdata->n_regulators; i++) {
- if (id == regl_pdata->regulator_data[i].id)
- return regl_pdata->regulator_data[i].initdata;
+ if (id == regl_pdata->regulator_data[i].id) {
+ initdata = regl_pdata->regulator_data[i].initdata;
+ reg_constr = &initdata->constraints;
+ reg_constr->ov_constraints = &da9063_vmon_constraints;
+ reg_constr->uv_constraints = &da9063_vmon_constraints;
+ return initdata;
+ }
}
return NULL;
--
2.34.1