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

Commit dd229555 authored by Sujeet Kumar's avatar Sujeet Kumar
Browse files

USB: phy-msm-usb: Reset PHY on PHCD timeout



If PHY reset is not enabled, PHY suspend
fails after few iteration of plug in plug out
testing. PHY suspend failed because setting
PHCD bit does not succeed.

Enabling PHY reset is helping recovering
from this issue. Add a retry for 3 times,
so that if PM does not call suspend,
then a retry by msm_otg_suspend() itself
can recover from this situation.

Also, return -EBUSY instead of -ETIMEOUT
because PM does not call suspend again on
-ETIMEOUT.

CRs-Fixed: 631053
Change-Id: I344f931e8ce9ec9f2c01f8f2aceb8e1baa6307a9
Signed-off-by: default avatarSujeet Kumar <ksujeet@codeaurora.org>
parent 707fd824
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -878,12 +878,17 @@ static int msm_otg_suspend(struct msm_otg *motg)
	struct usb_phy *phy = &motg->phy;
	struct usb_bus *bus = phy->otg->host;
	struct msm_otg_platform_data *pdata = motg->pdata;
	int cnt = 0;
	int cnt;
	bool host_bus_suspend, device_bus_suspend, dcp, prop_charger;
	bool floated_charger, sm_work_busy;
	u32 phy_ctrl_val = 0, cmd_val;
	u32 phy_ctrl_val, cmd_val;
	u32 portsc, config2;
	u32 func_ctrl;
	int phcd_retry_cnt = 0;

phcd_retry:
	cnt = 0;
	phy_ctrl_val = 0;

	if (atomic_read(&motg->in_lpm))
		return 0;
@@ -986,10 +991,14 @@ static int msm_otg_suspend(struct msm_otg *motg)

	if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) {
		dev_err(phy->dev, "Unable to suspend PHY\n");
		motg->reset_counter = 0;
		msm_otg_reset(phy);
		motg->ui_enabled = 1;
		enable_irq(motg->irq);
		return -ETIMEDOUT;
		if (phcd_retry_cnt++ < 3)
			goto phcd_retry;
		else
			return -EBUSY;
	}

	/*