1 From d1eff01309855f850d82e4ce9abe42ad76aa7f9f Mon Sep 17 00:00:00 2001
2 From: Yuxi Sun <b36102@freescale.com>
3 Date: Thu, 15 Dec 2011 10:12:53 +0800
4 Subject: [PATCH] ENGR00170342 PWM: fix pwm output can't be set to 100% full duty
6 The chip document says the counter counts up to period_cycles + 1
7 and then is reset to 0, so the actual period of the PWM wave is
10 Signed-off-by: Yuxi Sun <b36102@freescale.com>
11 (cherry picked from commit e1465447502c77b2951af7ace43d8f76fa5039fb)
13 arch/arm/plat-mxc/pwm.c | 6 +++++-
14 1 files changed, 5 insertions(+), 1 deletions(-)
16 diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
17 index 2f8a35e..ccba298 100644
18 --- a/arch/arm/plat-mxc/pwm.c
19 +++ b/arch/arm/plat-mxc/pwm.c
20 @@ -83,7 +83,11 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
21 prescale = period_cycles / 0x10000 + 1;
23 period_cycles /= prescale;
24 - c = (unsigned long long)period_cycles * duty_ns;
25 + /* the chip document says the counter counts up to
26 + * period_cycles + 1 and then is reset to 0, so the
27 + * actual period of the PWM wave is period_cycles + 2
29 + c = (unsigned long long)(period_cycles + 2) * duty_ns;