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

Commit a8c22f87 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Ashay Jaiswal
Browse files

power: qpnp-smbcharger: enable OTG in overcurrent scenario conditionally



Currently, in OTG overcurrent conditions, OTG is disabled and
enabled in the reset sequence when the number of retries is less
than 5. There is a sleep time of 20 ms between the above sequence.

However, there is a chance that the USBID interrupt for OTG
removal is handled between the OTG disable and enable sequence.
Even though the USB driver notifies the charger to disable OTG,
it will get enabled again because it's already in the OTG reset
sequence for enabling OTG. Fix this race condition by checking
the presence of OTG before enabling it in the OTG reset sequence.

CRs-Fixed: 887852
Change-Id: I9a34f7f8e34edde69c81abc9930a4b36a8c9e66c
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent bed8ba95
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -4182,11 +4182,24 @@ static int otg_oc_reset(struct smbchg_chip *chip)
		pr_err("Failed to disable OTG rc=%d\n", rc);

	msleep(20);

	/*
	 * There is a possibility that an USBID interrupt might have
	 * occurred notifying USB power supply to disable OTG. We
	 * should not enable OTG in such cases.
	 */
	if (!is_otg_present(chip)) {
		pr_smb(PR_STATUS,
			"OTG is not present, not enabling OTG_EN_BIT\n");
		goto out;
	}

	rc = smbchg_masked_write(chip, chip->bat_if_base + CMD_CHG_REG,
						OTG_EN_BIT, OTG_EN_BIT);
	if (rc)
		pr_err("Failed to re-enable OTG rc=%d\n", rc);

out:
	return rc;
}