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

Commit 7f7faa16 authored by Mayank Rana's avatar Mayank Rana
Browse files

dwc3-msm: Don't mark fatal error with IN_L2 for USB cable disconnect case



In some cases, it has been observed that USB PHY is not going into IN_L2
state with USB cable disconnect case. This change marks seeing IN_L2 error
as fatal with USB host mode or USB device bus suspend case only. USB cable
disconnect functionality does power collapse USB controller and PHYs
whereas performs POR sequence with USB cable connect. Hence going into USB
LPM sequence with USB PHY not suspended properly should be no harm.

This change also captures few important registers when IN_L2 error is seen.

CRs-Fixed: 1063744
Change-Id: Ibe5a85ce4c78b7346e8840916f868cf8011e2b92
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 311cf263
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ MODULE_PARM_DESC(dcp_max_current, "max current drawn for DCP charger");
#define CGCTL_REG		(QSCRATCH_REG_OFFSET + 0x28)
#define PWR_EVNT_IRQ_STAT_REG    (QSCRATCH_REG_OFFSET + 0x58)
#define PWR_EVNT_IRQ_MASK_REG    (QSCRATCH_REG_OFFSET + 0x5C)
#define QSCRATCH_USB30_STS_REG	(QSCRATCH_REG_OFFSET + 0xF8)


#define PWR_EVNT_POWERDOWN_IN_P3_MASK		BIT(2)
#define PWR_EVNT_POWERDOWN_OUT_P3_MASK		BIT(3)
@@ -1879,6 +1881,7 @@ static int dwc3_msm_prepare_suspend(struct dwc3_msm *mdwc)
{
	unsigned long timeout;
	u32 reg = 0;
	struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);

	if ((mdwc->in_host_mode || (mdwc->vbus_active
			&& mdwc->otg_state == OTG_STATE_B_SUSPEND))
@@ -1908,9 +1911,18 @@ static int dwc3_msm_prepare_suspend(struct dwc3_msm *mdwc)

	if (!(reg & PWR_EVNT_LPM_IN_L2_MASK)) {
		dev_err(mdwc->dev, "could not transition HS PHY to L2\n");
		queue_delayed_work(mdwc->dwc3_wq, &mdwc->resume_work, 0);
		dbg_event(0xFF, "PWR_EVNT_LPM",
			dwc3_msm_read_reg(mdwc->base, PWR_EVNT_IRQ_STAT_REG));
		dbg_event(0xFF, "QUSB_STS",
			dwc3_msm_read_reg(mdwc->base, QSCRATCH_USB30_STS_REG));
		/* Mark fatal error for host mode or USB bus suspend case */
		if (mdwc->in_host_mode || (mdwc->vbus_active
			&& mdwc->otg_state == OTG_STATE_B_SUSPEND)) {
			queue_delayed_work(mdwc->dwc3_wq,
					&mdwc->resume_work, 0);
			return -EBUSY;
		}
	}

	/* Clear L2 event bit */
	dwc3_msm_write_reg(mdwc->base, PWR_EVNT_IRQ_STAT_REG,