From patchwork Tue Feb 26 06:59:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ran Wang X-Patchwork-Id: 10829569 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 4FAE817EF for ; Tue, 26 Feb 2019 06:59:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B5362B218 for ; Tue, 26 Feb 2019 06:59:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D77C2B227; Tue, 26 Feb 2019 06:59:32 +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 AAE012B218 for ; Tue, 26 Feb 2019 06:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfBZG7Z (ORCPT ); Tue, 26 Feb 2019 01:59:25 -0500 Received: from mail-eopbgr150058.outbound.protection.outlook.com ([40.107.15.58]:64286 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725901AbfBZG7Z (ORCPT ); Tue, 26 Feb 2019 01:59:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Maf3dinF8BFqTW1gygX80fRXMIYgN9gCrIsTDcR3vi0=; b=Ie196uoM5Q5h3+wLHiQjV9ShgFACMGiYHoOeYPb6E2kUtFkeFDy9BivV+5FGj4ODnV830DBPjVuZZkQvhZ0Rj2zXFnei/P9iVPO39g3ADO9BUV1b390R86AXnqZQ4VmMvOMa7uPgj2Y/4fSQV4FWYkzV75FErdyQ+5nXiQIxNho= Received: from AM5PR0402MB2865.eurprd04.prod.outlook.com (10.175.41.148) by AM5PR0402MB2865.eurprd04.prod.outlook.com (10.175.41.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.16; Tue, 26 Feb 2019 06:59:21 +0000 Received: from AM5PR0402MB2865.eurprd04.prod.outlook.com ([fe80::54f5:3bc4:9018:f123]) by AM5PR0402MB2865.eurprd04.prod.outlook.com ([fe80::54f5:3bc4:9018:f123%6]) with mapi id 15.20.1643.019; Tue, 26 Feb 2019 06:59:21 +0000 From: Ran Wang To: Greg Kroah-Hartman , Rob Herring , Mark Rutland , Felipe Balbi , Yang Li CC: "linux-usb@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Ran Wang Subject: [PATCH v3 1/2] usb: dwc3: Add avoiding vbus glitch happen during xhci reset Thread-Topic: [PATCH v3 1/2] usb: dwc3: Add avoiding vbus glitch happen during xhci reset Thread-Index: AQHUzaDMOP2YLLnAD0aJ43gCn//B+Q== Date: Tue, 26 Feb 2019 06:59:21 +0000 Message-ID: <20190226070016.27372-1-ran.wang_1@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR01CA0065.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::29) To AM5PR0402MB2865.eurprd04.prod.outlook.com (2603:10a6:203:99::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ran.wang_1@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f80b7cc3-4a37-4a63-c530-08d69bb7ef26 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM5PR0402MB2865; x-ms-traffictypediagnostic: AM5PR0402MB2865: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BAM5PR0402MB2865=3B23=3A?= =?iso-8859-1?q?QGty5+DKbGPFSg2I+koRehyhNCTbsqoxrGIOactlrSs0txQweeZCiZTrEh7m?= =?iso-8859-1?q?1UDy3HzybiTxAZdACu9DBY1FNTprhEayMGTytcY08g162F6zUyCRPl/QI+Fn?= =?iso-8859-1?q?xavqIvvX4Un5Cu8PXul5JAv2GbKkCUe3kg7pKICSAk1VNL+Q8sYz9wjMNdUK?= =?iso-8859-1?q?bDyVn8+hoB4y3WHc91bOMZf9ka8Nc+173G5/sZSpfCU7kYnnsDSDsZIGVLmf?= =?iso-8859-1?q?p5FLE+uZoBS3AaGbUxj0iDfYnHwdIYTB9QjLQSKhUAdwkgZL0OSbZGAippYq?= =?iso-8859-1?q?nP8O5Ceco7hFSZrHpOA79ZgDxpKKNCI5bhyh5Rs4IkqviU1W0GqPLUGRz+Mf?= =?iso-8859-1?q?MHPIg/KakgUbHs2cd54GVTdfhFQ8EshFtGRsG3hR6vwAMSvfSBcOksvNwAYW?= =?iso-8859-1?q?8hlDLY1B6fHfPXxH4Wc4EL+WSPeDWfcyN0MZWgxQYYg8oYl7BBfumgJy/lLh?= =?iso-8859-1?q?v+5X2sl6FpcRzO3GA+3RIV2SjnuWD8J/nfcK8qY8AGJjDHJt4TadiZOuPahF?= =?iso-8859-1?q?WYsW2P2JmQUpBeZgogP9EeHv+8dqLBlih9fENJQgg0sK5YkOxSZoVK71I5xo?= =?iso-8859-1?q?xAR8L+sfsxcfZo6m+N1lsgB5pRQHcNxcj9T5YXRgDN3COgOz4LToJo8sNRv+?= =?iso-8859-1?q?ML5gmbpgnZUKpwaCQDkHZ4GheuZ91wnNFHz/N73IUNwy9jQNwBduax+3z2NO?= =?iso-8859-1?q?814mb8GnNrR/iFB+As7oBbCjz7FCvvZLSvK4f3n/ckfcuTpvLoE0uAis3ol7?= =?iso-8859-1?q?+6S9x92KthDyjetTknKc2hSy1jb/DWIVBcxUxQ1lNhJ0OjOmII5F7TUYE5Ch?= =?iso-8859-1?q?lHlrNmLQKX7VRsCFOpwCPDmk3ZPDwVZHGZQxoh5okFSJNdg1IRx/dsw09XnT?= =?iso-8859-1?q?BQgTf3zwVaMS+G/5UZKqXveONitrOmOH62msMYpqGhMZb9C8QfmI59nxwUQ9?= =?iso-8859-1?q?O6R+zN8ZWlLQFEfLC7fd+qD9DQ9hQFXDD26cfzmg7LczUVyOnF/yQfoxhnDG?= =?iso-8859-1?q?OXaF7x7V+untn5jwM60X0+QnzSf4fCmZxdf3Hv+Zq6NJtOr1HuydAUopTaoS?= =?iso-8859-1?q?59pShfdv9Q+SLfm5KwwhLvGUadE8BxHEC3wIrPSPoSRMmTK/Zn67wc8heHwB?= =?iso-8859-1?q?RHon/8/1gen8?= x-microsoft-antispam-prvs: x-forefront-prvs: 096029FF66 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(39860400002)(366004)(136003)(376002)(346002)(189003)(199004)(86362001)(25786009)(478600001)(316002)(14454004)(8676002)(66066001)(305945005)(6436002)(4326008)(8936002)(7736002)(50226002)(71190400001)(3846002)(6116002)(5660300002)(71200400001)(81166006)(81156014)(1076003)(486006)(68736007)(105586002)(2616005)(476003)(106356001)(110136005)(99286004)(6512007)(53936002)(256004)(97736004)(186003)(6486002)(36756003)(26005)(102836004)(54906003)(2906002)(6506007)(386003)(52116002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0402MB2865;H:AM5PR0402MB2865.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: fHqOzlHwM1lgPtA1kXjDdvELZmEWTzTKLaAoztHsSm9ISJjKpAZd1sXVJnunmC64MuGFZeESDVEvUdJJb+A9RGekdEorLzL83UiTM5LKSjJp7XnoQbLMitx7NrOfBllD7nZpk1zMsVSsLbDcc+tF6jW6RAmV5ogXBMU99/oMiAq7hMuuVUQSDjgf3NGr8X1H5Kpdb8LV3hZdDwhuKCf+Xf21Dtv5XoZrQjxaptsF8YCuVUs2SEzjADaRcOjzc3hXoT0m6SGAMy17PFwLRy/eZBokkugX8tciL8qxqgcGvUukhriRou2XIDiRw5GBIhERQC3sc2b6gi6Rl0RFLflm3aSQTicnKd14bs2yPW/s0VBeVEb9TODsfspqb6LC4fuZFG4bJG6v8CQ1MNnxdNqPPX32lh4UfUre0UoBft3eFcc= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f80b7cc3-4a37-4a63-c530-08d69bb7ef26 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2019 06:59:18.2143 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2865 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 When DWC3 is set to host mode by programming register DWC3_GCTL, VBUS (or its control signal) will turn on immediately on related Root Hub ports. Then the VBUS will be de-asserted for a little while during xhci reset (conducted by xhci driver) for a little while and back to normal. This VBUS glitch might cause some USB devices emuration fail if kernel boot with them connected. One SW workaround which can fix this is to program all PORTSC[PP] to 0 to turn off VBUS immediately after setting host mode in DWC3 driver(per signal measurement result, it will be too late to do it in xhci-plat.c or xhci.c). Signed-off-by: Ran Wang --- Changes in v3: - None Changes in v2: - Correct typos - Shorten the name to snps,host-vbus-glitches Documentation/devicetree/bindings/usb/dwc3.txt | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 8e5265e..453f562 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -106,6 +106,9 @@ Optional properties: When just one value, which means INCRX burst mode enabled. When more than one value, which means undefined length INCR burst type enabled. The values can be 1, 4, 8, 16, 32, 64, 128 and 256. + - snps,host-vbus-glitches: Power off all Root Hub ports immediately after + setting host mode to avoid vbus (negative) glitch happen in later + xhci reset. And the vbus will back to 5V automatically when reset done. - in addition all properties from usb-xhci.txt from the current directory are supported as well From patchwork Tue Feb 26 06:59:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ran Wang X-Patchwork-Id: 10829571 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 54676139A for ; Tue, 26 Feb 2019 06:59:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 407292B218 for ; Tue, 26 Feb 2019 06:59:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 350162B227; Tue, 26 Feb 2019 06:59:37 +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 95BFF2B218 for ; Tue, 26 Feb 2019 06:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726706AbfBZG7b (ORCPT ); Tue, 26 Feb 2019 01:59:31 -0500 Received: from mail-eopbgr150075.outbound.protection.outlook.com ([40.107.15.75]:30279 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725901AbfBZG7a (ORCPT ); Tue, 26 Feb 2019 01:59:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mgatY6+ele6liTiC6HYrjOF2RxfbtJYBdcv0TgWetQ0=; b=nN2zBytriSckXJ1l1J9B7AiXa4Tb10SSxcrtqITQu/VAIp41zJPxOYJAZGR6GwSulzl1Yw9aTiG7hWSz1SOnF4aqQa4T7KaxvZGDFuuQKP0EbZN0pDUK3kJJkpm4ovjDR444dATS5ReUdbSyijzRHiz0VIfBgmwNja7zCaO02r8= Received: from AM5PR0402MB2865.eurprd04.prod.outlook.com (10.175.41.148) by AM5PR0402MB2865.eurprd04.prod.outlook.com (10.175.41.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.16; Tue, 26 Feb 2019 06:59:25 +0000 Received: from AM5PR0402MB2865.eurprd04.prod.outlook.com ([fe80::54f5:3bc4:9018:f123]) by AM5PR0402MB2865.eurprd04.prod.outlook.com ([fe80::54f5:3bc4:9018:f123%6]) with mapi id 15.20.1643.019; Tue, 26 Feb 2019 06:59:25 +0000 From: Ran Wang To: Greg Kroah-Hartman , Rob Herring , Mark Rutland , Felipe Balbi , Yang Li CC: "linux-usb@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Ran Wang Subject: [PATCH v3 2/2] usb: dwc3: Add workaround for host mode VBUS glitch when boot Thread-Topic: [PATCH v3 2/2] usb: dwc3: Add workaround for host mode VBUS glitch when boot Thread-Index: AQHUzaDPFcJ4hglFSU2evLYpi8IQfw== Date: Tue, 26 Feb 2019 06:59:25 +0000 Message-ID: <20190226070016.27372-2-ran.wang_1@nxp.com> References: <20190226070016.27372-1-ran.wang_1@nxp.com> In-Reply-To: <20190226070016.27372-1-ran.wang_1@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR01CA0065.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::29) To AM5PR0402MB2865.eurprd04.prod.outlook.com (2603:10a6:203:99::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ran.wang_1@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 171a8fd2-ab6c-4202-5af3-08d69bb7f166 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM5PR0402MB2865; x-ms-traffictypediagnostic: AM5PR0402MB2865: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BAM5PR0402MB2865=3B23=3A?= =?iso-8859-1?q?0uVMABUq7Y5e8woi/Da+OzmPtsrasIcepsLxmDNsoGV8BHyzHzAixhv2J2kH?= =?iso-8859-1?q?mYjBWZ+H3ZGkLA+C2Dcqio8C5Ouj+wPvLkn5WNnGt5uDrdQx1lhUSV/emMah?= =?iso-8859-1?q?RIB4EHv35phhIHS+vX7Vge/vtptub8ZnRBOn9g5XBXlaIRdtg/PmQDUbjme2?= =?iso-8859-1?q?L+eUVHy8XA1x1XcRFkC9mQaWA63K7TlOGg6X8RLr/0OLXxiuTzWUZR4UKix0?= =?iso-8859-1?q?Zky2FSXFZE/mtlIbrr1b5TguHMGVgFZgPJEySpXwtmdTQ/EqY1I1ddixjTCc?= =?iso-8859-1?q?QR9o9akND11llcWJkMpfhzilX+yNXEyIAEFO/Tq71rnZw1oOh3XbVYdt7wXA?= =?iso-8859-1?q?mMu1iEz+Ygvr/d8YocGfSWRCODF5+3NA1KmjaPrVmQ6PuUTBaclTC10B6IFC?= =?iso-8859-1?q?Ri8YRxVjvRHF3opyfWZl4iPYvNmKcSDVpDtHAH8I3N0Waae5mnVuCUxMXrZx?= =?iso-8859-1?q?QZzVGV/00WVrrzWz3PaPPrhWbPMsJNyRuNNC00koOh5RaslA2G0wlCyLJmsq?= =?iso-8859-1?q?GXnfIeiTN4gt2CTqp0Tm5JAlARCcr3mFwDCCTyrSQjj7q7DUHKdihW5tpev8?= =?iso-8859-1?q?LSnedTnV2Xd/AMOchJyoPEZfJvE4ZByVLmIqAZN+mpQv+fifA+vfGtVbPxKU?= =?iso-8859-1?q?9VK8vNrel/GFSfUAE5ZD5fAk3+s9ng+QIeEdrDpNUpOFRHvosHb1XIkr9n57?= =?iso-8859-1?q?VM4IqXR9NJ7DR4fjL0caq3YC3WKmnrtNtjf/PC0ArZxstomdh3X1AAby4+fX?= =?iso-8859-1?q?de380oJNDel9w6V39Basmfg59S6Itc5x9GWiQZIdG+v+1RoMozuw5ULLNIiN?= =?iso-8859-1?q?n6ghz31IG4EqnLnSS+PGAIhn697N+782t0rbb/vaAiR2MR+ztysDwF3T1Wl5?= =?iso-8859-1?q?DI1OzP9Tz5IfdtYhC5qUeWqHpXzPu8jPQ/hLfsD87DsTGU7Iaqio/IzZ7sqK?= =?iso-8859-1?q?i8HCQUjGv5FEf0vD2M0HiKuYsgW4uhx2GkoWwcR96TbH1ruaB5J2A5vuxI+D?= =?iso-8859-1?q?R/5/BOxgxwrcV1968ZKoqWk1Dat0zRAC+Hl5eGRBIbCbHGyU/ILRrXe2bK+h?= =?iso-8859-1?q?bZaF1rzQgku15paeNnW4IZyLP5bOTIrm1Cj/EBbSZe9byCPLJIrHGMNlll+R?= =?iso-8859-1?q?q6UaSDabIvEe+tg+v/0dcXnhK9jzRqWY5limMcoqgJ9duXzCjd6d7TtuKjxL?= =?iso-8859-1?q?4zAyGC5ODsgY7mdE?= x-microsoft-antispam-prvs: x-forefront-prvs: 096029FF66 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(39860400002)(366004)(136003)(376002)(346002)(189003)(199004)(86362001)(25786009)(478600001)(316002)(14454004)(8676002)(66066001)(305945005)(6436002)(4326008)(8936002)(7736002)(50226002)(71190400001)(3846002)(6116002)(5660300002)(71200400001)(81166006)(81156014)(1076003)(486006)(68736007)(105586002)(2616005)(476003)(11346002)(106356001)(76176011)(110136005)(99286004)(6512007)(53936002)(256004)(97736004)(186003)(6486002)(36756003)(26005)(102836004)(446003)(54906003)(2906002)(6506007)(386003)(52116002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0402MB2865;H:AM5PR0402MB2865.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 08S+nFlHR+bFLdgjup/Tu+/srbWol6SOgpJQvbckHoa5LgDedPHYAJxCqexoZ5tNiBAbi6iJLuIj4K4BRezndk0pJX0WDiMYBc18fNKFeP2DfI3F72xCfacnCEIZgUlOC1MTD6TSe9DAAAJ1k3zHhL1wx7ihTDljlJ6afnJHvObz26qh0n9Udikhvip9b7DY3kffvGEynz4DFBBXk6m/xqZM+yvZeLys3zK3JcOItT1VkSRW7Jjz7M351gGNGxw0gC9KFw8xQ1LRE8Kr+fAWLmtXyYdHROYnTI/n32cGT5GB+w0IHqO3oNsQbc1e4L7g1nim5qIEuZPI9812+JSulwkzefqDJPQqNTy8qN6rMJhKmYeEJ5hPVKg5InuWmFLm6kpdk6J0HTEA46BbEKUkWTHXk8eaw/+Xgr6fE7fncxg= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 171a8fd2-ab6c-4202-5af3-08d69bb7f166 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2019 06:59:21.9535 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2865 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 When DWC3 is set to host mode by programming register DWC3_GCTL, VBUS (or its control signal) will be turned on immediately on related Root Hub ports. Then, the VBUS is turned off for a little while(15us) when do xhci reset (conducted by xhci driver) and back to normal finally, we can observe a negative glitch of related signal happen. This VBUS glitch might cause some USB devices enumeration fail if kernel boot with them connected. Such as LS1012AFWRY/LS1043ARDB/LX2160AQDS /LS1088ARDB with Kingston 16GB USB2.0/Kingston USB3.0/JetFlash Transcend 4GB USB2.0 drives. The fail cases include enumerated as full-speed device or report wrong device descriptor, etc. One SW workaround which can fix this is by programing all xhci PORTSC[PP] to 0 to turn off VBUS immediately after setting host mode in DWC3 driver (per signal measurement result, it will be too late to do it in xhci-plat.c or xhci.c). Then, after xhci reset complete in xhci driver, PORTSC[PP]s' value will back to 1 automatically and VBUS on at that time, no glitch happen and normal enumeration process has no impact. Signed-off-by: Ran Wang --- Changes in v3: - Add macro PORT_REGS_SIZE to replace 0x10 - Change initial value of i to 0 for the for loop - Cosmetic changes Changes in v2: - Rename related property to 'snps,host-vbus-glitches' - Rename related dwc member to 'host_vbus_glitches' - Add member 'host_vbus_glitches' description in 'dwc3' drivers/usb/dwc3/core.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/core.h | 12 +++++++++++ 2 files changed, 60 insertions(+), 0 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a1b126f..dd80e3d 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -100,6 +100,42 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) return 0; } +/* + * dwc3_power_of_all_roothub_ports - Power off all Root hub ports + * @dwc3: Pointer to our controller context structure + */ +static void dwc3_power_off_all_roothub_ports(struct dwc3 *dwc) +{ + int i, port_num; + u32 reg, op_regs_base, offset; + void __iomem *xhci_regs; + + /* xhci regs is not mapped yet, do it temperary here */ + if (dwc->xhci_resources[0].start) { + xhci_regs = ioremap(dwc->xhci_resources[0].start, + DWC3_XHCI_REGS_END); + if (IS_ERR(xhci_regs)) { + dev_err(dwc->dev, "Failed to ioremap xhci_regs\n"); + return; + } + + op_regs_base = HC_LENGTH(readl(xhci_regs)); + reg = readl(xhci_regs + XHCI_HCSPARAMS1); + port_num = HCS_MAX_PORTS(reg); + + for (i = 0; i < port_num; i++) { + offset = op_regs_base + XHCI_PORTSC_BASE + + PORT_REGS_SIZE * i; + reg = readl(xhci_regs + offset); + reg &= ~PORT_POWER; + writel(reg, xhci_regs + offset); + } + + iounmap(xhci_regs); + } else + dev_err(dwc->dev, "xhci base reg invalid\n"); +} + void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) { u32 reg; @@ -109,6 +145,15 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) reg |= DWC3_GCTL_PRTCAPDIR(mode); dwc3_writel(dwc->regs, DWC3_GCTL, reg); + /* + * We have to power off all Root hub ports immediately after DWC3 set + * to host mode to avoid VBUS glitch happen when xhci get reset later. + */ + if (dwc->host_vbus_glitches) { + if (mode == DWC3_GCTL_PRTCAP_HOST) + dwc3_power_off_all_roothub_ports(dwc); + } + dwc->current_dr_role = mode; } @@ -1306,6 +1351,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) dwc->dis_metastability_quirk = device_property_read_bool(dev, "snps,dis_metastability_quirk"); + dwc->host_vbus_glitches = device_property_read_bool(dev, + "snps,host-vbus-glitches"); + dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index df87641..c2dee0b 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -606,6 +606,15 @@ #define DWC3_OSTS_VBUSVLD BIT(1) #define DWC3_OSTS_CONIDSTS BIT(0) +/* Partial XHCI Register and Bit fields for quirk */ +#define XHCI_HCSPARAMS1 0x4 +#define XHCI_PORTSC_BASE 0x400 +#define PORT_REGS_SIZE 0x10 +#define PORT_POWER (1 << 9) +#define HCS_MAX_PORTS(p) (((p) >> 24) & 0x7f) +#define XHCI_HC_LENGTH(p) (((p)>>00)&0x00ff) +#define HC_LENGTH(p) XHCI_HC_LENGTH(p) + /* Structures */ struct dwc3_trb; @@ -1024,6 +1033,8 @@ struct dwc3_scratchpad_array { * 2 - No de-emphasis * 3 - Reserved * @dis_metastability_quirk: set to disable metastability quirk. + * @host-vbus-glitches: set to avoid vbus glitch during + * xhci reset. * @imod_interval: set the interrupt moderation interval in 250ns * increments or 0 to disable. */ @@ -1209,6 +1220,7 @@ struct dwc3 { unsigned tx_de_emphasis:2; unsigned dis_metastability_quirk:1; + unsigned host_vbus_glitches:1; u16 imod_interval; };