From: Hans de Goede <hdegoede@redhat.com>
To: Marek Vasut <marex@denx.de>, Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org
Subject: Re: [PATCH 10/10] power: supply: bq25890: Add new linux,iinlim-percentage property
Date: Mon, 28 Nov 2022 10:16:36 +0100 [thread overview]
Message-ID: <20f66702-18c1-4d2f-cdf3-a18bfc8035c7@redhat.com> (raw)
In-Reply-To: <d2f2fe8f-9463-d496-dc4f-e3f27dd84526@denx.de>
Hi Marek,
On 11/27/22 22:34, Marek Vasut wrote:
> On 11/27/22 19:02, Hans de Goede wrote:
>> Some devices, such as the Lenovo Yoga Tab 3 Pro (YT3-X90F) have
>> multiple batteries with a separate bq25890 charger for each battery.
>>
>> This requires the maximum current the external power-supply can deliver
>> to be divided over the chargers. The Android vendor kernel shipped
>> on the YT3-X90F divides this current with a 40/60 percent split so that
>> batteries are done charging at approx. the same time if both were fully
>> empty at the start.
>>
>> Add support for a new "linux,iinlim-percentage" percentage property which
>> can be set to indicate that a bq25890 charger should only use that
>> percentage of the external power-supply's maximum current.
>>
>> 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.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> drivers/power/supply/bq25890_charger.c | 24 +++++++++++++++++++++---
>> 1 file changed, 21 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
>> index b0d07ff24ace..2bd7721b969f 100644
>> --- a/drivers/power/supply/bq25890_charger.c
>> +++ b/drivers/power/supply/bq25890_charger.c
>> @@ -126,6 +126,7 @@ struct bq25890_device {
>> bool read_back_init_data;
>> bool force_hiz;
>> u32 pump_express_vbus_max;
>> + u32 iinlim_percentage;
>
> If this is percentage, u8 should be enough, right ?
It is not a charger-chip register value and it is used in
calculations so it is best if this is native integer size.
And I was passing its address directly to device_property_read_u32(),
but that has changed in v2.
>> enum bq25890_chip_version chip_version;
>> struct bq25890_init_data init_data;
>> struct bq25890_state state;
>> @@ -727,6 +728,18 @@ static int bq25890_power_supply_property_is_writeable(struct power_supply *psy,
>> }
>> }
>> +/*
>> + * If there are multiple chargers the maximum current the external power-supply
>> + * can deliver needs to be divided over the chargers. This is done according
>> + * to the bq->iinlim_percentage setting.
>> + */
>> +static int bq25890_charger_get_scaled_iinlim_regval(struct bq25890_device *bq,
>> + int iinlim_ua)
>> +{
>> + iinlim_ua = iinlim_ua * bq->iinlim_percentage / 100;
>
> Can this ever add up to value above 100 ?
> Should this use some clamp() ?
bq->iinlim_percentage should never be more then 100. I have added a check
for this when reading the property for version 2 of the series.
Thank you for all the reviews. I've also addressed all your other small
remarks and I will send out a v2 series with these fixed.
Regards,
Hans
>
>> + return bq25890_find_idx(iinlim_ua, TBL_IINLIM);
>> +}
>> +
>> /* On the BQ25892 try to get charger-type info from our supplier */
>> static void bq25890_charger_external_power_changed(struct power_supply *psy)
>> {
>
> [...]
>
prev parent reply other threads:[~2022-11-28 9:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-27 18:02 [PATCH 00/10] power: supply: bq25890: Fixes for 6.2 + further work for 6.3 Hans de Goede
2022-11-27 18:02 ` [PATCH 01/10] power: supply: bq25890: Only use pdata->regulator_init_data for vbus Hans de Goede
2022-11-27 21:16 ` Marek Vasut
2022-11-27 23:30 ` Sebastian Reichel
2022-11-27 18:02 ` [PATCH 02/10] power: supply: bq25890: Ensure pump_express_work is cancelled on remove Hans de Goede
2022-11-27 21:17 ` Marek Vasut
2022-11-27 23:17 ` Sebastian Reichel
2022-11-28 7:20 ` Hans de Goede
2022-11-27 18:02 ` [PATCH 03/10] power: supply: bq25890: Fix usb-notifier probe and remove races Hans de Goede
2022-11-27 21:19 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 04/10] power: supply: bq25890: Factor out chip state update Hans de Goede
2022-11-27 18:02 ` [PATCH 05/10] power: supply: bq25890: Add HiZ mode support Hans de Goede
2022-11-27 18:02 ` [PATCH 06/10] power: supply: bq25890: Fix setting of F_CONV_RATE rate when disabling HiZ mode Hans de Goede
2022-11-27 21:24 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 07/10] power: supply: bq25890: Always take HiZ mode into account for ADC rate Hans de Goede
2022-11-27 21:25 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 08/10] power: supply: bq25890: Support boards with more then one charger IC Hans de Goede
2022-11-27 21:27 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 09/10] power: supply: bq25890: Add support for having a secondary " Hans de Goede
2022-11-27 21:33 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 10/10] power: supply: bq25890: Add new linux,iinlim-percentage property Hans de Goede
2022-11-27 21:34 ` Marek Vasut
2022-11-28 9:16 ` Hans de Goede [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20f66702-18c1-4d2f-cdf3-a18bfc8035c7@redhat.com \
--to=hdegoede@redhat.com \
--cc=linux-pm@vger.kernel.org \
--cc=marex@denx.de \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox