[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3275428ea15aed2de31e1304769273e5eb637829.1571302099.git.matti.vaittinen@fi.rohmeurope.com>
Date: Thu, 17 Oct 2019 12:51:45 +0300
From: Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
To: matti.vaittinen@...rohmeurope.com, mazziesaccount@...il.com
Cc: Lee Jones <lee.jones@...aro.org>, Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
Pavel Machek <pavel@....cz>, Dan Murphy <dmurphy@...com>,
Alessandro Zummo <a.zummo@...ertech.it>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-clk@...r.kernel.org, linux-gpio@...r.kernel.org,
linux-leds@...r.kernel.org, linux-rtc@...r.kernel.org
Subject: [RFC PATCH 08/13] regulator: bd71828: Support in-kernel APIs to
change run-level
Add exported functions bd71828_set_runlevel and
bd71828_get_runlevel for setting and getting the system run
level.
Signed-off-by: Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
---
drivers/regulator/bd71828-regulator.c | 67 +++++++++++++++++++++++++++
include/linux/mfd/rohm-bd71828.h | 2 +
2 files changed, 69 insertions(+)
diff --git a/drivers/regulator/bd71828-regulator.c b/drivers/regulator/bd71828-regulator.c
index d5d0dcee90cf..e242d829cbf5 100644
--- a/drivers/regulator/bd71828-regulator.c
+++ b/drivers/regulator/bd71828-regulator.c
@@ -505,6 +505,73 @@ int bd71828_set_runlevel_voltage(struct regulator *regulator, unsigned int uv,
}
EXPORT_SYMBOL(bd71828_set_runlevel_voltage);
+/**
+ * bd71828_set_runlevel - change system run-level.
+ *
+ * @regulator: pointer to one of the BD71828 regulators obtained by
+ * call to regulator_get
+ * @level: New run-level the system should enter
+ *
+ * Changes the system to run-level which was given as argument. This
+ * operation will change state of all regulators which are set to be
+ * controlled by run-levels. Note that 'regulator' must point to a
+ * regulator which is controlled by run-levels.
+ */
+int bd71828_set_runlevel(struct regulator *regulator, unsigned int level)
+{
+ struct regulator_dev *rdev = regulator->rdev;
+ struct bd71828_regulator_data *rd = rdev_get_drvdata(rdev);
+
+ if (!rd)
+ return -ENOENT;
+
+ if (!rd || !rd->allow_runlvl)
+ return -EINVAL;
+
+ if (rd->gps)
+ return bd71828_dvs_gpio_set_run_level(rd, level);
+
+ return bd71828_dvs_i2c_set_run_level(rd->regmap, level);
+}
+EXPORT_SYMBOL(bd71828_set_runlevel);
+
+/**
+ * bd71828_get_runlevel - get the current system run-level.
+ *
+ * @regulator: pointer to one of the BD71828 regulators obtained by
+ * call to regulator_get
+ * @level: Pointer to value where current run-level is stored
+ *
+ * Returns the current system run-level. Note that 'regulator' must
+ * point to a regulator which is controlled by run-levels.
+ */
+int bd71828_get_runlevel(struct regulator *regulator, unsigned int *level)
+{
+ struct regulator_dev *rdev = regulator->rdev;
+ struct bd71828_regulator_data *rd = rdev_get_drvdata(rdev);
+ int ret;
+
+ if (!rd)
+ return -ENOENT;
+
+ if (!rd || !rd->allow_runlvl)
+ return -EINVAL;
+
+ if (!rd->gps)
+ ret = bd71828_dvs_i2c_get_run_level(rd->regmap, rd);
+ else
+ ret = bd71828_dvs_gpio_get_run_level(rd);
+
+ if (ret < 0)
+ return ret;
+
+ *level = (unsigned int) ret;
+
+ return 0;
+}
+EXPORT_SYMBOL(bd71828_get_runlevel);
+
+
static const struct regulator_ops dvs_buck_gpio_ops = {
.is_enabled = bd71828_dvs_gpio_is_enabled,
.get_voltage = bd71828_dvs_gpio_get_voltage,
diff --git a/include/linux/mfd/rohm-bd71828.h b/include/linux/mfd/rohm-bd71828.h
index 5f15c6a309e6..bbbd4f118550 100644
--- a/include/linux/mfd/rohm-bd71828.h
+++ b/include/linux/mfd/rohm-bd71828.h
@@ -424,5 +424,7 @@ enum {
int bd71828_set_runlevel_voltage(struct regulator *regulator, unsigned int uv,
unsigned int level);
+int bd71828_set_runlevel(struct regulator *regulator, unsigned int level);
+int bd71828_get_runlevel(struct regulator *regulator, unsigned int *level);
#endif /* __LINUX_MFD_BD71828_H__ */
--
2.21.0
--
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 =]
Powered by blists - more mailing lists