RE: [PATCH v7 2/2] pwm: Add support for RZ/G2L GPT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux