From 3ffad468cf1d9825b425733941bdad0d8d20e795 Mon Sep 17 00:00:00 2001 From: Matthias Kaehlcke Date: Tue, 16 May 2017 11:43:43 -0700 Subject: regulator: Allow for asymmetric settling times Some regulators have different settling times for voltage increases and decreases. To avoid a time penalty on the faster transition allow for different settings for up- and downward transitions. Signed-off-by: Matthias Kaehlcke Acked-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/core.c | 6 ++++++ drivers/regulator/of_regulator.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c0d9ae8d0860..919b7f178209 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2767,6 +2767,12 @@ static int _regulator_set_voltage_time(struct regulator_dev *rdev, ramp_delay = rdev->desc->ramp_delay; else if (rdev->constraints->settling_time) return rdev->constraints->settling_time; + else if (rdev->constraints->settling_time_up && + (new_uV > old_uV)) + return rdev->constraints->settling_time_up; + else if (rdev->constraints->settling_time_down && + (new_uV < old_uV)) + return rdev->constraints->settling_time_down; if (ramp_delay == 0) { rdev_dbg(rdev, "ramp_delay not set\n"); diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 09d677d5d3f0..96bf75458da5 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -90,6 +90,25 @@ static void of_get_regulation_constraints(struct device_node *np, if (!ret) constraints->settling_time = pval; + ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval); + if (!ret) + constraints->settling_time_up = pval; + if (constraints->settling_time_up && constraints->settling_time) { + pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us'\n", + np->name); + constraints->settling_time_up = 0; + } + + ret = of_property_read_u32(np, "regulator-settling-time-down-us", + &pval); + if (!ret) + constraints->settling_time_down = pval; + if (constraints->settling_time_down && constraints->settling_time) { + pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n", + np->name); + constraints->settling_time_down = 0; + } + ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); if (!ret) constraints->enable_time = pval; -- cgit v1.2.3