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

Commit 38483239 authored by Lena Salman's avatar Lena Salman
Browse files

usb: dwc3: Fix connect/disconnect USB host issue



The original problem of connect/disconnect device in host mode.
Cable connect/disconnect is working, however any consequent
device plug out/in,  device is not recognized and the core
doesn't go back to LPM.
This is caused due to incorrect sequence of entering LPM.
Sequence is fixed accordingly.

CRs-fixed: 688823
Change-Id: I96f1e08a01fbc4bf71322c625bc16cd7784abc9a
Signed-off-by: default avatarLena Salman <esalman@codeaurora.org>
parent 83dd8ec0
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -337,7 +337,7 @@ static inline void dwc3_msm_write_readback(void *base, u32 offset,
			__func__, val, offset);
}

static inline bool dwc3_msm_is_superspeed(struct dwc3_msm *mdwc)
static inline bool dwc3_msm_is_dev_superspeed(struct dwc3_msm *mdwc)
{
	u8 speed;

@@ -345,6 +345,18 @@ static inline bool dwc3_msm_is_superspeed(struct dwc3_msm *mdwc)
	return !!(speed & DSTS_CONNECTSPD_SS);
}

static inline bool dwc3_msm_is_superspeed(struct dwc3_msm *mdwc)
{
	u8 speed;

	if (mdwc->scope == POWER_SUPPLY_SCOPE_SYSTEM) {
		speed = dwc3_msm_read_reg(mdwc->base, USB3_PORTSC) & PORT_PE;
		return speed;
	}

	return dwc3_msm_is_dev_superspeed(mdwc);
}

/**
 * Dump all QSCRATCH registers.
 *
@@ -737,7 +749,7 @@ static int dwc3_msm_ep_queue(struct usb_ep *ep,
		return ret;
	}

	superspeed = dwc3_msm_is_superspeed(mdwc);
	superspeed = dwc3_msm_is_dev_superspeed(mdwc);
	dbm_set_speed(mdwc->dbm, (u8)superspeed);

	return 0;
@@ -1484,7 +1496,7 @@ static int dwc3_msm_prepare_suspend(struct dwc3_msm *mdwc)
		if (!atomic_read(&mdwc->in_p3)) {
			dev_err(mdwc->dev,
				"Not in P3, stoping LPM sequence\n");
			return -EPERM;
			return -EBUSY;
		}
	} else {
		/* Clear previous L2 events */
@@ -1511,7 +1523,7 @@ 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");
			return -EPERM;
			return -EBUSY;
		}
	}

@@ -1647,7 +1659,7 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc)
		dwc3_msm_write_reg(mdwc->base, QSCRATCH_CTRL_REG,
			mdwc->qscratch_ctl_val);

	if (dwc->softconnect && cable_connected) {
	if (host_bus_suspend || (dwc->softconnect && cable_connected)) {
		ret = dwc3_msm_prepare_suspend(mdwc);
		if (ret)
			return ret;