From: Benjamin Bara <bbara93@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: support.opensource@diasemi.com,
DLG-Adam.Ward.opensource@dm.renesas.com,
Martin Fuzzey <martin.fuzzey@flowbird.group>,
linux-kernel@vger.kernel.org,
Matti Vaittinen <mazziesaccount@gmail.com>,
Benjamin Bara <benjamin.bara@skidata.com>
Subject: [PATCH RFC v4 04/13] regulator: bd718x7: implement get_active_protections()
Date: Tue, 20 Jun 2023 22:02:57 +0200 [thread overview]
Message-ID: <20230419-dynamic-vmon-v4-4-4d3734e62ada@skidata.com> (raw)
In-Reply-To: <20230419-dynamic-vmon-v4-0-4d3734e62ada@skidata.com>
From: Benjamin Bara <benjamin.bara@skidata.com>
This is required as the mon_disable_reg_set_higher workaround property
requires the ops to find out if it the monitor is set without the
device-tree being aware of it.
Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
---
drivers/regulator/bd718x7-regulator.c | 74 ++++++++++++++++++++++++++++-------
1 file changed, 60 insertions(+), 14 deletions(-)
diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c
index b0b9938c20a1..fbf609d219fc 100644
--- a/drivers/regulator/bd718x7-regulator.c
+++ b/drivers/regulator/bd718x7-regulator.c
@@ -56,7 +56,7 @@
#define BD718XX_OPS(name, _list_voltage, _map_voltage, _set_voltage_sel, \
_get_voltage_sel, _set_voltage_time_sel, _set_ramp_delay, \
- _set_uvp, _set_ovp) \
+ _set_uvp, _set_ovp, _get_prot) \
static const struct regulator_ops name = { \
.enable = regulator_enable_regmap, \
.disable = regulator_disable_regmap, \
@@ -69,6 +69,7 @@ static const struct regulator_ops name = { \
.set_ramp_delay = (_set_ramp_delay), \
.set_under_voltage_protection = (_set_uvp), \
.set_over_voltage_protection = (_set_ovp), \
+ .get_active_protections = (_get_prot), \
}; \
\
static const struct regulator_ops BD718XX_HWOPNAME(name) = { \
@@ -81,6 +82,7 @@ static const struct regulator_ops BD718XX_HWOPNAME(name) = { \
.set_ramp_delay = (_set_ramp_delay), \
.set_under_voltage_protection = (_set_uvp), \
.set_over_voltage_protection = (_set_ovp), \
+ .get_active_protections = (_get_prot), \
} \
/*
@@ -457,6 +459,23 @@ static int bd718x7_xvp_sanity_check(struct regulator_dev *rdev, int lim_uV,
return 0;
}
+static int bd717x7_get_ldo_prot(struct regulator_dev *rdev, unsigned int *state)
+{
+ int ldo_offset = rdev->desc->id - BD718XX_LDO1;
+ int prot_bit = BD718XX_LDO1_VRMON80 << ldo_offset;
+ int ret;
+
+ ret = regmap_test_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2, prot_bit);
+ if (ret < 0)
+ return ret;
+
+ *state = REGULATOR_MONITOR_NONE;
+ if (ret)
+ *state = REGULATOR_MONITOR_UNDER_VOLTAGE;
+
+ return 0;
+}
+
static int bd718x7_set_ldo_uvp(struct regulator_dev *rdev, int lim_uV,
int severity, bool enable)
{
@@ -519,6 +538,33 @@ static int bd718x7_get_buck_uvp_info(int id, int *reg, int *bit)
return 0;
}
+static int bd717x7_get_buck_prot(struct regulator_dev *rdev, unsigned int *state)
+{
+ int ret, reg, bit;
+
+ ret = bd718x7_get_buck_uvp_info(rdev->desc->id, ®, &bit);
+ if (ret)
+ return ret;
+ ret = regmap_test_bits(rdev->regmap, reg, bit);
+ if (ret < 0)
+ return ret;
+
+ *state = REGULATOR_MONITOR_NONE;
+ if (ret)
+ *state = REGULATOR_MONITOR_UNDER_VOLTAGE;
+
+ ret = bd718x7_get_buck_ovp_info(rdev->desc->id, ®, &bit);
+ if (ret)
+ return ret;
+ ret = regmap_test_bits(rdev->regmap, reg, bit);
+ if (ret < 0)
+ return ret;
+ if (ret)
+ *state |= REGULATOR_MONITOR_OVER_VOLTAGE;
+
+ return 0;
+}
+
static int bd718x7_set_buck_uvp(struct regulator_dev *rdev, int lim_uV,
int severity, bool enable)
{
@@ -566,7 +612,7 @@ BD718XX_OPS(bd718xx_pickable_range_ldo_ops,
regulator_list_voltage_pickable_linear_range, NULL,
bd718xx_set_voltage_sel_pickable_restricted,
regulator_get_voltage_sel_pickable_regmap, NULL, NULL,
- bd718x7_set_ldo_uvp, NULL);
+ bd718x7_set_ldo_uvp, NULL, bd717x7_get_ldo_prot);
/* BD71847 and BD71850 LDO 5 is by default OFF at RUN state */
static const struct regulator_ops bd718xx_ldo5_ops_hwstate = {
@@ -582,27 +628,27 @@ BD718XX_OPS(bd718xx_pickable_range_buck_ops,
regulator_set_voltage_sel_pickable_regmap,
regulator_get_voltage_sel_pickable_regmap,
regulator_set_voltage_time_sel, NULL, bd718x7_set_buck_uvp,
- bd718x7_set_buck_ovp);
+ bd718x7_set_buck_ovp, bd717x7_get_buck_prot);
BD718XX_OPS(bd718xx_ldo_regulator_ops, regulator_list_voltage_linear_range,
NULL, bd718xx_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
- NULL);
+ NULL, bd717x7_get_ldo_prot);
BD718XX_OPS(bd718xx_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
NULL, bd718xx_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
- NULL);
+ NULL, bd717x7_get_ldo_prot);
BD718XX_OPS(bd718xx_buck_regulator_ops, regulator_list_voltage_linear_range,
NULL, regulator_set_voltage_sel_regmap,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
- NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
+ NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp, bd717x7_get_buck_prot);
BD718XX_OPS(bd718xx_buck_regulator_nolinear_ops, regulator_list_voltage_table,
regulator_map_voltage_ascend, regulator_set_voltage_sel_regmap,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
- NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
+ NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp, bd717x7_get_buck_prot);
/*
* OPS for BD71837
@@ -611,34 +657,34 @@ BD718XX_OPS(bd71837_pickable_range_ldo_ops,
regulator_list_voltage_pickable_linear_range, NULL,
bd71837_set_voltage_sel_pickable_restricted,
regulator_get_voltage_sel_pickable_regmap, NULL, NULL,
- bd718x7_set_ldo_uvp, NULL);
+ bd718x7_set_ldo_uvp, NULL, bd717x7_get_ldo_prot);
BD718XX_OPS(bd71837_pickable_range_buck_ops,
regulator_list_voltage_pickable_linear_range, NULL,
bd71837_set_voltage_sel_pickable_restricted,
regulator_get_voltage_sel_pickable_regmap,
regulator_set_voltage_time_sel, NULL, bd718x7_set_buck_uvp,
- bd718x7_set_buck_ovp);
+ bd718x7_set_buck_ovp, bd717x7_get_buck_prot);
BD718XX_OPS(bd71837_ldo_regulator_ops, regulator_list_voltage_linear_range,
NULL, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
- NULL);
+ NULL, bd717x7_get_ldo_prot);
BD718XX_OPS(bd71837_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
NULL, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
- NULL);
+ NULL, bd717x7_get_ldo_prot);
BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range,
NULL, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
- NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
+ NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp, bd717x7_get_buck_prot);
BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table,
regulator_map_voltage_ascend, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
- NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
+ NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp, bd717x7_get_buck_prot);
/*
* BD71837 bucks 3 and 4 support defining their enable/disable state also
* when buck enable state is under HW state machine control. In that case the
@@ -662,7 +708,7 @@ BD718XX_OPS(bd718xx_dvs_buck_regulator_ops, regulator_list_voltage_linear_range,
NULL, regulator_set_voltage_sel_regmap,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
regulator_set_ramp_delay_regmap, bd718x7_set_buck_uvp,
- bd718x7_set_buck_ovp);
+ bd718x7_set_buck_ovp, bd717x7_get_buck_prot);
--
2.34.1
next prev parent reply other threads:[~2023-06-20 20:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 20:02 [PATCH RFC v4 00/13] regulator: dynamic voltage monitoring support Benjamin Bara
2023-06-20 20:02 ` [PATCH RFC v4 01/13] regulator: da9063: fix null pointer deref with partial DT config Benjamin Bara
2023-06-20 20:02 ` [PATCH RFC v4 02/13] regulator: add getter for active monitors Benjamin Bara
2023-06-26 13:43 ` Matti Vaittinen
2023-06-26 16:37 ` Mark Brown
2023-06-20 20:02 ` [PATCH RFC v4 03/13] regulator: da9063: implement get_active_protections() Benjamin Bara
2023-06-20 20:02 ` Benjamin Bara [this message]
2023-06-26 13:45 ` [PATCH RFC v4 04/13] regulator: bd718x7: " Matti Vaittinen
2023-06-20 20:02 ` [PATCH RFC v4 05/13] regulator: introduce properties for monitoring workarounds Benjamin Bara
2023-06-26 13:47 ` Matti Vaittinen
2023-06-20 20:02 ` [PATCH RFC v4 06/13] regulator: set required ops " Benjamin Bara
2023-06-26 13:49 ` Matti Vaittinen
2023-06-20 20:03 ` [PATCH RFC v4 07/13] regulator: find active protections during initialization Benjamin Bara
2023-06-26 13:56 ` Matti Vaittinen
2023-06-26 16:49 ` Mark Brown
2023-07-03 18:43 ` Benjamin Bara
2023-07-04 13:49 ` Mark Brown
2023-06-20 20:03 ` [PATCH RFC v4 08/13] regulator: move monitor handling into own function Benjamin Bara
2023-06-26 14:04 ` Matti Vaittinen
2023-06-20 20:03 ` [PATCH RFC v4 09/13] regulator: implement mon_disable_reg_disabled Benjamin Bara
2023-07-03 10:31 ` Matti Vaittinen
2023-07-03 18:50 ` Benjamin Bara
2023-06-20 20:03 ` [PATCH RFC v4 10/13] regulator: implement mon_disable_reg_set_{higher,lower} Benjamin Bara
2023-07-03 10:45 ` Matti Vaittinen
2023-06-20 20:03 ` [PATCH RFC v4 11/13] regulator: implement mon_unsupported_reg_modes Benjamin Bara
2023-07-03 10:49 ` Matti Vaittinen
2023-06-20 20:03 ` [PATCH RFC v4 12/13] regulator: da9063: let the core handle the monitors Benjamin Bara
2023-06-20 20:03 ` [PATCH RFC v4 13/13] regulator: bd718x7: " Benjamin Bara
2023-07-03 11:02 ` Matti Vaittinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230419-dynamic-vmon-v4-4-4d3734e62ada@skidata.com \
--to=bbara93@gmail.com \
--cc=DLG-Adam.Ward.opensource@dm.renesas.com \
--cc=benjamin.bara@skidata.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.fuzzey@flowbird.group \
--cc=mazziesaccount@gmail.com \
--cc=support.opensource@diasemi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).