Skip to content

Commit 6a7d11e

Browse files
xdarklightbroonie
authored andcommitted
regulator: pwm-regulator: Calculate the output voltage for disabled PWMs
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 <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c92688c commit 6a7d11e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/regulator/pwm-regulator.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ static int pwm_regulator_get_voltage(struct regulator_dev *rdev)
157157

158158
pwm_get_state(drvdata->pwm, &pstate);
159159

160+
if (!pstate.enabled) {
161+
if (pstate.polarity == PWM_POLARITY_INVERSED)
162+
pstate.duty_cycle = pstate.period;
163+
else
164+
pstate.duty_cycle = 0;
165+
}
166+
160167
voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
161168
if (voltage < min(max_uV_duty, min_uV_duty) ||
162169
voltage > max(max_uV_duty, min_uV_duty))

0 commit comments

Comments
 (0)