From: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
To: matti.vaittinen@fi.rohmeurope.com, 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-kernel@vger.kernel.org, linux-power@fi.rohmeurope.com
Subject: [PATCH v2 11/17] regulator: helpers: Export helper voltage listing
Date: Tue, 19 Jan 2021 09:25:09 +0200 [thread overview]
Message-ID: <4bca1f81e1791e27ee461ee41b39fc7502d6eb7d.1611037866.git.matti.vaittinen@fi.rohmeurope.com> (raw)
In-Reply-To: <cover.1611037866.git.matti.vaittinen@fi.rohmeurope.com>
Some drivers need to translate voltage values to selectors prior regulator
registration. Currently a regulator_desc based list_voltages helper is only
exported for regulators using the linear_ranges. Export similar helper also
for regulators using simple linear mapping.
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
No changes since v1
drivers/regulator/helpers.c | 36 +++++++++++++++++++++++++-------
include/linux/regulator/driver.h | 2 ++
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index f42b394a0c46..3e19ecbf7267 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -508,6 +508,33 @@ int regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev,
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_pickable_linear_range);
+/**
+ * regulator_desc_list_voltage_linear - List voltages with simple calculation
+ *
+ * @desc: Regulator desc for regulator which volatges are to be listed
+ * @selector: Selector to convert into a voltage
+ *
+ * Regulators with a simple linear mapping between voltages and
+ * selectors can set min_uV and uV_step in the regulator descriptor
+ * and then use this function prior regulator registration to list
+ * the voltages. This is useful when voltages need to be listed during
+ * device-tree parsing.
+ */
+int regulator_desc_list_voltage_linear(const struct regulator_desc *desc,
+ unsigned int selector)
+{
+ if (selector >= desc->n_voltages)
+ return -EINVAL;
+
+ if (selector < desc->linear_min_sel)
+ return 0;
+
+ selector -= desc->linear_min_sel;
+
+ return desc->min_uV + (desc->uV_step * selector);
+}
+EXPORT_SYMBOL_GPL(regulator_desc_list_voltage_linear);
+
/**
* regulator_list_voltage_linear - List voltages with simple calculation
*
@@ -521,14 +548,7 @@ EXPORT_SYMBOL_GPL(regulator_map_voltage_pickable_linear_range);
int regulator_list_voltage_linear(struct regulator_dev *rdev,
unsigned int selector)
{
- if (selector >= rdev->desc->n_voltages)
- return -EINVAL;
- if (selector < rdev->desc->linear_min_sel)
- return 0;
-
- selector -= rdev->desc->linear_min_sel;
-
- return rdev->desc->min_uV + (rdev->desc->uV_step * selector);
+ return regulator_desc_list_voltage_linear(rdev->desc, selector);
}
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index d7c77ee370f3..39a540111645 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -543,4 +543,6 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc,
unsigned int selector);
+int regulator_desc_list_voltage_linear(const struct regulator_desc *desc,
+ unsigned int selector);
#endif
--
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-01-19 7:29 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 7:13 [PATCH v2 00/17] Support ROHM BD71815 PMIC Matti Vaittinen
2021-01-19 7:14 ` [PATCH v2 01/17] regulator: bd718x7, bd71828, Fix dvs voltage levels Matti Vaittinen
2021-01-19 7:14 ` [PATCH v2 02/17] rtc: bd70528: Do not require parent data Matti Vaittinen
2021-01-19 21:09 ` Alexandre Belloni
2021-01-20 6:37 ` Matti Vaittinen
2021-01-19 7:15 ` [PATCH v2 03/17] clk: BD718x7: Do not depend on parent driver data Matti Vaittinen
2021-01-19 7:15 ` [PATCH v2 04/17] mfd: bd718x7: simplify by cleaning unnecessary device data Matti Vaittinen
2021-01-25 13:56 ` Lee Jones
2021-01-19 7:16 ` [PATCH v2 05/17] dt_bindings: bd71828: Add clock output mode Matti Vaittinen
2021-02-09 2:22 ` Rob Herring
2021-01-19 7:17 ` [PATCH v2 06/17] dt_bindings: regulator: Add ROHM BD71815 PMIC regulators Matti Vaittinen
2021-02-09 2:24 ` Rob Herring
2021-02-09 13:10 ` Vaittinen, Matti
2021-02-09 13:50 ` Rob Herring
2021-01-19 7:21 ` [PATCH v2 07/17] dt_bindings: mfd: Add ROHM BD71815 PMIC Matti Vaittinen
2021-02-09 2:26 ` Rob Herring
2021-01-19 7:21 ` [PATCH v2 08/17] mfd: Add ROHM BD71815 ID Matti Vaittinen
2021-01-25 13:57 ` Lee Jones
2021-01-19 7:22 ` [PATCH v2 09/17] mfd: Support for ROHM BD71815 PMIC core Matti Vaittinen
2021-01-25 14:10 ` Lee Jones
2021-01-25 14:48 ` Matti Vaittinen
2021-01-26 8:29 ` Lee Jones
2021-01-19 7:23 ` [PATCH v2 10/17] gpio: support ROHM BD71815 GPOs Matti Vaittinen
2021-01-19 11:07 ` Bartosz Golaszewski
2021-01-19 13:01 ` Vaittinen, Matti
2021-03-23 9:57 ` Vaittinen, Matti
2021-03-26 14:44 ` Bartosz Golaszewski
2021-01-19 7:25 ` Matti Vaittinen [this message]
2021-01-19 7:26 ` [PATCH v2 12/17] regulator: rohm-regulator: linear voltage support Matti Vaittinen
2021-01-19 7:27 ` [PATCH v2 13/17] regulator: rohm-regulator: Support SNVS HW state Matti Vaittinen
2021-01-19 7:29 ` [PATCH v2 14/17] regulator: Support ROHM BD71815 regulators Matti Vaittinen
2021-01-19 7:30 ` [PATCH v2 15/17] clk: bd718x7: Add support for clk gate on ROHM BD71815 PMIC Matti Vaittinen
2021-02-12 3:40 ` Stephen Boyd
2021-01-19 7:31 ` [PATCH v2 16/17] rtc: bd70528: Support RTC on ROHM BD71815 Matti Vaittinen
2021-01-19 21:10 ` Alexandre Belloni
2021-01-19 7:34 ` [PATCH v2 17/17] MAINTAINERS: Add ROHM BD71815AGW 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=4bca1f81e1791e27ee461ee41b39fc7502d6eb7d.1611037866.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 NNTP newsgroup(s).