Re: [PATCH v2 13/20] power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol
From: Hans de Goede
Date: Tue Nov 16 2021 - 06:41:13 EST
Hi,
On 11/16/21 12:14, Andy Shevchenko wrote:
> On Sun, Nov 14, 2021 at 7:04 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>>
>> From: Yauhen Kharuzhy <jekhor@xxxxxxxxx>
>>
>> Add a "linux,pump-express-vbus-max" property which indicates if the Pump
>> Express+ protocol should be used to increase the charging protocol.
>>
>> If this new property is set and a DCP charger is detected then request
>> a higher charging voltage through the Pump Express+ protocol.
>>
>> So far this new property is only used on X86/ACPI (non devicetree) devs,
>> IOW it is not used in actual devicetree files. The devicetree-bindings
>> maintainers have requested properties like these to not be added to the
>> devicetree-bindings, so the new property is deliberately not added
>> to the existing devicetree-bindings.
>>
>> Changes by Hans de Goede:
>> - Port to my bq25890 patch-series + various cleanups
>> - Make behavior configurable through a new "linux,pump-express-vbus-max"
>> device-property
>> - Sleep 1 second before re-checking the Vbus voltage after requesting
>> it to be raised, to ensure that the ADC has time to sampled the new Vbus
>> - Add VBUSV bq25890_tables[] entry and use it in bq25890_get_vbus_voltage()
>> - Tweak commit message
>
> ...
>
>> +#define PUMP_EXPRESS_START_DELAY (5 * HZ)
>> +#define PUMP_EXPRESS_MAX_TRIES 6
>> +#define PUMP_EXPRESS_VBUS_MARGIN 1000000
>
> Units? Perhaps "_uV"?
>
> ...
>
>> + dev_dbg(bq->dev, "input voltage = %d mV\n", voltage);
>
> Just to be sure, is it indeed "mV" and not "uV"?
It is uV, will fix for the next version.
>
> ...
>
>> + while (bq25890_field_read(bq, F_PUMPX_UP) == 1)
>> + msleep(100);
>
> Infinite loop?
>
> Sounds like a good candidate to switch to read_poll_timeout() // note> it accepts any type of (op) with a variadic number of args.
Good catch, will fix.
>
> ...
>
>> +error:
>
> error_print: ?
>
>> + dev_err(bq->dev, "Failed to request hi-voltage charging\n");
>
> ...
>
>> + ret = device_property_read_u32(bq->dev, "linux,pump-express-vbus-max",
>> + &bq->pump_express_vbus_max);
>> + if (ret < 0)
>> + bq->pump_express_vbus_max = 0;
>
> Isn't it 0 by default?
>
> Anyway, for all optional properties one may use
>
> bq->...property... = $default;
> device_property_read_u32(bq->dev, "linux,...property...", &bq->...property...);
>
> I.e. no conditional needed.
Ack, will fix.
Regards,
Hans