From patchwork Wed Aug 21 03:18:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11105289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F10814DE for ; Wed, 21 Aug 2019 03:19:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12DD522DD6 for ; Wed, 21 Aug 2019 03:19:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Rwzv2UV7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727002AbfHUDTA (ORCPT ); Tue, 20 Aug 2019 23:19:00 -0400 Received: from mail-eopbgr140050.outbound.protection.outlook.com ([40.107.14.50]:47285 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726864AbfHUDTA (ORCPT ); Tue, 20 Aug 2019 23:19:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wv51SBkOZpfE+WeYTXDZW7I+UX2SeiJDfagI0n9mFPtpdYnLjyH3W2e1EmVQw5g8YkiRmNmGF++vZujK6WNncFNqTK/5lJ+4zr5/tNcoFTUtgc1Z4bEIsgqrGzZ5crrkgHSy0q2qeTIr02OlbvGudjrru/gnIBkgDH1yqLZcQNdCgbIhFL6XJRVfTCRmhg0WxJusevF82AMNPk1ofQSrlbKdV0Zd9U4BeUn0OtIyFhfzfz5DEZWGvpPJvEbkMrYN8Kon86hDIkbW/jSbho1TnKO69VJGX7kioA3oL/87i/WRIZ6WTmdfDNuMqxUCZ2b55sxcPJ79iMHfkrWRFfRLCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IPmdrKV5ttpe0GKfA+du2W5dAU7E/htG/7JVRusr+qM=; b=jva61E+95Er82f2VKyCRe3a0NSuDHiHySo/hp9S3fyRo9c+rEVzpyIJZXyTvEpT3gFC+HX9ob3J/u0FPkCg3fY965jPKVSHQqL4khrtFW6CEnRys1a8QyK3sy3FQJF6JwrZQQPYxXc+O6jQaQhqFcWtqzV82odAFGz0FF8QybkgGGdaAWIsAjCe+/RKAPRQoYf6UyzpYdVladDQHCDxthUkQ4yr98G+7elXIF4cEd1KQF2xGMUnsdYIudu2dySC5PEN2tJ6NWv26jreZMray24bfnnr1wG7uGDc9lsDjHyZkIyPmVJnoVBCpqYo0osXz1UyEN7srds4Sy7CXGFQiAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IPmdrKV5ttpe0GKfA+du2W5dAU7E/htG/7JVRusr+qM=; b=Rwzv2UV7WrSrfGOI9qMHpTYbqKpujm5SBGxROuukSyRPSxgEluhXSdIFTEuEzb0MiyeR2+e3cTiehL20TLjGO9FSuRbQl5a5ywTzmoDf9uKI3Uugyx68TCCryXypDVL3O1vgB5hGfVHS6nFn7WmWVL/1B+2fBwZQLYxxMlmyErE= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB3230.eurprd04.prod.outlook.com (10.170.227.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Wed, 21 Aug 2019 03:18:56 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::e039:172d:fe77:320a]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::e039:172d:fe77:320a%4]) with mapi id 15.20.2178.020; Wed, 21 Aug 2019 03:18:56 +0000 From: Peter Chen To: "mathias.nyman@intel.com" CC: "linux-usb@vger.kernel.org" , dl-linux-imx , Peter Chen Subject: [PATCH 1/1] usb: xhci: avoid VBus glitch during controller reset operation Thread-Topic: [PATCH 1/1] usb: xhci: avoid VBus glitch during controller reset operation Thread-Index: AQHVV88qu74WcWDk3UKcEVqZOYC8KQ== Date: Wed, 21 Aug 2019 03:18:56 +0000 Message-ID: <20190821031602.1030-1-peter.chen@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: HK0PR03CA0046.apcprd03.prod.outlook.com (2603:1096:203:2f::34) To VI1PR04MB5327.eurprd04.prod.outlook.com (2603:10a6:803:60::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peter.chen@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cc4270dd-bdd4-4ebb-5484-08d725e64cdd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:VI1PR04MB3230; x-ms-traffictypediagnostic: VI1PR04MB3230: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0136C1DDA4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(5660300002)(64756008)(4326008)(66946007)(25786009)(316002)(6512007)(486006)(476003)(2616005)(53936002)(8676002)(81156014)(5640700003)(50226002)(81166006)(44832011)(6486002)(2351001)(2501003)(36756003)(8936002)(386003)(478600001)(26005)(186003)(102836004)(3846002)(6116002)(1076003)(54906003)(6436002)(2906002)(86362001)(71200400001)(66446008)(6916009)(256004)(52116002)(7736002)(71190400001)(305945005)(6506007)(99286004)(14444005)(14454004)(66556008)(66476007)(66066001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB3230;H:VI1PR04MB5327.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: 6aQgEKeh1YhTK0YcXcmtNSzozch3VNp55viSZuZ22h9t5Fpo2tLe/p1MYbCU31Qy0vjEB2ElKXir6TgdsywCyQj4k7ACoJK4qrXKSQH9vxIZDtl7W7hxN+DLmaKdSvWzJh6BaNUrAkykdjsu4vrLmYVv75UNMJ0Yu7qDvJnMKRsXgDUg9urei8rO2GNTCgz7USBv2TpYxKUDTYcN3xuKocCRTMkEl9tBWJxYTB4icxXhduKBw/8sH0q9wa97PPKWurqPO2RMTIgLfT8WRBiDEw1bB4oNIggMRyy5xcFTzT+pXaZDLU+RwDZ05T651Yvg8xwih/Fzxdum55mrVBsrhV29UXUwQuv76aZ3+wWO/8k+c44hMdRu+7K9CwLgWAlrphiHvhyBOvbfVSPKfjiqCMRFlX2rc4Ekg3lEkawuxHY= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc4270dd-bdd4-4ebb-5484-08d725e64cdd X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Aug 2019 03:18:56.1032 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nLaFX7x2X995AOV6tV21zf5zGH2AwYoubl8ZXbYdTuqQFQc1aP4//FCTMnvhA6TtojynMwk/3Su6hoDCUcxQQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3230 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org According to xHCI 1.1 CH4.19.4 Port Power: While Chip Hardware Reset or HCRST is asserted, the value of PP is undefined. If the xHC supports power switches (PPC = ‘1’) then VBus may be deasserted during this time. PP (and VBus) shall be enabled immediately upon exiting the reset condition. The VBus glitch may cause some USB devices work abnormal, we observe it at NXP LS1012AFWRY/LS1043ARDB/LX2160AQDS/LS1088ARDB platforms. To avoid this Vbus glitch, we could set PP as 0 before HCRST, and the PP will back to 1 after HCRST according to spec. Reported-by: Ran Wang Signed-off-by: Peter Chen --- drivers/usb/host/xhci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6b34a573c3d9..f5a7b5d63031 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -167,7 +167,8 @@ int xhci_reset(struct xhci_hcd *xhci) { u32 command; u32 state; - int ret; + int ret, i; + u32 portsc; state = readl(&xhci->op_regs->status); @@ -181,6 +182,18 @@ int xhci_reset(struct xhci_hcd *xhci) return 0; } + /* + * Keep PORTSC.PP as 0 before HCRST to eliminate + * Vbus glitch, see CH 4.19.4. + */ + for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { + __le32 __iomem *port_addr = &xhci->op_regs->port_status_base + + NUM_PORT_REGS * i; + portsc = readl(port_addr); + portsc &= ~PORT_POWER; + writel(portsc, port_addr); + } + xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC"); command = readl(&xhci->op_regs->command); command |= CMD_RESET;