diff options
author | Andrew F. Davis <afd@ti.com> | 2016-12-01 11:44:16 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-12-01 12:42:27 -0500 |
commit | d8ca5bd158f738c4fa6974ee388c381f64db7905 (patch) | |
tree | 2657a344b39f62f92943b5070173e25d27d12ab4 | |
parent | 1001354ca34179f3db924eb66672442a173147dc (diff) |
regulator: tps65086: Fix 25mV ranges for BUCK regulators
The BUCK regulators 3, 4, and 5 also have a 10mV step mode,
adjust the tables and logic to reflect the data-sheet for
these regulators.
fixes: d2a2e729a666 ("regulator: tps65086: Add regulator driver for the TPS65086 PMIC")
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | Documentation/devicetree/bindings/mfd/tps65086.txt | 2 | ||||
-rw-r--r-- | drivers/regulator/tps65086-regulator.c | 54 |
2 files changed, 29 insertions, 27 deletions
diff --git a/Documentation/devicetree/bindings/mfd/tps65086.txt b/Documentation/devicetree/bindings/mfd/tps65086.txt index d3705612a846..9cfa886fe99f 100644 --- a/Documentation/devicetree/bindings/mfd/tps65086.txt +++ b/Documentation/devicetree/bindings/mfd/tps65086.txt | |||
@@ -23,7 +23,7 @@ Required properties: | |||
23 | defined below. | 23 | defined below. |
24 | 24 | ||
25 | Optional regulator properties: | 25 | Optional regulator properties: |
26 | - ti,regulator-step-size-25mv : This is applicable for buck[1,2,6], set this | 26 | - ti,regulator-step-size-25mv : This is applicable for buck[1-6], set this |
27 | if the regulator is factory set with a 25mv | 27 | if the regulator is factory set with a 25mv |
28 | step voltage mapping. | 28 | step voltage mapping. |
29 | - ti,regulator-decay : This is applicable for buck[1-6], set this if | 29 | - ti,regulator-decay : This is applicable for buck[1-6], set this if |
diff --git a/drivers/regulator/tps65086-regulator.c b/drivers/regulator/tps65086-regulator.c index 33f389d583ef..caf174ffa316 100644 --- a/drivers/regulator/tps65086-regulator.c +++ b/drivers/regulator/tps65086-regulator.c | |||
@@ -71,18 +71,17 @@ struct tps65086_regulator { | |||
71 | unsigned int decay_mask; | 71 | unsigned int decay_mask; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static const struct regulator_linear_range tps65086_buck126_10mv_ranges[] = { | 74 | static const struct regulator_linear_range tps65086_10mv_ranges[] = { |
75 | REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), | 75 | REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), |
76 | REGULATOR_LINEAR_RANGE(410000, 0x1, 0x7F, 10000), | 76 | REGULATOR_LINEAR_RANGE(410000, 0x1, 0x7F, 10000), |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static const struct regulator_linear_range tps65086_buck126_25mv_ranges[] = { | 79 | static const struct regulator_linear_range tps65086_buck126_25mv_ranges[] = { |
80 | REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), | 80 | REGULATOR_LINEAR_RANGE(1000000, 0x0, 0x18, 0), |
81 | REGULATOR_LINEAR_RANGE(1000000, 0x1, 0x18, 0), | ||
82 | REGULATOR_LINEAR_RANGE(1025000, 0x19, 0x7F, 25000), | 81 | REGULATOR_LINEAR_RANGE(1025000, 0x19, 0x7F, 25000), |
83 | }; | 82 | }; |
84 | 83 | ||
85 | static const struct regulator_linear_range tps65086_buck345_ranges[] = { | 84 | static const struct regulator_linear_range tps65086_buck345_25mv_ranges[] = { |
86 | REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), | 85 | REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), |
87 | REGULATOR_LINEAR_RANGE(425000, 0x1, 0x7F, 25000), | 86 | REGULATOR_LINEAR_RANGE(425000, 0x1, 0x7F, 25000), |
88 | }; | 87 | }; |
@@ -125,27 +124,27 @@ static int tps65086_of_parse_cb(struct device_node *dev, | |||
125 | static struct tps65086_regulator regulators[] = { | 124 | static struct tps65086_regulator regulators[] = { |
126 | TPS65086_REGULATOR("BUCK1", "buck1", BUCK1, 0x80, TPS65086_BUCK1CTRL, | 125 | TPS65086_REGULATOR("BUCK1", "buck1", BUCK1, 0x80, TPS65086_BUCK1CTRL, |
127 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(0), | 126 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(0), |
128 | tps65086_buck126_10mv_ranges, TPS65086_BUCK1CTRL, | 127 | tps65086_10mv_ranges, TPS65086_BUCK1CTRL, |
129 | BIT(0)), | 128 | BIT(0)), |
130 | TPS65086_REGULATOR("BUCK2", "buck2", BUCK2, 0x80, TPS65086_BUCK2CTRL, | 129 | TPS65086_REGULATOR("BUCK2", "buck2", BUCK2, 0x80, TPS65086_BUCK2CTRL, |
131 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(1), | 130 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(1), |
132 | tps65086_buck126_10mv_ranges, TPS65086_BUCK2CTRL, | 131 | tps65086_10mv_ranges, TPS65086_BUCK2CTRL, |
133 | BIT(0)), | 132 | BIT(0)), |
134 | TPS65086_REGULATOR("BUCK3", "buck3", BUCK3, 0x80, TPS65086_BUCK3VID, | 133 | TPS65086_REGULATOR("BUCK3", "buck3", BUCK3, 0x80, TPS65086_BUCK3VID, |
135 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(2), | 134 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(2), |
136 | tps65086_buck345_ranges, TPS65086_BUCK3DECAY, | 135 | tps65086_10mv_ranges, TPS65086_BUCK3DECAY, |
137 | BIT(0)), | 136 | BIT(0)), |
138 | TPS65086_REGULATOR("BUCK4", "buck4", BUCK4, 0x80, TPS65086_BUCK4VID, | 137 | TPS65086_REGULATOR("BUCK4", "buck4", BUCK4, 0x80, TPS65086_BUCK4VID, |
139 | BUCK_VID_MASK, TPS65086_BUCK4CTRL, BIT(0), | 138 | BUCK_VID_MASK, TPS65086_BUCK4CTRL, BIT(0), |
140 | tps65086_buck345_ranges, TPS65086_BUCK4VID, | 139 | tps65086_10mv_ranges, TPS65086_BUCK4VID, |
141 | BIT(0)), | 140 | BIT(0)), |
142 | TPS65086_REGULATOR("BUCK5", "buck5", BUCK5, 0x80, TPS65086_BUCK5VID, | 141 | TPS65086_REGULATOR("BUCK5", "buck5", BUCK5, 0x80, TPS65086_BUCK5VID, |
143 | BUCK_VID_MASK, TPS65086_BUCK5CTRL, BIT(0), | 142 | BUCK_VID_MASK, TPS65086_BUCK5CTRL, BIT(0), |
144 | tps65086_buck345_ranges, TPS65086_BUCK5CTRL, | 143 | tps65086_10mv_ranges, TPS65086_BUCK5CTRL, |
145 | BIT(0)), | 144 | BIT(0)), |
146 | TPS65086_REGULATOR("BUCK6", "buck6", BUCK6, 0x80, TPS65086_BUCK6VID, | 145 | TPS65086_REGULATOR("BUCK6", "buck6", BUCK6, 0x80, TPS65086_BUCK6VID, |
147 | BUCK_VID_MASK, TPS65086_BUCK6CTRL, BIT(0), | 146 | BUCK_VID_MASK, TPS65086_BUCK6CTRL, BIT(0), |
148 | tps65086_buck126_10mv_ranges, TPS65086_BUCK6CTRL, | 147 | tps65086_10mv_ranges, TPS65086_BUCK6CTRL, |
149 | BIT(0)), | 148 | BIT(0)), |
150 | TPS65086_REGULATOR("LDOA1", "ldoa1", LDOA1, 0xF, TPS65086_LDOA1CTRL, | 149 | TPS65086_REGULATOR("LDOA1", "ldoa1", LDOA1, 0xF, TPS65086_LDOA1CTRL, |
151 | VDOA1_VID_MASK, TPS65086_LDOA1CTRL, BIT(0), | 150 | VDOA1_VID_MASK, TPS65086_LDOA1CTRL, BIT(0), |
@@ -162,18 +161,6 @@ static struct tps65086_regulator regulators[] = { | |||
162 | TPS65086_SWITCH("VTT", "vtt", VTT, TPS65086_SWVTT_EN, BIT(4)), | 161 | TPS65086_SWITCH("VTT", "vtt", VTT, TPS65086_SWVTT_EN, BIT(4)), |
163 | }; | 162 | }; |
164 | 163 | ||
165 | static inline bool has_25mv_mode(int id) | ||
166 | { | ||
167 | switch (id) { | ||
168 | case BUCK1: | ||
169 | case BUCK2: | ||
170 | case BUCK6: | ||
171 | return true; | ||
172 | default: | ||
173 | return false; | ||
174 | } | ||
175 | } | ||
176 | |||
177 | static int tps65086_of_parse_cb(struct device_node *dev, | 164 | static int tps65086_of_parse_cb(struct device_node *dev, |
178 | const struct regulator_desc *desc, | 165 | const struct regulator_desc *desc, |
179 | struct regulator_config *config) | 166 | struct regulator_config *config) |
@@ -181,12 +168,27 @@ static int tps65086_of_parse_cb(struct device_node *dev, | |||
181 | int ret; | 168 | int ret; |
182 | 169 | ||
183 | /* Check for 25mV step mode */ | 170 | /* Check for 25mV step mode */ |
184 | if (has_25mv_mode(desc->id) && | 171 | if (of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) { |
185 | of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) { | 172 | switch (desc->id) { |
186 | regulators[desc->id].desc.linear_ranges = | 173 | case BUCK1: |
174 | case BUCK2: | ||
175 | case BUCK6: | ||
176 | regulators[desc->id].desc.linear_ranges = | ||
187 | tps65086_buck126_25mv_ranges; | 177 | tps65086_buck126_25mv_ranges; |
188 | regulators[desc->id].desc.n_linear_ranges = | 178 | regulators[desc->id].desc.n_linear_ranges = |
189 | ARRAY_SIZE(tps65086_buck126_25mv_ranges); | 179 | ARRAY_SIZE(tps65086_buck126_25mv_ranges); |
180 | break; | ||
181 | case BUCK3: | ||
182 | case BUCK4: | ||
183 | case BUCK5: | ||
184 | regulators[desc->id].desc.linear_ranges = | ||
185 | tps65086_buck345_25mv_ranges; | ||
186 | regulators[desc->id].desc.n_linear_ranges = | ||
187 | ARRAY_SIZE(tps65086_buck345_25mv_ranges); | ||
188 | break; | ||
189 | default: | ||
190 | dev_warn(config->dev, "25mV step mode only valid for BUCK regulators\n"); | ||
191 | } | ||
190 | } | 192 | } |
191 | 193 | ||
192 | /* Check for decay mode */ | 194 | /* Check for decay mode */ |