From: Peter Korsgaard Date: Wed, 1 Jul 2009 15:47:08 +0000 (+0200) Subject: ARM: S3C: PWM fix for low duty cycle X-Git-Tag: firefly_0821_release~13202^2~3^2~2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=165f5f64199f972a21f21effc125d89ed2488e58;p=firefly-linux-kernel-4.4.55.git ARM: S3C: PWM fix for low duty cycle The pwm hardware only checks the compare register after a decrement, so the pin never toggles if tcmp = tcnt. This happens when a very low duty cycle is requested. Fix it by always ensuring that tcmp < tcnt. Signed-off-by: Peter Korsgaard Signed-off-by: Ben Dooks --- diff --git a/arch/arm/plat-s3c24xx/pwm.c b/arch/arm/plat-s3c24xx/pwm.c index 0120b760315b..82a6d4de02a3 100644 --- a/arch/arm/plat-s3c24xx/pwm.c +++ b/arch/arm/plat-s3c24xx/pwm.c @@ -246,6 +246,10 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) tcmp = duty_ns / tin_ns; tcmp = tcnt - tcmp; + /* the pwm hw only checks the compare register after a decrement, + so the pin never toggles if tcmp = tcnt */ + if (tcmp == tcnt) + tcmp--; pwm_dbg(pwm, "tin_ns=%lu, tcmp=%ld/%lu\n", tin_ns, tcmp, tcnt);