From patchwork Tue Feb 19 07:23:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ran Wang X-Patchwork-Id: 10819341 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 5A5811399 for ; Tue, 19 Feb 2019 07:23:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC1D2B532 for ; Tue, 19 Feb 2019 07:23:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 301722B7C1; Tue, 19 Feb 2019 07:23: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 BC3B22B532 for ; Tue, 19 Feb 2019 07:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725768AbfBSHXT (ORCPT ); Tue, 19 Feb 2019 02:23:19 -0500 Received: from mail-eopbgr130057.outbound.protection.outlook.com ([40.107.13.57]:58769 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725536AbfBSHXS (ORCPT ); Tue, 19 Feb 2019 02:23:18 -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=FlulyL+gvQJeveEX2RwGdP7L+Mp9Ul6v3Aji28gJZMo=; b=txuOkRE9xuHTrQhgBuX09Ofd5bRjW4z0+OJPqSbHlR0pTlhgxqlFYiIMjCK+bh5Ra0sssojv91k58MGPdLKCySvdboFtNgXwQpk4RoVWabVN/iI63U/IMjyj11M2nlWHUliH8bcoOi9o2JfRR6iyGfjRvXgvvgOczmH+uIIKKAc= Received: from AM5PR0402MB2865.eurprd04.prod.outlook.com (10.175.41.148) by AM5PR0402MB2867.eurprd04.prod.outlook.com (10.175.41.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.19; Tue, 19 Feb 2019 07:23:14 +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.1622.020; Tue, 19 Feb 2019 07:23:14 +0000 From: Ran Wang To: Greg Kroah-Hartman , Rob Herring , Mark Rutland , Felipe Balbi CC: "linux-usb@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Ran Wang Subject: [PATCH v2 1/2] usb: dwc3: Add avoiding vbus glitch happen during xhci reset Thread-Topic: [PATCH v2 1/2] usb: dwc3: Add avoiding vbus glitch happen during xhci reset Thread-Index: AQHUyCP5Y8sg90dKJ0SA+tfrnC4TyA== Date: Tue, 19 Feb 2019 07:23:14 +0000 Message-ID: <20190219072358.43493-1-ran.wang_1@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR04CA0021.apcprd04.prod.outlook.com (2603:1096:203:36::33) 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: d1a38f4e-0882-4117-a7c5-08d6963b1c1e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM5PR0402MB2867; x-ms-traffictypediagnostic: AM5PR0402MB2867: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BAM5PR0402MB2867=3B23=3A?= =?iso-8859-1?q?5j88UCTP5s6+3fMtRzl1yn9vCZXpc8tt2vBJ9BZmhLRiZEa7L2iifyNj/VFc?= =?iso-8859-1?q?2ZspN/b95oyrpa3aD1iKW3RuMx4VBXi/DclWXMVtem5C/VcGvEhcNUNQhTeF?= =?iso-8859-1?q?5mF1SasTkCAlGSCOXLBSG4srNfHeIaz+MORzon6ikqMt0D5EKs6xAJskicTA?= =?iso-8859-1?q?4JrR57LX2yU4WpwqGmk2uLGvMkliuuUdWrFm/n5jWqF0/PMX082cMgsQN6gh?= =?iso-8859-1?q?jSOdLNMrsWWp5dW4pLy7Fs98KFr500zSBi30pOsvm0J44VOOveBMO4EBPaIz?= =?iso-8859-1?q?88P1/8phrRzgzHZ9JaFQEidGCFmviBbjvMBrfNEXpIUnqEQpuJxUdXVU39lm?= =?iso-8859-1?q?DrDlawlTrjw6oCe62mrr6YrAzzwP7JwDs1jeyXeKtv0j/WoYSlJ77Tqu0sJK?= =?iso-8859-1?q?0ItHy5SsBayAO/j203F51rT3JGFdUSRu9KBt5+JvkNKNGm5rC/tSLhokp7p5?= =?iso-8859-1?q?y85w8q1d86grB2MPfqeghw6PswvT8uV/SOxVpmzMcHEdPmKkfR/eZ3OrjnsQ?= =?iso-8859-1?q?c/H3k1kRDA8fpKY4HcuuWUnZudS5FoDCfd6gYHP1j9N7wxLgbSTsoycb6cn9?= =?iso-8859-1?q?iIxLzL18B65ZqEOdAQBWlOz2ezpRZvjxxdReX83G+u4gNVGWlEnjI+bPXNCt?= =?iso-8859-1?q?MOdaHAYjvdGFMuQa8/3T7Bu0FNChjLuGn0kTDBEsbPXRVY5EA129toXUrZ78?= =?iso-8859-1?q?8vE1OEK213X69OkHHqWLbxEjsldvxguNP5WW/6wuMRJmV0cVrTm9zNxJaQjl?= =?iso-8859-1?q?dQDT8NBNO45BwfZeceyeT51SKzd8IToUt5GTKbCrzfKFZmAeCetnNwdfptKb?= =?iso-8859-1?q?wcANboL08j1KGta+rIhVeJJIVj7Qu2fquedyEp7EK2T1ElAIfOtIyNxzAPnx?= =?iso-8859-1?q?IIlZZIkJgUjoBcwWqiuUmaiWYYRYyKv444DX8SrSUmVZhP4rHkIzCd0S748x?= =?iso-8859-1?q?xvgV6aAn7JVlbGHFCYPQLwv9tJkQro5ynX+jvr6DsME5fYLzHg20NXITu29/?= =?iso-8859-1?q?S1W7JQlTXF519lmi2t1J0GvBY/bA5+oCdZTlX0+9zziIToykPVvUfiUBZBe3?= =?iso-8859-1?q?2NRQL0qbkoF1zXgL8JVu+/3iIcKNPYtlNm9EvInoXy6LEDZXsLrWQBahbaqM?= =?iso-8859-1?q?TXJ1g83+urlC?= x-microsoft-antispam-prvs: x-forefront-prvs: 09538D3531 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(366004)(136003)(396003)(39860400002)(376002)(189003)(199004)(81166006)(81156014)(71190400001)(71200400001)(50226002)(8676002)(256004)(2906002)(68736007)(476003)(2616005)(106356001)(8936002)(66066001)(97736004)(1076003)(105586002)(478600001)(6486002)(186003)(14454004)(99286004)(110136005)(316002)(25786009)(3846002)(26005)(6116002)(6512007)(86362001)(4326008)(486006)(36756003)(5660300002)(7736002)(305945005)(53936002)(52116002)(102836004)(6436002)(386003)(6506007)(54906003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0402MB2867;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: AUYyVxD4CsRGGdl/QAwWsnJd+1SdcNuea6Kq7CZ1LvvkOjALACx0G39h97C524vJMMeUXhJ2EYfflatMh1kjQ+v51jNtXpPGJkAVO7S5N1qqbj711rrdaguShje/9SRJvWXbcJsBDc1lz5nUG0zAf1VKQvMmaR4t0f9pJsdTfwb1R6ARE2ztu8eklElriABVWAomcioTMQz7sIGq+dZW2kIbIkus9wxPLqhj+JaC0tjiHbLiFh49Y3uCJ2BDJMGVu7TfB5UBPcj8A7ZeA2y1+s+kbojrYFTop1Ki+Zgdhh0Z/ZmOA3yOC/q0neSXRnDOoHV6S7zdoEm/S1vuWjVEvWsqE6pt9Vgml8cKZ1QhJMSo4ANxYhIhSP9Zi2UVjYG17KVCU1qHvwKrLCz8uvdBAg3JdFMOn8xjxyXxSEj2grI= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1a38f4e-0882-4117-a7c5-08d6963b1c1e X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Feb 2019 07:23:10.7686 (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: AM5PR0402MB2867 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 Reviewed-by: Rob Herring --- 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 19 07:23:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ran Wang X-Patchwork-Id: 10819339 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 212EE1399 for ; Tue, 19 Feb 2019 07:23:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 062B52B532 for ; Tue, 19 Feb 2019 07:23:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE6122B7C1; Tue, 19 Feb 2019 07:23:34 +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 5553E2B532 for ; Tue, 19 Feb 2019 07:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726573AbfBSHXX (ORCPT ); Tue, 19 Feb 2019 02:23:23 -0500 Received: from mail-eopbgr130057.outbound.protection.outlook.com ([40.107.13.57]:58769 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725787AbfBSHXV (ORCPT ); Tue, 19 Feb 2019 02:23:21 -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=JFyMd3wRAe5F+r8FSZ6dkpOyu1ydRElYDyPyzoM9se0=; b=g+PG89+cZcoS0Vva0XiCsY3vPNHsLdZ2NxvpKTSvLm3ER6r1bJzffAz6yFZuszx5ACtUljGzobgGEMViiEJsfrz4P4iaVHMjQ9MxOvKx5n5kjuYZZQogDvQ9OuOgi/bqV6FIZ5WPdHWlaiViKOD9+BhSuK6Fo4TRqYh7LfM9ZnE= Received: from AM5PR0402MB2865.eurprd04.prod.outlook.com (10.175.41.148) by AM5PR0402MB2867.eurprd04.prod.outlook.com (10.175.41.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.19; Tue, 19 Feb 2019 07:23:17 +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.1622.020; Tue, 19 Feb 2019 07:23:17 +0000 From: Ran Wang To: Greg Kroah-Hartman , Rob Herring , Mark Rutland , Felipe Balbi CC: "linux-usb@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Ran Wang Subject: [PATCH v2 2/2] usb: dwc3: Add workaround for host mode VBUS glitch when boot Thread-Topic: [PATCH v2 2/2] usb: dwc3: Add workaround for host mode VBUS glitch when boot Thread-Index: AQHUyCP7Q8ykT1GH70SnZGQkOrdM8w== Date: Tue, 19 Feb 2019 07:23:17 +0000 Message-ID: <20190219072358.43493-2-ran.wang_1@nxp.com> References: <20190219072358.43493-1-ran.wang_1@nxp.com> In-Reply-To: <20190219072358.43493-1-ran.wang_1@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR04CA0021.apcprd04.prod.outlook.com (2603:1096:203:36::33) 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: ee2c3be0-d045-430f-cc01-08d6963b1e31 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM5PR0402MB2867; x-ms-traffictypediagnostic: AM5PR0402MB2867: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BAM5PR0402MB2867=3B23=3A?= =?iso-8859-1?q?4Ftkq33/Flk5wpF4nUEulY0ho/BUOe7Zr3o5cZKxR71LukPqEGr9P641Zr7c?= =?iso-8859-1?q?HE9rw+0zZQt2A//gB4QyuqBnOIwZcfSaojVzEvhWX62A+vWsFLr/nBXnm97z?= =?iso-8859-1?q?+PngHLY1+zY590nen5eI6XL7Eq41iMRuBRzjPOMlsMnKIlJV974AErYOPAHW?= =?iso-8859-1?q?FuYX+eFgHBv8eN/6cS2vY0YxiaawFdG3/FDvHD5ymbZhxG+QGpeFo02+nOxU?= =?iso-8859-1?q?tecPQNdvf2yuPdsHVDHd23oo6IsfZA9pH/rMUiaxd8p+j1ZkOgSrYI+Ajc0D?= =?iso-8859-1?q?65Lgf86SPOgPBw7G1xN0URTiybLmK6ZS84F8H2VB0BQW4tmDy8YSsRqzhXtq?= =?iso-8859-1?q?pdsfFhmsDHp9o4M8LeohitPj+eA4cZHQNDDIwnxDDKxXZ9AQtaySMJFO+Ebo?= =?iso-8859-1?q?d0dF0nMWjq21LM5TY6E5jAXvYZfpiyBsRpog8of2SJse2RQHUnFNn2GWGLvs?= =?iso-8859-1?q?8ZRs0lCT9lO/sfQaHQL0+Jacp/Mjqcmj5giQha4PTUPz/qTxumJKcZowS2AV?= =?iso-8859-1?q?HE3KS1N5f/5O8N/IIC5HwRUe+uQbTbV1UlhL07oXzYlLs+EmVKoHnONUTP5Z?= =?iso-8859-1?q?mt3MKW0OPRIlS0D3R/ukR184W9zFO+qfF61tKYsXcfcRpN5tYnKVl+lNQcCf?= =?iso-8859-1?q?BBm6Ut7qlRgJbyurox4iTM7pMmdJM10QxZ5nxnu3+M3jICUAe+31plMFJP8c?= =?iso-8859-1?q?BDIpADCWB6weR3PitOSuNzEz6Yug53anNIG9unLdaVlhkROkJqVv6pGSReEl?= =?iso-8859-1?q?tMUdA6EOZVZOAwbdwmcxhxzxABV4Pe0Mvqgze1ViBIk2OabmuGVbVfs5E0Hg?= =?iso-8859-1?q?3fJHw/YQ0LSGxde1djGg8JGS0n8TkUfTHvd+rdVuXO8fAZATJNaeRsWDmxIj?= =?iso-8859-1?q?3afYzu0hHB1t128Y2hLqhxYUBs6KVJaIdCXkVKoqiGOIvVTZ5Gu0xEvLTaJN?= =?iso-8859-1?q?NbMRA4O9ujoFvCUfYagFBeFLlia/cMldwlre6Ib4jmphppn+pstu5V5ylUXP?= =?iso-8859-1?q?I2hCTy1RssTMeMNsWzfqpJDvFQxst/eKljlA4AFoSrEldnVeq5t81jVVwoAZ?= =?iso-8859-1?q?R5NUvTtgUt1RAVXeX7/KveuJ0S5C7DYN0q272MxWB/B7JdrM5OzWxEDVj55C?= =?iso-8859-1?q?I3uBdXL//ph6gLSjiXQE+vC/YxAgbZnDLYh5hCSsHDhrVwKsGL15l+Oe+as/?= =?iso-8859-1?q?v3IGs3C6nfVZX3at?= x-microsoft-antispam-prvs: x-forefront-prvs: 09538D3531 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(366004)(136003)(396003)(39860400002)(376002)(189003)(199004)(81166006)(81156014)(71190400001)(71200400001)(50226002)(8676002)(256004)(2906002)(68736007)(476003)(2616005)(106356001)(8936002)(66066001)(97736004)(1076003)(105586002)(478600001)(6486002)(186003)(14454004)(99286004)(110136005)(316002)(25786009)(3846002)(26005)(6116002)(6512007)(86362001)(4326008)(486006)(36756003)(5660300002)(7736002)(446003)(11346002)(305945005)(53936002)(52116002)(102836004)(76176011)(6436002)(386003)(6506007)(54906003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0402MB2867;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: Q8iM7lxM9116pgk1tbHCEajRP8HieDo+oDaqHtvEcQ/Xxc7e0QQSJATOV5Sk98R9Hl1j+T+dTGi+FOGJwAp57BJlbYRSUonauhI3tNvQ3DFUPHBvgGzWnOFzUyysnLWSc0xU1W1pcfw9FdkEh7vQeiupO0wCickw2fa/287mupVCkdmmokeoKi41B5+wkNE7SpopnZ62jSAfmwmcPOjo+S0BgjlmW5CDXEfAJYskj3EF6qsECFM1Jqq0KrX/QNeeTLzLm2Tf7cYOb85kI7p/HOrQiP4QDKYpZw3eaniTCsb4DEGzMk64IIiULUCnq49wv+o0TccpIMQoaTrxAAW5vdFr0NiuWV/wD4Attmq6ZlLUiRxCnVvmn4XEy8FcVKWaNI6yAMdDuZbA8IPDne8Di8mtUI/s33N6dTLAda15SL0= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee2c3be0-d045-430f-cc01-08d6963b1e31 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Feb 2019 07:23:14.4867 (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: AM5PR0402MB2867 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 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 | 47 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/core.h | 12 +++++++++++- 2 files changed, 58 insertions(+), 1 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a1b126f..02d11bc 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -100,6 +100,41 @@ 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 = 1; i <= port_num; i++) { + offset = op_regs_base + XHCI_PORTSC_BASE + 0x10*(i-1); + 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 +144,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 +1350,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..9b3a7ed 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -606,6 +606,14 @@ #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_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 +1032,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 +1219,7 @@ struct dwc3 { unsigned tx_de_emphasis:2; unsigned dis_metastability_quirk:1; + unsigned host_vbus_glitches:1; u16 imod_interval; }; @@ -1217,7 +1228,6 @@ struct dwc3 { #define INCRX_UNDEF_LENGTH_BURST_MODE 1 #define work_to_dwc(w) (container_of((w), struct dwc3, drd_work)) - /* -------------------------------------------------------------------------- */ struct dwc3_event_type {