Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: bq24190: Fix BQ24296 Vbus regulator support

There are 2 issues with bq24296_set_otg_vbus():

1. When writing the OTG_CONFIG bit it uses POC_CHG_CONFIG_SHIFT which
should be POC_OTG_CONFIG_SHIFT.

2. When turning the regulator off it never turns charging back on. Note
this must be done through bq24190_charger_set_charge_type(), to ensure
that the charge_type property value of none/trickle/fast is honored.

Resolve both issues to fix BQ24296 Vbus regulator support not working.

Fixes: b150a703b56f ("power: supply: bq24190_charger: Add support for BQ24296")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20241116203648.169100-2-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Hans de Goede and committed by
Sebastian Reichel
b3ded607 c28dc9fc

+9 -3
+9 -3
drivers/power/supply/bq24190_charger.c
··· 567 567 568 568 static int bq24296_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable) 569 569 { 570 + union power_supply_propval val = { .intval = bdi->charge_type }; 570 571 int ret; 571 572 572 573 ret = pm_runtime_resume_and_get(bdi->dev); ··· 588 587 589 588 ret = bq24190_write_mask(bdi, BQ24190_REG_POC, 590 589 BQ24296_REG_POC_OTG_CONFIG_MASK, 591 - BQ24296_REG_POC_CHG_CONFIG_SHIFT, 590 + BQ24296_REG_POC_OTG_CONFIG_SHIFT, 592 591 BQ24296_REG_POC_OTG_CONFIG_OTG); 593 - } else 592 + } else { 594 593 ret = bq24190_write_mask(bdi, BQ24190_REG_POC, 595 594 BQ24296_REG_POC_OTG_CONFIG_MASK, 596 - BQ24296_REG_POC_CHG_CONFIG_SHIFT, 595 + BQ24296_REG_POC_OTG_CONFIG_SHIFT, 597 596 BQ24296_REG_POC_OTG_CONFIG_DISABLE); 597 + if (ret < 0) 598 + goto out; 599 + 600 + ret = bq24190_charger_set_charge_type(bdi, &val); 601 + } 598 602 599 603 out: 600 604 pm_runtime_mark_last_busy(bdi->dev);