From patchwork Fri Jan 19 21:31:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 764044 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2066.outbound.protection.outlook.com [40.107.104.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CF3C5789B; Fri, 19 Jan 2024 21:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705699910; cv=fail; b=Vrcwzi6aSiNBkke569aDnucywLPBvQSbnwqR7TcrgmRppPpohHZ85o6gub8mGMLdBivDKv2W+asN2GcC4fkhIz/H1fJ3sv/HnEPUe/G256fsiJK/APAYPs/gIOqWTAunuVlERapzUu1hZvkw8wpBI7aiNoOUeKw5/1keylYXWos= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705699910; c=relaxed/simple; bh=HraOdqhfdSQQK2n8bd3HC2Iaq09d3z8l9zFaFSY2TGk=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=Nx3gnYNYZMaMwcVbhXlbKAbncjqWEPDllop3jEyEhgQ7BGjITRncrBVxbvlZmv0iQ7MtGpIWuZGvFFTUQfd4YXA3/q+aQnnHieq4zG/sfB5kput1QfEcNxbRastaP/XKFomrn8oemGfSi9T3BeWFAFSRcTpObaUH7/lJuSEXXBE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=B1p7qjem; arc=fail smtp.client-ip=40.107.104.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="B1p7qjem" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JFA4/t6aPZLTp2Jk6HS2e94HcfHr5o068iYKyMUa1jjeY4X8qyTPn2K9kkipdOBkTH5HIcZwu0kgOBjCG7gYmKc54kM7SbEQLMbGPRN0sWCHHDpOOi0hPx1X4fh1QddwGTZ31IVt3YjWwMfX6yq7K7XNrvzmQRalSsbLWHM8EuHXl6F08nMWaydmvBY5Bpf6W+63o93N4ov7BRfPNL6wk+8UwRQIEtWj+7p+/1iMzseJhUX5O9bqVP8ZKS5vCeNuUFyFlWish5yzlb9E+fF1Dmu6SzBbUt8qcYL9Fev4xb1aBgRYtknv8ONoavLRWhEXKDUJmBkdxuH+9LjaxFubJw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aa5Yh+YstoUqdEz5JjT88gDzczrZHiAwy+c6tvds8+0=; b=TJYOwvJyys8+Z41fTl3tt39/BLr2kKUSW95p2rXpdXtO4dXTy/EzSQKCyUOdlaPVH12CDILTJSnKBKICxjqoJKEFpTeezECLpXle74cM/nWo5NqYxAW1idX97OQtxdCOMUjWguTkU6BNf4lOm9dxqS7z8ys5SeAD9mXAAYw3b22u5yW3wz6geq8r0VmNdxvc+UV9gFy3ksK3EM3xn7GKN0JaP2UzZKVHQsKP05TjEn/CFbyBfg9gO6R41VkpDu4GwKKlY3q5rTRUUaEFe5mXZh1di/TA6vMR8l24YxhiB+coRxKucEwXXRf/+XRX+EB6OSSzw5z4Y4wOUh8ES8fazQ== 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=aa5Yh+YstoUqdEz5JjT88gDzczrZHiAwy+c6tvds8+0=; b=B1p7qjem9TmReWEbk88aQJBHaxwW6IHC5ZXAFCHo0CGiJ6sZnYA2qFlLRpeikyZmRlGHeKuvgGgPw9JcmO6nK6TNWzybcRGW/twbSsc2rcOuTk1TbZqJLjU17QxERNQVd4ZTypoIAOSvHU2u0KXH3h+vPGtufURjOxpZNPBITYg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM9PR04MB8795.eurprd04.prod.outlook.com (2603:10a6:20b:40a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.27; Fri, 19 Jan 2024 21:31:46 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::b8af:bfe5:dffd:59a9]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::b8af:bfe5:dffd:59a9%4]) with mapi id 15.20.7202.027; Fri, 19 Jan 2024 21:31:46 +0000 From: Frank Li To: ran.wang_1@nxp.com, Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Felipe Balbi , linux-usb@vger.kernel.org (open list:USB SUBSYSTEM), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, pku.leo@gmail.com, sergei.shtylyov@cogentembedded.com Subject: [PATCH 1/2] dt-bindings: usb: dwc3: Add snps,host-vbus-glitches avoiding vbus glitch Date: Fri, 19 Jan 2024 16:31:28 -0500 Message-Id: <20240119213130.3147517-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BY3PR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:39b::21) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8795:EE_ X-MS-Office365-Filtering-Correlation-Id: 95461b46-c4f5-4104-3f14-08dc19360989 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: asVnvgT1Ofd6TLLiA6NgpTb2D437abZV6s2rLCaTtH0DqxY2qEqmNRBkXHtxQQ81Xyfw/V0kdqyQhtTR94LC3obah+TkInPcWP9NKCfYUGrb7ATn1mMIH4kt9PIdDQ4Iv41PZHHZJpr/w75yf5d1QYihHpcCoI14hqZxfo7BpnqbRqDXI/Yo8Ii/kRx8NAckccQFKfncMFSa5TWJJJFWEufwxx0yBH6Tww/4qtt/UfwnIJNA8zt9iWP4YbnerXoQfPgdR/fb5UOMzJFbFricNIqNE8jHY6yaShBnWBrTyn5+luz7QnIGmWsbJhzgJgUjMMr2PUMhWALrAJlT9ru1V4QD9YMKnuoR0kDSVRASBq5XZYyc6z0GOOxy5xtpKqgId1pujyez96NNurjl7oDqaUy3ThuzEhDhpePYC4/N5QUCEm81rOn7p9cv8iLqc3Du5Kd9H3jetuOTrdq76jp6fqnbtvN5QkdYdQjg+pVIO4jYgxYVAB0JxSlESQ8YQDeOmbQoTEqMQ3xJSXmOMlRt58CaaC3cp9AvJPfEEClxdRB5/L9AycogkaTAK4hsgerBoOUCSH9rbSsA0g0d26HU37zc12zLEDJc4u3BgtqlxwavSs7jE8zXSI/xI3qE6qUxxiYxZjnOfv74F+Gm/sKzSQ1O6RE9gC1PFbubPmKN5Ow= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9642.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(136003)(376002)(366004)(346002)(39860400002)(230173577357003)(230922051799003)(230273577357003)(64100799003)(1800799012)(186009)(451199024)(41300700001)(1076003)(5660300002)(38350700005)(7416002)(26005)(4326008)(8676002)(8936002)(2906002)(86362001)(83380400001)(478600001)(6506007)(52116002)(6512007)(66476007)(6666004)(2616005)(6486002)(36756003)(66556008)(66946007)(316002)(110136005)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5h4gkTXHljU05SmoEkNkkduxUJ/3Q8671mo8YfTUQvlCShEivXff7vKGUK9B54zBsmDtZsmIax5iPcURkX4sjSS07oHX8wHjTpA4oEwdVx94N3AH/Ldj5vV31jIdpy5OrwbgYyf1HN7UinTStpNB09KDE+xfkuK6/guB1tikaAjr4H+BVvThlMpx+LUN7OLO92kTOYxjvzDk5aT2Ue32l17slhmevM/p0QqlD4Dn6zfid+n8F/aUj8ey+fr9eEdZBwgKRjeBHpKDypyEuRM3pYZzT9ixZEwLb0OsiQdHLfD7YK5aXTPOPEJxhbTFMpn7unPxhrr7Pr4eAqnx244hhj2OPv5St6BcdnJiC+hW77/JAZiXQ4Fo66e1kXTuWgb0MSxdZes902tux2V7lQm2uHUAO0k4h9SCkMONHsqeg+dDB+gdrFvMIOfDlnqojTTwMvVa4NCiyXtBlT3oaas5bogAVgdiwGK3WFZrtPY6tIXpGG5yGgvmWBcAQNrrl9TP0CVqW6V+SyO2ZXtJ76xlXij0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p.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95461b46-c4f5-4104-3f14-08dc19360989 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 21:31:46.0982 (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: CA4UQADsDnXwhvA3+No1ZO4XQDkYtLQjYOXrPdEmKThgMWsyHiDMQ8A1QMNuYFC0f/Zo5CVILBrTQGcb+ODPSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8795 From: Ran Wang 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: Peter Chen Signed-off-by: Frank Li --- Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml index 203a1eb66691f..dbf272b76e0b5 100644 --- a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml +++ b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml @@ -273,6 +273,13 @@ properties: with an external supply. type: boolean + snps,host-vbus-glitches: + description: + When set, 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. + type: boolean + snps,is-utmi-l1-suspend: description: True when DWC3 asserts output signal utmi_l1_suspend_n, false when From patchwork Fri Jan 19 21:31:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 764865 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2066.outbound.protection.outlook.com [40.107.104.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 270AD58210; Fri, 19 Jan 2024 21:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705699913; cv=fail; b=mz61vg3zjKqw/DUo2O5bDF24xE3Qsi22PHqo9ZLG4yvgmZ+HGQvKk0+z6LPxOKzK4W1S7jc/9zfRkL0Z6k8IFLsIj03ngfik3Sq0aOp1E5ryvS4xu22aBAr7mP5ApGDEHt1EsgjdEKJaBAQhRGUTdfrI2Se/GNUo7pPjYLBNTCA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705699913; c=relaxed/simple; bh=sWn7eNJsv7QevaCwVtRZTZGoKX7P8VRhvgQ1e8fwVw0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=MMaZ5AvQKUrGG+iSlgSn8wA2dTw+7zjNupxHRDTT2rGMMsvvkolLVcvb8uAxzmhBkjFxKb6l3yGYyukxy7eh2XeviIcQOghYTWFWkT/aI3xHilqgwx/+4rB7gdPNyNL67yrZuJ4p9T2GMVtXSaqavbtekTyy/tkUhTDlIsVsZtw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=bU/eU2Sw; arc=fail smtp.client-ip=40.107.104.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="bU/eU2Sw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgOq/d/0xgI9Ddau4fXGVT0InMDMFyU8NQkLp+CJTiGtUqOIId7wik1fXqb251ef7f7Jt2m5jAOREeJHI0674oIRNIVR9ZAFZtl3XZEpaoKtS8VPZldaWQEeIUbZm21R97hfHnT7EDPrqt7qVovd7bkFTq5uzCFm8EXf9wKjQ8X2nOU70EXa3TzFBq7TaN5t6ZAEOFB70DmLLMoWflmnP3jytzNpljzwAsBboG+Lc+r84CZcxAfgXwd1qxEKHaMxPL+scRkPRzhzfBJSMqN1bJGjIxFWEWVkzhfHWbjlUJ47qApGbq81ChK0x5FbpbsbEyuaaD7yLcfRkT80qvSr2A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3fVOIiSbFLuzbmEiE10O7ufJbCdQqgHUs8529IcsgEM=; b=WCNwt/1ypMU0uG8DfIN9OPYfJ2WWzoiGtIvJpI5158ukQ5WBMGs14rJEN5S8kmTHVGQDUUbrg5Fn9sO91rH9Zr3/fpNL7ZjNA/xRznoqCK+9O1+pKn/IYNsp8veXbOXA/BNvuY5YNihZUOgmVgD7maOa19kG+HBjMO6XUiOuzsjaYs7pNJtJXiC5FO35GHMdHM1hxv8ewzVawMMxhUgyOHzmXP86HZnThmYfzB9uXPq6+Y+Zu3vCIbKMv6uG6N2JgRS0kr68kFm/DsnXsnz2ZH4+IVILJzk32QdZ27SXfk4GnQi9ZNe2SMnPITF27vHgSg/o1urNUwuzygz3KEuVwA== 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=3fVOIiSbFLuzbmEiE10O7ufJbCdQqgHUs8529IcsgEM=; b=bU/eU2SwgUbzhWgbwz2JyhX08EMP9QF859VufzKnSue+POYE7FG0e4QYNx+s+eYkEQze+0ILXHoj+XSVFe+xFY5q7ioJXEAIF7MvG4l1k6ce4Jv+rcs61NHCdH3UKlD+ySF1cu47pJh/DCBaNDtRT6wTGht8EweZy8V1QX1FKR8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM9PR04MB8795.eurprd04.prod.outlook.com (2603:10a6:20b:40a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.27; Fri, 19 Jan 2024 21:31:49 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::b8af:bfe5:dffd:59a9]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::b8af:bfe5:dffd:59a9%4]) with mapi id 15.20.7202.027; Fri, 19 Jan 2024 21:31:49 +0000 From: Frank Li To: ran.wang_1@nxp.com, Thinh Nguyen , Greg Kroah-Hartman , linux-usb@vger.kernel.org (open list:DESIGNWARE USB3 DRD IP DRIVER), linux-kernel@vger.kernel.org (open list) Cc: balbi@kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, pku.leo@gmail.com, robh+dt@kernel.org, sergei.shtylyov@cogentembedded.com Subject: [PATCH 2/2] usb: dwc3: Add workaround for host mode VBUS glitch when boot Date: Fri, 19 Jan 2024 16:31:29 -0500 Message-Id: <20240119213130.3147517-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240119213130.3147517-1-Frank.Li@nxp.com> References: <20240119213130.3147517-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:39b::21) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8795:EE_ X-MS-Office365-Filtering-Correlation-Id: 8aa251c2-5905-4676-28d5-08dc19360b98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: temKoJ2utQMN13ebSZ9qfcmwM2n82KmvAnwkRavLZrnhQiQPJARuqRz4HBseTSzRmpPScT4B+sPc4c5FJF0P7kyIJLgJYdoVPFe19XHoW6jBVJGhMPFwtndHaVVd0sZB25/hbPyH9RT9xyQSpZ2HN2izbV7b9KfCcj9WNHV4uqPN/MP9tUl2SzfolKD/iUWWizto5zhsAo+kBROWUmgBgn75AdHU9ctO2Hsy4JzHtva+raH40M//1x7U47z9kODfBl9kl4C3CYQ3lBYeM00JOM52ZckVzLPqrIVzPr/veTvTGimdAIyg5SYYGgAtMnATTRx3OggX1q9AXSKS0hTdEhonMlf1xj195hykn0UGWpPpkskPcBoynIqOd3VS9IUB7fs1XoF7KKOftR4HpsZoXVvbOtzfzz7XI6XnwKsmP9aH00w0nHlQuVnpFOflc06g30alb2qyUotaEVcT23y3Pik5TMOxVF0jMY51kaEj/PAgCmkab07vtMiYm1xoTB8YxqlhyTD3P6cryz2oeEAtzyIHRQa6CKEeoMzwlHlcEUL2cpdjDuu/qqk4jyGPOIG7knOrJYT3V51QhYVrHu14ig8hp4wXT9Ybu09R6T72Z/o= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9642.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(136003)(376002)(366004)(346002)(39860400002)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(41300700001)(1076003)(5660300002)(38350700005)(7416002)(26005)(4326008)(8676002)(8936002)(2906002)(86362001)(83380400001)(478600001)(6506007)(966005)(52116002)(45080400002)(6512007)(66476007)(6666004)(2616005)(6486002)(36756003)(66556008)(66946007)(316002)(110136005)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BH3DqpHaVc0e4N8LclasmiHmnDyKzbFs0Wn7ro0xrUly/+lX9ZREsvE5oErxIbOPaPEpsx0sG6IzfIBRPEbEcjdkS6bwtw1OiGHYmglGr3Q5xQrjRdkjhNErayf5aNIkIaSe/EHNfeOccDfy3Fh/mg/++bj9eqcJ/ZCpDJzYnbuTRXwMYbJeX7RXqemzE2RmOBxFv0UdhXNhFu46P9yWSsd18DZQyFB/TtaQNq3E86yLgaTLUnfHLphiat+PT3VNz4XzvWkhluG9UJ0jkSDl6tC9XdjG4dvXvryyODH3U4lIpXQMuvFROc7yLx0LIjqjAL+1NE/WNT5uXGKItaQfJIth4e9TJUSpei4sIRgW+8KBKk3tgl747cK0SvMGi0iz1quxXkDqIPinhjODjFgOgjlFA+wFXdEKo4q1OW8QBAO+cOfkW6X7Y8Doyifu9o1W9imz7yc6jiNEoAvOMoYOt5bSrxnPt6AdWSObGQvRy+zRY0s2z4X/G2bY5TDNCTk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g: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8aa251c2-5905-4676-28d5-08dc19360b98 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 21:31:49.5361 (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: Hmicvz5S5DZiGHZfM3dYc+urNTMsYiK13r14fXl+DbIN2wCSs4FAwVj08t+q+lyer0b3J0LwRCCe9a3HqPkUTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8795 From: Ran Wang 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 Reviewed-by: Peter Chen Signed-off-by: Frank Li --- Notes: Last review at June 06, 2019. Fixed all review comments and sent again. https://lore.kernel.org/linux-kernel/AM5PR0402MB2865979E26017BC5937DBBA5F1170@AM5PR0402MB2865.eurprd04.prod.outlook.com/ drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/host.c | 46 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3e55838c00014..a57adf0c11dd1 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1626,6 +1626,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) dwc->dis_split_quirk = device_property_read_bool(dev, "snps,dis-split-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 e3eea965e57bf..0269bacbbf6bd 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1135,6 +1135,7 @@ struct dwc3_scratchpad_array { * @dis_split_quirk: set to disable split boundary. * @wakeup_configured: set if the device is configured for remote wakeup. * @suspended: set to track suspend event due to U3/L2. + * @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. * @max_cfg_eps: current max number of IN eps used across all USB configs. @@ -1353,6 +1354,7 @@ struct dwc3 { unsigned tx_de_emphasis:2; unsigned dis_metastability_quirk:1; + unsigned host_vbus_glitches:1; unsigned dis_split_quirk:1; unsigned async_callbacks:1; diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 61f57fe5bb783..af8903ee37c20 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -11,6 +11,7 @@ #include #include +#include "../host/xhci.h" #include "core.h" static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc, @@ -28,6 +29,44 @@ static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc, dwc->xhci_resources[1].name = name; } +#define XHCI_HCSPARAMS1 0x4 +#define XHCI_PORTSC_BASE 0x400 + +/* + * dwc3_power_off_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"); +} + static int dwc3_host_get_irq(struct dwc3 *dwc) { struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); @@ -66,6 +105,13 @@ int dwc3_host_init(struct dwc3 *dwc) int ret, irq; int prop_idx = 0; + /* + * 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) + dwc3_power_off_all_roothub_ports(dwc); + irq = dwc3_host_get_irq(dwc); if (irq < 0) return irq;