> -----Original Message-----
> From: Mark Brown [mailto:[email protected]] 
> Sent: Wednesday, February 17, 2010 9:45 PM
> To: Nayak, Rajendra
> Cc: [email protected]; Liam Girdwood; Samuel Ortiz
> Subject: Re: [PATCH 1/2] twl6030: regulator: Fix vsel 
> calculations in set/get voltage apis
> 
> On Wed, Feb 17, 2010 at 08:54:14PM +0530, Rajendra Nayak wrote:
> 
> >             /* use the first in-range value */
> > -           if (min_uV <= uV && uV <= max_uV)
> > +           if (min_uV <= uV && uV <= max_uV) {
> > +                   if (twl_class_is_6030())
> > +                           /*
> > +                            * Use the below formula to 
> calculate vsel
> > +                            * mV = 1000mv + 100mv * (vsel - 1)
> > +                            */
> > +                           vsel = (LDO_MV(mV) - 1000)/100 + 1;
> >                     return twlreg_write(info, 
> TWL_MODULE_PM_RECEIVER,
> >                                                     
> VREG_VOLTAGE, vsel);
> 
> This looks wrong - this code is inside a loop over vsel->voltage
> mappings, if that mapping is wrong and needs to be ignored (which is
> what this code is doing) then we shouldn't be looking at it at all.

Mark,

Not sure if I understood your comment completely, but here's how I think
it will work.

The for loop runs through all the valid voltages supported by the regulator
and and when it finds the first in-range value programs the VOLTAGE register.
For twl4030 the VOLTAGE register can be programmed with just the index
of the table since the mapping was something like
1800mV = 0x0
2800mV = 0x1
2900mV = 0x2
3000mV = 0x3

Now for twl6030 I just have added an additional vsel calulation part after
the in-range value is found, since using the table index directly as vsel
would not work.

regards,
Rajendra

> --
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to