All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Thierry Reding <thierry.reding@gmail.com>
Cc: linux-kernel@vger.kernel.org, Bo Shen <voice.shen@atmel.com>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH 2/2] PWM: atmel: correct CDTY calculation
Date: Fri, 14 Mar 2014 15:54:09 +0100	[thread overview]
Message-ID: <53231811.1020309@atmel.com> (raw)
In-Reply-To: <1394806749-29778-3-git-send-email-alexandre.belloni@free-electrons.com>

On 14/03/2014 15:19, Alexandre Belloni :
>>From the datasheet, the actual duty cycle is:
> (period - (1/clk) * CDTY)/period
> 
> This actually correct the polarity of the PWM and solves the issue that pwm-leds
> exhibits: when setting a duty cycle of 0 and then disabling a channel, the level
> was wrong (1 when the polarity was normal and 0 when the polarity was inversed).
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  drivers/pwm/pwm-atmel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
> index 2d69e9c431dd..0adc952cc4ef 100644
> --- a/drivers/pwm/pwm-atmel.c
> +++ b/drivers/pwm/pwm-atmel.c
> @@ -133,7 +133,7 @@ static int atmel_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>  	prd = div;
>  	div *= duty_ns;
>  	do_div(div, period_ns);
> -	dty = div;
> +	dty = prd - div;
>  
>  	ret = clk_enable(atmel_pwm->clk);
>  	if (ret) {
> 


-- 
Nicolas Ferre

WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Thierry Reding <thierry.reding@gmail.com>
Cc: <linux-kernel@vger.kernel.org>, Bo Shen <voice.shen@atmel.com>,
	<linux-pwm@vger.kernel.org>
Subject: Re: [PATCH 2/2] PWM: atmel: correct CDTY calculation
Date: Fri, 14 Mar 2014 15:54:09 +0100	[thread overview]
Message-ID: <53231811.1020309@atmel.com> (raw)
In-Reply-To: <1394806749-29778-3-git-send-email-alexandre.belloni@free-electrons.com>

On 14/03/2014 15:19, Alexandre Belloni :
>>From the datasheet, the actual duty cycle is:
> (period - (1/clk) * CDTY)/period
> 
> This actually correct the polarity of the PWM and solves the issue that pwm-leds
> exhibits: when setting a duty cycle of 0 and then disabling a channel, the level
> was wrong (1 when the polarity was normal and 0 when the polarity was inversed).
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  drivers/pwm/pwm-atmel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
> index 2d69e9c431dd..0adc952cc4ef 100644
> --- a/drivers/pwm/pwm-atmel.c
> +++ b/drivers/pwm/pwm-atmel.c
> @@ -133,7 +133,7 @@ static int atmel_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>  	prd = div;
>  	div *= duty_ns;
>  	do_div(div, period_ns);
> -	dty = div;
> +	dty = prd - div;
>  
>  	ret = clk_enable(atmel_pwm->clk);
>  	if (ret) {
> 


-- 
Nicolas Ferre

  reply	other threads:[~2014-03-14 14:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14 14:19 [PATCH 0/2] PWM: atmel: few fixes Alexandre Belloni
2014-03-14 14:19 ` [PATCH 1/2] PWM: atmel: Fix polarity handling Alexandre Belloni
2014-03-14 14:52   ` Nicolas Ferre
2014-03-14 14:52     ` Nicolas Ferre
2014-03-14 14:19 ` [PATCH 2/2] PWM: atmel: correct CDTY calculation Alexandre Belloni
2014-03-14 14:19   ` Alexandre Belloni
2014-03-14 14:54   ` Nicolas Ferre [this message]
2014-03-14 14:54     ` Nicolas Ferre
2014-03-18 20:14 ` [PATCH 0/2] PWM: atmel: few fixes Thierry Reding

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=53231811.1020309@atmel.com \
    --to=nicolas.ferre@atmel.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=voice.shen@atmel.com \
    /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.