summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>2024-01-13 23:46:27 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-07-24 08:53:21 +0200
commitcad3ec23e398542c28283bcf3708dc4b71c2eb75 (patch)
tree5cfa85dbfbceb399352c7418ea49097b673ce9b3 /drivers/regulator
parent7e5ec0059e4dddb2cc373cff594a179c04b90e8d (diff)
downloadlinux-cad3ec23e398542c28283bcf3708dc4b71c2eb75.tar.gz
linux-cad3ec23e398542c28283bcf3708dc4b71c2eb75.tar.bz2
linux-cad3ec23e398542c28283bcf3708dc4b71c2eb75.zip
regulator: pwm-regulator: Calculate the output voltage for disabled PWMs
commit 6a7d11efd6915d80a025f2a0be4ae09d797b91ec upstream. If a PWM output is disabled then it's voltage has to be calculated based on a zero duty cycle (for normal polarity) or duty cycle being equal to the PWM period (for inverted polarity). Add support for this to pwm_regulator_get_voltage(). Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Link: https://msgid.link/r/20240113224628.377993-3-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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/pwm-regulator.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index 226ca4c62673..d27b9a7a30c9 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -157,6 +157,13 @@ static int pwm_regulator_get_voltage(struct regulator_dev *rdev)
pwm_get_state(drvdata->pwm, &pstate);
+ if (!pstate.enabled) {
+ if (pstate.polarity == PWM_POLARITY_INVERSED)
+ pstate.duty_cycle = pstate.period;
+ else
+ pstate.duty_cycle = 0;
+ }
+
voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
if (voltage < min(max_uV_duty, min_uV_duty) ||
voltage > max(max_uV_duty, min_uV_duty))