[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bc465932-b2e5-7ff4-1b9a-cf2d76079251@redhat.com>
Date: Mon, 31 Jan 2022 16:18:23 +0100
From: Hans de Goede <hdegoede@...hat.com>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
Cc: "Rafael J . Wysocki" <rafael@...nel.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Mark Gross <markgross@...nel.org>,
Andy Shevchenko <andy@...nel.org>,
Wolfram Sang <wsa@...nel.org>,
Lee Jones <lee.jones@...aro.org>,
Sebastian Reichel <sre@...nel.org>,
MyungJoo Ham <myungjoo.ham@...sung.com>,
Chanwoo Choi <cw00.choi@...sung.com>,
Ard Biesheuvel <ardb@...nel.org>, Len Brown <lenb@...nel.org>,
linux-acpi@...r.kernel.org, Yauhen Kharuzhy <jekhor@...il.com>,
Tsuchiya Yuto <kitakar@...il.com>,
Fabio Aiuto <fabioaiuto83@...il.com>,
platform-driver-x86@...r.kernel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-efi@...r.kernel.org
Subject: Re: [PATCH v4 12/20] power: supply: bq25890: Support higher charging
voltages through Pump Express+ protocol
Hi,
On 1/31/22 14:48, Andy Shevchenko wrote:
> On Sun, Jan 30, 2022 at 09:45:49PM +0100, Hans de Goede wrote:
>> From: Yauhen Kharuzhy <jekhor@...il.com>
>>
>> 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
>
> ...
>
>> +static void bq25890_pump_express_work(struct work_struct *data)
>> +{
>> + struct bq25890_device *bq =
>> + container_of(data, struct bq25890_device, pump_express_work.work);
>> + int voltage, i, ret;
>> +
>> + dev_dbg(bq->dev, "Start to request input voltage increasing\n");
>> +
>> + /* Enable current pulse voltage control protocol */
>> + ret = bq25890_field_write(bq, F_PUMPX_EN, 1);
>> + if (ret < 0)
>> + goto error_print;
>> +
>> + for (i = 0; i < PUMP_EXPRESS_MAX_TRIES; i++) {
>
>> + voltage = bq25890_get_vbus_voltage(bq);
>> + if (voltage < 0)
>> + goto error_print;
>
> It also can be (at least in align with the rest error paths)
>
> ret = bq25890_get_vbus_voltage(bq);
> if (ret < 0)
> goto error_print;
> voltage = ret;
>
> followed up (but not necessarily)...
The suggested pattern is useful when ret needs to be set on the error-exit
path, but we are not doing that here. So I prefer to just keep this as is.
Regards,
Hans
>
>> + dev_dbg(bq->dev, "input voltage = %d uV\n", voltage);
>> +
>> + if ((voltage + PUMP_EXPRESS_VBUS_MARGIN_uV) >
>> + bq->pump_express_vbus_max)
>> + break;
>> +
>> + ret = bq25890_field_write(bq, F_PUMPX_UP, 1);
>> + if (ret < 0)
>> + goto error_print;
>> +
>> + /* Note a single PUMPX up pulse-sequence takes 2.1s */
>> + ret = regmap_field_read_poll_timeout(bq->rmap_fields[F_PUMPX_UP],
>> + ret, !ret, 100000, 3000000);
>> + if (ret < 0)
>> + goto error_print;
>> +
>> + /* Make sure ADC has sampled Vbus before checking again */
>> + msleep(1000);
>> + }
>> +
>> + bq25890_field_write(bq, F_PUMPX_EN, 0);
>> +
>> + dev_info(bq->dev, "Hi-voltage charging requested, input voltage is %d mV\n",
>> + voltage);
>
>> + return;
>> +error_print:
>
> if (ret < 0)
>
> But it's up to you.
>
>> + dev_err(bq->dev, "Failed to request hi-voltage charging\n");
>> +}
>
Powered by blists - more mailing lists