devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	od@zcrc.me, linux-pwm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/6] pwm: jz4740: Apply configuration atomically
Date: Mon, 22 Jul 2019 21:34:56 +0200	[thread overview]
Message-ID: <20190722193456.h4hfte5cczucermd@pengutronix.de> (raw)
In-Reply-To: <20190607154410.10633-4-paul@crapouillou.net>

Hello Paul,

On Fri, Jun 07, 2019 at 05:44:07PM +0200, Paul Cercueil wrote:
> -static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> -			     int duty_ns, int period_ns)
> +static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> +			    struct pwm_state *state)
>  {
>  	struct jz4740_pwm_chip *jz4740 = to_jz4740(pwm->chip);
>  	unsigned long long tmp;
>  	unsigned long period, duty;
>  	unsigned int prescaler = 0;
>  	uint16_t ctrl;
> -	bool is_enabled;
>  
> -	tmp = (unsigned long long)clk_get_rate(jz4740->clk) * period_ns;
> +	tmp = (unsigned long long)clk_get_rate(jz4740->clk) * state->period;
>  	do_div(tmp, 1000000000);
>  	period = tmp;
>  
> @@ -96,16 +95,14 @@ static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>  	if (prescaler == 6)
>  		return -EINVAL;
>  
> -	tmp = (unsigned long long)period * duty_ns;
> -	do_div(tmp, period_ns);
> +	tmp = (unsigned long long)period * state->duty_cycle;
> +	do_div(tmp, state->period);
>  	duty = period - tmp;
>  
>  	if (duty >= period)
>  		duty = period - 1;
>  
> -	is_enabled = jz4740_timer_is_enabled(pwm->hwpwm);
> -	if (is_enabled)
> -		jz4740_pwm_disable(chip, pwm);
> +	jz4740_pwm_disable(chip, pwm);

I assume this stops the PWM. Does this complete the currently running
period? How does the PWM behave then? (Does it still drive the output?
If so, on which level?)

>  
>  	jz4740_timer_set_count(pwm->hwpwm, 0);
>  	jz4740_timer_set_duty(pwm->hwpwm, duty);

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2019-07-22 19:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 15:44 [PATCH v2 0/6] PWM JZ4740 fixes and cleanups Paul Cercueil
2019-06-07 15:44 ` [PATCH v2 1/6] dt-bindings: Remove unused compatible strings Paul Cercueil
2019-07-09  2:04   ` Rob Herring
2019-07-09  3:18     ` Paul Cercueil
2019-07-09 15:46       ` Rob Herring
2019-08-08  8:28     ` Uwe Kleine-König
2019-08-12 23:39       ` Rob Herring
2019-06-07 15:44 ` [PATCH v2 2/6] pwm: jz4740: Remove unused devicetree " Paul Cercueil
2019-08-08  8:24   ` Uwe Kleine-König
2019-06-07 15:44 ` [PATCH v2 3/6] pwm: jz4740: Apply configuration atomically Paul Cercueil
2019-07-22 19:34   ` Uwe Kleine-König [this message]
2019-07-23 20:46     ` Paul Cercueil
2019-07-24  6:47       ` Uwe Kleine-König
2019-07-29 21:19         ` Paul Cercueil
2019-06-07 15:44 ` [PATCH v2 4/6] pwm: jz4740: Drop dependency on MACH_INGENIC Paul Cercueil
2019-06-07 15:44 ` [PATCH v2 5/6] pwm: jz4740: Force TCU2 channels to return to their init level Paul Cercueil
2019-06-07 15:44 ` [PATCH v2 6/6] pwm: jz4740: Use __init_or_module and __exit for .probe and .remove Paul Cercueil
2019-06-08 10:31   ` Paul Cercueil

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=20190722193456.h4hfte5cczucermd@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=od@zcrc.me \
    --cc=paul@crapouillou.net \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).