All of lore.kernel.org
 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: "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>,
	Thierry Reding <thierry.reding@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: RE: [PATCH v7 2/2] pwm: Add support for RZ/G2L GPT
Date: Fri, 30 Sep 2022 06:51:12 +0000	[thread overview]
Message-ID: <OS0PR01MB592278A1194D0E8B36123F0E86569@OS0PR01MB5922.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20220930063429.xlcmimr6m3z3o5wh@pengutronix.de>

Hi Uwe,

> Subject: Re: [PATCH v7 2/2] pwm: Add support for RZ/G2L GPT
> 
> Hello Biju,
> 
> On Thu, Sep 29, 2022 at 05:36:38PM +0000, Biju Das wrote:
> > > +static u8 rzg2l_calculate_prescale(struct rzg2l_gpt_chip
> *rzg2l_gpt,
> > > +				   u64 period_cycles)
> > > +{
> > > +	u32 prescaled_period_cycles;
> > > +	u8 prescale;
> > > +
> > > +	prescaled_period_cycles = period_cycles >> 32;
> > > +
> > > +	if (prescaled_period_cycles >= 256)
> > > +		prescale = 5;
> > > +	else
> > > +		prescale = (roundup_pow_of_two(prescaled_period_cycles + 1)
> > > + 1) / 2;
> >
> >
> > This algorithm won't give desired result.
> >
> > prescaled_period_cycles		Expected result
> > 0					->0
> > 1..3					->1
> > 4..15					->2
> > 16..63				->3
> > 64..255				->4
> > 256 >					->5
> 
> Oh, indeed, it fails for prescaled_period_cycles ∈ { 0, 3, 15, 63, 255
> }.
> 
> The correct formula is:
> 
> 	if (prescaled_period_cycles >= 256)
> 		prescale = 5;
> 	else
> 		prescale = (roundup_pow_of_two(prescaled_period_cycles) +
> 1) / 2;
> 

Round_pow_of_two(n) --> n=0 is not acceptable 

Round_pow_of_two(58)--> 64  as per the above formula, it becomes 64 + 1 /2 = 32
Which is very high value.

I am sure since the expected result is log4, we don't get the desired result with
The above equation. Please correct me, if I am wrong.  

        0
      100
    10000
  1000000
100000000

Cheers,
Biju

  reply	other threads:[~2022-09-30  6:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 14:57 [PATCH v7 0/2] Add support for RZ/G2L GPT Biju Das
2022-09-21 14:57 ` [PATCH v7 1/2] dt-bindings: pwm: Add RZ/G2L GPT binding Biju Das
2022-09-21 14:57 ` [PATCH v7 2/2] pwm: Add support for RZ/G2L GPT Biju Das
2022-09-28 13:50   ` Thierry Reding
2022-09-28 14:09     ` Geert Uytterhoeven
2022-09-28 17:34     ` Biju Das
2022-09-28 18:07       ` Geert Uytterhoeven
2022-09-28 19:21         ` Biju Das
2022-09-29  9:48       ` Thierry Reding
2022-10-01 14:10         ` Biju Das
2022-10-11 11:53         ` Biju Das
2022-09-29 17:36   ` Biju Das
2022-09-30  6:34     ` Uwe Kleine-König
2022-09-30  6:51       ` Biju Das [this message]
2022-09-30  7:03         ` Uwe Kleine-König
2022-09-30  7:43           ` 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=OS0PR01MB592278A1194D0E8B36123F0E86569@OS0PR01MB5922.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 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.