summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2014-04-09 12:47:17 +0530
committerLaxman Dewangan <ldewangan@nvidia.com>2014-04-10 01:04:40 -0700
commit93457cfc6f5dbb77453952772e0eee962d9ef97b (patch)
treeda59e65ab24eef6e37a403293ceea8245411fbe8 /drivers
parent44702c84acd2a8d67db29842bfbba5488755ea46 (diff)
regulator: pwm: add support for setting voltage time sel
The pwm voltage ramp for each level is not linear in nature sometimes and it can be exponential. In this case, the voltage ramp time which is independent of amount of voltage levels need to be provided to calculate the proper ramp time. Change-Id: Idfa17b3bc0a565e66104091090f4fcdb32882be5 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/393889
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/pwm-regulator.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index aa813933ed41..aeb36fd3b528 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -46,6 +46,7 @@ struct pwm_regulator {
int enable_gpio;
int idle_gpio;
int standby_gpio;
+ unsigned int voltage_time_sel;
};
static int pwm_regulator_set_voltage_sel(
@@ -118,12 +119,22 @@ static unsigned int pwm_regulator_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_IDLE;
}
+static int pwm_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+ unsigned int old_selector, unsigned int new_selector)
+{
+ struct pwm_regulator *preg = rdev_get_drvdata(rdev);
+
+ if (preg->voltage_time_sel)
+ return preg->voltage_time_sel;
+ return regulator_set_voltage_time_sel(rdev, old_selector, new_selector);
+}
+
static struct regulator_ops pwm_regulator_ops = {
.set_voltage_sel = pwm_regulator_set_voltage_sel,
.get_voltage_sel = pwm_regulator_get_voltage_sel,
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
- .set_voltage_time_sel = regulator_set_voltage_time_sel,
+ .set_voltage_time_sel = pwm_regulator_set_voltage_time_sel,
.set_mode = pwm_regulator_set_mode,
.get_mode = pwm_regulator_get_mode,
};
@@ -149,6 +160,10 @@ static int pwm_regulator_parse_dt(struct device *dev,
return ret;
}
+ ret = of_property_read_u32(node, "voltage-time-sel", &pval);
+ if (!ret)
+ preg->voltage_time_sel = pval;
+
preg->enable_gpio = of_get_named_gpio(node, "enable-gpio", 0);
if ((preg->enable_gpio < 0) && (preg->enable_gpio != -ENOENT)) {
dev_err(dev, "Enable gpio not available, %d\n",