From: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
To: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
linux-power@fi.rohmeurope.com, linux-kernel@vger.kernel.org
Subject: [PATCH v6 10/16] regulator: rohm-regulator: linear voltage support
Date: Mon, 5 Apr 2021 14:43:26 +0300 [thread overview]
Message-ID: <8a9519e2fb81569c7488737901f0ecab926c658e.1617616855.git.matti.vaittinen@fi.rohmeurope.com> (raw)
In-Reply-To: <cover.1617616855.git.matti.vaittinen@fi.rohmeurope.com>
The helper for obtaining HW-state based DVS voltage levels currently only
works for regulators using linear-ranges. Extend support to regulators with
simple linear mappings and add also proper error path if pickable-ranges
regulators call this.
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Mark Brown <broonie@kernel.org>
---
Changes since v3:
- No changes
drivers/regulator/rohm-regulator.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/rohm-regulator.c b/drivers/regulator/rohm-regulator.c
index 5c558b153d55..63aabb8c7786 100644
--- a/drivers/regulator/rohm-regulator.c
+++ b/drivers/regulator/rohm-regulator.c
@@ -22,13 +22,26 @@ static int set_dvs_level(const struct regulator_desc *desc,
return ret;
return 0;
}
-
+ /* If voltage is set to 0 => disable */
if (uv == 0) {
if (omask)
return regmap_update_bits(regmap, oreg, omask, 0);
}
+ /* Some setups don't allow setting own voltage but do allow enabling */
+ if (!mask) {
+ if (omask)
+ return regmap_update_bits(regmap, oreg, omask, omask);
+
+ return -EINVAL;
+ }
for (i = 0; i < desc->n_voltages; i++) {
- ret = regulator_desc_list_voltage_linear_range(desc, i);
+ /* NOTE to next hacker - Does not support pickable ranges */
+ if (desc->linear_range_selectors)
+ return -EINVAL;
+ if (desc->n_linear_ranges)
+ ret = regulator_desc_list_voltage_linear_range(desc, i);
+ else
+ ret = regulator_desc_list_voltage_linear(desc, i);
if (ret < 0)
continue;
if (ret == uv) {
--
2.25.4
--
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND
~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =]
next prev parent reply other threads:[~2021-04-05 11:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-05 11:40 [PATCH v6 00/16] Support ROHM BD71815 PMIC Matti Vaittinen
2021-04-05 11:40 ` [PATCH v6 01/16] rtc: bd70528: Do not require parent data Matti Vaittinen
2021-04-05 11:40 ` [PATCH v6 02/16] mfd: bd718x7: simplify by cleaning unnecessary device data Matti Vaittinen
2021-04-05 11:41 ` [PATCH v6 03/16] dt_bindings: bd71828: Add clock output mode Matti Vaittinen
2021-04-05 11:41 ` [PATCH v6 04/16] dt_bindings: regulator: Add ROHM BD71815 PMIC regulators Matti Vaittinen
2021-04-05 11:41 ` [PATCH v6 05/16] dt_bindings: mfd: Add ROHM BD71815 PMIC Matti Vaittinen
2021-04-05 11:42 ` [PATCH v6 06/16] mfd: Add ROHM BD71815 ID Matti Vaittinen
2021-04-05 11:42 ` [PATCH v6 07/16] mfd: Sort ROHM chip ID list for better readability Matti Vaittinen
2021-04-05 11:42 ` [PATCH v6 08/16] mfd: Support for ROHM BD71815 PMIC core Matti Vaittinen
2021-04-05 11:43 ` [PATCH v6 09/16] gpio: support ROHM BD71815 GPOs Matti Vaittinen
2021-04-05 11:43 ` Matti Vaittinen [this message]
2021-04-05 11:43 ` [PATCH v6 11/16] regulator: rohm-regulator: Support SNVS HW state Matti Vaittinen
2021-04-05 11:44 ` [PATCH v6 12/16] regulator: bd718x7, bd71828: Use ramp-delay helper Matti Vaittinen
2021-04-05 11:44 ` [PATCH v6 13/16] regulator: Support ROHM BD71815 regulators Matti Vaittinen
2021-04-05 11:44 ` [PATCH v6 14/16] clk: bd718x7: Add support for clk gate on ROHM BD71815 PMIC Matti Vaittinen
2021-04-05 11:44 ` [PATCH v6 15/16] rtc: bd70528: Support RTC on ROHM BD71815 Matti Vaittinen
2021-04-05 11:45 ` [PATCH v6 16/16] MAINTAINERS: Add ROHM BD71815AGW Matti Vaittinen
2021-04-14 13:11 ` [GIT PULL] Immutable branch between MFD, Clock, GPIO, Regulator and RTC due for the v5.13 merge window Lee Jones
2021-04-14 14:53 ` Lee Jones
2021-04-14 17:09 ` Vaittinen, Matti
2021-04-14 17:15 ` Lee Jones
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=8a9519e2fb81569c7488737901f0ecab926c658e.1617616855.git.matti.vaittinen@fi.rohmeurope.com \
--to=matti.vaittinen@fi.rohmeurope.com \
--cc=broonie@kernel.org \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-power@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.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 read-only IMAP folder(s) and NNTP newsgroup(s).