From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: "linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
Chris Paterson <Chris.Paterson2@renesas.com>,
Lee Jones <lee@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
William Breathitt Gray <william.gray@linaro.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>,
Thierry Reding <thierry.reding@gmail.com>,
"kernel@pengutronix.de" <kernel@pengutronix.de>
Subject: Re: [PATCH v15 6/6] pwm: Add Renesas RZ/G2L MTU3a PWM driver
Date: Tue, 18 Apr 2023 00:41:34 +0200 [thread overview]
Message-ID: <20230417224134.splsu7ipupttuila@pengutronix.de> (raw)
In-Reply-To: <OS0PR01MB592260E8E4F583704C2844B0869C9@OS0PR01MB5922.jpnprd01.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 2782 bytes --]
Hello Biju,
On Mon, Apr 17, 2023 at 11:06:59AM +0000, Biju Das wrote:
> Thanks for the feedback.
>
> > Subject: Re: [PATCH v15 6/6] pwm: Add Renesas RZ/G2L MTU3a PWM driver
> >
> > Hello,
> >
> > On Fri, Apr 14, 2023 at 09:53:09AM +0000, Biju Das wrote:
> > > > On Thu, Mar 30, 2023 at 12:16:32PM +0100, Biju Das wrote:
> > > > > + val = RZ_MTU3_TCR_CKEG_RISING | prescale;
> > > > > + if (priv->map->channel == pwm->hwpwm) {
> > > > > + rz_mtu3_8bit_ch_write(priv->mtu, RZ_MTU3_TCR,
> > > > > + RZ_MTU3_TCR_CCLR_TGRA | val);
> > > >
> > > > If the sibling PWM on the same channel is on, you're overwriting its
> > > > prescale value here, are you not?
> > >
> > > Yes, you are correct. Will cache prescale and add the below code in
> > > rz_mtu3_pwm_config(). Is it ok?
> > >
> > > + * Prescalar is shared by multiple channels, so prescale can
> > > + * NOT be modified when there are multiple channels in use with
> > > + * different settings.
> > > + */
> > > + if (prescale != rz_mtu3_pwm->prescale[ch] && rz_mtu3_pwm-
> > >user_count[ch] > 1)
> > > + return -EBUSY;
> >
> > If the other PWM is off, you can (and should) change the prescale value.
> > Also if the current prescale value is less than the one you want to set, you
> > can handle that.
> >
>
> You mean like below??
>
> static int rz_mtu3_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> const struct pwm_state *state)
> {
> struct rz_mtu3_pwm_chip *rz_mtu3_pwm = to_rz_mtu3_pwm_chip(chip);
> struct rz_mtu3_pwm_channel *priv;
> u64 period_cycles;
> u64 duty_cycles;
> u8 prescale;
> u16 pv, dc;
> u8 val;
> u32 ch;
>
> priv = rz_mtu3_get_channel(rz_mtu3_pwm, pwm->hwpwm);
> ch = priv - rz_mtu3_pwm->channel_data;
>
> period_cycles = mul_u64_u32_div(state->period, rz_mtu3_pwm->rate,
> NSEC_PER_SEC);
> prescale = rz_mtu3_pwm_calculate_prescale(rz_mtu3_pwm, period_cycles);
>
> /*
> * Prescalar is shared by multiple channels, so prescale can
> * NOT be modified when there are multiple channels in use with
> * different settings. Modify prescalar if other PWM is off or current
> * prescale value is less than the one we want to set.
> */
> if (rz_mtu3_pwm->enable_count[ch] > 1 &&
> rz_mtu3_pwm->prescale[ch] > prescale)
> return -EBUSY;
>
> pv = rz_mtu3_pwm_calculate_pv_or_dc(period_cycles, prescale);
Here it starts to get wrong. If rz_mtu3_pwm->enable_count[ch] > 1 you
have to use rz_mtu3_pwm->prescale[ch] instead of prescale.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-04-17 22:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230330111632.169434-1-biju.das.jz@bp.renesas.com>
2023-03-30 11:16 ` [PATCH v15 6/6] pwm: Add Renesas RZ/G2L MTU3a PWM driver Biju Das
2023-04-14 6:26 ` Uwe Kleine-König
2023-04-14 9:53 ` Biju Das
2023-04-14 16:55 ` Uwe Kleine-König
2023-04-17 11:06 ` Biju Das
2023-04-17 22:41 ` Uwe Kleine-König [this message]
2023-04-18 6:16 ` Biju Das
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=20230417224134.splsu7ipupttuila@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=Chris.Paterson2@renesas.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=daniel.lezcano@linaro.org \
--cc=geert+renesas@glider.be \
--cc=kernel@pengutronix.de \
--cc=lee@kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=thierry.reding@gmail.com \
--cc=william.gray@linaro.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 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).