From d4b73015cb156577572eaeacb236bb1ba99bfd38 Mon Sep 17 00:00:00 2001 From: William Wu Date: Mon, 4 Nov 2019 10:59:31 +0800 Subject: [PATCH] usb: host: xhci: add a quirk for disable autosuspend Some USB controllers (such as rk3328 SoC DWC3 controller with INNO USB 3.0 PHY) don't support autosuspend well, when receive remote wakeup signal from autosuspend, the Port Link State training failed, the correct PLC is Resume->Recovery->U0, but when the issue happens, the wrong PLC is Resume->Recovery->Inactive, cause resuming SS port fail. This issue always occurs when connect with external USB 3.0 HUB. This patch adds a quirk to disable xHC USB 3.0 root HUB autosuspend function. Change-Id: I6afade864235a7669f415d933b7b4983c0d46289 Signed-off-by: William Wu --- drivers/usb/host/xhci-plat.c | 3 +++ drivers/usb/host/xhci.c | 4 ++++ drivers/usb/host/xhci.h | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 256df57c9570..bebec6f33fe7 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -294,6 +294,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if (device_property_read_bool(tmpdev, "xhci-trb-ent-quirk")) xhci->quirks |= XHCI_TRB_ENT_QUIRK; + if (device_property_read_bool(tmpdev, "usb3-dis-autosuspend")) + xhci->quirks |= XHCI_DIS_AUTOSUSPEND; + device_property_read_u32(tmpdev, "imod-interval-ns", &xhci->imod_interval); } diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 36865d50171f..56ee2884df25 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "xhci.h" #include "xhci-trace.h" @@ -5100,6 +5101,9 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) /* xHCI private pointer was set in xhci_pci_probe for the second * registered roothub. */ + if (xhci->quirks & XHCI_DIS_AUTOSUSPEND) + xhci->shared_hcd->self.root_hub->quirks |= + USB_QUIRK_AUTO_SUSPEND; return 0; } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6a3fa191553c..f9ea951e8919 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1870,6 +1870,7 @@ struct xhci_hcd { #define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34) #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) #define XHCI_TRB_ENT_QUIRK BIT_ULL(36) +#define XHCI_DIS_AUTOSUSPEND BIT_ULL(37) unsigned int num_active_eps; unsigned int limit_active_eps;