devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yash Shah <yash.shah@sifive.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: mark.rutland@arm.com, linux-pwm@vger.kernel.org,
	devicetree@vger.kernel.org, Palmer Dabbelt <palmer@sifive.com>,
	linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	Sachin Ghadi <sachin.ghadi@sifive.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	kernel@pengutronix.de, Paul Walmsley <paul.walmsley@sifive.com>,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH v8 2/2] pwm: sifive: Add a driver for SiFive SoC PWM
Date: Tue, 12 Mar 2019 12:22:38 +0530	[thread overview]
Message-ID: <CAJ2_jOG50Bh0Zu64-htwy+VFy5Bce1Wj5dnMKVEE35C3MEbLPA@mail.gmail.com> (raw)
In-Reply-To: <20190311132922.iowselp7qvmroiaa@pengutronix.de>

On Mon, Mar 11, 2019 at 6:59 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Hello,
>
> On Mon, Mar 11, 2019 at 05:10:17PM +0530, Yash Shah wrote:
> > On Fri, Mar 8, 2019 at 5:27 PM Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> wrote:
> > > On Fri, Mar 08, 2019 at 04:59:36PM +0530, Yash Shah wrote:
> > > > On Thu, Mar 7, 2019 at 8:57 PM Uwe Kleine-König
> > > > <u.kleine-koenig@pengutronix.de> wrote:
> > > > > > +     if (state->period != cur_state.period) {
> > > > >
> > > > > Did you test this with more than one consumer? For sure the following
> > > > > should work:
> > > > >
> > > > >         pwm1 = pwm_get(.. the first ..);
> > > > >         pwm_apply_state(pwm1, { .enabled = true, .period = 10000000, .... });
> > > > >
> > > > >         pwm2 = pwm_get(.. the second ..);
> > > > >         pwm_apply_state(pwm2, { .enabled = true, .period = 10000000, .... });
> > > > >
> > > > > but for the second pwm_apply_state() run state->period is likely not
> > > > > exactly 10000000.
> > > >
> > > > Yes, I have tested multiple consumers using sysfs interface. It is working.
> > >
> > > Can you provide details about your testing here? What is the parent clk
> > > rate? Which settings did you test? Can you confirm my claim that the
> > > above sequence would fail or point out my error in reasoning?
> > >
> >
> > I have tested on HiFive Unleashed board using sysfs interface.
> > Parent clk rate is around 512 Mhz.
> > I have tested scenarios as you mentioned above with various period and
> > duty_cycle values.
> >
> > After considering your below suggestion,
> >  | To get the result independent of the prior configuration you better use
> >  | the real targeted period length as input instead of the last configured
> >  | approximation
> > I will introduce approx_period feild, which will be used as the
> > targeted period length.
> > Also, in pwm_sifive_get_state, I will make below change
> > - state->period = pwm->real_period;
> > + state->period = pwm->approx_period.
> > So with this change in place, I believe the cur_state.period for the
> > second pwm_apply_state() above (pwm2) will be exactly 10000000
>
> I don't understand your intention completely. Just send a new patch
> round, then I will gladly take another look.

I was planning to go with above-mentioned change but then I realized
that pwm state should always reflect the current hardware state, so I
have dropped the above idea.
Coming back to your concern on

 |     if (state->period != cur_state.period) {

It is not failing for the scenario you mentioned but failing for
another way around.

         pwm1 = pwm_get(.. the first ..);
         pwm_apply_state(pwm1, { .enabled = true, .period = 10000000, .... });

         pwm2 = pwm_get(.. the second ..);
         pwm_apply_state(pwm2, { .enabled = true, .period = 20000000, .... });

The pwm2 should get an error for period mismatch but with v8 patch, it
is not getting any error.

I am sending a v9 patch which has the fix for this.
With v9 changes, I have tested all scenarios and it is working fine.

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

  reply	other threads:[~2019-03-12  6:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 10:53 [PATCH v8 0/2] PWM support for HiFive Unleashed Yash Shah
2019-03-01 10:53 ` [PATCH v8 1/2] pwm: sifive: Add DT documentation for SiFive PWM Controller Yash Shah
2019-03-01 10:53 ` [PATCH v8 2/2] pwm: sifive: Add a driver for SiFive SoC PWM Yash Shah
2019-03-07 15:27   ` Uwe Kleine-König
2019-03-08 11:29     ` Yash Shah
2019-03-08 11:57       ` Uwe Kleine-König
2019-03-11 11:40         ` Yash Shah
2019-03-11 13:29           ` Uwe Kleine-König
2019-03-12  6:52             ` Yash Shah [this message]
2019-03-04 11:09 ` [PATCH v8 0/2] PWM support for HiFive Unleashed Andreas Schwab
2019-03-05  8:25   ` Yash Shah
2019-03-05  8:32     ` Andreas Schwab

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=CAJ2_jOG50Bh0Zu64-htwy+VFy5Bce1Wj5dnMKVEE35C3MEbLPA@mail.gmail.com \
    --to=yash.shah@sifive.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=palmer@sifive.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=sachin.ghadi@sifive.com \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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).