2021-11-08 00:52:12

by Yauhen Kharuzhy

[permalink] [raw]
Subject: [PATCH 4/4] bq25890_charger: Enable continuous conversion for ADC at charging

Instead of one shot run of ADC at beginning of charging, run continuous
conversion to ensure that all charging-related values are monitored
properly (input voltage, input current, themperature etc.).

Signed-off-by: Yauhen Kharuzhy <[email protected]>
---
drivers/power/supply/bq25890_charger.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index fb2f1578503c..26ac7cde8c02 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -609,12 +609,12 @@ static irqreturn_t __bq25890_handle_irq(struct bq25890_device *bq)

if (!new_state.online && bq->state.online) { /* power removed */
/* disable ADC */
- ret = bq25890_field_write(bq, F_CONV_START, 0);
+ ret = bq25890_field_write(bq, F_CONV_RATE, 0);
if (ret < 0)
goto error;
} else if (new_state.online && !bq->state.online) { /* power inserted */
/* enable ADC, to have control of charge current/voltage */
- ret = bq25890_field_write(bq, F_CONV_START, 1);
+ ret = bq25890_field_write(bq, F_CONV_RATE, 1);
if (ret < 0)
goto error;
}
--
2.33.1


2021-11-08 04:31:46

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH 4/4] bq25890_charger: Enable continuous conversion for ADC at charging

Hi,

On 11/7/21 21:20, Yauhen Kharuzhy wrote:
> Instead of one shot run of ADC at beginning of charging, run continuous
> conversion to ensure that all charging-related values are monitored
> properly (input voltage, input current, themperature etc.).
>
> Signed-off-by: Yauhen Kharuzhy <[email protected]>

Thank you for finding this! This explains why all the ADC returned
values like current_now where 0 when charging, I thought this was
just something which was only supported while not charging, heh.

As before, the patch subject prefix should be: "power: supply: bq25890: "

Otherwise the patch looks good to me:

Reviewed-by: Hans de Goede <[email protected]>

Sebastian, this really is a pure bug-fix patch, any chance you
can pick this up for a future 5.16-rc# pull-req ?

Regards,

Hans




> ---
> drivers/power/supply/bq25890_charger.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
> index fb2f1578503c..26ac7cde8c02 100644
> --- a/drivers/power/supply/bq25890_charger.c
> +++ b/drivers/power/supply/bq25890_charger.c
> @@ -609,12 +609,12 @@ static irqreturn_t __bq25890_handle_irq(struct bq25890_device *bq)
>
> if (!new_state.online && bq->state.online) { /* power removed */
> /* disable ADC */
> - ret = bq25890_field_write(bq, F_CONV_START, 0);
> + ret = bq25890_field_write(bq, F_CONV_RATE, 0);
> if (ret < 0)
> goto error;
> } else if (new_state.online && !bq->state.online) { /* power inserted */
> /* enable ADC, to have control of charge current/voltage */
> - ret = bq25890_field_write(bq, F_CONV_START, 1);
> + ret = bq25890_field_write(bq, F_CONV_RATE, 1);
> if (ret < 0)
> goto error;
> }
>

2021-11-15 15:24:26

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 4/4] bq25890_charger: Enable continuous conversion for ADC at charging

Hi,

On Sun, Nov 07, 2021 at 09:48:38PM +0100, Hans de Goede wrote:
> Hi,
>
> On 11/7/21 21:20, Yauhen Kharuzhy wrote:
> > Instead of one shot run of ADC at beginning of charging, run continuous
> > conversion to ensure that all charging-related values are monitored
> > properly (input voltage, input current, themperature etc.).
> >
> > Signed-off-by: Yauhen Kharuzhy <[email protected]>
>
> Thank you for finding this! This explains why all the ADC returned
> values like current_now where 0 when charging, I thought this was
> just something which was only supported while not charging, heh.
>
> As before, the patch subject prefix should be: "power: supply: bq25890: "
>
> Otherwise the patch looks good to me:
>
> Reviewed-by: Hans de Goede <[email protected]>
>
> Sebastian, this really is a pure bug-fix patch, any chance you
> can pick this up for a future 5.16-rc# pull-req ?
>
> Regards,
>
> Hans

Thanks, queued to power-supply's fixes branch.

-- Sebastian


Attachments:
(No filename) (981.00 B)
signature.asc (833.00 B)
Download all attachments

2021-11-15 15:41:42

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH 4/4] bq25890_charger: Enable continuous conversion for ADC at charging

Hi,

On 11/15/21 16:23, Sebastian Reichel wrote:
> Hi,
>
> On Sun, Nov 07, 2021 at 09:48:38PM +0100, Hans de Goede wrote:
>> Hi,
>>
>> On 11/7/21 21:20, Yauhen Kharuzhy wrote:
>>> Instead of one shot run of ADC at beginning of charging, run continuous
>>> conversion to ensure that all charging-related values are monitored
>>> properly (input voltage, input current, themperature etc.).
>>>
>>> Signed-off-by: Yauhen Kharuzhy <[email protected]>
>>
>> Thank you for finding this! This explains why all the ADC returned
>> values like current_now where 0 when charging, I thought this was
>> just something which was only supported while not charging, heh.
>>
>> As before, the patch subject prefix should be: "power: supply: bq25890: "
>>
>> Otherwise the patch looks good to me:
>>
>> Reviewed-by: Hans de Goede <[email protected]>
>>
>> Sebastian, this really is a pure bug-fix patch, any chance you
>> can pick this up for a future 5.16-rc# pull-req ?
>>
>> Regards,
>>
>> Hans
>
> Thanks, queued to power-supply's fixes branch.

Thank you.

Note I also added this to my:

[PATCH v2 00/20] power-suppy/i2c/extcon: Fix charger setup on Xiaomi Mi Pad 2 and Lenovo Yogabook

Series, together with 2 of the 3 other patches from this series
(with some minor fixes applied to one of them).

So you can skip:

[PATCH v2 02/20] power: supply: bq25890: Fix ADC continuous conversion setting when charging

from that series (I reworded the commit msg subject a bit,
but it is the exact same patch).

If I end up doing a v3, I'll drop this patch.

Regards,

Hans