linux-yocto/drivers/regulator
Martin Blumenstingl 8f2852c1d7 regulator: pwm-regulator: Manage boot-on with disabled PWM channels
commit b3cbdcc191 upstream.

Odroid-C1 uses a Monolithic Power Systems MP2161 controlled via PWM for
the VDDEE voltage supply of the Meson8b SoC. Commit 6b9352f3f8 ("pwm:
meson: modify and simplify calculation in meson_pwm_get_state") results
in my Odroid-C1 crashing with memory corruption in many different places
(seemingly at random). It turns out that this is due to a currently not
supported corner case.

The VDDEE regulator can generate between 860mV (duty cycle of ~91%) and
1140mV (duty cycle of 0%). We consider it to be enabled by the bootloader
(which is why it has the regulator-boot-on flag in .dts) as well as
being always-on (which is why it has the regulator-always-on flag in
.dts) because the VDDEE voltage is generally required for the Meson8b
SoC to work. The public S805 datasheet [0] states on page 17 (where "A5"
refers to the Cortex-A5 CPU cores):
  [...] So if EE domains is shut off, A5 memory is also shut off. That
  does not matter. Before EE power domain is shut off, A5 should be shut
  off at first.

It turns out that at least some bootloader versions are keeping the PWM
output disabled. This is not a problem due to the specific design of the
regulator: when the PWM output is disabled the output pin is pulled LOW,
effectively achieving a 0% duty cycle (which in return means that VDDEE
voltage is at 1140mV).

The problem comes when the pwm-regulator driver tries to initialize the
PWM output. To do so it reads the current state from the hardware, which
is:
  period: 3666ns
  duty cycle: 3333ns (= ~91%)
  enabled: false
Then those values are translated using the continuous voltage range to
860mV.
Later, when the regulator is being enabled (either by the regulator core
due to the always-on flag or first consumer - in this case the lima
driver for the Mali-450 GPU) the pwm-regulator driver tries to keep the
voltage (at 860mV) and just enable the PWM output. This is when things
start to go wrong as the typical voltage used for VDDEE is 1100mV.

Commit 6b9352f3f8 ("pwm: meson: modify and simplify calculation in
meson_pwm_get_state") triggers above condition as before that change
period and duty cycle were both at 0. Since the change to the pwm-meson
driver is considered correct the solution is to be found in the
pwm-regulator driver. Update the duty cycle during driver probe if the
regulator is flagged as boot-on so that a call to pwm_regulator_enable()
(by the regulator core during initialization of a regulator flagged with
boot-on) without any preceding call to pwm_regulator_set_voltage() does
not change the output voltage.

[0] https://dn.odroid.com/S805/Datasheet/S805_Datasheet%20V0.8%2020150126.pdf

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://msgid.link/r/20240113224628.377993-4-martin.blumenstingl@googlemail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-24 08:53:21 +02:00
..
88pg86x.c
88pm800-regulator.c
88pm8607.c
aat2870-regulator.c
ab8500-ext.c
ab8500.c
act8865-regulator.c
act8945a-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
ad5398.c regulator: ad5398: Add device tree support 2025-06-04 14:42:15 +02:00
anatop-regulator.c
arizona-ldo1.c
arizona-micsupp.c
as3711-regulator.c
as3722-regulator.c
atc260x-regulator.c regulator: Use bitfield values for range selectors 2023-07-25 12:14:27 +01:00
aw37503-regulator.c regulator: aw37503: Switch back to use struct i2c_driver's .probe() 2023-08-24 21:43:28 +01:00
axp20x-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
bcm590xx-regulator.c
bd718x7-regulator.c regulator: Use bitfield values for range selectors 2023-07-25 12:14:27 +01:00
bd9571mwv-regulator.c
bd9576-regulator.c
bd71815-regulator.c regulator: bd71815: fix ramp values 2024-06-27 13:49:09 +02:00
bd71828-regulator.c regulator: bd71828: Don't overwrite runtime voltages 2024-06-12 11:12:46 +02:00
core.c regulator: check that dummy regulator has been probed before using it 2025-03-28 21:59:54 +01:00
cpcap-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
cros-ec-regulator.c
da903x-regulator.c
da9052-regulator.c
da9055-regulator.c
da9062-regulator.c regulator: da9062: Make the use of IRQ optional 2023-07-13 17:35:06 +01:00
da9063-regulator.c regulator: da9063: better fix null deref with partial DT 2023-08-04 13:26:53 +01:00
da9121-regulator.c regulator: da9121-regulator: Remove redundant of_match_ptr() macros 2023-08-09 12:52:41 +01:00
da9121-regulator.h
da9210-regulator.c
da9210-regulator.h
da9211-regulator.c
da9211-regulator.h
db8500-prcmu.c
dbx500-prcmu.c
dbx500-prcmu.h
devres.c
dummy.c regulator: dummy: force synchronous probing 2025-03-28 21:59:54 +01:00
dummy.h
fan53555.c regulator: fan53555: add enable_time support and soft-start times 2025-07-10 16:03:16 +02:00
fan53880.c
fixed-helper.c
fixed.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
gpio-regulator.c regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods 2025-07-10 16:03:05 +02:00
helpers.c regulator: pickable ranges: don't always cache vsel 2024-06-12 11:12:48 +02:00
hi655x-regulator.c
hi6421-regulator.c regulator: hi6421: Remove redundant of_match_ptr() macros 2023-08-09 12:52:42 +01:00
hi6421v530-regulator.c
hi6421v600-regulator.c
internal.h
irq_helpers.c regulator: irq_helpers: duplicate IRQ name 2024-06-12 11:11:25 +02:00
isl6271a-regulator.c
isl9305.c
Kconfig regulator: aw37503: add regulator driver for Awinic AW37503 2023-08-21 13:10:21 +01:00
lm363x-regulator.c
lochnagar-regulator.c
lp872x.c regulator: lp872x: Fix Wvoid-pointer-to-enum-cast warning 2023-08-10 15:44:46 +01:00
lp873x-regulator.c
lp3971.c
lp3972.c
lp8755.c regulator: lp8755: Drop useless header 2023-08-08 15:23:16 +01:00
lp8788-buck.c
lp8788-ldo.c
lp87565-regulator.c regulator: lp87565: Remove redundant of_match_ptr() macros 2023-08-09 12:52:41 +01:00
ltc3589.c regulator: ltc3589: Fix Wvoid-pointer-to-enum-cast warning 2023-08-10 15:44:44 +01:00
ltc3676.c
Makefile regulator: aw37503: add regulator driver for Awinic AW37503 2023-08-21 13:10:21 +01:00
max1586.c
max5970-regulator.c regulator: max5970: Fix regulator child node name 2024-03-26 18:19:13 -04:00
max8649.c
max8660.c
max8893.c regulator: max8893: Drop "_new" from probe callback 2023-07-21 11:55:42 +01:00
max8907-regulator.c
max8925-regulator.c
max8952.c
max8973-regulator.c
max8997-regulator.c
max8998.c
max14577-regulator.c regulator: max14577: Add error check for max14577_read_reg() 2025-06-27 11:08:50 +01:00
max20086-regulator.c regulator: max20086: Change enable gpio to optional 2025-06-27 11:08:43 +01:00
max20411-regulator.c
max77541-regulator.c regulator: Use bitfield values for range selectors 2023-07-25 12:14:27 +01:00
max77620-regulator.c
max77650-regulator.c regulator: Use bitfield values for range selectors 2023-07-25 12:14:27 +01:00
max77686-regulator.c
max77693-regulator.c
max77802-regulator.c
max77826-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
max77857-regulator.c regulator: max77857: Fix Wvoid-pointer-to-enum-cast warning 2023-08-10 15:44:45 +01:00
mc13xxx-regulator-core.c
mc13xxx.h
mc13783-regulator.c
mc13892-regulator.c
mcp16502.c regulator: mcp16502: Remove redundant of_match_ptr() macros 2023-08-09 12:52:43 +01:00
mp886x.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
mp5416.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
mp8859.c
mpq7920.c regulator: mpq7920: Remove redundant of_match_ptr() macro 2023-08-09 12:52:44 +01:00
mpq7920.h
mt6311-regulator.c regulator: mt6311: Drop useless header 2023-08-08 15:23:13 +01:00
mt6311-regulator.h
mt6315-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
mt6323-regulator.c
mt6331-regulator.c
mt6332-regulator.c
mt6357-regulator.c
mt6358-regulator.c regulator: mt6358: Fail probe on unknown chip ID 2023-11-20 11:59:04 +01:00
mt6359-regulator.c regulator: Remove duplicated include in mt6359-regulator.c 2023-07-18 15:11:31 +01:00
mt6360-regulator.c regulator: mt6360: De-capitalize devicetree regulator subnodes 2024-05-17 12:01:58 +02:00
mt6370-regulator.c
mt6380-regulator.c
mt6397-regulator.c
mtk-dvfsrc-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
of_regulator.c regulator: of: Implement the unwind path of of_regulator_match() 2025-02-08 09:51:55 +01:00
palmas-regulator.c
pbias-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
pca9450-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
pcap-regulator.c
pcf50633-regulator.c
pf8x00-regulator.c
pfuze100-regulator.c regulator: pfuze100-regulator: Remove redundant of_match_ptr() macro 2023-08-09 12:52:45 +01:00
pv88060-regulator.c
pv88060-regulator.h
pv88080-regulator.c
pv88080-regulator.h
pv88090-regulator.c
pv88090-regulator.h
pwm-regulator.c regulator: pwm-regulator: Manage boot-on with disabled PWM channels 2025-07-24 08:53:21 +02:00
qcom_rpm-regulator.c regulator: qcom_rpm-regulator: Use devm_kmemdup to replace devm_kmalloc + memcpy 2023-08-10 15:44:43 +01:00
qcom_smd-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
qcom_spmi-regulator.c
qcom_usb_vbus-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
qcom-labibb-regulator.c
qcom-refgen-regulator.c regulator: qcom-refgen: fix module autoloading 2024-06-12 11:11:26 +02:00
qcom-rpmh-regulator.c regulator: qcom-rpmh: Fix smps4 regulator for pm8550ve 2023-11-20 11:59:07 +01:00
raa215300.c regulator: raa215300: Add missing blank space 2023-08-18 16:21:44 +01:00
rc5t583-regulator.c regulator: rc5t583: Drop useless header 2023-08-08 15:23:12 +01:00
rk808-regulator.c objtool, regulator: rk808: Remove potential undefined behavior in rk806_set_mode_dcdc() 2025-05-02 07:50:56 +02:00
rn5t618-regulator.c
rohm-regulator.c regulator: Use bitfield values for range selectors 2023-07-25 12:14:27 +01:00
rpi-panel-attiny-regulator.c regulator: rpi-panel-attiny: Drop useless header 2023-08-08 15:23:12 +01:00
rt4801-regulator.c
rt4803.c
rt4831-regulator.c
rt5033-regulator.c
rt5120-regulator.c
rt5190a-regulator.c
rt5739.c regulator: rt5739: Add DID check and compatible for rt5733 2023-07-09 22:48:53 +01:00
rt5759-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
rt6160-regulator.c
rt6190-regulator.c
rt6245-regulator.c
rtmv20-regulator.c
rtq2134-regulator.c
rtq2208-regulator.c regulator: rtq2208: Fix uninitialized use of regulator_config 2024-11-14 13:19:30 +01:00
rtq6752-regulator.c
s2mpa01.c regulator: s2mpa01: Drop useless header 2023-08-08 15:23:11 +01:00
s2mps11.c
s5m8767.c
sc2731-regulator.c
scmi-regulator.c
sky81452-regulator.c
slg51000-regulator.c
slg51000-regulator.h
sm5703-regulator.c
stm32-booster.c
stm32-pwr.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
stm32-vrefbuf.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
stpmic1_regulator.c
stw481x-vmmc.c
sy7636a-regulator.c
sy8106a-regulator.c
sy8824x.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
sy8827n.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
ti-abb-regulator.c regulator: ti-abb: don't use devm_platform_ioremap_resource_byname for shared interrupt register 2024-02-05 20:14:34 +00:00
tps6105x-regulator.c
tps6286x-regulator.c regulator: tps6286x-regulator: Remove redundant of_match_ptr() macros 2023-08-09 12:52:46 +01:00
tps6287x-regulator.c regulator: tps6287x: Force writing VSEL bit 2024-06-12 11:12:48 +02:00
tps6507x-regulator.c
tps6524x-regulator.c
tps6586x-regulator.c
tps6594-regulator.c regulator: tps6594-regulator: Correct multi-phase configuration 2024-06-12 11:12:48 +02:00
tps51632-regulator.c
tps62360-regulator.c
tps65023-regulator.c
tps65086-regulator.c regulator: tps65086: Select dedicated regulator config for chip variant 2023-08-18 22:06:52 +01:00
tps65090-regulator.c
tps65132-regulator.c regulator: tps65132: Add of_match table 2024-05-17 12:02:12 +02:00
tps65217-regulator.c
tps65218-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
tps65219-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
tps65910-regulator.c regulator: tps65910: Drop useless header 2023-08-08 15:23:10 +01:00
tps65912-regulator.c
tps68470-regulator.c
twl-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
twl6030-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
uniphier-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
userspace-consumer.c regulator: userspace-consumer: add module device table 2024-03-26 18:19:34 -04:00
vctrl-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
vexpress-regulator.c regulator: Explicitly include correct DT includes 2023-07-14 20:52:54 +01:00
virtual.c
vqmmc-ipq4019-regulator.c regulator: vqmmc-ipq4019: fix module autoloading 2024-06-12 11:11:26 +02:00
wm831x-dcdc.c
wm831x-isink.c
wm831x-ldo.c
wm8350-regulator.c
wm8400-regulator.c
wm8994-regulator.c