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

Commit c998f3f9 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar
Browse files

power: qpnp-smbcharger: set allow detection in UV interrupt



The current driver uses rerun APSD to detect the proper charger type
if SDP is reported. The pull downs on D+/D- by USB PHY causes any charger
type to be reported as SDP and in rerun APSD trick the detection is made
to run after USB PHY has been notified to remove its pull downs.

This works great except for when the charger is really an SDP. Rerunning
APSD is an expensive operation timewise - it takes 1 second to do it.
To confirm an SDP is plugged in , APSD is run twice. That exceeds the time
limits mentioned in the spec for SDP detection.

Fix this by utilizing the usbin_uv falling edge interrupt to notify the
USB PHY to remove the pulls. The USBIN_UV interrupt is raised within 20mS
of USB insertion. APSD is configured to run 600mS after USB insertion.
That gives the interrupt thread 600-20 = 580mS to notify USB PHY.

580mS is plenty time to notify the USB PHY and for it to remove the pull
down. However, that may not be the case if the device is resuming from
suspend state. Mark the USBIN UV interrupt EARLY to handle this.

Change-Id: I6ec512f1f3f6680702cd532b32f0b75c6cf4d6f0
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 1c33e78d
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -4525,6 +4525,15 @@ static irqreturn_t usbin_uv_handler(int irq, void *_chip)
	if (chip->apsd_rerun_ignore_uv_irq)
		goto out;

	/*
	 * set usb_psy's allow_detection if this is a new insertion, i.e. it is
	 * not already src_detected and usbin_uv is seen falling
	 */
	if (!(reg & USBIN_UV_BIT) && !(reg & USBIN_SRC_DET_BIT)) {
		pr_smb(PR_MISC, "setting usb psy allow detection 1\n");
		power_supply_set_allow_detection(chip->usb_psy, 1);
	}

	if ((reg & USBIN_UV_BIT) && (reg & USBIN_SRC_DET_BIT)) {
		pr_smb(PR_STATUS, "Very weak charger detected\n");
		chip->very_weak_charger = true;
@@ -5728,7 +5737,8 @@ static int smbchg_request_irqs(struct smbchg_chip *chip)
		case SMBCHG_USB_CHGPTH_SUBTYPE:
		case SMBCHG_LITE_USB_CHGPTH_SUBTYPE:
			REQUEST_IRQ(chip, spmi_resource, chip->usbin_uv_irq,
				"usbin-uv", usbin_uv_handler, flags, rc);
				"usbin-uv", usbin_uv_handler,
				flags | IRQF_EARLY_RESUME, rc);
			REQUEST_IRQ(chip, spmi_resource, chip->usbin_ov_irq,
				"usbin-ov", usbin_ov_handler, flags, rc);
			REQUEST_IRQ(chip, spmi_resource, chip->src_detect_irq,