summaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorGuillermo Rodriguez <guille.rodriguez@gmail.com>2016-05-13 07:09:37 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-07-11 06:49:35 -0400
commitf718c54c1abab7171d375112bffd199046749953 (patch)
tree20ac27d690f99b21855e2f9751381c0ea688aa2c /drivers/pwm
parent396d502c5167da69096c683c4566388ba42d2623 (diff)
pwm: atmel: Fix disabling of PWM channels
When disabling a PWM channel, the PWM clock was being stopped immediately after writing to PWM_DIS. As a result, the disabling of the PWM channel did not complete properly, and the PWM output might be left at the wrong level. Fix this by waiting for the channel to be effectively disabled (by checking the PWM_SR register) before disabling the clock. Signed-off-by: Guillermo Rodriguez <guille.rodriguez@gmail.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-atmel.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index 0e4bd4e8e582..f3df529737f2 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -271,6 +271,16 @@ static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
271 mutex_unlock(&atmel_pwm->isr_lock); 271 mutex_unlock(&atmel_pwm->isr_lock);
272 atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << pwm->hwpwm); 272 atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << pwm->hwpwm);
273 273
274 /*
275 * Wait for the PWM channel disable operation to be effective before
276 * stopping the clock.
277 */
278 timeout = jiffies + 2 * HZ;
279
280 while ((atmel_pwm_readl(atmel_pwm, PWM_SR) & (1 << pwm->hwpwm)) &&
281 time_before(jiffies, timeout))
282 usleep_range(10, 100);
283
274 clk_disable(atmel_pwm->clk); 284 clk_disable(atmel_pwm->clk);
275} 285}
276 286