All of lore.kernel.org
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: plat-mxc: Fix pwm frequency
Date: Fri, 1 Jul 2011 10:03:11 +0200	[thread overview]
Message-ID: <20110701080311.GS6069@pengutronix.de> (raw)
In-Reply-To: <1309485035-5964-1-git-send-email-troy.kisky@boundarydevices.com>

On Thu, Jun 30, 2011 at 06:50:35PM -0700, Troy Kisky wrote:
> 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

> 
> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
> ---
>  arch/arm/plat-mxc/pwm.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
> index 73f17b2..844415e 100644
> --- a/arch/arm/plat-mxc/pwm.c
> +++ b/arch/arm/plat-mxc/pwm.c
> @@ -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;
>  
> -- 
> 1.7.0.4
> 
> 

-- 
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 |

       reply	other threads:[~2011-07-01  8:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1309485035-5964-1-git-send-email-troy.kisky@boundarydevices.com>
2011-07-01  8:03 ` Sascha Hauer [this message]
2011-07-01 18:53   ` [PATCH 2/2] ARM: plat-mxc: Fix pwm frequency Troy Kisky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110701080311.GS6069@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.