diff options
author | Yuxi Sun <b36102@freescale.com> | 2011-12-15 10:12:53 +0800 |
---|---|---|
committer | Andy Voltz <andy.voltz@timesys.com> | 2012-03-09 11:26:47 -0500 |
commit | b1cc800794a27e5f964c4bd7b7d9ef8bc7ab4b04 (patch) | |
tree | 790079641d1fcb207134ac3aee7edecc744e6069 | |
parent | e66b78490f74a394e8dc0bc6a4e8441c16f62df7 (diff) |
ENGR00170342 PWM: fix pwm output can't be set to 100% full duty
The chip document says the counter counts up to period_cycles + 1
and then is reset to 0, so the actual period of the PWM wave is
period_cycles + 2
Signed-off-by: Yuxi Sun <b36102@freescale.com>
(cherry picked from commit e1465447502c77b2951af7ace43d8f76fa5039fb)
-rw-r--r-- | arch/arm/plat-mxc/pwm.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c index 2f8a35ec1038..ccba298090bc 100644 --- a/arch/arm/plat-mxc/pwm.c +++ b/arch/arm/plat-mxc/pwm.c @@ -83,7 +83,11 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) prescale = period_cycles / 0x10000 + 1; period_cycles /= prescale; - c = (unsigned long long)period_cycles * duty_ns; + /* the chip document says the counter counts up to + * period_cycles + 1 and then is reset to 0, so the + * actual period of the PWM wave is period_cycles + 2 + */ + c = (unsigned long long)(period_cycles + 2) * duty_ns; do_div(c, period_ns); duty_cycles = c; |