From patchwork Tue Feb 5 06:18:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 10796889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1B311390 for ; Tue, 5 Feb 2019 06:19:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0B7D2AC4E for ; Tue, 5 Feb 2019 06:19:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4D992AC60; Tue, 5 Feb 2019 06:19:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C5752AC4E for ; Tue, 5 Feb 2019 06:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727925AbfBEGT1 (ORCPT ); Tue, 5 Feb 2019 01:19:27 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:37510 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbfBEGTP (ORCPT ); Tue, 5 Feb 2019 01:19:15 -0500 Received: by mail-ed1-f67.google.com with SMTP id h15so1923602edb.4 for ; Mon, 04 Feb 2019 22:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AK104Dr/qrW4/sFcXOd9y68fEzu0AcfzXkX+YAtBebU=; b=KsVeM1El9FDVE4wVpMDo3+uFExTe5bsQTBIf5wMoAdyp1okaxvtEv91IkWyckEoqjc J2JNVPjZ411OOPAe9goVzzEy6PXn3OS2TuRK5L9y79hQJlHPu8iwMIhyDTg2AJEXZ538 yB72oUIrtChUuhp7+h+EdhqQjzn7un94ih2Ks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AK104Dr/qrW4/sFcXOd9y68fEzu0AcfzXkX+YAtBebU=; b=oDCotzxAXjPv9JiWNxPBeerclDjDnpeLvMTn+ooHDS9dqWKTXdUvuU4f2sIc2NbW15 UXKSUJKnWOwD/8teE2xbMZ2b4zVNnqPuXQbW2n8WMAqrKJgdX4zzgfYQJw4e4Q23pXFW /6RRchDWNB/dm34LPg63sZB6aC8XCuje5zPEwnn2hi3qa0/T/u/yfT0qVTjsj1i3l2Dc UGVG40y1cGcJpamuNb1Q/0T+tD9R8BJEI31DPzwDj1IYUGwqkf2Yx5o6Y0qZDulsRrBP xKd1RdJVdK5JR4582uC7dDhKubEMOuk/vRf6zl4tbyZqSozzIR0nRvaA6FJODglKYmM0 EZlA== X-Gm-Message-State: AHQUAuZuFd1krym0cX/wj1R5vEIHIvz+QG4O4SeVdcfidAI6jzjeZSEE C0NBDEi1cFLubqpZ6sSM4Vuw4w== X-Google-Smtp-Source: AHgI3IZo94iE/x/23FLD8i0N49E2GcOuXzOPPK3EVLGZVOygjemZMvUMnD9X1rPoD1rBXGfxj5Kxmw== X-Received: by 2002:a50:af43:: with SMTP id g61mr2408690edd.286.1549347553694; Mon, 04 Feb 2019 22:19:13 -0800 (PST) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id t26sm2835120ejs.48.2019.02.04.22.19.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Feb 2019 22:19:13 -0800 (PST) From: Srinath Mannam To: Greg Kroah-Hartman , Mathias Nyman , Rob Herring , Mark Rutland Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Srinath Mannam Subject: [PATCH 1/2] dt-bindings: usb-xhci: Add usb-phy-port-reset property Date: Tue, 5 Feb 2019 11:48:53 +0530 Message-Id: <1549347534-11320-2-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549347534-11320-1-git-send-email-srinath.mannam@broadcom.com> References: <1549347534-11320-1-git-send-email-srinath.mannam@broadcom.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add usb-phy-port-reset optional property to set quirk in xhci platform driver which forces USB port PHY reset on port disconnect event. Signed-off-by: Srinath Mannam Reviewed-by: Ray Jui --- Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt index fea8b15..ecbdb15 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt @@ -40,6 +40,7 @@ Optional properties: - usb3-lpm-capable: determines if platform is USB3 LPM capable - quirk-broken-port-ped: set if the controller has broken port disable mechanism - imod-interval-ns: default interrupt moderation interval is 5000ns + - usb-phy-port-reset: set this to do USB PORT PHY reset while disconnect - phys : see usb-hcd.txt in the current directory additionally the properties from usb-hcd.txt (in the current directory) are From patchwork Tue Feb 5 06:18:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 10796887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E019F1390 for ; Tue, 5 Feb 2019 06:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD5D72AC4E for ; Tue, 5 Feb 2019 06:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C004B2AC60; Tue, 5 Feb 2019 06:19:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B3722AC4E for ; Tue, 5 Feb 2019 06:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727923AbfBEGTZ (ORCPT ); Tue, 5 Feb 2019 01:19:25 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34973 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727884AbfBEGTU (ORCPT ); Tue, 5 Feb 2019 01:19:20 -0500 Received: by mail-ed1-f66.google.com with SMTP id x30so1940757edx.2 for ; Mon, 04 Feb 2019 22:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2joTHd/qfxG2VDYCb9Jw7yy8c8PzPgqLNKek+stZxME=; b=NtT1GhgM5wYXPv49A+7GW1Z+JN+NPHkPIB1FJLBYrGJM6x8hhR2jQuCpbLDZMT3FUv WcWCYkFd7HyAeEfI/xH750iW4rwT3gylgtYUk6srb08HYeZde+tS1VXjUSW8PJ5iCGp5 VpydCrsiTB2CHDW9PotfZuYPCNce8y7paEdnA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2joTHd/qfxG2VDYCb9Jw7yy8c8PzPgqLNKek+stZxME=; b=IC7A9sxpK915oobxq4h+j1v8jBf6Fu3hKfMhZXPe4T1Dj7DnEuNCWqfWTM6puywRCP 8wAZyE7sa7CwmoHdGmR0GyciINhYHXvmqFUSs8IDEenHm+UdFwfjyz7nM01lZs5LZKI5 I21HNcvNCyR3amQkiNhmohAlt+gjWCLzXxIOtmohe/gtE42vtX/2ynRCvSL483oGjI1H Htq3THxjf0LeuBXMVMV8uJHKEyM81fY6cOgM1CI7ZOo9ClOlv7z/hjeFiOctKZ0FwG5y RtdDcvLFs/LDcO5jqtTRNqVeZSkLtd63JewHg2TDUFN9Rtfe1SoiZieBXemeYZjKI7L2 QKlQ== X-Gm-Message-State: AHQUAuYRqiSo60Xs8gFTCmO3P8w1ysHLsmtx+CfR3fm4f1xUQ2eXazgy g6PHWYWWTsQFo68hfhlhPrv6eg== X-Google-Smtp-Source: AHgI3IavOc2gOjrPjzXbFOmPpl7yHLjTFQy7iGDHobTicrYKYeBPeOvKSUInVCCEsCAyDEBjgTYrQQ== X-Received: by 2002:a17:906:4f84:: with SMTP id o4mr1033156eju.227.1549347558364; Mon, 04 Feb 2019 22:19:18 -0800 (PST) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id t26sm2835120ejs.48.2019.02.04.22.19.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Feb 2019 22:19:17 -0800 (PST) From: Srinath Mannam To: Greg Kroah-Hartman , Mathias Nyman , Rob Herring , Mark Rutland Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Srinath Mannam Subject: [PATCH 2/2] drivers: xhci: Add quirk to reset xHCI port PHY Date: Tue, 5 Feb 2019 11:48:54 +0530 Message-Id: <1549347534-11320-3-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549347534-11320-1-git-send-email-srinath.mannam@broadcom.com> References: <1549347534-11320-1-git-send-email-srinath.mannam@broadcom.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a quirk to reset xHCI port PHY on port disconnect event. Stingray USB HS PHY has an issue, that USB High Speed device detected at Full Speed after the same port has connected to Full speed device. This problem can be resolved with that port PHY reset on disconnect. Signed-off-by: Srinath Mannam Reviewed-by: Ray Jui --- drivers/usb/core/hcd.c | 6 ++++++ drivers/usb/core/phy.c | 21 +++++++++++++++++++++ drivers/usb/core/phy.h | 1 + drivers/usb/host/xhci-plat.c | 3 +++ drivers/usb/host/xhci-ring.c | 9 ++++++--- drivers/usb/host/xhci.h | 1 + include/linux/usb/hcd.h | 1 + 7 files changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 015b126..e2b87a6 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2663,6 +2663,12 @@ int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1) return hcd->driver->find_raw_port_number(hcd, port1); } +int usb_hcd_phy_port_reset(struct usb_hcd *hcd, int port) +{ + return usb_phy_roothub_port_reset(hcd->phy_roothub, port); +} +EXPORT_SYMBOL_GPL(usb_hcd_phy_port_reset); + static int usb_hcd_request_irqs(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags) { diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c index 38b2c77..c64767d 100644 --- a/drivers/usb/core/phy.c +++ b/drivers/usb/core/phy.c @@ -162,6 +162,27 @@ void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub) } EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off); +int usb_phy_roothub_port_reset(struct usb_phy_roothub *phy_roothub, int port) +{ + struct usb_phy_roothub *roothub_entry; + struct list_head *head; + int i = 0; + + if (!phy_roothub) + return -EINVAL; + + head = &phy_roothub->list; + + list_for_each_entry(roothub_entry, head, list) { + if (i == port) + return phy_reset(roothub_entry->phy); + i++; + } + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(usb_phy_roothub_port_reset); + int usb_phy_roothub_suspend(struct device *controller_dev, struct usb_phy_roothub *phy_roothub) { diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h index 88a3c03..e8be444 100644 --- a/drivers/usb/core/phy.h +++ b/drivers/usb/core/phy.h @@ -18,6 +18,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub); +int usb_phy_roothub_port_reset(struct usb_phy_roothub *phy_roothub, int port); int usb_phy_roothub_suspend(struct device *controller_dev, struct usb_phy_roothub *phy_roothub); diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index ef09cb0..5a3b486 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -289,6 +289,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if (device_property_read_bool(tmpdev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; + if (device_property_read_bool(tmpdev, "usb-phy-port-reset")) + xhci->quirks |= XHCI_RESET_PHY_ON_DISCONNECT; + device_property_read_u32(tmpdev, "imod-interval-ns", &xhci->imod_interval); } diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 40fa25c..2dc3116 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1685,9 +1685,12 @@ static void handle_port_status(struct xhci_hcd *xhci, if (hcd->speed < HCD_USB3) { xhci_test_and_clear_bit(xhci, port, PORT_PLC); - if ((xhci->quirks & XHCI_RESET_PLL_ON_DISCONNECT) && - (portsc & PORT_CSC) && !(portsc & PORT_CONNECT)) - xhci_cavium_reset_phy_quirk(xhci); + if ((portsc & PORT_CSC) && !(portsc & PORT_CONNECT)) { + if (xhci->quirks & XHCI_RESET_PLL_ON_DISCONNECT) + xhci_cavium_reset_phy_quirk(xhci); + else if (xhci->quirks & XHCI_RESET_PHY_ON_DISCONNECT) + usb_hcd_phy_port_reset(hcd, port_id - 1); + } } cleanup: diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 652dc36..530c5ff 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1846,6 +1846,7 @@ struct xhci_hcd { #define XHCI_DEFAULT_PM_RUNTIME_ALLOW BIT_ULL(33) #define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34) #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) +#define XHCI_RESET_PHY_ON_DISCONNECT BIT_ULL(36) unsigned int num_active_eps; unsigned int limit_active_eps; diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 7dc3a41..a5ea26f 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -456,6 +456,7 @@ extern int usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags); extern void usb_remove_hcd(struct usb_hcd *hcd); extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1); +extern int usb_hcd_phy_port_reset(struct usb_hcd *hcd, int port); struct platform_device; extern void usb_hcd_platform_shutdown(struct platform_device *dev);