Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andrew F. Davis and committed by
Mark Brown
d8ca5bd1 1001354c

+29 -27
+1 -1
Documentation/devicetree/bindings/mfd/tps65086.txt
··· 23 23 defined below. 24 24 25 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 27 if the regulator is factory set with a 25mv 28 28 step voltage mapping. 29 29 - ti,regulator-decay : This is applicable for buck[1-6], set this if
+28 -26
drivers/regulator/tps65086-regulator.c
··· 71 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 75 REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), 76 76 REGULATOR_LINEAR_RANGE(410000, 0x1, 0x7F, 10000), 77 77 }; 78 78 79 79 static const struct regulator_linear_range tps65086_buck126_25mv_ranges[] = { 80 - REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), 81 - REGULATOR_LINEAR_RANGE(1000000, 0x1, 0x18, 0), 80 + REGULATOR_LINEAR_RANGE(1000000, 0x0, 0x18, 0), 82 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 85 REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), 87 86 REGULATOR_LINEAR_RANGE(425000, 0x1, 0x7F, 25000), 88 87 }; ··· 124 125 static struct tps65086_regulator regulators[] = { 125 126 TPS65086_REGULATOR("BUCK1", "buck1", BUCK1, 0x80, TPS65086_BUCK1CTRL, 126 127 BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(0), 127 - tps65086_buck126_10mv_ranges, TPS65086_BUCK1CTRL, 128 + tps65086_10mv_ranges, TPS65086_BUCK1CTRL, 128 129 BIT(0)), 129 130 TPS65086_REGULATOR("BUCK2", "buck2", BUCK2, 0x80, TPS65086_BUCK2CTRL, 130 131 BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(1), 131 - tps65086_buck126_10mv_ranges, TPS65086_BUCK2CTRL, 132 + tps65086_10mv_ranges, TPS65086_BUCK2CTRL, 132 133 BIT(0)), 133 134 TPS65086_REGULATOR("BUCK3", "buck3", BUCK3, 0x80, TPS65086_BUCK3VID, 134 135 BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(2), 135 - tps65086_buck345_ranges, TPS65086_BUCK3DECAY, 136 + tps65086_10mv_ranges, TPS65086_BUCK3DECAY, 136 137 BIT(0)), 137 138 TPS65086_REGULATOR("BUCK4", "buck4", BUCK4, 0x80, TPS65086_BUCK4VID, 138 139 BUCK_VID_MASK, TPS65086_BUCK4CTRL, BIT(0), 139 - tps65086_buck345_ranges, TPS65086_BUCK4VID, 140 + tps65086_10mv_ranges, TPS65086_BUCK4VID, 140 141 BIT(0)), 141 142 TPS65086_REGULATOR("BUCK5", "buck5", BUCK5, 0x80, TPS65086_BUCK5VID, 142 143 BUCK_VID_MASK, TPS65086_BUCK5CTRL, BIT(0), 143 - tps65086_buck345_ranges, TPS65086_BUCK5CTRL, 144 + tps65086_10mv_ranges, TPS65086_BUCK5CTRL, 144 145 BIT(0)), 145 146 TPS65086_REGULATOR("BUCK6", "buck6", BUCK6, 0x80, TPS65086_BUCK6VID, 146 147 BUCK_VID_MASK, TPS65086_BUCK6CTRL, BIT(0), 147 - tps65086_buck126_10mv_ranges, TPS65086_BUCK6CTRL, 148 + tps65086_10mv_ranges, TPS65086_BUCK6CTRL, 148 149 BIT(0)), 149 150 TPS65086_REGULATOR("LDOA1", "ldoa1", LDOA1, 0xF, TPS65086_LDOA1CTRL, 150 151 VDOA1_VID_MASK, TPS65086_LDOA1CTRL, BIT(0), ··· 161 162 TPS65086_SWITCH("VTT", "vtt", VTT, TPS65086_SWVTT_EN, BIT(4)), 162 163 }; 163 164 164 - static inline bool has_25mv_mode(int id) 165 - { 166 - switch (id) { 167 - case BUCK1: 168 - case BUCK2: 169 - case BUCK6: 170 - return true; 171 - default: 172 - return false; 173 - } 174 - } 175 - 176 165 static int tps65086_of_parse_cb(struct device_node *dev, 177 166 const struct regulator_desc *desc, 178 167 struct regulator_config *config) ··· 168 181 int ret; 169 182 170 183 /* Check for 25mV step mode */ 171 - if (has_25mv_mode(desc->id) && 172 - of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) { 173 - regulators[desc->id].desc.linear_ranges = 184 + if (of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) { 185 + switch (desc->id) { 186 + case BUCK1: 187 + case BUCK2: 188 + case BUCK6: 189 + regulators[desc->id].desc.linear_ranges = 174 190 tps65086_buck126_25mv_ranges; 175 - regulators[desc->id].desc.n_linear_ranges = 191 + regulators[desc->id].desc.n_linear_ranges = 176 192 ARRAY_SIZE(tps65086_buck126_25mv_ranges); 193 + break; 194 + case BUCK3: 195 + case BUCK4: 196 + case BUCK5: 197 + regulators[desc->id].desc.linear_ranges = 198 + tps65086_buck345_25mv_ranges; 199 + regulators[desc->id].desc.n_linear_ranges = 200 + ARRAY_SIZE(tps65086_buck345_25mv_ranges); 201 + break; 202 + default: 203 + dev_warn(config->dev, "25mV step mode only valid for BUCK regulators\n"); 204 + } 177 205 } 178 206 179 207 /* Check for decay mode */