diff options
author | Yuxi Sun <b36102@freescale.com> | 2011-12-15 10:12:53 +0800 |
---|---|---|
committer | Nitin Garg <nitin.garg@freescale.com> | 2012-03-06 15:51:44 -0600 |
commit | 1201aa6b1e7c2c2d3e6361c686419309022ae4df (patch) | |
tree | dfa2c8146c57d0552f430d8382e8e03875d2ac76 | |
parent | bf6e9fd7d957c8e4677b226c6403d14328d2ff0c (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>
-rw-r--r-- | arch/arm/plat-mxc/pwm.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c index 564549418ba5..5effdb3d6d3e 100644 --- a/arch/arm/plat-mxc/pwm.c +++ b/arch/arm/plat-mxc/pwm.c @@ -6,7 +6,7 @@ * published by the Free Software Foundation. * * Derived from pxa PWM driver by eric miao <eric.miao@marvell.com> - * Copyright 2009-2011 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2009-2012 Freescale Semiconductor, Inc. All Rights Reserved. */ #include <linux/module.h> @@ -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; |