Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit c2c80ec

Browse files
committed
Merge tag 'regulator-fix-v6.10-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "A bunch of fixes that came in during the merge window. Matti found several issues with some of the more complexly configured Rohm regulators and the helpers they use and there were some errors in the specification of tps6594 when regulators are grouped together" * tag 'regulator-fix-v6.10-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: tps6594-regulator: Correct multi-phase configuration regulator: tps6287x: Force writing VSEL bit regulator: pickable ranges: don't always cache vsel regulator: rohm-regulator: warn if unsupported voltage is set regulator: bd71828: Don't overwrite runtime voltages
2 parents 09f8f2c + 74b38cd commit c2c80ec

File tree

6 files changed

+48
-77
lines changed

6 files changed

+48
-77
lines changed

drivers/regulator/bd71828-regulator.c

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,11 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
206206
.suspend_reg = BD71828_REG_BUCK1_SUSP_VOLT,
207207
.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
208208
.suspend_on_mask = BD71828_MASK_SUSP_EN,
209-
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
210209
/*
211210
* LPSR voltage is same as SUSPEND voltage. Allow
212-
* setting it so that regulator can be set enabled at
213-
* LPSR state
211+
* only enabling/disabling regulator for LPSR state
214212
*/
215-
.lpsr_reg = BD71828_REG_BUCK1_SUSP_VOLT,
216-
.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
213+
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
217214
},
218215
.reg_inits = buck1_inits,
219216
.reg_init_amnt = ARRAY_SIZE(buck1_inits),
@@ -288,13 +285,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
288285
ROHM_DVS_LEVEL_SUSPEND |
289286
ROHM_DVS_LEVEL_LPSR,
290287
.run_reg = BD71828_REG_BUCK3_VOLT,
291-
.idle_reg = BD71828_REG_BUCK3_VOLT,
292-
.suspend_reg = BD71828_REG_BUCK3_VOLT,
293-
.lpsr_reg = BD71828_REG_BUCK3_VOLT,
294288
.run_mask = BD71828_MASK_BUCK3_VOLT,
295-
.idle_mask = BD71828_MASK_BUCK3_VOLT,
296-
.suspend_mask = BD71828_MASK_BUCK3_VOLT,
297-
.lpsr_mask = BD71828_MASK_BUCK3_VOLT,
298289
.idle_on_mask = BD71828_MASK_IDLE_EN,
299290
.suspend_on_mask = BD71828_MASK_SUSP_EN,
300291
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -329,13 +320,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
329320
ROHM_DVS_LEVEL_SUSPEND |
330321
ROHM_DVS_LEVEL_LPSR,
331322
.run_reg = BD71828_REG_BUCK4_VOLT,
332-
.idle_reg = BD71828_REG_BUCK4_VOLT,
333-
.suspend_reg = BD71828_REG_BUCK4_VOLT,
334-
.lpsr_reg = BD71828_REG_BUCK4_VOLT,
335323
.run_mask = BD71828_MASK_BUCK4_VOLT,
336-
.idle_mask = BD71828_MASK_BUCK4_VOLT,
337-
.suspend_mask = BD71828_MASK_BUCK4_VOLT,
338-
.lpsr_mask = BD71828_MASK_BUCK4_VOLT,
339324
.idle_on_mask = BD71828_MASK_IDLE_EN,
340325
.suspend_on_mask = BD71828_MASK_SUSP_EN,
341326
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -370,13 +355,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
370355
ROHM_DVS_LEVEL_SUSPEND |
371356
ROHM_DVS_LEVEL_LPSR,
372357
.run_reg = BD71828_REG_BUCK5_VOLT,
373-
.idle_reg = BD71828_REG_BUCK5_VOLT,
374-
.suspend_reg = BD71828_REG_BUCK5_VOLT,
375-
.lpsr_reg = BD71828_REG_BUCK5_VOLT,
376358
.run_mask = BD71828_MASK_BUCK5_VOLT,
377-
.idle_mask = BD71828_MASK_BUCK5_VOLT,
378-
.suspend_mask = BD71828_MASK_BUCK5_VOLT,
379-
.lpsr_mask = BD71828_MASK_BUCK5_VOLT,
380359
.idle_on_mask = BD71828_MASK_IDLE_EN,
381360
.suspend_on_mask = BD71828_MASK_SUSP_EN,
382361
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -493,13 +472,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
493472
ROHM_DVS_LEVEL_SUSPEND |
494473
ROHM_DVS_LEVEL_LPSR,
495474
.run_reg = BD71828_REG_LDO1_VOLT,
496-
.idle_reg = BD71828_REG_LDO1_VOLT,
497-
.suspend_reg = BD71828_REG_LDO1_VOLT,
498-
.lpsr_reg = BD71828_REG_LDO1_VOLT,
499475
.run_mask = BD71828_MASK_LDO_VOLT,
500-
.idle_mask = BD71828_MASK_LDO_VOLT,
501-
.suspend_mask = BD71828_MASK_LDO_VOLT,
502-
.lpsr_mask = BD71828_MASK_LDO_VOLT,
503476
.idle_on_mask = BD71828_MASK_IDLE_EN,
504477
.suspend_on_mask = BD71828_MASK_SUSP_EN,
505478
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -533,13 +506,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
533506
ROHM_DVS_LEVEL_SUSPEND |
534507
ROHM_DVS_LEVEL_LPSR,
535508
.run_reg = BD71828_REG_LDO2_VOLT,
536-
.idle_reg = BD71828_REG_LDO2_VOLT,
537-
.suspend_reg = BD71828_REG_LDO2_VOLT,
538-
.lpsr_reg = BD71828_REG_LDO2_VOLT,
539509
.run_mask = BD71828_MASK_LDO_VOLT,
540-
.idle_mask = BD71828_MASK_LDO_VOLT,
541-
.suspend_mask = BD71828_MASK_LDO_VOLT,
542-
.lpsr_mask = BD71828_MASK_LDO_VOLT,
543510
.idle_on_mask = BD71828_MASK_IDLE_EN,
544511
.suspend_on_mask = BD71828_MASK_SUSP_EN,
545512
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -573,13 +540,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
573540
ROHM_DVS_LEVEL_SUSPEND |
574541
ROHM_DVS_LEVEL_LPSR,
575542
.run_reg = BD71828_REG_LDO3_VOLT,
576-
.idle_reg = BD71828_REG_LDO3_VOLT,
577-
.suspend_reg = BD71828_REG_LDO3_VOLT,
578-
.lpsr_reg = BD71828_REG_LDO3_VOLT,
579543
.run_mask = BD71828_MASK_LDO_VOLT,
580-
.idle_mask = BD71828_MASK_LDO_VOLT,
581-
.suspend_mask = BD71828_MASK_LDO_VOLT,
582-
.lpsr_mask = BD71828_MASK_LDO_VOLT,
583544
.idle_on_mask = BD71828_MASK_IDLE_EN,
584545
.suspend_on_mask = BD71828_MASK_SUSP_EN,
585546
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -614,13 +575,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
614575
ROHM_DVS_LEVEL_SUSPEND |
615576
ROHM_DVS_LEVEL_LPSR,
616577
.run_reg = BD71828_REG_LDO4_VOLT,
617-
.idle_reg = BD71828_REG_LDO4_VOLT,
618-
.suspend_reg = BD71828_REG_LDO4_VOLT,
619-
.lpsr_reg = BD71828_REG_LDO4_VOLT,
620578
.run_mask = BD71828_MASK_LDO_VOLT,
621-
.idle_mask = BD71828_MASK_LDO_VOLT,
622-
.suspend_mask = BD71828_MASK_LDO_VOLT,
623-
.lpsr_mask = BD71828_MASK_LDO_VOLT,
624579
.idle_on_mask = BD71828_MASK_IDLE_EN,
625580
.suspend_on_mask = BD71828_MASK_SUSP_EN,
626581
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -655,13 +610,7 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
655610
ROHM_DVS_LEVEL_SUSPEND |
656611
ROHM_DVS_LEVEL_LPSR,
657612
.run_reg = BD71828_REG_LDO5_VOLT,
658-
.idle_reg = BD71828_REG_LDO5_VOLT,
659-
.suspend_reg = BD71828_REG_LDO5_VOLT,
660-
.lpsr_reg = BD71828_REG_LDO5_VOLT,
661613
.run_mask = BD71828_MASK_LDO_VOLT,
662-
.idle_mask = BD71828_MASK_LDO_VOLT,
663-
.suspend_mask = BD71828_MASK_LDO_VOLT,
664-
.lpsr_mask = BD71828_MASK_LDO_VOLT,
665614
.idle_on_mask = BD71828_MASK_IDLE_EN,
666615
.suspend_on_mask = BD71828_MASK_SUSP_EN,
667616
.lpsr_on_mask = BD71828_MASK_LPSR_EN,
@@ -720,9 +669,6 @@ static const struct bd71828_regulator_data bd71828_rdata[] = {
720669
.suspend_reg = BD71828_REG_LDO7_VOLT,
721670
.lpsr_reg = BD71828_REG_LDO7_VOLT,
722671
.run_mask = BD71828_MASK_LDO_VOLT,
723-
.idle_mask = BD71828_MASK_LDO_VOLT,
724-
.suspend_mask = BD71828_MASK_LDO_VOLT,
725-
.lpsr_mask = BD71828_MASK_LDO_VOLT,
726672
.idle_on_mask = BD71828_MASK_IDLE_EN,
727673
.suspend_on_mask = BD71828_MASK_SUSP_EN,
728674
.lpsr_on_mask = BD71828_MASK_LPSR_EN,

drivers/regulator/helpers.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,32 @@ int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev)
161161
}
162162
EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_pickable_regmap);
163163

