linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH v6 2/2] pwm: Add support for RZ/G2L GPT
Date: Sat, 24 Sep 2022 10:53:30 +0000	[thread overview]
Message-ID: <TYCPR01MB59336AAF4DD1D304FA53451286509@TYCPR01MB5933.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <OS0PR01MB59220ECD0B2D42DF5012B6C7864E9@OS0PR01MB5922.jpnprd01.prod.outlook.com>

Hi Uwe,

> Subject: RE: [PATCH v6 2/2] pwm: Add support for RZ/G2L GPT
> 
> Hi Uwe,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [PATCH v6 2/2] pwm: Add support for RZ/G2L GPT
> >
> > Hello,
> >
> > On Wed, Sep 21, 2022 at 01:46:54PM +0000, Biju Das wrote:
> > > > Actually it's worse:
> > > >
> > > > - When both channels are used, setting the duty-cycle on one
> > aborts the
> > > >   currently running period on the other and starts it anew.
> > > >
> > > > (Did I get this correctly?)
> > >
> > > I think, I have fixed that issue with the below logic Which allows
> > to
> > > update duty cycle on the fly.
> > >
> > > Now the only limitation is w.r.to disabling channels as we need to
> > > disable together as stopping the counter affects both.
> > >
> > >       /*
> > > 	 * Counter must be stopped before modifying mode, prescaler,
> > timer
> > > 	 * counter and buffer enable registers. These registers are
> > shared
> > > 	 * between both channels. So allow updating these registers only
> > for the
> > > 	 * first enabled channel.
> > > 	 */
> > > 	if (rzg2l_gpt->user_count <= 1)
> > > 		rzg2l_gpt_disable(rzg2l_gpt);
> > >
> > > 	is_counter_running = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCR) &
> > RZG2L_GTCR_CST;
> > > 	if (!is_counter_running)
> > > 		/* GPT set operating mode (saw-wave up-counting) */
> > > 		rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR, RZG2L_GTCR_MD,
> > > 				 RZG2L_GTCR_MD_SAW_WAVE_PWM_MODE);
> >
> > So if the PWM is already running (e.g. from the bootloader) and the
> > mode is wrong, this isn't fixed? Similar problems in the if blocks
> > below.

What is your thought on caching the registers that needs counter to be stopped
for updating values. Basically, we don't stop the counter if the values are same?

This allows updating period/duty cycle on the fly without stopping the counter
even for the single channel use case.

Please share your thoughts.

Cheers,
Biju


> 
> This is taken care by the above code. It stops the counter for first
> enabled channel in Linux and then changes the mode as per Linux.
> 
> <snippet>
> 	if (rzg2l_gpt->user_count <= 1)
> 		rzg2l_gpt_disable(rzg2l_gpt);
> </snippet>
> 
> Cheers,
> Biju
> 
> >
> > > 	/* Set count direction */
> > > 	rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTUDDTYC, RZG2L_UP_COUNTING);
> > >
> > > 	if (!is_counter_running)
> > > 		/* Select count clock */
> > > 		rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR, RZG2L_GTCR_TPCS,
> > > 				 FIELD_PREP(RZG2L_GTCR_TPCS, prescale));
> > >
> > > 	/* Set period */
> > > 	rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTPR, pv);
> > >
> > > 	/* Set duty cycle */
> > > 	rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTCCR(pwm->hwpwm), dc);
> > >
> > > 	if (!is_counter_running) {
> > > 		/* Set initial value for counter */
> > > 		rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTCNT, 0);
> > >
> > > 		/* Set no buffer operation */
> > > 		rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTBER, 0);
> > > 	}
> >
> > Best regards
> > Uwe
> >
> > --
> > Pengutronix e.K.                           | Uwe Kleine-König
> > |
> > Industrial Linux Solutions                 |
> > https://www.pengutronix.de/ |

  reply	other threads:[~2022-09-24 10:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 17:13 [PATCH v6 0/2] Add support for RZ/G2L GPT Biju Das
2022-09-05 17:13 ` [PATCH v6 1/2] dt-bindings: pwm: Add RZ/G2L GPT binding Biju Das
2022-09-05 17:13 ` [PATCH v6 2/2] pwm: Add support for RZ/G2L GPT Biju Das
2022-09-19  7:57   ` Uwe Kleine-König
2022-09-20 15:31     ` Biju Das
2022-09-20 15:53       ` Uwe Kleine-König
2022-09-20 17:00         ` Biju Das
2022-09-21 10:50           ` Biju Das
2022-09-21 13:35             ` Uwe Kleine-König
2022-09-21 13:46               ` Biju Das
2022-09-22  5:36                 ` Uwe Kleine-König
2022-09-22  6:15                   ` Biju Das
2022-09-24 10:53                     ` Biju Das [this message]
2022-09-24 13:42                       ` Uwe Kleine-König
2022-09-24 16:10                         ` Biju Das
2022-09-26  7:30                           ` Geert Uytterhoeven
2022-09-26  8:00                             ` Biju Das
2022-09-26 12:16                               ` Geert Uytterhoeven

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=TYCPR01MB59336AAF4DD1D304FA53451286509@TYCPR01MB5933.jpnprd01.prod.outlook.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=biju.das@bp.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=lee.jones@linaro.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.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).