From 15920a69b7bc7f1636986235d704e532d81130f5 Mon Sep 17 00:00:00 2001 From: Pratham Pratap Date: Thu, 2 Jul 2020 16:19:01 +0530 Subject: [PATCH] usb: phy: snps: Enable auto-resume during host mode bus suspend Currently driver is enabling auto-resume irrespective of whether peripheral is connected to the host or not. Adding PHY flags before enabling auto-resume ensures that some peripheral must have been connected before bus suspend. This change enables auto-resume only during host mode real bus suspend. Change-Id: Ifed2f0a773ace31738628a988062f96e92efad44 Signed-off-by: Pratham Pratap --- drivers/usb/phy/phy-msm-snps-hs.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-msm-snps-hs.c b/drivers/usb/phy/phy-msm-snps-hs.c index f95628713994..ac6a4ef288ad 100644 --- a/drivers/usb/phy/phy-msm-snps-hs.c +++ b/drivers/usb/phy/phy-msm-snps-hs.c @@ -487,15 +487,23 @@ suspend: if (suspend) { /* Bus suspend */ if (phy->cable_connected || (phy->phy.flags & PHY_HOST_MODE)) { - /* Enable auto-resume functionality by pulsing signal */ - msm_usb_write_readback(phy->base, - USB2_PHY_USB_PHY_HS_PHY_CTRL2, - USB2_AUTO_RESUME, USB2_AUTO_RESUME); - usleep_range(500, 1000); - msm_usb_write_readback(phy->base, - USB2_PHY_USB_PHY_HS_PHY_CTRL2, - USB2_AUTO_RESUME, 0); - + /* Enable auto-resume functionality only when + * there is some peripheral connected and real + * bus suspend happened + */ + if ((phy->phy.flags & PHY_HSFS_MODE) || + (phy->phy.flags & PHY_LS_MODE)) { + /* Enable auto-resume functionality by pulsing + * signal + */ + msm_usb_write_readback(phy->base, + USB2_PHY_USB_PHY_HS_PHY_CTRL2, + USB2_AUTO_RESUME, USB2_AUTO_RESUME); + usleep_range(500, 1000); + msm_usb_write_readback(phy->base, + USB2_PHY_USB_PHY_HS_PHY_CTRL2, + USB2_AUTO_RESUME, 0); + } msm_hsphy_enable_clocks(phy, false); } else {/* Cable disconnect */ mutex_lock(&phy->phy_lock);