164+
static int write_separate_vsel_and_range(struct regulator_dev *rdev,
165+
unsigned int sel, unsigned int range)
166+
{
167+
bool range_updated;
168+
int ret;
169+
170+
ret = regmap_update_bits_base(rdev->regmap, rdev->desc->vsel_range_reg,
171+
rdev->desc->vsel_range_mask,
172+
range, &range_updated, false, false);
173+
if (ret)
174+
return ret;
175+
176+
/*
177+
* Some PMICs treat the vsel_reg same as apply-bit. Force it to be
178+
* written if the range changed, even if the old selector was same as
179+
* the new one
180+
*/
181+
if (rdev->desc->range_applied_by_vsel && range_updated)
182+
return regmap_write_bits(rdev->regmap,
183+
rdev->desc->vsel_reg,
184+
rdev->desc->vsel_mask, sel);
185+
186+
return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
187+
rdev->desc->vsel_mask, sel);
188+
}
189+
164190
/**
165191
* regulator_set_voltage_sel_pickable_regmap - pickable range set_voltage_sel
166192
*
@@ -199,21 +225,12 @@ int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev,
199225
range = rdev->desc->linear_range_selectors_bitfield[i];
200226
range <<= ffs(rdev->desc->vsel_range_mask) - 1;
201227

202-
if (rdev->desc->vsel_reg == rdev->desc->vsel_range_reg) {
203-
ret = regmap_update_bits(rdev->regmap,
204-
rdev->desc->vsel_reg,
228+
if (rdev->desc->vsel_reg == rdev->desc->vsel_range_reg)
229+
ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
205230
rdev->desc->vsel_range_mask |
206231
rdev->desc->vsel_mask, sel | range);
207-
} else {
208-
ret = regmap_update_bits(rdev->regmap,
209-
rdev->desc->vsel_range_reg,
210-
rdev->desc->vsel_range_mask, range);
211-
if (ret)
212-
return ret;
213-
214-
ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
215-
rdev->desc->vsel_mask, sel);
216-
}
232+
else
233+
ret = write_separate_vsel_and_range(rdev, sel, range);
217234

218235
if (ret)
219236
return ret;

drivers/regulator/rohm-regulator.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ static int set_dvs_level(const struct regulator_desc *desc,
4646
continue;
4747
if (ret == uv) {
4848
i <<= ffs(desc->vsel_mask) - 1;
49+
4950
ret = regmap_update_bits(regmap, reg, mask, i);
5051
if (omask && !ret)
5152
ret = regmap_update_bits(regmap, oreg, omask,
5253
omask);
5354
break;
5455
}
5556
}
57+
if (i == desc->n_voltages)
58+
pr_warn("Unsupported %s voltage %u\n", prop, uv);
59+
5660
return ret;
5761
}
5862

drivers/regulator/tps6287x-regulator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static struct regulator_desc tps6287x_reg = {
115115
.vsel_mask = 0xFF,
116116
.vsel_range_reg = TPS6287X_CTRL2,
117117
.vsel_range_mask = TPS6287X_CTRL2_VRANGE,
118+
.range_applied_by_vsel = true,
118119
.ramp_reg = TPS6287X_CTRL1,
119120
.ramp_mask = TPS6287X_CTRL1_VRAMP,
120121
.ramp_delay_table = tps6287x_ramp_table,

drivers/regulator/tps6594-regulator.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,30 +400,30 @@ static struct tps6594_regulator_irq_type *tps65224_ldos_irq_types[] = {
400400
static const struct regulator_desc tps6594_multi_regs[] = {
401401
TPS6594_REGULATOR("BUCK12", "buck12", TPS6594_BUCK_1,
402402
REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS6594_MASK_BUCKS_VSET,
403-
TPS6594_REG_BUCKX_VOUT_1(1),
403+
TPS6594_REG_BUCKX_VOUT_1(0),
404404
TPS6594_MASK_BUCKS_VSET,
405-
TPS6594_REG_BUCKX_CTRL(1),
405+
TPS6594_REG_BUCKX_CTRL(0),
406406
TPS6594_BIT_BUCK_EN, 0, 0, bucks_ranges,
407407
4, 4000, 0, NULL, 0, 0),
408408
TPS6594_REGULATOR("BUCK34", "buck34", TPS6594_BUCK_3,
409409
REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS6594_MASK_BUCKS_VSET,
410-
TPS6594_REG_BUCKX_VOUT_1(3),
410+
TPS6594_REG_BUCKX_VOUT_1(2),
411411
TPS6594_MASK_BUCKS_VSET,
412-
TPS6594_REG_BUCKX_CTRL(3),
412+
TPS6594_REG_BUCKX_CTRL(2),
413413
TPS6594_BIT_BUCK_EN, 0, 0, bucks_ranges,
414414
4, 0, 0, NULL, 0, 0),
415415
TPS6594_REGULATOR("BUCK123", "buck123", TPS6594_BUCK_1,
416416
REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS6594_MASK_BUCKS_VSET,
417-
TPS6594_REG_BUCKX_VOUT_1(1),
417+
TPS6594_REG_BUCKX_VOUT_1(0),
418418
TPS6594_MASK_BUCKS_VSET,
419-
TPS6594_REG_BUCKX_CTRL(1),
419+
TPS6594_REG_BUCKX_CTRL(0),
420420
TPS6594_BIT_BUCK_EN, 0, 0, bucks_ranges,
421421
4, 4000, 0, NULL, 0, 0),
422422
TPS6594_REGULATOR("BUCK1234", "buck1234", TPS6594_BUCK_1,
423423
REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS6594_MASK_BUCKS_VSET,
424-
TPS6594_REG_BUCKX_VOUT_1(1),
424+
TPS6594_REG_BUCKX_VOUT_1(0),
425425
TPS6594_MASK_BUCKS_VSET,
426-
TPS6594_REG_BUCKX_CTRL(1),
426+
TPS6594_REG_BUCKX_CTRL(0),
427427
TPS6594_BIT_BUCK_EN, 0, 0, bucks_ranges,
428428
4, 4000, 0, NULL, 0, 0),
429429
};

include/linux/regulator/driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ enum regulator_type {
299299
* @vsel_range_reg: Register for range selector when using pickable ranges
300300
* and ``regulator_map_*_voltage_*_pickable`` functions.
301301
* @vsel_range_mask: Mask for register bitfield used for range selector
302+
* @range_applied_by_vsel: A flag to indicate that changes to vsel_range_reg
303+
* are only effective after vsel_reg is written
302304
* @vsel_reg: Register for selector when using ``regulator_map_*_voltage_*``
303305
* @vsel_mask: Mask for register bitfield used for selector
304306
* @vsel_step: Specify the resolution of selector stepping when setting
@@ -389,6 +391,7 @@ struct regulator_desc {
389391

390392
unsigned int vsel_range_reg;
391393
unsigned int vsel_range_mask;
394+
bool range_applied_by_vsel;
392395
unsigned int vsel_reg;
393396
unsigned int vsel_mask;
394397
unsigned int vsel_step;

0 commit comments

Comments
 (0)