Skip to content

Commit 3ffad46

Browse files
Matthias Kaehlckebroonie
authored andcommitted
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 <[email protected]> Acked-by: Laxman Dewangan <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 543853d commit 3ffad46

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

drivers/regulator/core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,6 +2767,12 @@ static int _regulator_set_voltage_time(struct regulator_dev *rdev,
27672767
ramp_delay = rdev->desc->ramp_delay;
27682768
else if (rdev->constraints->settling_time)
27692769
return rdev->constraints->settling_time;
2770+
else if (rdev->constraints->settling_time_up &&
2771+
(new_uV > old_uV))
2772+
return rdev->constraints->settling_time_up;
2773+
else if (rdev->constraints->settling_time_down &&
2774+
(new_uV < old_uV))
2775+
return rdev->constraints->settling_time_down;
27702776

27712777
if (ramp_delay == 0) {
27722778
rdev_dbg(rdev, "ramp_delay not set\n");

drivers/regulator/of_regulator.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@ static void of_get_regulation_constraints(struct device_node *np,
9090
if (!ret)
9191
constraints->settling_time = pval;
9292

93+
ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval);
94+
if (!ret)
95+
constraints->settling_time_up = pval;
96+
if (constraints->settling_time_up && constraints->settling_time) {
97+
pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us'\n",
98+
np->name);
99+
constraints->settling_time_up = 0;
100+
}
101+
102+
ret = of_property_read_u32(np, "regulator-settling-time-down-us",
103+
&pval);
104+
if (!ret)
105+
constraints->settling_time_down = pval;
106+
if (constraints->settling_time_down && constraints->settling_time) {
107+
pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n",
108+
np->name);
109+
constraints->settling_time_down = 0;
110+
}
111+
93112
ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval);
94113
if (!ret)
95114
constraints->enable_time = pval;

include/linux/regulator/machine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ struct regulator_state {
110110
* @ramp_delay: Time to settle down after voltage change (unit: uV/us)
111111
* @settling_time: Time to settle down after voltage change when voltage
112112
* change is non-linear (unit: microseconds).
113+
* @settling_time_up: Time to settle down after voltage increase when voltage
114+
* change is non-linear (unit: microseconds).
115+
* @settling_time_down : Time to settle down after voltage decrease when
116+
* voltage change is non-linear (unit: microseconds).
113117
* @active_discharge: Enable/disable active discharge. The enum
114118
* regulator_active_discharge values are used for
115119
* initialisation.
@@ -152,6 +156,8 @@ struct regulation_constraints {
152156

153157
unsigned int ramp_delay;
154158
unsigned int settling_time;
159+
unsigned int settling_time_up;
160+
unsigned int settling_time_down;
155161
unsigned int enable_time;
156162

157163
unsigned int active_discharge;

0 commit comments

Comments
 (0)