[PATCH RFC v2 2/2] regulator: da9063: disable monitoring while regulator is off

From: Benjamin Bara
Date: Fri Apr 21 2023 - 05:13:29 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 | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 82f52a2a031a..13a6b189f23a 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -99,6 +99,7 @@ struct da9063_regulator_info {
.desc.vsel_reg = DA9063_REG_V##regl_name##_A, \
.desc.vsel_mask = DA9063_V##regl_name##_MASK, \
.desc.linear_min_sel = DA9063_V##regl_name##_BIAS, \
+ .desc.mon_disable_while_reg_off = 1, \
.sleep = BFIELD(DA9063_REG_V##regl_name##_A, DA9063_LDO_SL), \
.suspend = BFIELD(DA9063_REG_##regl_name##_CONT, DA9063_LDO_CONF), \
.suspend_sleep = BFIELD(DA9063_REG_V##regl_name##_B, DA9063_LDO_SL), \
@@ -124,6 +125,7 @@ struct da9063_regulator_info {
.desc.vsel_reg = DA9063_REG_V##regl_name##_A, \
.desc.vsel_mask = DA9063_VBUCK_MASK, \
.desc.linear_min_sel = DA9063_VBUCK_BIAS, \
+ .desc.mon_disable_while_reg_off = 1, \
.sleep = BFIELD(DA9063_REG_V##regl_name##_A, DA9063_BUCK_SL), \
.suspend = BFIELD(DA9063_REG_##regl_name##_CONT, DA9063_BUCK_CONF), \
.suspend_sleep = BFIELD(DA9063_REG_V##regl_name##_B, DA9063_BUCK_SL), \

--
2.34.1