@@ -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,
@@ -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__ */
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@fi.rohmeurope.com> --- drivers/regulator/bd71828-regulator.c | 67 +++++++++++++++++++++++++++ include/linux/mfd/rohm-bd71828.h | 2 + 2 files changed, 69 insertions(+)