From patchwork Sun Jan 21 22:24:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 764819 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2065.outbound.protection.outlook.com [40.107.6.65]) (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 5BD5738F8B; Sun, 21 Jan 2024 22:24:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705875896; cv=fail; b=qJIeH2I13/PECOky9RPgqu78KybRISIY9y4vULEPjdZcRagGUvxrPXnff8XjnTyriJKi1ZbYRkQrjgUGWuV8IvW6KDTnbPv4LbPFAIBdSuION+mn5ATpf3qIxQAeFavOm5FZfLxkU/1YsZh7rSB4vuEKyZGakJTh0DyRsoWW67I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705875896; c=relaxed/simple; bh=QW8sn+VQ/3fwnaQ31eT8VGBdDK7MJ46DE1RzDubC/bI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TTs5Vum3xSXT3Q0o88M7efOOIGZgEE94YqN8OjHI6ecn3Ho/VtQ52EOxcoqM9lZdByBcqA+psemoLfXHouiMn+lqTT2DTLEfU+TnfKoeYs6TXePZNUum1hLXH42XQSUwO44irX7manXOV92+mutodbkK+LMgdRzCbo3DWE6ddfs= 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=IAhFx0Lb; arc=fail smtp.client-ip=40.107.6.65 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="IAhFx0Lb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UUevEvxZFOFWo/AROrn7E8A0FPFgliXkff3A3IM/dYozuq1VBoEwBSbSIPBTtIeMHwdjnp8d1GEJYmyjty4ofRgw5KJtcsfv8bDRk8DuP6polFTjuklp1lUVii1NIy5R8JApzL8APwV8r7ICjb54Mycdi1UXKorZ16LGgELTSZAN2rEjD9NnOv9NT0yX1aWdgkTgzdLjmbi5iqXCx0W0ZqFU/RAu6I2o1zqjVcTGG+aMzj0aueCS458NURWKQxTQC4WyjVS6lkm8uS7wlNIiU8hlvCjzuodNvswU45atMVdvTJPSOWWzgqjXexvlXXbbETQntUpEZbhDJ1JiNFEILg== 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=1kPmnKpcvuhnrqH1o3P/DoLtZPg2O4Dnl52Ecnuv6nI=; b=NJFR17XrfozuQ1SkP6rKrw3w4VZfLZLtho3/w0FVUTpy8LUp9cxxALnxCioxvY8W5R95XUS5PAdicnQcXHLnvN1Pr4WCvVU9SKVrU8psdK03rUCUlZiBGdalDqlYe5jpIEjuYg03jwO+wBpcV/d0c/hDSdGUwopRopoZjVsO3a/y9PNDhACY83no2Tlqm3mtDnkRoDOjwi7GFzrpZUWCkOU58NnaiK2iuUSj3FqVkJF3RCaiHgEDWUnR8VYYRgZBC21Ah/AH6/pZYIkix5dO6hpCXfIbrrjLdSirSDk3VmXvKoroTNXod9EDAVxyPzKPCk/hlAq4uMEMZgO4FL0QIg== 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=1kPmnKpcvuhnrqH1o3P/DoLtZPg2O4Dnl52Ecnuv6nI=; b=IAhFx0LbxfnJQ7n/oY6fvkNEDx54jfCMvP25fARz7hJDMZTm289jbmjctNoZ4z9PCLJmBX46j3vV7c3fkLuv5MbY0UoySWONWeH5P03N9aYN3aLRGue529sO5XPlaVG2a5w9OiBY70WBVVoid+fNiRSt/fkLahbzyZ6liTsWxkw= 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 PAXPR04MB9074.eurprd04.prod.outlook.com (2603:10a6:102:227::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.31; Sun, 21 Jan 2024 22:24:51 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7202.031; Sun, 21 Jan 2024 22:24:51 +0000 From: Frank Li To: frank.li@nxp.com, mathias.nyman@intel.com Cc: Thinh.Nguyen@synopsys.com, balbi@kernel.org, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, pku.leo@gmail.com, ran.wang_1@nxp.com, robh+dt@kernel.org, sergei.shtylyov@cogentembedded.com, imx@lists.linux.dev Subject: [PATCH v2 1/3] XHCI: Separate PORT and CAPs macros into dedicated file Date: Sun, 21 Jan 2024 17:24:26 -0500 Message-Id: <20240121222428.3396428-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121222428.3396428-1-Frank.Li@nxp.com> References: <20240121222428.3396428-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0063.namprd17.prod.outlook.com (2603:10b6:a03:167::40) 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_|PAXPR04MB9074:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d505675-c897-41c6-e6b5-08dc1acfc8c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Oc9BkcteUotmmCYk2fO8WHGU15Bi93B3zrK0Xn0O1S8MOK9MV5tNh34I5oGjLsB6+jz3e9n0li5OJlM2vNGXKxS4Ajd4ahK1BhLXrWN9Uf/anujubgVtqFkynu+vBbNjPFp+d6EkeyVGRODYd7WEwQN8vrTA5jhl4nYvOaasbVICwWuyCDJkstpb+44qSzOXqA1pic1bVqpAs9FlTXss+FYzFN27HBVZttw9gMw2SmQnrX+l5+mtksWoiFj2PYY35eCTAz8yfJUYVSoInEGA3f40RSvwoXlPOY7JW1xVZOQcvBdoBA+iRodp0Svj9xnq/fCqPtWpfIJ5isFLwj8fxDO0x/ZPruQrBXcc80ADb2qNRDx8vmVIAqAeEtTRW1n2UoTS3Q3K878s8pGNqvUXUx1Z/WvKAITTQKEj2X9Gx5ySQF05cHo/gUqyjafjhIFXzshheeAXoJIb+3wMRcsHvhtawJ7lQ34IfS6nGyQaxSj6xfLC0PDFEURlA0bNvE8LAR6tlzMJf1E/Qci7j2O1hnuqYCylmOfC4SVZrD87GDeYTbbNfKQFzxQMR1qximw2nX00LZ0m4BUKCZJUV1bskjuJKjlO8atK/C7KHBMXKL6P8movMlpNSU05pAlff319 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)(366004)(346002)(136003)(396003)(39860400002)(376002)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(86362001)(8936002)(4326008)(8676002)(316002)(66556008)(66476007)(66946007)(36756003)(5660300002)(6506007)(6486002)(2906002)(41300700001)(52116002)(30864003)(7416002)(38100700002)(38350700005)(83380400001)(66574015)(26005)(1076003)(2616005)(6512007)(6666004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YxqSJgFiXfD21RwmnrBMgQIY/03ZZMcQSprY11bqxHdgK587dGrJnNMhbLt0yhg3E1ytBw0VslI4Cd6coBZkVJ0CM/bXYsiPkHq8kySb3LWHbOdqUjiRKN5h5MAZPBw0olYWq0crVQpIVv5fPtA6Xaw70wMAinJ8j4dwX03mqRjZiIxcnlJkE0bHKSllusN9wDKvTHDceW2vJfRYuBXLDdlvJEI8KYK7xCucSzB53kAv3eMKGBN6E3oAxdL5MRjM49jy4mQgvLgnwPiEH438zd8c0ErJh65B8e1hVGR8tTYVzaFGnSjhtzq4Zhvz/CI8LZWEz2nudocaDvlA27+96JDGFa5g3iLGew3EZgwP34yRhKM2Vj1g8nv13yW8cVYHd4kQ0gfd0QZCwIHHatKzLQSqdlk2I8lK2E75iqYvOjjdbE7U/Am+hW8vZ3coA8Nsz5JVKS2N1/0zJUrlQQmrNc7sKh2lSCj7goVDoGDBO2tHQ93ebT7lbV+s9BhDJIj9wJPecOaQa6S7Mdi63AesRhUVxLFkBlMPasdPxKDAYpF3tFFpuboAvO6SWpwo2CKk2/oUwQvvLe3owPiiNhZWBV0hYsNAZqppBTRArxaexeQwRYcnUIbzwjtm6sMrBnBXxyIv6hO3i3wnRFD3CiwXJ326fageak1G9n4H0wc2q+fKEnYE6eqN5oJZhtQ4ISEz/jxy4Oy9VVva3uWo4/XXKH1P7895FfciTJMi26/HOg9QD5j6bEM0oLwQ2H5osmutYkBItBV8fvW+g4BHookXojWZiGMI+huGNdGINYQAOSzo8aQPmga8DO2fGZ2LlIKEI5zfUhlj06s4zinTB93C0sCWukT6sWCdUfw865/pOi5b/rRcUUvm7DuRTeKrictfkbO81+yHUxQzKOwjLYej1Yl0vagYs0bUYXa8AnQLdB6xe1E3VMEmMCu2Hb1lBWC6T/mUfwvCA1RmO/0rD4pYibu5x4lZztGZoTE6eJ/B4B5pkJuxqmckS5R55n2hvMjpYb20Mb3DzqL7t0LLXajQgjcPmbnrFtFLCokTLGLvqol1Y+/FQi7OkZv0tpNoejDsUIiQDzODC/c0oFtvfjHvf27xWTbNRo6Xf8G6OPsKyZmKH5kLugFkTmvM//lPuCRkSlDYmukNqJ2SHlXnoZ845lSTvSYLQs/GgEW+FT0jlHzCgwsYIStXB75ZmVDkmPEqC0pSTnLVN7TMJNayXyFD5ighZfI/un3SrEGUNNurnBM2X5EtoXpx3VkRtIy3nhcf3+DTnl1Kdqjc56JUPNqh03feMHu1t1SBknxtP0M+PEyAS/ZplwQ6+6h80cKgW/0Torv7hrkZja/a54K/Pw/GHqsrJfuhS9e2ZnLTsPv7Gn85tFve/ZwVE8TpnA3FylBCVvNQCkW7JpaZtTKa+PnQMtdJLlzRCNCF6BJ3T2J73ApZhb23dSoGUfiMPHkvFqDFU6fUuGutryM1Xa2JR4ezvhHboWvcckw+OuxF7nyturxo2q4qcfzKZmcQ6Ecuu5mSbHChWy9KffqZGJ/BJENcXIsYGtUiT5XgFKTMbdAUv5E= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d505675-c897-41c6-e6b5-08dc1acfc8c9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2024 22:24:51.2400 (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: XF0Ov87PKSMYQM5b1uP3SuiUNsuKNdtnnETpiGHxSPRRQyw+wxwd+84rIFWnc+UZguOC1+NHJRvdg2MRWrSUEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9074 Split the PORT and CAPs macro definitions into a separate file to facilitate sharing with other files without the need to include the entire xhci.h. Signed-off-by: Frank Li --- drivers/usb/host/xhci-caps.h | 85 ++++++++++++ drivers/usb/host/xhci-port.h | 176 +++++++++++++++++++++++ drivers/usb/host/xhci.h | 262 +---------------------------------- 3 files changed, 264 insertions(+), 259 deletions(-) create mode 100644 drivers/usb/host/xhci-caps.h create mode 100644 drivers/usb/host/xhci-port.h diff --git a/drivers/usb/host/xhci-caps.h b/drivers/usb/host/xhci-caps.h new file mode 100644 index 0000000000000..9e94cebf4a56d --- /dev/null +++ b/drivers/usb/host/xhci-caps.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* hc_capbase bitmasks */ +/* bits 7:0 - how long is the Capabilities register */ +#define HC_LENGTH(p) XHCI_HC_LENGTH(p) +/* bits 31:16 */ +#define HC_VERSION(p) (((p) >> 16) & 0xffff) + +/* HCSPARAMS1 - hcs_params1 - bitmasks */ +/* bits 0:7, Max Device Slots */ +#define HCS_MAX_SLOTS(p) (((p) >> 0) & 0xff) +#define HCS_SLOTS_MASK 0xff +/* bits 8:18, Max Interrupters */ +#define HCS_MAX_INTRS(p) (((p) >> 8) & 0x7ff) +/* bits 24:31, Max Ports - max value is 0x7F = 127 ports */ +#define HCS_MAX_PORTS(p) (((p) >> 24) & 0x7f) + +/* HCSPARAMS2 - hcs_params2 - bitmasks */ +/* bits 0:3, frames or uframes that SW needs to queue transactions + * ahead of the HW to meet periodic deadlines */ +#define HCS_IST(p) (((p) >> 0) & 0xf) +/* bits 4:7, max number of Event Ring segments */ +#define HCS_ERST_MAX(p) (((p) >> 4) & 0xf) +/* bits 21:25 Hi 5 bits of Scratchpad buffers SW must allocate for the HW */ +/* bit 26 Scratchpad restore - for save/restore HW state - not used yet */ +/* bits 27:31 Lo 5 bits of Scratchpad buffers SW must allocate for the HW */ +#define HCS_MAX_SCRATCHPAD(p) ((((p) >> 16) & 0x3e0) | (((p) >> 27) & 0x1f)) + +/* HCSPARAMS3 - hcs_params3 - bitmasks */ +/* bits 0:7, Max U1 to U0 latency for the roothub ports */ +#define HCS_U1_LATENCY(p) (((p) >> 0) & 0xff) +/* bits 16:31, Max U2 to U0 latency for the roothub ports */ +#define HCS_U2_LATENCY(p) (((p) >> 16) & 0xffff) + +/* HCCPARAMS - hcc_params - bitmasks */ +/* true: HC can use 64-bit address pointers */ +#define HCC_64BIT_ADDR(p) ((p) & (1 << 0)) +/* true: HC can do bandwidth negotiation */ +#define HCC_BANDWIDTH_NEG(p) ((p) & (1 << 1)) +/* true: HC uses 64-byte Device Context structures + * FIXME 64-byte context structures aren't supported yet. + */ +#define HCC_64BYTE_CONTEXT(p) ((p) & (1 << 2)) +/* true: HC has port power switches */ +#define HCC_PPC(p) ((p) & (1 << 3)) +/* true: HC has port indicators */ +#define HCS_INDICATOR(p) ((p) & (1 << 4)) +/* true: HC has Light HC Reset Capability */ +#define HCC_LIGHT_RESET(p) ((p) & (1 << 5)) +/* true: HC supports latency tolerance messaging */ +#define HCC_LTC(p) ((p) & (1 << 6)) +/* true: no secondary Stream ID Support */ +#define HCC_NSS(p) ((p) & (1 << 7)) +/* true: HC supports Stopped - Short Packet */ +#define HCC_SPC(p) ((p) & (1 << 9)) +/* true: HC has Contiguous Frame ID Capability */ +#define HCC_CFC(p) ((p) & (1 << 11)) +/* Max size for Primary Stream Arrays - 2^(n+1), where n is bits 12:15 */ +#define HCC_MAX_PSA(p) (1 << ((((p) >> 12) & 0xf) + 1)) +/* Extended Capabilities pointer from PCI base - section 5.3.6 */ +#define HCC_EXT_CAPS(p) XHCI_HCC_EXT_CAPS(p) + +#define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) + +/* db_off bitmask - bits 0:1 reserved */ +#define DBOFF_MASK (~0x3) + +/* run_regs_off bitmask - bits 0:4 reserved */ +#define RTSOFF_MASK (~0x1f) + +/* HCCPARAMS2 - hcc_params2 - bitmasks */ +/* true: HC supports U3 entry Capability */ +#define HCC2_U3C(p) ((p) & (1 << 0)) +/* true: HC supports Configure endpoint command Max exit latency too large */ +#define HCC2_CMC(p) ((p) & (1 << 1)) +/* true: HC supports Force Save context Capability */ +#define HCC2_FSC(p) ((p) & (1 << 2)) +/* true: HC supports Compliance Transition Capability */ +#define HCC2_CTC(p) ((p) & (1 << 3)) +/* true: HC support Large ESIT payload Capability > 48k */ +#define HCC2_LEC(p) ((p) & (1 << 4)) +/* true: HC support Configuration Information Capability */ +#define HCC2_CIC(p) ((p) & (1 << 5)) +/* true: HC support Extended TBC Capability, Isoc burst count > 65535 */ +#define HCC2_ETC(p) ((p) & (1 << 6)) diff --git a/drivers/usb/host/xhci-port.h b/drivers/usb/host/xhci-port.h new file mode 100644 index 0000000000000..f19efb966d180 --- /dev/null +++ b/drivers/usb/host/xhci-port.h @@ -0,0 +1,176 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* PORTSC - Port Status and Control Register - port_status_base bitmasks */ +/* true: device connected */ +#define PORT_CONNECT (1 << 0) +/* true: port enabled */ +#define PORT_PE (1 << 1) +/* bit 2 reserved and zeroed */ +/* true: port has an over-current condition */ +#define PORT_OC (1 << 3) +/* true: port reset signaling asserted */ +#define PORT_RESET (1 << 4) +/* Port Link State - bits 5:8 + * A read gives the current link PM state of the port, + * a write with Link State Write Strobe set sets the link state. + */ +#define PORT_PLS_MASK (0xf << 5) +#define XDEV_U0 (0x0 << 5) +#define XDEV_U1 (0x1 << 5) +#define XDEV_U2 (0x2 << 5) +#define XDEV_U3 (0x3 << 5) +#define XDEV_DISABLED (0x4 << 5) +#define XDEV_RXDETECT (0x5 << 5) +#define XDEV_INACTIVE (0x6 << 5) +#define XDEV_POLLING (0x7 << 5) +#define XDEV_RECOVERY (0x8 << 5) +#define XDEV_HOT_RESET (0x9 << 5) +#define XDEV_COMP_MODE (0xa << 5) +#define XDEV_TEST_MODE (0xb << 5) +#define XDEV_RESUME (0xf << 5) + +/* true: port has power (see HCC_PPC) */ +#define PORT_POWER (1 << 9) +/* bits 10:13 indicate device speed: + * 0 - undefined speed - port hasn't be initialized by a reset yet + * 1 - full speed + * 2 - low speed + * 3 - high speed + * 4 - super speed + * 5-15 reserved + */ +#define DEV_SPEED_MASK (0xf << 10) +#define XDEV_FS (0x1 << 10) +#define XDEV_LS (0x2 << 10) +#define XDEV_HS (0x3 << 10) +#define XDEV_SS (0x4 << 10) +#define XDEV_SSP (0x5 << 10) +#define DEV_UNDEFSPEED(p) (((p) & DEV_SPEED_MASK) == (0x0<<10)) +#define DEV_FULLSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_FS) +#define DEV_LOWSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_LS) +#define DEV_HIGHSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_HS) +#define DEV_SUPERSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_SS) +#define DEV_SUPERSPEEDPLUS(p) (((p) & DEV_SPEED_MASK) == XDEV_SSP) +#define DEV_SUPERSPEED_ANY(p) (((p) & DEV_SPEED_MASK) >= XDEV_SS) +#define DEV_PORT_SPEED(p) (((p) >> 10) & 0x0f) + +/* Bits 20:23 in the Slot Context are the speed for the device */ +#define SLOT_SPEED_FS (XDEV_FS << 10) +#define SLOT_SPEED_LS (XDEV_LS << 10) +#define SLOT_SPEED_HS (XDEV_HS << 10) +#define SLOT_SPEED_SS (XDEV_SS << 10) +#define SLOT_SPEED_SSP (XDEV_SSP << 10) +/* Port Indicator Control */ +#define PORT_LED_OFF (0 << 14) +#define PORT_LED_AMBER (1 << 14) +#define PORT_LED_GREEN (2 << 14) +#define PORT_LED_MASK (3 << 14) +/* Port Link State Write Strobe - set this when changing link state */ +#define PORT_LINK_STROBE (1 << 16) +/* true: connect status change */ +#define PORT_CSC (1 << 17) +/* true: port enable change */ +#define PORT_PEC (1 << 18) +/* true: warm reset for a USB 3.0 device is done. A "hot" reset puts the port + * into an enabled state, and the device into the default state. A "warm" reset + * also resets the link, forcing the device through the link training sequence. + * SW can also look at the Port Reset register to see when warm reset is done. + */ +#define PORT_WRC (1 << 19) +/* true: over-current change */ +#define PORT_OCC (1 << 20) +/* true: reset change - 1 to 0 transition of PORT_RESET */ +#define PORT_RC (1 << 21) +/* port link status change - set on some port link state transitions: + * Transition Reason + * ------------------------------------------------------------------------------ + * - U3 to Resume Wakeup signaling from a device + * - Resume to Recovery to U0 USB 3.0 device resume + * - Resume to U0 USB 2.0 device resume + * - U3 to Recovery to U0 Software resume of USB 3.0 device complete + * - U3 to U0 Software resume of USB 2.0 device complete + * - U2 to U0 L1 resume of USB 2.1 device complete + * - U0 to U0 (???) L1 entry rejection by USB 2.1 device + * - U0 to disabled L1 entry error with USB 2.1 device + * - Any state to inactive Error on USB 3.0 port + */ +#define PORT_PLC (1 << 22) +/* port configure error change - port failed to configure its link partner */ +#define PORT_CEC (1 << 23) +#define PORT_CHANGE_MASK (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \ + PORT_RC | PORT_PLC | PORT_CEC) + + +/* Cold Attach Status - xHC can set this bit to report device attached during + * Sx state. Warm port reset should be perfomed to clear this bit and move port + * to connected state. + */ +#define PORT_CAS (1 << 24) +/* wake on connect (enable) */ +#define PORT_WKCONN_E (1 << 25) +/* wake on disconnect (enable) */ +#define PORT_WKDISC_E (1 << 26) +/* wake on over-current (enable) */ +#define PORT_WKOC_E (1 << 27) +/* bits 28:29 reserved */ +/* true: device is non-removable - for USB 3.0 roothub emulation */ +#define PORT_DEV_REMOVE (1 << 30) +/* Initiate a warm port reset - complete when PORT_WRC is '1' */ +#define PORT_WR (1 << 31) + +/* We mark duplicate entries with -1 */ +#define DUPLICATE_ENTRY ((u8)(-1)) + +/* Port Power Management Status and Control - port_power_base bitmasks */ +/* Inactivity timer value for transitions into U1, in microseconds. + * Timeout can be up to 127us. 0xFF means an infinite timeout. + */ +#define PORT_U1_TIMEOUT(p) ((p) & 0xff) +#define PORT_U1_TIMEOUT_MASK 0xff +/* Inactivity timer value for transitions into U2 */ +#define PORT_U2_TIMEOUT(p) (((p) & 0xff) << 8) +#define PORT_U2_TIMEOUT_MASK (0xff << 8) +/* Bits 24:31 for port testing */ + +/* USB2 Protocol PORTSPMSC */ +#define PORT_L1S_MASK 7 +#define PORT_L1S_SUCCESS 1 +#define PORT_RWE (1 << 3) +#define PORT_HIRD(p) (((p) & 0xf) << 4) +#define PORT_HIRD_MASK (0xf << 4) +#define PORT_L1DS_MASK (0xff << 8) +#define PORT_L1DS(p) (((p) & 0xff) << 8) +#define PORT_HLE (1 << 16) +#define PORT_TEST_MODE_SHIFT 28 + +/* USB3 Protocol PORTLI Port Link Information */ +#define PORT_RX_LANES(p) (((p) >> 16) & 0xf) +#define PORT_TX_LANES(p) (((p) >> 20) & 0xf) + +/* USB2 Protocol PORTHLPMC */ +#define PORT_HIRDM(p)((p) & 3) +#define PORT_L1_TIMEOUT(p)(((p) & 0xff) << 2) +#define PORT_BESLD(p)(((p) & 0xf) << 10) + +/* use 512 microseconds as USB2 LPM L1 default timeout. */ +#define XHCI_L1_TIMEOUT 512 + +/* Set default HIRD/BESL value to 4 (350/400us) for USB2 L1 LPM resume latency. + * Safe to use with mixed HIRD and BESL systems (host and device) and is used + * by other operating systems. + * + * XHCI 1.0 errata 8/14/12 Table 13 notes: + * "Software should choose xHC BESL/BESLD field values that do not violate a + * device's resume latency requirements, + * e.g. not program values > '4' if BLC = '1' and a HIRD device is attached, + * or not program values < '4' if BLC = '0' and a BESL device is attached. + */ +#define XHCI_DEFAULT_BESL 4 + +/* + * USB3 specification define a 360ms tPollingLFPSTiemout for USB3 ports + * to complete link training. usually link trainig completes much faster + * so check status 10 times with 36ms sleep in places we need to wait for + * polling to complete. + */ +#define XHCI_PORT_POLLING_LFPS_TIME 36 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index a5c72a634e6a9..c6349e7e1e957 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -22,6 +22,9 @@ #include "xhci-ext-caps.h" #include "pci-quirks.h" +#include "xhci-port.h" +#include "xhci-caps.h" + /* max buffer size for trace and debug messages */ #define XHCI_MSG_MAX 500 @@ -62,90 +65,6 @@ struct xhci_cap_regs { /* Reserved up to (CAPLENGTH - 0x1C) */ }; -/* hc_capbase bitmasks */ -/* bits 7:0 - how long is the Capabilities register */ -#define HC_LENGTH(p) XHCI_HC_LENGTH(p) -/* bits 31:16 */ -#define HC_VERSION(p) (((p) >> 16) & 0xffff) - -/* HCSPARAMS1 - hcs_params1 - bitmasks */ -/* bits 0:7, Max Device Slots */ -#define HCS_MAX_SLOTS(p) (((p) >> 0) & 0xff) -#define HCS_SLOTS_MASK 0xff -/* bits 8:18, Max Interrupters */ -#define HCS_MAX_INTRS(p) (((p) >> 8) & 0x7ff) -/* bits 24:31, Max Ports - max value is 0x7F = 127 ports */ -#define HCS_MAX_PORTS(p) (((p) >> 24) & 0x7f) - -/* HCSPARAMS2 - hcs_params2 - bitmasks */ -/* bits 0:3, frames or uframes that SW needs to queue transactions - * ahead of the HW to meet periodic deadlines */ -#define HCS_IST(p) (((p) >> 0) & 0xf) -/* bits 4:7, max number of Event Ring segments */ -#define HCS_ERST_MAX(p) (((p) >> 4) & 0xf) -/* bits 21:25 Hi 5 bits of Scratchpad buffers SW must allocate for the HW */ -/* bit 26 Scratchpad restore - for save/restore HW state - not used yet */ -/* bits 27:31 Lo 5 bits of Scratchpad buffers SW must allocate for the HW */ -#define HCS_MAX_SCRATCHPAD(p) ((((p) >> 16) & 0x3e0) | (((p) >> 27) & 0x1f)) - -/* HCSPARAMS3 - hcs_params3 - bitmasks */ -/* bits 0:7, Max U1 to U0 latency for the roothub ports */ -#define HCS_U1_LATENCY(p) (((p) >> 0) & 0xff) -/* bits 16:31, Max U2 to U0 latency for the roothub ports */ -#define HCS_U2_LATENCY(p) (((p) >> 16) & 0xffff) - -/* HCCPARAMS - hcc_params - bitmasks */ -/* true: HC can use 64-bit address pointers */ -#define HCC_64BIT_ADDR(p) ((p) & (1 << 0)) -/* true: HC can do bandwidth negotiation */ -#define HCC_BANDWIDTH_NEG(p) ((p) & (1 << 1)) -/* true: HC uses 64-byte Device Context structures - * FIXME 64-byte context structures aren't supported yet. - */ -#define HCC_64BYTE_CONTEXT(p) ((p) & (1 << 2)) -/* true: HC has port power switches */ -#define HCC_PPC(p) ((p) & (1 << 3)) -/* true: HC has port indicators */ -#define HCS_INDICATOR(p) ((p) & (1 << 4)) -/* true: HC has Light HC Reset Capability */ -#define HCC_LIGHT_RESET(p) ((p) & (1 << 5)) -/* true: HC supports latency tolerance messaging */ -#define HCC_LTC(p) ((p) & (1 << 6)) -/* true: no secondary Stream ID Support */ -#define HCC_NSS(p) ((p) & (1 << 7)) -/* true: HC supports Stopped - Short Packet */ -#define HCC_SPC(p) ((p) & (1 << 9)) -/* true: HC has Contiguous Frame ID Capability */ -#define HCC_CFC(p) ((p) & (1 << 11)) -/* Max size for Primary Stream Arrays - 2^(n+1), where n is bits 12:15 */ -#define HCC_MAX_PSA(p) (1 << ((((p) >> 12) & 0xf) + 1)) -/* Extended Capabilities pointer from PCI base - section 5.3.6 */ -#define HCC_EXT_CAPS(p) XHCI_HCC_EXT_CAPS(p) - -#define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) - -/* db_off bitmask - bits 0:1 reserved */ -#define DBOFF_MASK (~0x3) - -/* run_regs_off bitmask - bits 0:4 reserved */ -#define RTSOFF_MASK (~0x1f) - -/* HCCPARAMS2 - hcc_params2 - bitmasks */ -/* true: HC supports U3 entry Capability */ -#define HCC2_U3C(p) ((p) & (1 << 0)) -/* true: HC supports Configure endpoint command Max exit latency too large */ -#define HCC2_CMC(p) ((p) & (1 << 1)) -/* true: HC supports Force Save context Capability */ -#define HCC2_FSC(p) ((p) & (1 << 2)) -/* true: HC supports Compliance Transition Capability */ -#define HCC2_CTC(p) ((p) & (1 << 3)) -/* true: HC support Large ESIT payload Capability > 48k */ -#define HCC2_LEC(p) ((p) & (1 << 4)) -/* true: HC support Configuration Information Capability */ -#define HCC2_CIC(p) ((p) & (1 << 5)) -/* true: HC support Extended TBC Capability, Isoc burst count > 65535 */ -#define HCC2_ETC(p) ((p) & (1 << 6)) - /* Number of registers per port */ #define NUM_PORT_REGS 4 @@ -291,181 +210,6 @@ struct xhci_op_regs { #define CONFIG_CIE (1 << 9) /* bits 10:31 - reserved and should be preserved */ -/* PORTSC - Port Status and Control Register - port_status_base bitmasks */ -/* true: device connected */ -#define PORT_CONNECT (1 << 0) -/* true: port enabled */ -#define PORT_PE (1 << 1) -/* bit 2 reserved and zeroed */ -/* true: port has an over-current condition */ -#define PORT_OC (1 << 3) -/* true: port reset signaling asserted */ -#define PORT_RESET (1 << 4) -/* Port Link State - bits 5:8 - * A read gives the current link PM state of the port, - * a write with Link State Write Strobe set sets the link state. - */ -#define PORT_PLS_MASK (0xf << 5) -#define XDEV_U0 (0x0 << 5) -#define XDEV_U1 (0x1 << 5) -#define XDEV_U2 (0x2 << 5) -#define XDEV_U3 (0x3 << 5) -#define XDEV_DISABLED (0x4 << 5) -#define XDEV_RXDETECT (0x5 << 5) -#define XDEV_INACTIVE (0x6 << 5) -#define XDEV_POLLING (0x7 << 5) -#define XDEV_RECOVERY (0x8 << 5) -#define XDEV_HOT_RESET (0x9 << 5) -#define XDEV_COMP_MODE (0xa << 5) -#define XDEV_TEST_MODE (0xb << 5) -#define XDEV_RESUME (0xf << 5) - -/* true: port has power (see HCC_PPC) */ -#define PORT_POWER (1 << 9) -/* bits 10:13 indicate device speed: - * 0 - undefined speed - port hasn't be initialized by a reset yet - * 1 - full speed - * 2 - low speed - * 3 - high speed - * 4 - super speed - * 5-15 reserved - */ -#define DEV_SPEED_MASK (0xf << 10) -#define XDEV_FS (0x1 << 10) -#define XDEV_LS (0x2 << 10) -#define XDEV_HS (0x3 << 10) -#define XDEV_SS (0x4 << 10) -#define XDEV_SSP (0x5 << 10) -#define DEV_UNDEFSPEED(p) (((p) & DEV_SPEED_MASK) == (0x0<<10)) -#define DEV_FULLSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_FS) -#define DEV_LOWSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_LS) -#define DEV_HIGHSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_HS) -#define DEV_SUPERSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_SS) -#define DEV_SUPERSPEEDPLUS(p) (((p) & DEV_SPEED_MASK) == XDEV_SSP) -#define DEV_SUPERSPEED_ANY(p) (((p) & DEV_SPEED_MASK) >= XDEV_SS) -#define DEV_PORT_SPEED(p) (((p) >> 10) & 0x0f) - -/* Bits 20:23 in the Slot Context are the speed for the device */ -#define SLOT_SPEED_FS (XDEV_FS << 10) -#define SLOT_SPEED_LS (XDEV_LS << 10) -#define SLOT_SPEED_HS (XDEV_HS << 10) -#define SLOT_SPEED_SS (XDEV_SS << 10) -#define SLOT_SPEED_SSP (XDEV_SSP << 10) -/* Port Indicator Control */ -#define PORT_LED_OFF (0 << 14) -#define PORT_LED_AMBER (1 << 14) -#define PORT_LED_GREEN (2 << 14) -#define PORT_LED_MASK (3 << 14) -/* Port Link State Write Strobe - set this when changing link state */ -#define PORT_LINK_STROBE (1 << 16) -/* true: connect status change */ -#define PORT_CSC (1 << 17) -/* true: port enable change */ -#define PORT_PEC (1 << 18) -/* true: warm reset for a USB 3.0 device is done. A "hot" reset puts the port - * into an enabled state, and the device into the default state. A "warm" reset - * also resets the link, forcing the device through the link training sequence. - * SW can also look at the Port Reset register to see when warm reset is done. - */ -#define PORT_WRC (1 << 19) -/* true: over-current change */ -#define PORT_OCC (1 << 20) -/* true: reset change - 1 to 0 transition of PORT_RESET */ -#define PORT_RC (1 << 21) -/* port link status change - set on some port link state transitions: - * Transition Reason - * ------------------------------------------------------------------------------ - * - U3 to Resume Wakeup signaling from a device - * - Resume to Recovery to U0 USB 3.0 device resume - * - Resume to U0 USB 2.0 device resume - * - U3 to Recovery to U0 Software resume of USB 3.0 device complete - * - U3 to U0 Software resume of USB 2.0 device complete - * - U2 to U0 L1 resume of USB 2.1 device complete - * - U0 to U0 (???) L1 entry rejection by USB 2.1 device - * - U0 to disabled L1 entry error with USB 2.1 device - * - Any state to inactive Error on USB 3.0 port - */ -#define PORT_PLC (1 << 22) -/* port configure error change - port failed to configure its link partner */ -#define PORT_CEC (1 << 23) -#define PORT_CHANGE_MASK (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \ - PORT_RC | PORT_PLC | PORT_CEC) - - -/* Cold Attach Status - xHC can set this bit to report device attached during - * Sx state. Warm port reset should be perfomed to clear this bit and move port - * to connected state. - */ -#define PORT_CAS (1 << 24) -/* wake on connect (enable) */ -#define PORT_WKCONN_E (1 << 25) -/* wake on disconnect (enable) */ -#define PORT_WKDISC_E (1 << 26) -/* wake on over-current (enable) */ -#define PORT_WKOC_E (1 << 27) -/* bits 28:29 reserved */ -/* true: device is non-removable - for USB 3.0 roothub emulation */ -#define PORT_DEV_REMOVE (1 << 30) -/* Initiate a warm port reset - complete when PORT_WRC is '1' */ -#define PORT_WR (1 << 31) - -/* We mark duplicate entries with -1 */ -#define DUPLICATE_ENTRY ((u8)(-1)) - -/* Port Power Management Status and Control - port_power_base bitmasks */ -/* Inactivity timer value for transitions into U1, in microseconds. - * Timeout can be up to 127us. 0xFF means an infinite timeout. - */ -#define PORT_U1_TIMEOUT(p) ((p) & 0xff) -#define PORT_U1_TIMEOUT_MASK 0xff -/* Inactivity timer value for transitions into U2 */ -#define PORT_U2_TIMEOUT(p) (((p) & 0xff) << 8) -#define PORT_U2_TIMEOUT_MASK (0xff << 8) -/* Bits 24:31 for port testing */ - -/* USB2 Protocol PORTSPMSC */ -#define PORT_L1S_MASK 7 -#define PORT_L1S_SUCCESS 1 -#define PORT_RWE (1 << 3) -#define PORT_HIRD(p) (((p) & 0xf) << 4) -#define PORT_HIRD_MASK (0xf << 4) -#define PORT_L1DS_MASK (0xff << 8) -#define PORT_L1DS(p) (((p) & 0xff) << 8) -#define PORT_HLE (1 << 16) -#define PORT_TEST_MODE_SHIFT 28 - -/* USB3 Protocol PORTLI Port Link Information */ -#define PORT_RX_LANES(p) (((p) >> 16) & 0xf) -#define PORT_TX_LANES(p) (((p) >> 20) & 0xf) - -/* USB2 Protocol PORTHLPMC */ -#define PORT_HIRDM(p)((p) & 3) -#define PORT_L1_TIMEOUT(p)(((p) & 0xff) << 2) -#define PORT_BESLD(p)(((p) & 0xf) << 10) - -/* use 512 microseconds as USB2 LPM L1 default timeout. */ -#define XHCI_L1_TIMEOUT 512 - -/* Set default HIRD/BESL value to 4 (350/400us) for USB2 L1 LPM resume latency. - * Safe to use with mixed HIRD and BESL systems (host and device) and is used - * by other operating systems. - * - * XHCI 1.0 errata 8/14/12 Table 13 notes: - * "Software should choose xHC BESL/BESLD field values that do not violate a - * device's resume latency requirements, - * e.g. not program values > '4' if BLC = '1' and a HIRD device is attached, - * or not program values < '4' if BLC = '0' and a BESL device is attached. - */ -#define XHCI_DEFAULT_BESL 4 - -/* - * USB3 specification define a 360ms tPollingLFPSTiemout for USB3 ports - * to complete link training. usually link trainig completes much faster - * so check status 10 times with 36ms sleep in places we need to wait for - * polling to complete. - */ -#define XHCI_PORT_POLLING_LFPS_TIME 36 - /** * struct xhci_intr_reg - Interrupt Register Set * @irq_pending: IMAN - Interrupt Management Register. Used to enable From patchwork Sun Jan 21 22:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 764513 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2065.outbound.protection.outlook.com [40.107.6.65]) (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 5F0CF38FB9; Sun, 21 Jan 2024 22:24:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705875898; cv=fail; b=ny2uUMOhWWMu9fmlsfA/UPjAVSt8W36tesipJmK3MIzthxkdfQHXjcPyKY1fPki1Ysfcg+GF1aSvePj2l6OZZf18rB3zOzlqoBWDJlZrEOYjxheVPoXXzgnFAvlZCw2oxG+JHTjT9woM04xIEUufK1zGzYzycZLinlcSP2vidjc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705875898; c=relaxed/simple; bh=NqWfXzouQuD5pJi9v80L3T6A/gzQ0pETLZ1AH5q7uHk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=r1TksvUR5xPBEG5LsLytgBqgPtnvhs+EH6NNJKBkrpnMImeFQyD8O8dx1/gz0snp6QMh+AvBH7NJROlNT2SXkVlZCVf6AZ1bZsymDXw7v7NvpU2cac/q17SmUhstvwuEbfJnot28GsGMTZwY1rgynS3ziREdrkL7s44rKemDGZU= 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=Kce2WTuO; arc=fail smtp.client-ip=40.107.6.65 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="Kce2WTuO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AuFP9xWUFZzvMA2KB1hmXX2q7nfoonFHMaUenYHSkI+oMxoqWPZorWwvi4asFPGnM5yj4jVYCMfS76mFtHYjPXahzA0m8y83tGq9g68KpYfOz5zZrt9xoTphfQk5oAlv3GXnhUxHe3JW+zowNLwtCinFxJ3wwZ++buwlvsU4NpDEqWckRybBXscCN/JyApnq03u7GzV8SibcV6l8S7A+9S98HYZ8FgEeUgK9OGTg6XsUBNktQeHu8z2T3FAjXfv6YTYsqMQqbPFnDfOjcwV4Qg5DFo7aHRtudIXLi4fyLhw5jR4r/3VKXIMVOUGt93Z/P/z6pTHMfYHUw7sUHElLWw== 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=JDR8jTXkAo/LOx6kRR5GYFpIM24pu/gcbxUJRoGaIwc=; b=f36rKWB3GmLWGiPuvQr2rCeBSBQqxD0Tpq3wPy0Qq2V30spB5O4Na0CCZJQUFSu2eQVF2y86JJWZmlE5sPT0GMXelwvNPTh3O4mWTAxKcptQhUKKPP2Pn7ZWbRLgnoglo7sabgXI9aFZD639DdVVyQv+T6od35gNV+ml7hpo9qA7YdmYO75E39M/G5kixRiqAj0+unemtmGOaPGCeCtM1qKKL9lamyHWs+Jg3pxQdtpH8DJNLd8pUhnd/kHRbGxis5JxgRt+xGQPCo8y8SzYOxPoufGpVJkSSdBvmDZC2l0ZNYM5Vkd/D1hlQVPvsvHQN/16yrEB1TSjfrneGfzwcA== 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=JDR8jTXkAo/LOx6kRR5GYFpIM24pu/gcbxUJRoGaIwc=; b=Kce2WTuOMRBJ03/gjHk81XqgYlY7+ShFYwNMxSPjwjt+fa/AKfpJ+qALy+04C8mO3ZIiclB6hGyH9wJktGez+fI7Ca0hOYuEBzlf1yK2CPPGy/rSKF5uLOgAJA1BFjetE5w7+1ly+ezwg9qHmkVKkfZq2Zgw0BdYamQmSkBz82M= 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 PAXPR04MB9074.eurprd04.prod.outlook.com (2603:10a6:102:227::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.31; Sun, 21 Jan 2024 22:24:54 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7202.031; Sun, 21 Jan 2024 22:24:54 +0000 From: Frank Li To: frank.li@nxp.com, mathias.nyman@intel.com Cc: Thinh.Nguyen@synopsys.com, balbi@kernel.org, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, pku.leo@gmail.com, ran.wang_1@nxp.com, robh+dt@kernel.org, sergei.shtylyov@cogentembedded.com, imx@lists.linux.dev Subject: [PATCH v2 2/3] dt-bindings: usb: dwc3: Add snps,host-vbus-glitches-quirk avoid vbus glitch Date: Sun, 21 Jan 2024 17:24:27 -0500 Message-Id: <20240121222428.3396428-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121222428.3396428-1-Frank.Li@nxp.com> References: <20240121222428.3396428-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0063.namprd17.prod.outlook.com (2603:10b6:a03:167::40) 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_|PAXPR04MB9074:EE_ X-MS-Office365-Filtering-Correlation-Id: c59cf9b1-3371-4ac0-f40b-08dc1acfcafe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LDueyT37gXQhHstyqGXelUqgp12BSrRgufxO85USGY/3r0yb89A/VhljCPzFLhULHFltl0XvIgnZpWml2Upz77P7ykAWoTqsRlatTyil/XXEqx6ok9Bbd7yxidigxzBFlONl+igKvMFZ6zB8bK6ytkGfJtv9BCt0wjLaU1Ddcaqwq/UrHi7XwTLaHPg/gkcV51J8opN6H7oUdXyWaW7LX0SEBGt/JDjwrmOaxoxkWzGrwk2HA3ZDiLWE+C+zPpEJcHM7rzN/K/k1ybR3nNcb2UGNvZdN/BUXEDfqZt0Wq1TZQk45CWfZoWfFha0tn99sQkiHuZUoTwPstrPRSajxaajQzY77gqSTFRYz+fsurQHrKhZgEvRB2lxYbEI22LpYNE/has9A5xxEa/UneXxuwqKrxEQYHfHP5GWSZ/wvISt7DJMM/Hn2IfQv+G6XnSE9VKEG+1C0ezWr+udZ2YtbJky62/8PxfudeMxE+SuzjJkspbaRY7hcK8Hghsfq6nJPfxWhJsN8ZJl9ldMAIKkZVPgyE0EFXynTO4jhnhRFf+g+bdB3bOsyIo84AV5AqQyv10dPFDXvL3L5h2JbgzcETiixFRfz/6l9ZY0mCkjl/5Sp/1MhuUU2jIQ3yBSyyrvpx9lQds+g04d/Rjhv1kfl/yRctI5yQ8P1B+YUr3orAFU= 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)(366004)(346002)(136003)(396003)(39860400002)(376002)(230922051799003)(230273577357003)(230173577357003)(186009)(1800799012)(64100799003)(451199024)(86362001)(8936002)(4326008)(8676002)(316002)(66556008)(66476007)(66946007)(36756003)(5660300002)(6506007)(6486002)(2906002)(41300700001)(52116002)(7416002)(38100700002)(38350700005)(83380400001)(26005)(1076003)(2616005)(6512007)(6666004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5jPHQSlzNqx2wA+fBBd/L7yZSYigDKsl3GRluCk0VBQh/9MpATP8kdJ7UbywOKAvT/4Hx9p6NZuuLYFGwXVlZwQJjBTmkX+UZwL3JrS/ut7rfpsxZ8/+EwBHlTGQOQIUpWiAkEYO4/n1MDgFebaQfVRoJ2vXuQ0S27giHEbflqDkZbvky7NwsqU2KwyKnI3ndlcOCDCvr7wQMl2XA1Z4XR+U3D/FWj+KKxfKW6Al5jDLWpg1FYGu9TaE3biaGlWI70pXwIyfhTWozhuA4NGD6Xn2k/Q9EL24iVQtI64JMBF4YTSWPUpjOcCBFtmPUDv/1F9LfuiWbJoe1p3RsQI4VJdsrmx6Uneasy0OJUJGQt4qJHZ+/gDtPWiUJdoSnhVgU99M94tGPnuR2Qg5WcU7qxO/mc8nE0tV4iRT8e0uL2QBB5UyEjsM55e0lfktWKYy1nVoR6jmarqpprn6jvWZDqSbUb/xAcO9zNhv9dBUQCQ0cvKhZ7KPCxEL0P6D24F2CBFmZXbFD6Ub1yAnf/nVkT5CgNaasz5/rE6pHaI60iBKxcDAiY/cjZCXOEkD0QkkkJl19kGXxBSjd8vp5R6nBU/i3MWIQ3fFXRW1O3Y/sdHDcXUwyLAXyh3WONtQ2FmiKxQsEMcG4cVrSa4QWuucJUYuPi8/9wMOL3btrbQYTs1ILUGHec5r7E7xCkC3teNjBynN514xnn9bY/2ugKdel/oQn7RRk+hdAG0FsvSmXs3yOWGMQYwfpGfvMjt16toOw+EoKxcTQVCktq4GMYDAcUjGs01QC7uTyamWcE7Dr9N33wcqsdGohXbxQ6rBH7E3xbc+Q4FsYIoEUR63IDs+QmtyQYi0YgKol3S1qfiA/Ea+N7wynQPS6S/UyRURWLnYDwLVjzSTFhLbH4NagJFW7BY9H0B8FvZA96u/+nu/cGAEXtZOOgXw/y0tBKCPrZlS4gSaQsFJsrfnTamM8X2BWubSxzFBbb9xZ5B9lfaRj2xvG+kVY94mNb2/TA2tvuGo+pBr6oyzfnaNm/kU5WmPglb12C17vjlNuxNV3zr3SyHMP7KPgjbWiLAF4734HHJNge1V2XruOowM1ep7X1rDjBkYPcdHMRo8tz/0nTQDPRffZu4v9c5rnrmcqEd6WrbrZcvsgrn30G+1CMggNXOZVNs78jgpCdFrwJRoBuNCo0wefZAIt4jk1svSlBYMvj2dY42bLQ1Si7PYM6/yLx54Fnif/4+UGt78LRS6i2eSWl5HttTxLJ/8RVRBefV4YniUX/SchGmMsLg8NEtFkpR8kfPai3gigHi+aE2zI/ylufaOrfTrwhYff09GtHU3+D+W2goTS3TuxAR0RXmTSB/roeRkTzV13VZi0JjbSHWafY7v/aOhTDQYkyJ2oWl7vdaOMbsE88/sYOvcQWD8JQrA124ZKgZEhlsIclh+XDJa4h9YHD4YVkDpfgBWzDDb5sX1bPUG++xAI8fQTC5zU+zJUd5RqTbFdwp8Ut8OAQeSD55U/8NwSN5BVLed//cs8FYj2rBK8vGWY2l1fcgGGsvRLA2dzXLJIIQtU6KlZ9CNo2U= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c59cf9b1-3371-4ac0-f40b-08dc1acfcafe X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2024 22:24:54.7544 (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: ilwekou36ExUzkwM3+2BY6wKytfs1/4s2dGMfKRjwCdJL8nbKB+8GOIf/sy7a5iMyTs4ewQaOZSh24w6yshCRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9074 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..8f5d250070c78 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-quirk: + 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 Sun Jan 21 22:24: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: 764818 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2062.outbound.protection.outlook.com [40.107.22.62]) (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 5AF9F39ACD; Sun, 21 Jan 2024 22:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705875903; cv=fail; b=JtkJ82/nQ6jiNu58n7kWgG3UEl1X3QxIWmriT4eNgAoae9sGUmp89aD+d4Ud6Ss1RHibZ2pOzurJfYHynyX450jHHdtcPTrxch6k+Z5MkIb5HcBjtG65jx6aKmeGvPohVDbmBjJj/9qbEqGFXPkFEefnoHOFwLQQkXo4HcN2M7o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705875903; c=relaxed/simple; bh=XVV1gSwV1UV1ScFgRL+jni2ulTpDQ7D9i/nGFyLqyAM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=trTD7TKn+W0rgrs4NYGgxEZbTs06tv0Bb1oyfmNiqq7uhv6w6k3GLerds/npRMtRkmIWDs7B1o+ArH1nV+fc/rvtLDuW20/5Oz74njitlHjvuZwP8p359fcTv+jFTA218ejSIBkgGZhe7ynuRcnl/8DEx6KANoi4d0SXn6VqgGA= 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=m/ISb2s5; arc=fail smtp.client-ip=40.107.22.62 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="m/ISb2s5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ffz62ZuZTocsviF5YRFG0mNS7R+JfA31xnyYrej4uBbFLJltwfuO6U8NDECsKwbPHQmo1uBQKUpujKTotNitfxltORFEba7g/ZTmVrthemeY1C7uMom1h0Odsh1eEJ9nQIj2JfjMZM063TE0UoGe9B5bBmIE2DY/XJcQ0sIAFtSFwe96HY+6ub6RwE66a0OxsfvzJjtHT2WTalV7ohskhscamuOMGKimLEnT7De8CxDI6oO7jmTPAO4N797CrDgC4qctc0n3IoBahQpo/OVzmTLXgZfi8RI3LOewl+m0uKreGQDe9KgzTCXIkrHWJPy35hU8Nm8T7DrWIuW8wGJM5w== 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=6WjEhoaKrfQXQ/3+dXzeqTAvAdn0vYPi9jBmGKxZQCs=; b=iw+SGziU5SikRd5cbV/7XRgM32Y0Nf+ZJh+GYLEp9uFfQstg7k+drqpJLHN12qpgy5BmOV4MlTt7oA31WQCQY0P980U8A2DDSreMRKKl2GJyBpl58syeUEtCahrVtdL71o2gtHkHQAgeHOIr/aWtRSgsD1tniUujUcxEt2+pKThOQI1KvOoEMf7+3gEWF0lF4UdxJTsZSGtotczmFIysZN00X0wacOcY6TC3J2VtFSv6ZrKUlJqeatjV5ya+hiRAlRW4meQPIbhn0Nul+dKvGiB4O1/sG4PC+h/Ofs75FjflYTWHNlTlKfr0xnQZmCsutJGPur8pysyaAA7DKckHnA== 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=6WjEhoaKrfQXQ/3+dXzeqTAvAdn0vYPi9jBmGKxZQCs=; b=m/ISb2s5dSJBbnhwa8TH5813rDd1EM1CoHEQYAkgeF5EjASQUtq/sfApe47UTs3hfQ47BznpiEtG9FXKAq6ymE1NSeQMBFCvTFhFnQmORSCTlq5Z83/srvdZOIAd9YX8Uu20swkq9XzKYU1eNohULpBCwqyJl/GJo7SXnGWdnOQ= 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 PAXPR04MB9074.eurprd04.prod.outlook.com (2603:10a6:102:227::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.31; Sun, 21 Jan 2024 22:24:58 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7202.031; Sun, 21 Jan 2024 22:24:58 +0000 From: Frank Li To: frank.li@nxp.com, mathias.nyman@intel.com Cc: Thinh.Nguyen@synopsys.com, balbi@kernel.org, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, pku.leo@gmail.com, ran.wang_1@nxp.com, robh+dt@kernel.org, sergei.shtylyov@cogentembedded.com, imx@lists.linux.dev Subject: [PATCH v2 3/3] usb: dwc3: Add workaround for host mode VBUS glitch when boot Date: Sun, 21 Jan 2024 17:24:28 -0500 Message-Id: <20240121222428.3396428-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121222428.3396428-1-Frank.Li@nxp.com> References: <20240121222428.3396428-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0063.namprd17.prod.outlook.com (2603:10b6:a03:167::40) 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_|PAXPR04MB9074:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b938549-5803-483e-2b05-08dc1acfcd1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XaIwgAakE21eHL/WMoh9wZJ33kO/BYafDY0M2EaCLHKVA76TYsyFBtsLhohdDTD1B7JaDPml+Px7CyIOeaIxIPvlkoouKOPqk2j7ZTMAyxjGDM4ZmB2qW6KDhjqoZzuiAByRb4sr+5TIRLaVZGFpg0gPE8wGajoovdaQNPhjvjESI9RukRcJsof5wpmI/GOArBWf65nvORWlprhX2yVEB/m/2cuHHoxiNshFXyXL5USVtrQ/2k/ndHsxcGOMIkUITCJkQOdiEkw24nBIgHe2LXyNReWXm0WanJtgWBRdt1EZBC0ngYTWcig5O1oNoGJbvFr2Jl6o4WeRfY4r7+kSSznnRT8ZONGSt/aeYNpsHWOgqvoIOyrzOXTviWgXTzVYGVl1RTfjFEY2/qMOP6E9rSF67ZDkFVGwa72GI36ZJB0yzjELSD4v1sNTzZuwog8XOShxUdJK4TnJoMc0ozyKPlxvSfvZXTqX+yebgPFtAjrrDrlGoQhHlJS54KWQ4J+A7tR6i8BAnxtbDIWuhrmL/fDOvlkt+y9H3YaNRYXUpJUGXF5HEkjdInnwZqQfY3FCowLs1xqMdAyi4dccbD+VPvbCe3XJdhkaEp8PvsnNnTan8gkgq+s29rBp8QUvbL0v 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)(366004)(346002)(136003)(396003)(39860400002)(376002)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(86362001)(8936002)(4326008)(8676002)(316002)(66556008)(66476007)(66946007)(36756003)(5660300002)(6506007)(6486002)(2906002)(41300700001)(52116002)(7416002)(38100700002)(38350700005)(83380400001)(26005)(1076003)(2616005)(6512007)(6666004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B5o11h7AC9ublTvHs7kqJiE+ZjuPInpBeCCpJRALyMRrhFRgrubRH6fb2zmWNxAtbGnaYRFx96TZKgJwsi4k2Lfs06wdwlaMsAlHUSVfDWtFhdRDHFRrGT9vR/6hKxM5wc8w5FooGqeYfXlcoR1SOkqiPFxxuYwz/CrwMHMFf1+kUuJpfV9MUGzEPp+sykS4C/tdqddCn0wpOfTzhrPyY6xJkKQcceJ8X+qxiIhW27PNB/+UxfQAlgZi77kb3V2ORMuH8sWIRmrt92AfJCJin7lffje0fXVPgTituwrwy4MPE/pBfotgpjm1xFVCfvOzm/0U0pdkSF1KmLTbOp61h0INv1Ub/BYeLlv7XfQncOFXS1xNJ2rT5c4BdmT4Ia8UOdKJxZ7fH3+CO/6ueShbIQKOpDrr1Hl9mBhvcHk9gfbFN+B6J/giRTPYnkQaZRtWOxScD/mGajT4EsZUWH4JJczgoAkwdIQfMFHrTbw/P/JsAxqpKuxNPPt7w4szAqMFHlbSt8N7LNMlfjMjVz2ruDMwUaEIQpXSG/AxbjA7l5ukgrR1SrnzOLSuPO3jc1E1OmJ1ovjZ9KW7/U5HPRm3Jrf/XrTvWA5xujtd69MTwOHZ/z/DKhoyAl6mzjlSsiv6ALHHuOOkwCXFzQ6cy7IobUVkHcU/EVFb2IduUPByDUd0fTq5eKsufHRcK/N8K5TKs0sZzag72lG8qQ48ksCjBPGajl9t3t35LbBSVWMfoce2hnuNb5yj5sEFM8vhql0S5HWdLSJYdTIN7/q9SVUgVfdrv52yYUijZvCU5Q15R8f1JU+4Mj4O3LwCPdDPkCA+xaBsN73nP9wVBRmT6hh32Tm3GBa8+BCEkRPWy/IGluJa4STruu5rxRXaXVW1we2dgpKTVoBIdaur2yNSrVGMOa2CiT9894/aZbhHJ3BYl5qwfQ4Y45L3M2KGrYtu50mrjMlh6eNA9ohWfY+P9JogcMh/tU+HBm3ahyuu831013d4g2wftc7f/0BF6p7tTr8esROsNwqUtHCSIYwxqNid5ibkf9B0yxCGcxKdrKIve3cszjUA1VGtfiVpUD4lCMil6cbxIyCFD/6JxY6JdVD8QTvTLp6pM+newqP+Ci5FCasZ05iqJgvYKwRw90kebF5YdwcXPc4436haj0gnLbAwYfXNmPhe/Ar0i8h9l9yNF2slocpMOKfgSDaLTmRrbvMEhrY89yc3HwB7h+Pa+KyVBjpDZpHV176TdZo0Ds8oeMo8hNldthzTO2rcmXMQy1dzgJcDyIiiu1SvVtkYGfAvKlxpwe8rxk10WgsO34ZGt+RvU/bInpUj+CjslCTJJmYAOTqjmPEem0PH6+ThqeG7VcMBY3UU6zctuwA03xQlMElOSN4ojp9P0zczjgX/lV9WuiiC4+yOaoQ+h2ZM22JAUkimbidUiBkSFHfWZubhtpaf25IdWmOjaehiU44y8t3qal63PMIpyVOg106oZNCQ4omimEwmg1i9TARcqzGkdcTQMz0ZBNCMB5ni8VbCU5kGgvXRZv0eg5uXyoK1qz8MkiZ9UZabRkpTPXfxefdDl50= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b938549-5803-483e-2b05-08dc1acfcd1c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2024 22:24:58.5101 (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: fm87IuUU8ol6+LQ0hAKigFNrqdS3XJVu1OzJo/uBpB8sHeknB9PqoQoqFPFZfq9LvC22e6AzP/Rcjw4H4XkqYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9074 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 --- drivers/usb/dwc3/core.c | 3 +++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/host.c | 48 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3e55838c00014..3b68e8e45b8b9 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1626,6 +1626,9 @@ 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_quirk = device_property_read_bool(dev, + "snps,host-vbus-glitches-quirk"); + 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..df544ec730d22 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1132,6 +1132,7 @@ struct dwc3_scratchpad_array { * 2 - No de-emphasis * 3 - Reserved * @dis_metastability_quirk: set to disable metastability quirk. + * @host_vbus_glitches_quirk: set to avoid vbus glitch during xhci reset. * @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. @@ -1353,6 +1354,7 @@ struct dwc3 { unsigned tx_de_emphasis:2; unsigned dis_metastability_quirk:1; + unsigned host_vbus_glitches_quirk: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..ee1ffe1500560 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -11,6 +11,9 @@ #include #include +#include "../host/xhci-port.h" +#include "../host/xhci-ext-caps.h" +#include "../host/xhci-caps.h" #include "core.h" static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc, @@ -28,6 +31,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 +107,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_quirk) + dwc3_power_off_all_roothub_ports(dwc); + irq = dwc3_host_get_irq(dwc); if (irq < 0) return irq;