pwm: mxs: Fix zero duty cycle
Subsystems (2)
Fabio Estevam
reviewerPATCH 1/1 pwm: mxs: Fix zero duty cycle
From: Fabio Estevam <[email protected]>
Currently, when a duty cycle of zero is requested, the PWM stops getting updated. This causes the minimal brightness of an LED to not turned off completely as expected.
For example, driving an LED via led-pwm and running:
echo 255 > /sys/class/leds/red/brightness
makes the LED to go to its maximum brightness as expected.
After running:
echo 0 > /sys/class/leds/red/brightness
The PWM controlled LED does not turn off. Instead, the LED brightness stays at its maximum.
The reason for this behavior is that when brightness is set to 0, state->enabled goes to 0 and the PWM is disabled by setting the PWM_CTRL + CLR register.
Fix this problem by keeping the PWM controller turned on, even in the case when a zero duty cycle is requested.
--- drivers/pwm/pwm-mxs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-mxs.c +1 -1
@@ -65,7 +65,7 @@ static int mxs_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,return ret; } -if (!state->enabled &&pwm_is_enabled (pwm)) +if (pwm_is_enabled (pwm))writel (1 << pwm->hwpwm, mxs->base +PWM_CTRL +CLR ); rate =clk_get_rate (mxs->clk);
Signature · 1 line
2.34.1
Hello Fabio,
Quoted 39 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Currently, when a duty cycle of zero is requested, the PWM stops getting updated. This causes the minimal brightness of an LED to not turned off completely as expected.
For example, driving an LED via led-pwm and running:
echo 255 >
/sys/class/leds/red/brightnessmakes the LED to go to its maximum brightness as expected.
After running:
echo 0 >
/sys/class/leds/red/brightnessThe PWM controlled LED does not turn off. Instead, the LED brightness stays at its maximum.
The reason for this behavior is that when brightness is set to 0,
state->enabledgoes to 0 and the PWM is disabled by setting thePWM_CTRL+ CLR register.Fix this problem by keeping the PWM controller turned on, even in the case when a zero duty cycle is requested.
Fixes bf29c2ff82fd ("pwm: mxs: Implement ->apply()")Reported-by Rogan Dawes <[email protected]>Signed-off-by Fabio Estevam <[email protected]>Tested-by Rogan Dawes <[email protected]>--- drivers/pwm/pwm-mxs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pwm/pwm-mxs.c +0
-0
drivers/pwm/pwm-mxs.c static int mxs_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, · line 71
Quoted 8 lines
drivers/pwm/pwm-mxs.c +1
-1@@ -65,7 +65,7 @@ static int mxs_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,return ret; } -if (!state->enabled &&pwm_is_enabled (pwm)) +if (pwm_is_enabled (pwm))writel (1 << pwm->hwpwm, mxs->base +PWM_CTRL +CLR ); rate =clk_get_rate (mxs->clk);
This patch is wrong. I'll prepare a better fix.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |