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

Commit dabce32c authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

qcom: smb-lib: rerun APSD on insertion for micro USB mode



In case of very slow insertion of SDP/DCP there is a possibility
that D+/D- makes contact while APSD is in progress. This will
result in an incorrect type detection.
Fix this by doing a APSD rerun after charger-type detection is
complete.

CRs-Fixed: 2032590
Change-Id: I0037b90f29dbe65a2cdb2771d5caceff77862f03
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 9b3e8a81
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -685,6 +685,7 @@ static void smblib_uusb_removal(struct smb_charger *chg)
	chg->voltage_max_uv = MICRO_5V;
	chg->voltage_max_uv = MICRO_5V;
	chg->usb_icl_delta_ua = 0;
	chg->usb_icl_delta_ua = 0;
	chg->pulse_cnt = 0;
	chg->pulse_cnt = 0;
	chg->uusb_apsd_rerun_done = false;


	/* clear USB ICL vote for USB_PSY_VOTER */
	/* clear USB ICL vote for USB_PSY_VOTER */
	rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0);
	rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0);
@@ -752,6 +753,7 @@ int smblib_rerun_apsd_if_required(struct smb_charger *chg)
				rc);
				rc);
	}
	}


	chg->uusb_apsd_rerun_done = true;
	smblib_rerun_apsd(chg);
	smblib_rerun_apsd(chg);


	return 0;
	return 0;
@@ -3482,6 +3484,17 @@ irqreturn_t smblib_handle_usb_source_change(int irq, void *data)
	}
	}
	smblib_dbg(chg, PR_REGISTER, "APSD_STATUS = 0x%02x\n", stat);
	smblib_dbg(chg, PR_REGISTER, "APSD_STATUS = 0x%02x\n", stat);


	if (chg->micro_usb_mode && (stat & APSD_DTC_STATUS_DONE_BIT)
			&& !chg->uusb_apsd_rerun_done) {
		/*
		 * Force re-run APSD to handle slow insertion related
		 * charger-mis-detection.
		 */
		chg->uusb_apsd_rerun_done = true;
		smblib_rerun_apsd(chg);
		return IRQ_HANDLED;
	}

	smblib_handle_apsd_done(chg,
	smblib_handle_apsd_done(chg,
		(bool)(stat & APSD_DTC_STATUS_DONE_BIT));
		(bool)(stat & APSD_DTC_STATUS_DONE_BIT));


+1 −0
Original line number Original line Diff line number Diff line
@@ -312,6 +312,7 @@ struct smb_charger {
	int			vconn_attempts;
	int			vconn_attempts;
	int			default_icl_ua;
	int			default_icl_ua;
	int			otg_cl_ua;
	int			otg_cl_ua;
	bool			uusb_apsd_rerun_done;


	/* workaround flag */
	/* workaround flag */
	u32			wa_flags;
	u32			wa_flags;