[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230419-dynamic-vmon-v4-3-4d3734e62ada@skidata.com>
Date: Tue, 20 Jun 2023 22:02:56 +0200
From: Benjamin Bara <bbara93@...il.com>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: support.opensource@...semi.com,
DLG-Adam.Ward.opensource@...renesas.com,
Martin Fuzzey <martin.fuzzey@...wbird.group>,
linux-kernel@...r.kernel.org,
Matti Vaittinen <mazziesaccount@...il.com>,
Benjamin Bara <benjamin.bara@...data.com>
Subject: [PATCH RFC v4 03/13] regulator: da9063: implement
get_active_protections()
From: Benjamin Bara <benjamin.bara@...data.com>
Implement the new get_active_protections() op. This helps to find out if
a monitor is enabled and the DT is unaware of it. This could result to
an invalid state, as the !PWR_OK state might be triggered if the
regulator is turned off while the monitor stays active.
Signed-off-by: Benjamin Bara <benjamin.bara@...data.com>
---
drivers/regulator/da9063-regulator.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 308ad63fcf78..071b368f154f 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -207,6 +207,24 @@ static const unsigned int da9063_bmem_bio_merged_limits[] = {
4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
};
+static int da9063_get_xvp(struct regulator_dev *rdev, unsigned int *state)
+{
+ struct da9063_regulator *regl = rdev_get_drvdata(rdev);
+ unsigned int val;
+ int ret;
+
+ ret = regmap_field_read(regl->vmon, &val);
+ if (ret)
+ return ret;
+
+ *state = REGULATOR_MONITOR_NONE;
+ if (val)
+ *state = REGULATOR_MONITOR_OVER_VOLTAGE |
+ REGULATOR_MONITOR_UNDER_VOLTAGE;
+
+ return 0;
+}
+
static int da9063_set_xvp(struct regulator_dev *rdev, int lim_uV, int severity, bool enable)
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
@@ -580,6 +598,7 @@ static const struct regulator_ops da9063_buck_ops = {
.set_suspend_mode = da9063_buck_set_suspend_mode,
.set_over_voltage_protection = da9063_set_xvp,
.set_under_voltage_protection = da9063_set_xvp,
+ .get_active_protections = da9063_get_xvp,
};
static const struct regulator_ops da9063_ldo_ops = {
@@ -598,6 +617,7 @@ static const struct regulator_ops da9063_ldo_ops = {
.set_suspend_mode = da9063_ldo_set_suspend_mode,
.set_over_voltage_protection = da9063_set_xvp,
.set_under_voltage_protection = da9063_set_xvp,
+ .get_active_protections = da9063_get_xvp,
};
/* Info of regulators for DA9063 */
--
2.34.1
Powered by blists - more mailing lists