PKGBUILDs/core/kernel26-olinuxino/1145-ENGR00170342-PWM-fix-pwm-output-can-t-be-set-to-100.patch
2012-07-14 22:54:21 +03:00

35 lines
1.2 KiB
Diff

From d1eff01309855f850d82e4ce9abe42ad76aa7f9f Mon Sep 17 00:00:00 2001
From: Yuxi Sun <b36102@freescale.com>
Date: Thu, 15 Dec 2011 10:12:53 +0800
Subject: [PATCH] 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)
---
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 2f8a35e..ccba298 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;
--
1.5.4.4