Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c9cec22 authored by Xiaozhe Shi's avatar Xiaozhe Shi Committed by Abhijeet Dharmapurikar
Browse files

power: qpnp-smbcharger: do not disable parallel charging during hotswap



Currently the parallel charging algorithm stops if the battery charging
stops. However, this can create issues with hotswap. When turning on and
off the parallel charger without a battery, any delay in raising the
input current of the primary charger with the secondary charger turned
off could cause the device to UVLO.

To fix this, try to not disable the parallel charger when it's active
and there is no battery present. Also, allow the input current to rise
during a hotswap so that if parallel charging does need to be disabled
for a different reason, the main charger can still recover all of its
ICL.

Change-Id: I97e19c792337436389d0c9b4931162a44ac62a15
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 3fb78b35
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -1450,7 +1450,11 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
	enum power_supply_type usb_supply_type;
	char *usb_type_name = "null";

	if (!chip->batt_present) {
	/*
	 * if the battery is not present, do not allow the usb ICL to lower in
	 * order to avoid browning out the device during a hotswap.
	 */
	if (!chip->batt_present && current_ma < chip->usb_max_current_ma) {
		pr_info_ratelimited("Ignoring usb current->%d, battery is absent\n",
				current_ma);
		return 0;
@@ -1964,7 +1968,18 @@ static bool smbchg_is_parallel_usb_ok(struct smbchg_chip *chip,
		return false;
	}

	if (get_prop_charge_type(chip) != POWER_SUPPLY_CHARGE_TYPE_FAST) {
	/*
	 * If the battery is not present, try not to change parallel charging
	 * from OFF to ON or from ON to OFF, as it could cause the device to
	 * brown out in the instant that the USB settings are changed.
	 *
	 * Only allow parallel charging check to report false (thereby turnin
	 * off parallel charging) if the battery is still there, or if parallel
	 * charging is disabled in the first place.
	 */
	if (get_prop_charge_type(chip) != POWER_SUPPLY_CHARGE_TYPE_FAST
			&& (get_prop_batt_present(chip)
				|| chip->parallel.current_max_ma == 0)) {
		pr_smb(PR_STATUS, "Not in fast charge, skipping\n");
		return false;
	}