From fe6ad78765d52228f58993c8c786ec881150c334 Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Fri, 22 Jan 2021 23:57:03 +0530 Subject: [PATCH 1/2] usb: dwc3-msm: Set host mode HSPHY speed flags based on CCS Currently the driver checks whether the PED bit of the PORTSC register is set to decide whether any device is connected, and then checks the PORTSPEED field to check for the speed and accordingly updates the HSPHY speed flag with LS or FS/HS. Hence, the PDC is programmed to fire HS_PHY_IRQ only on the rising edge of Dp/Dm. In a case where the connected peripheral has failed to enumerate, the PED bit can be cleared by the host driver. When such a device is disconnected, there is no HS_PHY_IRQ fired to wakeup SW and disconnect handling does not happen. Fix this by setting HSPHY speed flags based on the CCS bit of the PORTSC register so that the PDC is programmed to fire HS_PHY_IRQ on the falling edge of Dp/Dm. Change-Id: I122d170434da19fd6aeb022a5fa8a85f1ea6f541 Signed-off-by: Ajay Agarwal --- drivers/usb/dwc3/dwc3-msm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index b4e705b3eb36..44d93f1bbd87 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -2666,7 +2666,7 @@ static void dwc3_set_phy_speed_flags(struct dwc3_msm *mdwc) for (i = 0; i < num_ports; i++) { reg = dwc3_msm_read_reg(mdwc->base, USB3_PORTSC + i*0x10); - if (reg & PORT_PE) { + if (reg & PORT_CONNECT) { if (DEV_HIGHSPEED(reg) || DEV_FULLSPEED(reg)) mdwc->hs_phy->flags |= PHY_HSFS_MODE; else if (DEV_LOWSPEED(reg)) From 4ee28c3cb783cdc1a03ee0695378ab01d19d1bb8 Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Mon, 25 Jan 2021 18:48:47 +0530 Subject: [PATCH 2/2] usb: phy: snps: Enable autoresume for FS/HS peripherals only Currently the driver enables autoresume for all the connected peripherals. In a case where an LS device is connected but fails the enumeration, this autoresume enablement is leading to PHY keeping the Dm pulled up even when the peripheral is detached. Hence, the detach hs_phy_irq is never fired and disconnect is not processed. Since remote wakeup from LS peripherals is not a requirement on our platforms, enable autoresume for FS/HS devices only. Change-Id: I0a62d08e58af18b523af322c64529f5183d55907 Signed-off-by: Ajay Agarwal --- drivers/usb/phy/phy-msm-snps-hs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/usb/phy/phy-msm-snps-hs.c b/drivers/usb/phy/phy-msm-snps-hs.c index f1fef3c48c96..d6d76c450ef4 100644 --- a/drivers/usb/phy/phy-msm-snps-hs.c +++ b/drivers/usb/phy/phy-msm-snps-hs.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. */ #include @@ -487,12 +487,11 @@ static int msm_hsphy_set_suspend(struct usb_phy *uphy, int suspend) suspend: if (suspend) { /* Bus suspend */ if (phy->cable_connected) { - /* Enable auto-resume functionality only during host - * mode bus suspend with some peripheral connected. + /* Enable auto-resume functionality during host mode + * bus suspend with some FS/HS peripheral connected. */ if ((phy->phy.flags & PHY_HOST_MODE) && - ((phy->phy.flags & PHY_HSFS_MODE) || - (phy->phy.flags & PHY_LS_MODE))) { + (phy->phy.flags & PHY_HSFS_MODE)) { /* Enable auto-resume functionality by pulsing * signal */