diff options
author | Yuxi Sun <b36102@freescale.com> | 2011-12-15 10:12:53 +0800 |
---|---|---|
committer | Jason Liu <r64343@freescale.com> | 2012-07-20 13:19:00 +0800 |
commit | ac3711f7f24b94db9f78fd7e9bf134c2ecd025ab (patch) | |
tree | 87953437571703440837f94b624ecdf6fb07373d /arch/arm/plat-mxc/pwm.c | |
parent | 671ad1306f82b25fc831e9af5e2ff60dda27e668 (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>
Diffstat (limited to 'arch/arm/plat-mxc/pwm.c')
-rwxr-xr-x | 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 c95622c27734..c663acf65c3f 100755 --- a/arch/arm/plat-mxc/pwm.c +++ b/arch/arm/plat-mxc/pwm.c @@ -86,7 +86,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; |