Skip to contentSkip to conversation

ARM: plat-mxc: Fix pwm frequency

PATCH New Sascha Hauer 2 participants 2 messages Jul 1, 2011 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 ARM: plat-mxc: Fix pwm frequency

Quoted 3 lines · Troy Kisky

The PWMPR register is number of clocks + 2, so include a -2 when setting the register. There is currently no rounding up, so this may give a higher frequency than requested.

Have you checked this applies to mx2/3 aswell?

Sascha

Quoted 29 lines
---
 arch/arm/plat-mxc/pwm.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/plat-mxc/pwm.c +7 -1
index 73f17b2..844415e 100644
@@ -76,7 +76,13 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
 		duty_cycles = c;
 
 		writel(duty_cycles, pwm->mmio_base + MX3_PWMSAR);
-		writel(period_cycles, pwm->mmio_base + MX3_PWMPR);
+		if (period_cycles < 2)
+			period_cycles = 2;
+		/*
+		 * manual says - "A value of zero in the PWMPR will result in
+		 * a period of two clock cycles for the output signal.
+		 */
+		writel(period_cycles - 2, pwm->mmio_base + MX3_PWMPR);
 
 		cr = MX3_PWMCR_PRESCALER(prescale) | MX3_PWMCR_EN;
 
Signature · 1 line
1.7.0.4
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#2 lore raw

PATCH 2/2 ARM: plat-mxc: Fix pwm frequency

Quoted 32 lines · Sascha Hauer
Quoted 3 lines · Troy Kisky

The PWMPR register is number of clocks + 2, so include a -2 when setting the register. There is currently no rounding up, so this may give a higher frequency than requested.

Have you checked this applies to mx2/3 aswell?

Sascha

Quoted 23 lines
---
 arch/arm/plat-mxc/pwm.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/plat-mxc/pwm.c +7 -1
index 73f17b2..844415e 100644
@@ -76,7 +76,13 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
 		duty_cycles = c;
 
 		writel(duty_cycles, pwm->mmio_base + MX3_PWMSAR);
-		writel(period_cycles, pwm->mmio_base + MX3_PWMPR);
+		if (period_cycles < 2)
+			period_cycles = 2;
+		/*
+		 * manual says - "A value of zero in the PWMPR will result in
+		 * a period of two clock cycles for the output signal.
+		 */
+		writel(period_cycles - 2, pwm->mmio_base + MX3_PWMPR);
 
Quoted 7 lines
Quoted 6 lines
arch/arm/plat-mxc/pwm.c +0 -0
 		cr = MX3_PWMCR_PRESCALER(prescale) | MX3_PWMCR_EN;
 
Signature · 1 line
1.7.0.4

I just checked. It applies to mx27, mx31, mx25, mx51, mx53.

Thanks for the reminder.

Troy