]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ARM:imx:fix pwm period value
authorJason Chen <jason.chen@linaro.org>
Mon, 19 Dec 2011 03:23:28 +0000 (11:23 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 6 Jan 2012 23:38:02 +0000 (15:38 -0800)
commit 5776ac2eb33164c77cdb4d2b48feee15616eaba3 upstream.

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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/arm/plat-mxc/pwm.c

index 99d060cd362254f0b949d64c4d6bae411e7cc2ec..16404864fdee19deebe31cfd65a8e6041cb25548 100644 (file)
@@ -76,6 +76,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);