From 5e112fa22288c28f2d3661a60a3253e242d4a9d3 Mon Sep 17 00:00:00 2001 From: LeoLiu-oc Date: Fri, 26 Mar 2021 17:21:10 +0800 Subject: [PATCH 2905/2944] ck: xhci: Show Zhaoxin XHCI root hub speed correctly Some Zhaoxin xHCI controllers follow usb3.1 spec, but only support gen1 speed 5G. While in Linux kernel, if xHCI suspport usb3.1,root hub speed will show on 10G. To fix this issue, read usb speed ID supported by xHCI to determine root hub speed. The patch is scheduled to be submitted to the kernel mainline in 2021. Signed-off-by: LeoLiu-oc Reviewed-by: Artie Ding --- drivers/usb/host/xhci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 962c75fc..82cdc33 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5064,6 +5064,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) */ struct device *dev = hcd->self.sysdev; unsigned int minor_rev; + u8 i; int retval; /* Accept arbitrarily long scatter-gather lists */ @@ -5118,6 +5119,22 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; break; } + + /* usb3.1 has gen1 and gen2, Some zx's xHCI controller that follow usb3.1 spec + * but only support gen1 + */ + if (xhci->quirks & XHCI_ZHAOXIN_HOST) { + minor_rev = 0; + for (i = 0; i < xhci->usb3_rhub.psi_count; i++) { + if (XHCI_EXT_PORT_PSIV(xhci->usb3_rhub.psi[i]) >= 5) + minor_rev = 1; + } + if (minor_rev != 1) { + hcd->speed = HCD_USB3; + hcd->self.root_hub->speed = USB_SPEED_SUPER; + } + } + xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", minor_rev, minor_rev ? "Enhanced " : ""); -- 1.8.3.1