Re: [RFT][PATCH 1/2] regulator: lm363x: Fix off-by-one n_voltages for lm3632 ldo_vpos/ldo_vneg

From: Axel Lin
Date: Sun Jul 07 2019 - 22:02:15 EST


Axel Lin <axel.lin@xxxxxxxxxx> æ 2019å6æ26æ éä äå11:12åéï
>
> Dan Murphy <dmurphy@xxxxxx> æ 2019å6æ26æ éä äå11:07åéï
> >
> > Hello
> >
> > On 6/26/19 8:26 AM, Axel Lin wrote:
> > > According to the datasheet https://www.ti.com/lit/ds/symlink/lm3632a.pdf
> > > Table 20. VPOS Bias Register Field Descriptions VPOS[5:0]
> > > Sets the Positive Display Bias (LDO) Voltage (50 mV per step)
> > > 000000: 4 V
> > > 000001: 4.05 V
> > > 000010: 4.1 V
> > > ....................
> > > 011101: 5.45 V
> > > 011110: 5.5 V (Default)
> > > 011111: 5.55 V
> > > ....................
> > > 100111: 5.95 V
> > > 101000: 6 V
> > > Note: Codes 101001 to 111111 map to 6 V
> > >
> > > The LM3632_LDO_VSEL_MAX should be 0b101000 (0x28), so the maximum voltage
> > > can match the datasheet.
> > >
> > > Fixes: 3a8d1a73a037 ("regulator: add LM363X driver")
> > > Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
> > > ---
> > > drivers/regulator/lm363x-regulator.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c
> > > index 5647e2f97ff8..e4a27d63bf90 100644
> > > --- a/drivers/regulator/lm363x-regulator.c
> > > +++ b/drivers/regulator/lm363x-regulator.c
> > > @@ -30,7 +30,7 @@
> > >
> > > /* LM3632 */
> > > #define LM3632_BOOST_VSEL_MAX 0x26
> > > -#define LM3632_LDO_VSEL_MAX 0x29
> > > +#define LM3632_LDO_VSEL_MAX 0x28
> >
> > Similar comment as I made on the LM36274
> >
> > These are 0 based registers so it is 28 + 1
> The code shows: .n_voltages = LM3632_LDO_VSEL_MAX + 1
> so LM3632_LDO_VSEL_MAX needs to be 0x28.
>
> .name = "ldo_vpos",
> .of_match = "vpos",
> .id = LM3632_LDO_POS,
> .ops = &lm363x_regulator_voltage_table_ops,
> .n_voltages = LM3632_LDO_VSEL_MAX + 1,

Hi Dan,
I'm wondering if you read my previous reply.
You can try to call regulator_list_voltage() for selector 0x29 with
current code,
I believe it will return 6.05V which is wrong because the h/w only
support up to 6V.
And that is exactly the issue this patch try to fix.

BTW, you seem mixes the meaning of latest valid selector
(LM3632_LDO_VSEL_MAX) with n_voltage
since you mentioned it's 0 based registers.
>From the context all the LM3632_LDO_xxx_MAX are defined as latest
valid selector because you
can find the code: .n_voltages = LM3632_LDO_VSEL_MAX + 1.

Regards,
Axel