[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1432737621-27590-1-git-send-email-ldewangan@nvidia.com>
Date: Wed, 27 May 2015 20:10:20 +0530
From: Laxman Dewangan <ldewangan@...dia.com>
To: <lgirdwood@...il.com>, <broonie@...nel.org>
CC: <linux-kernel@...r.kernel.org>, <cfreeman@...dia.com>,
<abrestic@...omium.org>, Laxman Dewangan <ldewangan@...dia.com>
Subject: [PATCH 1/2] regulator: core: add support to get VSEL register from hw driver
Currently VSEL register is read from desc only if set_voltage_sel
callback is regulator_set_voltage_sel_regmap() but there are cases
where set_voltage_sel() is implemented inside the HW regulator driver
like MAX8973.
Add callback on the regulator ops to get the voltage selection
register address and mask from device regulator driver. Use this
new callback in regulator_get_hardware_vsel_register().
Signed-off-by: Laxman Dewangan <ldewangan@...dia.com>
---
drivers/regulator/core.c | 19 +++++++++++++------
include/linux/regulator/driver.h | 7 +++++++
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 443eaab..8c19bdf 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2392,14 +2392,20 @@ int regulator_get_hardware_vsel_register(struct regulator *regulator,
{
struct regulator_dev *rdev = regulator->rdev;
const struct regulator_ops *ops = rdev->desc->ops;
+ int ret = 0;
- if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap)
+ if (ops->set_voltage_sel == regulator_set_voltage_sel_regmap) {
+ *vsel_reg = rdev->desc->vsel_reg;
+ *vsel_mask = rdev->desc->vsel_mask;
+ } else if (ops->get_voltage_sel_register) {
+ mutex_lock(&rdev->mutex);
+ ret = ops->get_voltage_sel_register(rdev, vsel_reg, vsel_mask);
+ mutex_unlock(&rdev->mutex);
+ } else {
return -EOPNOTSUPP;
+ }
- *vsel_reg = rdev->desc->vsel_reg;
- *vsel_mask = rdev->desc->vsel_mask;
-
- return 0;
+ return ret;
}
EXPORT_SYMBOL_GPL(regulator_get_hardware_vsel_register);
@@ -2422,7 +2428,8 @@ int regulator_list_hardware_vsel(struct regulator *regulator,
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
- if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap)
+ if ((ops->set_voltage_sel != regulator_set_voltage_sel_regmap) &&
+ !ops->get_voltage_sel_register)
return -EOPNOTSUPP;
return selector;
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index fffa688..7b7433f 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -103,6 +103,9 @@ struct regulator_linear_range {
* @set_bypass: Set the regulator in bypass mode.
* @get_bypass: Get the regulator bypass mode state.
*
+ * @get_voltage_sel_register: Get hardware voltage sel register address
+ * and its voltage mask.
+ *
* @enable_time: Time taken for the regulator voltage output voltage to
* stabilise after being enabled, in microseconds.
* @set_ramp_delay: Set the ramp delay for the regulator. The driver should
@@ -175,6 +178,10 @@ struct regulator_ops {
int (*set_bypass)(struct regulator_dev *dev, bool enable);
int (*get_bypass)(struct regulator_dev *dev, bool *enable);
+ /* Get HW VSEL register */
+ int (*get_voltage_sel_register)(struct regulator_dev *dev,
+ unsigned *vsel_reg, unsigned *vsel_mask);
+
/* the operations below are for configuration of regulator state when
* its parent PMIC enters a global STANDBY/HIBERNATE state */
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists