diff mbox series

[07/10] power: supply: bq25890: Always take HiZ mode into account for ADC rate

Message ID 20221127180233.103678-8-hdegoede@redhat.com (mailing list archive)
State Superseded
Headers show
Series power: supply: bq25890: Fixes for 6.2 + further work for 6.3 | expand

Commit Message

Hans de Goede Nov. 27, 2022, 6:02 p.m. UTC
The code to check if F_CONV_RATE has been set, or if a manual ADC
conversion needs to be triggered, as well as the code to set
the initial F_CONV_RATE value at probe both where not taking
HiZ mode into account. Add checks for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/bq25890_charger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Marek Vasut Nov. 27, 2022, 9:25 p.m. UTC | #1
On 11/27/22 19:02, Hans de Goede wrote:
> The code to check if F_CONV_RATE has been set, or if a manual ADC
> conversion needs to be triggered, as well as the code to set
> the initial F_CONV_RATE value at probe both where not taking
> HiZ mode into account. Add checks for this.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Reviewed-by: Marek Vasut <marex@denx.de>
diff mbox series

Patch

diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index bd6858231271..03e31c5b0df5 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -467,7 +467,7 @@  static void bq25890_update_state(struct bq25890_device *bq,
 	/* update state in case we lost an interrupt */
 	__bq25890_handle_irq(bq);
 	*state = bq->state;
-	do_adc_conv = !state->online && bq25890_is_adc_property(psp);
+	do_adc_conv = (!state->online || state->hiz) && bq25890_is_adc_property(psp);
 	if (do_adc_conv)
 		bq25890_field_write(bq, F_CONV_START, 1);
 	mutex_unlock(&bq->lock);
@@ -956,7 +956,7 @@  static int bq25890_hw_init(struct bq25890_device *bq)
 	}
 
 	/* Configure ADC for continuous conversions when charging */
-	ret = bq25890_field_write(bq, F_CONV_RATE, !!bq->state.online);
+	ret = bq25890_field_write(bq, F_CONV_RATE, bq->state.online && !bq->state.hiz);
 	if (ret < 0) {
 		dev_dbg(bq->dev, "Config ADC failed %d\n", ret);
 		return ret;