Skip to content

Commit d8ca5bd

Browse files
glneobroonie
authored andcommitted
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: d2a2e72 ("regulator: tps65086: Add regulator driver for the TPS65086 PMIC") Signed-off-by: Andrew F. Davis <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 1001354 commit d8ca5bd

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

Documentation/devicetree/bindings/mfd/tps65086.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Required properties:
2323
defined below.
2424

2525
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
2727
if the regulator is factory set with a 25mv
2828
step voltage mapping.
2929
- ti,regulator-decay : This is applicable for buck[1-6], set this if

drivers/regulator/tps65086-regulator.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@ struct tps65086_regulator {
7171
unsigned int decay_mask;
7272
};
7373

74-
static const struct regulator_linear_range tps65086_buck126_10mv_ranges[] = {
74+
static const struct regulator_linear_range tps65086_10mv_ranges[] = {
7575
REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0),
7676
REGULATOR_LINEAR_RANGE(410000, 0x1, 0x7F, 10000),
7777
};
7878

7979
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),
8281
REGULATOR_LINEAR_RANGE(1025000, 0x19, 0x7F, 25000),
8382
};
8483

85-
static const struct regulator_linear_range tps65086_buck345_ranges[] = {
84+
static const struct regulator_linear_range tps65086_buck345_25mv_ranges[] = {
8685
REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0),
8786
REGULATOR_LINEAR_RANGE(425000, 0x1, 0x7F, 25000),
8887
};
@@ -125,27 +124,27 @@ static int tps65086_of_parse_cb(struct device_node *dev,
125124
static struct tps65086_regulator regulators[] = {
126125
TPS65086_REGULATOR("BUCK1", "buck1", BUCK1, 0x80, TPS65086_BUCK1CTRL,
127126
BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(0),
128-
tps65086_buck126_10mv_ranges, TPS65086_BUCK1CTRL,
127+
tps65086_10mv_ranges, TPS65086_BUCK1CTRL,
129128
BIT(0)),
130129
TPS65086_REGULATOR("BUCK2", "buck2", BUCK2, 0x80, TPS65086_BUCK2CTRL,
131130
BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(1),
132-
tps65086_buck126_10mv_ranges, TPS65086_BUCK2CTRL,
131+
tps65086_10mv_ranges, TPS65086_BUCK2CTRL,
133132
BIT(0)),
134133
TPS65086_REGULATOR("BUCK3", "buck3", BUCK3, 0x80, TPS65086_BUCK3VID,
135134
BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(2),
136-
tps65086_buck345_ranges, TPS65086_BUCK3DECAY,
135+
tps65086_10mv_ranges, TPS65086_BUCK3DECAY,
137136
BIT(0)),
138137
TPS65086_REGULATOR("BUCK4", "buck4", BUCK4, 0x80, TPS65086_BUCK4VID,
139138
BUCK_VID_MASK, TPS65086_BUCK4CTRL, BIT(0),
140-
tps65086_buck345_ranges, TPS65086_BUCK4VID,
139+
tps65086_10mv_ranges, TPS65086_BUCK4VID,
141140
BIT(0)),
142141
TPS65086_REGULATOR("BUCK5", "buck5", BUCK5, 0x80, TPS65086_BUCK5VID,
143142
BUCK_VID_MASK, TPS65086_BUCK5CTRL, BIT(0),
144-
tps65086_buck345_ranges, TPS65086_BUCK5CTRL,
143+
tps65086_10mv_ranges, TPS65086_BUCK5CTRL,
145144
BIT(0)),
146145
TPS65086_REGULATOR("BUCK6", "buck6", BUCK6, 0x80, TPS65086_BUCK6VID,
147146
BUCK_VID_MASK, TPS65086_BUCK6CTRL, BIT(0),
148-
tps65086_buck126_10mv_ranges, TPS65086_BUCK6CTRL,
147+
tps65086_10mv_ranges, TPS65086_BUCK6CTRL,
149148
BIT(0)),
150149
TPS65086_REGULATOR("LDOA1", "ldoa1", LDOA1, 0xF, TPS65086_LDOA1CTRL,
151150
VDOA1_VID_MASK, TPS65086_LDOA1CTRL, BIT(0),
@@ -162,31 +161,34 @@ static struct tps65086_regulator regulators[] = {
162161
TPS65086_SWITCH("VTT", "vtt", VTT, TPS65086_SWVTT_EN, BIT(4)),
163162
};
164163

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-
177164
static int tps65086_of_parse_cb(struct device_node *dev,
178165
const struct regulator_desc *desc,
179166
struct regulator_config *config)
180167
{
181168
int ret;
182169

183170
/* Check for 25mV step mode */
184-
if (has_25mv_mode(desc->id) &&
185-
of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) {
186-
regulators[desc->id].desc.linear_ranges =
171+
if (of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) {
172+
switch (desc->id) {
173+
case BUCK1:
174+
case BUCK2:
175+
case BUCK6:
176+
regulators[desc->id].desc.linear_ranges =
187177
tps65086_buck126_25mv_ranges;
188-
regulators[desc->id].desc.n_linear_ranges =
178+
regulators[desc->id].desc.n_linear_ranges =
189179
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+
}
190192
}
191193

192194
/* Check for decay mode */

0 commit comments

Comments
 (0)