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

regulator: twl: voltage lists for vdd1/2 on twl4030

_opp_supported_by_regulators() wrongly ignored errors from
regulator_is_supported_voltage(), so it considered errors as
success. Since
commit 498209445124 ("regulator: core: simplify return value on suported_voltage")
regulator_is_supported_voltage() returns a real boolean, so
errors make _opp_supported_by_regulators() return false.

That reveals a problem with the declaration of the VDD1/2
regulators on twl4030.
The VDD1/VDD2 regulators on twl4030 are neither defined with
voltage lists nor with the continuous flag set, so
regulator_is_supported_voltage() returns false and an error
before above mentioned commit (which was considered success)
The result is that after the above mentioned commit cpufreq
does not work properly e.g. dm3730.

[ 2.490997] core: _opp_supported_by_regulators: OPP minuV: 1012500 maxuV: 1012500, not supported by regulator
[ 2.501617] cpu cpu0: _opp_add: OPP not supported by regulators (300000000)
[ 2.509246] core: _opp_supported_by_regulators: OPP minuV: 1200000 maxuV: 1200000, not supported by regulator
[ 2.519775] cpu cpu0: _opp_add: OPP not supported by regulators (600000000)
[ 2.527313] core: _opp_supported_by_regulators: OPP minuV: 1325000 maxuV: 1325000, not supported by regulator
[ 2.537750] cpu cpu0: _opp_add: OPP not supported by regulators (800000000)

The patch fixes declaration of VDD1/2 regulators by
adding proper voltage lists.

Fixes: 498209445124 ("regulator: core: simplify return value on suported_voltage")
Cc: stable@vger.kernel.org
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd-torpedo-37xx-devkit
Link: https://lore.kernel.org/r/20190814214319.24087-1-andreas@kemnade.info
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andreas Kemnade and committed by
Mark Brown
3829100a 5d2fc542

+20 -3
+20 -3
drivers/regulator/twl-regulator.c
··· 359 359 2500, 2750, 360 360 }; 361 361 362 + /* 600mV to 1450mV in 12.5 mV steps */ 363 + static const struct regulator_linear_range VDD1_ranges[] = { 364 + REGULATOR_LINEAR_RANGE(600000, 0, 68, 12500) 365 + }; 366 + 367 + /* 600mV to 1450mV in 12.5 mV steps, everything above = 1500mV */ 368 + static const struct regulator_linear_range VDD2_ranges[] = { 369 + REGULATOR_LINEAR_RANGE(600000, 0, 68, 12500), 370 + REGULATOR_LINEAR_RANGE(1500000, 69, 69, 12500) 371 + }; 372 + 362 373 static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) 363 374 { 364 375 struct twlreg_info *info = rdev_get_drvdata(rdev); ··· 438 427 } 439 428 440 429 static const struct regulator_ops twl4030smps_ops = { 430 + .list_voltage = regulator_list_voltage_linear_range, 431 + 441 432 .set_voltage = twl4030smps_set_voltage, 442 433 .get_voltage = twl4030smps_get_voltage, 443 434 }; ··· 479 466 }, \ 480 467 } 481 468 482 - #define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \ 469 + #define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf, \ 470 + n_volt) \ 483 471 static const struct twlreg_info TWL4030_INFO_##label = { \ 484 472 .base = offset, \ 485 473 .id = num, \ ··· 493 479 .owner = THIS_MODULE, \ 494 480 .enable_time = turnon_delay, \ 495 481 .of_map_mode = twl4030reg_map_mode, \ 482 + .n_voltages = n_volt, \ 483 + .n_linear_ranges = ARRAY_SIZE(label ## _ranges), \ 484 + .linear_ranges = label ## _ranges, \ 496 485 }, \ 497 486 } 498 487 ··· 535 518 TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08); 536 519 TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08); 537 520 TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08); 538 - TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08); 539 - TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08); 521 + TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08, 68); 522 + TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08, 69); 540 523 /* VUSBCP is managed *only* by the USB subchip */ 541 524 TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08); 542 525 TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);