Skip to content

Commit

Permalink
ARM:imx:fix pwm period value
Browse files Browse the repository at this point in the history
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>
Cc: stable@kernel.org
  • Loading branch information
Jason Chen authored and Sascha Hauer committed Dec 19, 2011
1 parent 384703b commit 5776ac2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions arch/arm/plat-mxc/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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);

Expand Down

0 comments on commit 5776ac2

Please sign in to comment.