diff options
author | Matthias Kaehlcke <mka@chromium.org> | 2017-05-16 14:43:43 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-05-17 05:49:25 -0400 |
commit | 3ffad468cf1d9825b425733941bdad0d8d20e795 (patch) | |
tree | 8132700ab118a649e9d002c36d941c6c509b5546 | |
parent | 543853de356b8ce95d6d99757501d9d5c916ca09 (diff) |
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 <mka@chromium.org>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/core.c | 6 | ||||
-rw-r--r-- | drivers/regulator/of_regulator.c | 19 | ||||
-rw-r--r-- | include/linux/regulator/machine.h | 6 |
3 files changed, 31 insertions, 0 deletions
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, | |||
2767 | ramp_delay = rdev->desc->ramp_delay; | 2767 | ramp_delay = rdev->desc->ramp_delay; |
2768 | else if (rdev->constraints->settling_time) | 2768 | else if (rdev->constraints->settling_time) |
2769 | return rdev->constraints->settling_time; | 2769 | 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; | ||
2770 | 2776 | ||
2771 | if (ramp_delay == 0) { | 2777 | if (ramp_delay == 0) { |
2772 | rdev_dbg(rdev, "ramp_delay not set\n"); | 2778 | 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, | |||
90 | if (!ret) | 90 | if (!ret) |
91 | constraints->settling_time = pval; | 91 | constraints->settling_time = pval; |
92 | 92 | ||
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 | |||
93 | ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); | 112 | ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); |
94 | if (!ret) | 113 | if (!ret) |
95 | constraints->enable_time = pval; | 114 | constraints->enable_time = pval; |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 117699d1f7df..9cd4fef37203 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
@@ -110,6 +110,10 @@ struct regulator_state { | |||
110 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) | 110 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) |
111 | * @settling_time: Time to settle down after voltage change when voltage | 111 | * @settling_time: Time to settle down after voltage change when voltage |
112 | * change is non-linear (unit: microseconds). | 112 | * 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). | ||
113 | * @active_discharge: Enable/disable active discharge. The enum | 117 | * @active_discharge: Enable/disable active discharge. The enum |
114 | * regulator_active_discharge values are used for | 118 | * regulator_active_discharge values are used for |
115 | * initialisation. | 119 | * initialisation. |
@@ -152,6 +156,8 @@ struct regulation_constraints { | |||
152 | 156 | ||
153 | unsigned int ramp_delay; | 157 | unsigned int ramp_delay; |
154 | unsigned int settling_time; | 158 | unsigned int settling_time; |
159 | unsigned int settling_time_up; | ||
160 | unsigned int settling_time_down; | ||
155 | unsigned int enable_time; | 161 | unsigned int enable_time; |
156 | 162 | ||
157 | unsigned int active_discharge; | 163 | unsigned int active_discharge; |