Skip to content

Commit

Permalink
ARM: S3C: PWM fix for low duty cycle
Browse files Browse the repository at this point in the history
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 <jacmet@sunsite.dk>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Peter Korsgaard authored and Ben Dooks committed Jul 30, 2009
1 parent 9b71de4 commit 165f5f6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/arm/plat-s3c24xx/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 165f5f6

Please sign in to comment.