Patchwork ARM:imx:fix pwm period value

login
register
mail settings
Submitter Jason Chen
Date Dec. 19, 2011, 3:23 a.m.
Message ID <1324265008-22866-1-git-send-email-jason.chen@linaro.org>
Download mbox | patch
Permalink /patch/132151/
State New
Headers show

Comments

Jason Chen - Dec. 19, 2011, 3:23 a.m.
According to imx pwm RM, the real period value should be
PERIOD value in PWMPR plus 2.

PWMO (Hz) = PCLK(Hz) / (period +2)

Signed-off-by: Jason Chen <jason.chen@linaro.org>
---
 arch/arm/plat-mxc/pwm.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Patch

diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
index 6b78490..0b112d2 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/arch/arm/plat-mxc/pwm.c
@@ -78,6 +78,15 @@  int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
 		do_div(c, period_ns);
 		duty_cycles = c;
 
+		/*
+		 * according to imx pwm RM, the real period value should be
+		 * PERIOD value in PWMPR plus 2.
+		 */
+		if (period_cycles > 2)
+			period_cycles -= 2;
+		else
+			period_cycles = 0;
+
 		writel(duty_cycles, pwm->mmio_base + MX3_PWMSAR);
 		writel(period_cycles, pwm->mmio_base + MX3_PWMPR);