From patchwork Tue Jan 23 16:42:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13527809 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2078.outbound.protection.outlook.com [40.107.6.78]) (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 671E08613F; Tue, 23 Jan 2024 16:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028189; cv=fail; b=dKi3P9bSbw2k4wh2jgycb5foXQQO5qLINrX07WWQzhJqEm7BG72KgtgiiH5hByGenpdx6WWk8RN9huCIneRh82Igsic25sZ5brWqrOQB3txQk0+rpvgnzdmTY0G+bWO9pbNF2LQJ0CzB+lHcGv4T8PUKZGlNa0BR+tt0d5jQFuo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028189; 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=szj5qr66ElHMI8JaqzpEtpsQMhgcqfj3A6cgeUX5cWhxGbU8O0oQY8zVqaBjLyEHr9UZshJ8XoZadv42vx9+3t5O4d+bmemxnM/DEDoB3K2TvWil9MVvrLtKiJ7nQkfF5DVpY5hLJ/mw5CawGlfRbZveFRyAkgvu656lUbHiGEw= 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=H9x0ZUqW; arc=fail smtp.client-ip=40.107.6.78 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="H9x0ZUqW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XBStMt2th+BsCvC6hIO/00b7N1+YZvzlMa/6V2tD8FU2/MIuKgOQzpGtpkais21O/X/FS81Mk9MkDdLoCP9ViFhYjsQeL6TjvhPKs4LlKNssBPv2ntZPC09R9eYzOBpn28h4XIS3TCEZiVZJU5mftXcbJWJV6im8Wv3vyEOdWa65NycqSVba/q91cp5Fyx1NEERhDEnnvZO95+Gx06fVdItskiWQGRD/j3aDHB6FfDO0LfsmKMBnl0STTElHP/XAxQH4CCWwb5/Mwo1g+xH7jLWotCn8GmrzoKP+8MN7uKdo93fymfoQxvtn7U5bb2aZ6Svm8GH48Pn3Lwq4hRWJdA== 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=mlgUHbmKORcyNaE2lAW5FJ5FMZa6USHWqRYUOd99VeSYdvwYudy0IweJppeK9fYTXkHQk7c9apt54SBTsMWV52Fp9G5BDl6MlwbZ2+u2Li2JUpB5COCs4+N9BoDqre20IBxvAggpanEerIHzpTN6MNKs75EiXNozEiZ5Fr2PqJCOP9re2/S0JwaI1OSHN7cr9rEG7RgHfgyUvZGB3tocv4iW0PWhwo30W7ZdnBjGusy/BRxQTtfCY1y8lHtwZG0uJWHgKo7T+wk+hbmAgqgQMnYg9I7tm6c9VtxoZgPpGMkD3gPFwEIlejZ9Iz5PdKu0EXWgKzk09A3vNxL/BB47jQ== 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=H9x0ZUqWItUC5HxzBOLu+kDy6IFKz9dwQ46xf0mNbkQ0I/GYo5paiKKPZz8W7wdE/ZrRbtLPcw0WyKYtXSX6fQmggUtQFXk+vX28r6Yb/NXSxPj1iXKLFYv7ggWaiM6a6reKctZxqEy3pszIvihi4cUgJHFdOPK2pOOAnuzY6Ls= 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 DBBPR04MB7929.eurprd04.prod.outlook.com (2603:10a6:10:1ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.37; Tue, 23 Jan 2024 16:43:02 +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.035; Tue, 23 Jan 2024 16:43:02 +0000 From: Frank Li To: thinh.nguyen@synopsys.com Cc: Frank.Li@nxp.com, balbi@kernel.org, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, mathias.nyman@intel.com, pku.leo@gmail.com, ran.wang_1@nxp.com, robh+dt@kernel.org, sergei.shtylyov@cogentembedded.com Subject: [PATCH v3 1/3] XHCI: Separate PORT and CAPs macros into dedicated file Date: Tue, 23 Jan 2024 11:42:39 -0500 Message-Id: <20240123164241.3689109-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123164241.3689109-1-Frank.Li@nxp.com> References: <20240123164241.3689109-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0107.namprd05.prod.outlook.com (2603:10b6:a03:334::22) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7929:EE_ X-MS-Office365-Filtering-Correlation-Id: 48b34c18-b857-46e8-e4f1-08dc1c325d9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E3tP0dWaybuY6zKsrLhKkPW/mq2y4APYLM8BhsXBIv6HVewzjgWCFVzOibN7lrRkQAa2ByTRAQOB4vZ+sIqEphozTzBguDszC4HgAroyt6jSuQ8I9n3T1tcDTB+F9JK/aGDveVFTuvSp6RfcAKVjI9b3wl6O3K9qdY2Pov52735EceUdZyCZcyCPy/psmFnprr5GXiRGrl3YF69hRzZECRZOu0V8qZozobgA3inX8WFWJPtfIRCH/8OuY1yzFrnnBdAkO4Xd4G9TO3RfbWJ7t8uW8QnxIK1Ffi6zYSAv5RmfJewpYDbrEPxb3dKBPONA+8pFTROUN5JpDKbUFnP2qhy+pxivoULUGqrxIr23bwzAux5uSLmQ90K+Wv/0q4qzca7z+I8NRXfTbiegPAfDG5vclzWrGXllSDgbU+x4h4mPeEG9EBpEFstc1iPXvIa0f+dLbjU38prDsIVzcXh0+EALy2sEzBjTYjxCPrZl7KJ3Er9NzBzDRPsQ3W5G/o9B3Uy/fn6nYTYXt/VXi27/+D+M6DMrA5o5X79ncCpEb8NfznWRxAoKd4qNvHVu5nwqFo6bSnHtUNU/5lPKGrwY4Xvju+RlAjGZ1SKYkaej7WGvHQYfPzTfudzNQDLeEgCL 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)(376002)(136003)(346002)(396003)(39860400002)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(36756003)(4326008)(8936002)(8676002)(30864003)(2906002)(5660300002)(7416002)(41300700001)(38350700005)(2616005)(6666004)(6506007)(52116002)(6512007)(83380400001)(478600001)(1076003)(26005)(66946007)(316002)(66574015)(6486002)(66556008)(66476007)(6916009)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4T1BA2lP/4+e/Sg7CI60w9aijz5kSCpgCqVwkIwrdizMU/kcG2hZYkw7Balu2a/IExTCv9EF0lj2y9ewBweWvWgXIuEAr1CY5qXRThsuIHmYJv0bSg88hKKTzTs9VemZQJ6J8MRfnrxR0n5fQVj9gi5TEFOebizJWIgyzAQ9R7kK09f7dELelv/BLbVI9f0E5Fgl07RCpd9cCxYYn03+48QxuW0HHxCl0+zzUXOsmZNXmDeDLKv8/BQjmRuJ+tv63r5JCBfOsYVBF5W2bM1t7m03t4/occ9S3D4FHO2Bawp16XwCN1VjkooGw39eNF/lRfIC8ycbwdD6JNeQ7bdGn/Q2FqhoNn6oHtAx3K+uEqXweV3D5NnsAeN5g0cJRsOe9eTuC9O6FjSXonrbjCYku3fbur4y4xKhx4gv8EyiqxXLJymkcazcomdIwanWpthTTdgrJwMlIsHpqdEBHP7L1LniZht8edACgPfcq5XJwvBxbYczdUhLECmcOO1EPecfYaJ/PTPX8/RD9qNN1jO2RmmUnnLeY3MAcqhH1pr+Q6/pqityrrSM17fx7ZyzjDxT5MOtwrF8f/6ucZC8eKJNkW09LOU2t+oFTjubf1KcBnupP4XVNgwStH1ZzxZl572LKSf77T5ZSoBMhKauq5iRXAretdxFCLBNDYZ3DKJOApfC6gD6aZ5b/USmcJKD8uuU+5TUeDmp78HYYul6MdBwYJumeF1J5XOuVkscNJ0Zv7z5ASELPPj1Fr6rNB1a2H/w1BFx2FxoCmhSNVAFixMqkm8okrLYF/izEiAw+oehOkpIZzExyU7yiVQWEjek5tVKFo3meGUgDv8YUMK1uYwq/NKTf/ckh7D9BkKF458/zoJaHed7U1AOkDHzcCVWo7uSL8wcE2VM53+xfFnU6iILcH4iuvkgER84QtgmnS03w2UqP4up+6einjgojTuG3txha/wm9Lj0625RVR6/rah0/pPZ26eRFKSdPygqoMUEr9IWVQoyQbm7VLTYDtGi4PL62at3MmL9ltrfqzpzOlsi97HLKjeVyh9tW+PkmnQETst3HjuCurPijl1kIaWIm5TXE+TsDTlP0Hasr6tVmit+LWTwzjbTuht4qaZExflixuxtBpevapzMEJWAJXWYX4L8I+Xn5IGM0zdBynH5mcj+PSBX1MqdWlfoSV65uhSaXhCrnCUTz60bRmbVUg3K946mH0jkemaHGs1HBg+YjF3NpTIa7r3Ug+RzbPFrAgTa1/Irdf74rn0EwLYjSkTnCdW54ZONl/UVo5/HZFHpDfLj9Mi7HUiIhNpvLsijBmjeH5qCYvNTQCOzJ029Wah6Gef/xDAYDRvbaDkVHalL4Y2bEGo9+Q05VmEdM+K5hARJ7kVomRvpcTgbGltGdXOANNEmegcZISJw0X6vQ4DsXRPFNiefiw9Sic8xSyiuQ2nuSZ8XYlajbPa/DVdvx3X1XeInJu3ZUOkW3ExIHm6ZW66zQengPPEq8A8WR0ntISqOWj8nt8h1AGo8bmxd8yhkMCG69zper/Wy7Q7FO82aT2VjPqkgPpLIgIlkvn/O/QfTR8g= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48b34c18-b857-46e8-e4f1-08dc1c325d9e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 16:43:02.7746 (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: B6P4TCaqxC9AM2bmXl/tuWlH/F4ogzYcBd+7Iy13UnskWrJetvdC6fDpwU6ZfC+UooPb4/Js0mQXOtKy1y0Caw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7929 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 Tue Jan 23 16:42:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13527810 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2078.outbound.protection.outlook.com [40.107.6.78]) (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 520E386151; Tue, 23 Jan 2024 16:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028191; cv=fail; b=OUbZTv9g+TEZiCA5orq7XPdKJu3AA5JdvAb5ezcnKUP6HHmNUJt0WdXR5EKkJ3Zv2fqnJMCH+GTle9SL4ZacwAwk6f5IsgAUtI8myL79d4+/W0fKnDuAIW1i6PJ08AIwlcYnxCWHpBwW+qapjso/ULe9x+7QFqkaOw4caqjf+Rw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028191; c=relaxed/simple; bh=NqWfXzouQuD5pJi9v80L3T6A/gzQ0pETLZ1AH5q7uHk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Y5vGcg4Ld0tQdkjcjcTnhErx5DqfpRSicQe7qGEEfYVWc2MaWAIUr3b70pnokQboZhprL7Wl1gT+NiNw3zOV0NToaz0Lt+wKWDInRhnJ8OUrDRrsZopr0ODHTyVjCVn8eh1+t9R0Z0jjm0NHE4sT4fmr4FV8kA6WpVb+DcjwsJI= 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=bUPEC9w6; arc=fail smtp.client-ip=40.107.6.78 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="bUPEC9w6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C/BsgjpNltpEdYhv0U/NLE5nxT4RUgKFMx4LmLpA78IebD4+vR/+s5vhgQWb77A9weXAGna7/9YhbCGDqyrgAW+2y0Wkees2/XqHxgEEAGUK+VDPqD4Gie3FlgviU2bD/lKfFcSaO17tHEe661M5iU9v1jhSJOUElAZbapmk5yuqhrV2VtTzhreGxBaBQLl3gpW/IdpUlcYnxHOLdMosFnbf0V96p2ejC1x/yQ/gllR/sGZV2eHNBKB2nGXjV9cW8bIysVu8oVHwDyFY27S6J4ajakUqe0YPebHe5fUe3cB1sAUpA9UfPEc3Zg6tO1vrIIeSLvi/iV0QOek9xkLW4w== 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=fm2Q4iFFNRgyOSIKvdKcmHNc1jOYJjCs2xOpCaM5oseNJK1VzQirpBe7LIvhX1ZBR/XOZta4dLsSMUm/hiCSSO5v9V/qVu8fh0jClAOSJqknXYFktIeQSpo2fjd67Oh+1Z56Tm87+u26BPy0tEdHAq7Ey8LhfPWDBlrm/i2Cg9VcT753yBhWRhFdFvIbP/MUAJqzovWXsd26bvDncgKdlJo+Tbm73tzeVlsup17q1GRGtRwLyEJjcR1G9A0WfqoqlIs8GRbdAqhBBdfAoWWZdjgkuw5pLgWpGIfZGyt75T+SgebvfxMC8XW/q0kXgzO2WfHR+NWqUgEthXoVRf6hvA== 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=bUPEC9w6PNmC8PCGiAvfrCZKMAQBhGEIY60M6kHN/yPCGZMlfGEF1MhFua/YvfAuoZcU9cjMXSd960wZdX3YSnO+eWfA2ooBn6FR86iwWLJICmfzH3o25TlJomvrdUR3dRzJDU057NMpkoVb79+18l7wMkB0zDi9xdfY0i2u1L4= 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 DBBPR04MB7929.eurprd04.prod.outlook.com (2603:10a6:10:1ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.37; Tue, 23 Jan 2024 16:43:06 +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.035; Tue, 23 Jan 2024 16:43:06 +0000 From: Frank Li To: thinh.nguyen@synopsys.com Cc: Frank.Li@nxp.com, balbi@kernel.org, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, mathias.nyman@intel.com, pku.leo@gmail.com, ran.wang_1@nxp.com, robh+dt@kernel.org, sergei.shtylyov@cogentembedded.com Subject: [PATCH v3 2/3] dt-bindings: usb: dwc3: Add snps,host-vbus-glitches-quirk avoid vbus glitch Date: Tue, 23 Jan 2024 11:42:40 -0500 Message-Id: <20240123164241.3689109-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123164241.3689109-1-Frank.Li@nxp.com> References: <20240123164241.3689109-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0107.namprd05.prod.outlook.com (2603:10b6:a03:334::22) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7929:EE_ X-MS-Office365-Filtering-Correlation-Id: b4bea6b3-887a-436c-cc00-08dc1c325fd1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HUOEDI7ZRByyg96IU1Fod+0OlS3EkGk0ux8AOXgbxkb+IUJMq6A66jpbF5cY/jxYMQGKWOjmjZ1GSg25z/BHeFKE7wX0kLU9nfcso8GmaogTdt3O3QelNP86ICnUt9WTIFRP7BOPhCTn1nhEScp6JDknYydQiZJKb5O7Shz3TNuCV0x56UBooLygBZKfWHNX7rwxBIGoMd7gwBXtiKWKi9EyrMfHNn3FkHEx24WLxwblu4PhGHgTaZv5x0KnoqtDgLe9yOKGvA1bYZpd5g7OXKSeJiLsGRR9aIIPtQcVkfIv8H6oLs1TyX+sLu52x/GSfM7B2KfgRmSylzgNDfcXJmZKOurZdBodZBbNa5j1c+w1GEezJ8ynWqYVMe52txJBgkvF11m5tEC1eKCUoAVoNIcbgI9j1/hIxpdW3ke35JLzAHP1+Tvs0DFhPYzMUOXYDBvzdwwJF4ZqayOk35raTHDNjlvzuAOdJK1tDdqGS5QL319K3WdZFFjTf0HpyltIkxRt97d8WCTXHrnBVDAVjkb89yxPsq8AiU81O+Fe8eF/YeT6eGVMgxh/KvOanozGX8jAus8JUh9cdWC5M5DMpD3AIEA790rONfEH0DMqoiTtHzoVFOB5UiQMSqK2fPOkVGmJS3Tu9nDw2QT2hh4J2seVtfxqqRYcXaOnxUVFQgU= 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)(376002)(136003)(346002)(396003)(39860400002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(36756003)(4326008)(8936002)(8676002)(2906002)(5660300002)(7416002)(41300700001)(38350700005)(2616005)(6666004)(6506007)(52116002)(6512007)(83380400001)(478600001)(1076003)(26005)(66946007)(316002)(6486002)(66556008)(66476007)(6916009)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WAHvafgmpZ11jZJbx/hmhR6BbbSLLogKlJFrh07lmAUhxNt4dUX6KtDJi8G8nL+mRiDo7332PkQh2KSaqLm83z8Ix6ARTkECIl82ltkHm1g7uc7FhkCoKOcq9f/SU9xZiAuZev7COT3+zgb3fgT3skR+g9OtdUFtM3ppWMTDT+mHH6mjpcR4wJlz8VlzpYIy7ZSNPEIn9VBHz7RS4C3JW03UJKHOx0imHM+L/SmbaJLqlaOATFqYKq57q40oqkjNUVXekLszE7LrwCM6MTkqNLRkdtOHQc9/RW/+oZhBGsvWupH9Dl+HYVZO5fo0h3XRDaL10QsTM1xyJBISCvTN2P6yKNwVK83L35HGkKy7WIlsWg/zJzZS5ujIWW3d4L9Z72BcXZq3TED0TA390KEqILfOKA/kdm28iGVj/TvjMO5iOt4g01LCe955Qz0LpOo//XEjJCNe+0RLjzgcYgBl0uxhZIMF3WBkD2GBkzqaAEK2kT6tVw1cHlJP+L3BLyIefnM0X6j1xw/lmteYN1QX6RwvbBD8QurIrFrUndVH9bMdGX+ryG83uvhpd/6zbZF00/3WLV+C+Q/4w5i8baUjKeFlo1NI1eR1APnNI9A5DPUqZhsw5w61xLm0GejIfX61SG1PN45byXTob2Xeo4uMfwbhZGWzuHYlHdX3oCWJCt+hTNjt8FwJ+YFZLqGRE7sH2EC1N/AG87Ex3KzHX8KnRGB3JJbOP3Z+ikS2h8jFfGx0u+7A+FtyYh9zSt/92CsFgDsNXET1iCYtxiXha+VCiKHOwUukiclDKcuEcJrW8guz3inD6O0pM5wW+KFjK+H7ni7dvkxdQYDrAO0oTXVWu8wB+uHZtaHDtB5LOe28l+9wRW3uk3ZEzXw0bw5v5V0U0YgxBC37PrTQ1oTh54mm34iDKWgc9Cp0dVkjPT87YWQJc3gtxVV/1/zeGgQVjI3sWoE73BKDit3+EsZ+hLUKBx/mNwv/ygUvSzhPl/dU5XiUPKv7yTqYwH2O596GZBFSO8LLNetndIx3DQJpyQYeFUNkRva3OyQiDYTXWdZW0XlssgyZs7h9pQ6GEUVggtz0L6OC49O8HwMO7oY5d/ZbQc11ANyIfvbR3taQ9/Rx8i/wew/grBJ4hAP5jHj3mRSDYUgb/6nn0vVZ01YHC9p+2cZaUQEwGc3Q6U3P4dIYM7+XI3+TfqJYUhfmOgg3Cqc7CNjZgnX1phc5DUpHJQewIUzJPRlGxC8hSXJkt6/f5MbDw2yw3hQTLKIzBf83ytnvB6EFkRBKd5K8o5llorxXEX9RAgLjzu3nGXkyvULrD1iJ5WcE+D4tdj3NmF5TRJqmAVBDP5bNEqlfYgyb1Tx6rT+r9ACy+YHB+hrQ1hHKlB0moZYdsPRcasW4x9ETrrLRAhTuIqgGiDuobQKTGjMrO4HVFXWUAv3PXoPHpDS2a2s8aGl6CFup60tulJPaBjRKtwCGiYW4f9gZ/VfhM4DwUUfCjFynPwDODdr96xHOrdIAzzH2V2OJj1ddYhoJQC/gx+tB/OY+qJhtFuzQJd78uGZ9T9bgD9obVENyxU1xF78= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4bea6b3-887a-436c-cc00-08dc1c325fd1 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 16:43:06.2987 (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: i42KZJHLaB5JslXd6WjaZ1WePJf5bGhPDOFDqFySie8VDbFrWPkYBzytoYupmFKGY2sXOuGQ1PY7lXD1VO4eRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7929 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 Tue Jan 23 16:42:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13527811 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2078.outbound.protection.outlook.com [40.107.6.78]) (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 543C186AC7; Tue, 23 Jan 2024 16:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028193; cv=fail; b=V9PkdFi9rR1ODlicV3o685mO3IcDuLhsioe2VXyVjh9pMpRivYcWPDEY086ZFOduV532gZVF1n+9AIwQbUfDSYWJbc6b4+nEnxNbOFIT4vAL9gyGs8fwkZ1EuiGvSTyAOgUNGSQ/Ciw/rMp3nDqXerms7OmTeRNTUw5tELQo2qM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028193; c=relaxed/simple; bh=ClQflWiWr/3JAWBrONH/PyimVOgNCCN1R7ncz/TKSpQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XMFiW+KVOrOAwNA+/HclAveaAQLi3IhsZ9RbOIIcBIQvJXp4N34n+DwVyjqcUmALAZfTzecA5UDNKgM/F8yFlgVSfY4p1of2aaRq4wz7K6BwmegJWF/mqlLaUish049bsPdmyzO0+1uDrO0rd/90kASnDFo7i6Xf02246s5Q4Io= 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=P6bPBlxp; arc=fail smtp.client-ip=40.107.6.78 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="P6bPBlxp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UjtM3MHRcUTOBrEG+ckt4cZF8tzZRxzqXX1JL3WHI7to72dTDbA9r6zPv3UQKuTaqljsHAiaVnmuCe0KCpVmfGqSlx7fEaYcR+UGt39DwmuwZFkMDM6WU/0JeplY7B20kxZ5bYHc5ytYq54ESYpPYQpVRcE68Omxnh/+VgnaS8nzyhXsBrWipcKdnXH34m2P761xz4QfDW2JgKtqs98tYjfX3Jj2V4EzWgVq5gbn4CvW6A7eKb7TtQfJmcbUpjHGhV56+kqwShio8N4T0fL/7y4sCwbskwvK1Zy5uIWOJmqV6dA3C1WGZOIeeYwbcFgNVwGxl9ulItqcKNJJRW8Log== 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=Mb/PNUWzHvJLRi4Fvm5d48nIOk2bYdXGoLM6UlH56mI=; b=Y0l5ug9MEcf6Nh9HK98720yArkzW5LRqaacNPshFtvs/g5KnZxc35qWPZyCYDc/k0UhVpF99jrnhC3qpDdjRip40kb3Imq+HWPOhhSHmu39niEQvlHMMi6faVHshKZG4yS8FKgkLfrtX4zpxi4p1gz1QxNbXY8EiAEAOlJY3kRY3OSPAWNpTJaJ2/ywB1T81nKehoS8f6p97Em8yjPePCH8aksPmiamwIsca/X0sYOJkxkvQJkTo8937C3WAlXctUWi5H4AM4FkLVmFQhS7s8V8WqnO/k2TccppY1V05B3cjctKjkgC8ujrK6NHaWaxULiCrcoUiyIHFMlxcQxdeOg== 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=Mb/PNUWzHvJLRi4Fvm5d48nIOk2bYdXGoLM6UlH56mI=; b=P6bPBlxpu24WItgst9ak0C39gvm+fmYaH/4l2NPOVCVA1+1NlB6LeLGxbyv8702SRo3TktXXzFeYiagkPLrX3a+md8sCYb9FvDxqAp3CFaZoea1J+9pridcKK7JkHJFu/FydA3aOTPUTAF8Y3w09I2l7DjhkRWltsGx75H6EYnI= 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 DBBPR04MB7929.eurprd04.prod.outlook.com (2603:10a6:10:1ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.37; Tue, 23 Jan 2024 16:43:10 +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.035; Tue, 23 Jan 2024 16:43:10 +0000 From: Frank Li To: thinh.nguyen@synopsys.com Cc: Frank.Li@nxp.com, balbi@kernel.org, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, mark.rutland@arm.com, mathias.nyman@intel.com, pku.leo@gmail.com, ran.wang_1@nxp.com, robh+dt@kernel.org, sergei.shtylyov@cogentembedded.com Subject: [PATCH v3 3/3] usb: dwc3: Add workaround for host mode VBUS glitch when boot Date: Tue, 23 Jan 2024 11:42:41 -0500 Message-Id: <20240123164241.3689109-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123164241.3689109-1-Frank.Li@nxp.com> References: <20240123164241.3689109-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0107.namprd05.prod.outlook.com (2603:10b6:a03:334::22) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7929:EE_ X-MS-Office365-Filtering-Correlation-Id: da837f37-49a5-47b7-b69b-08dc1c3261eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iIntBQ9kOxUDPUlEV5I3kW9MlyB8yZcYBW86nuJ9W7C8s8XtZEE1WL5VF89jKlXHgrWAftIx3f8XqumhHoMOZokkn/qJ38rHvH4zQ7nQhuQlPbkORSiMfQoiT440qFCljMFEz4BXlPkSEvh9SVWbbLf7o8a4g2lHHMXjH2MUFFCNM4RW+SeTuVSUjc8JZ7Z8XfE6lbNL0m9Nu3Kv7h9n4errlrD+bAXe21l/qGgGfK3ITNS28YD82uQ34AvPO+h9IAS7dWmLVSqgWar06mh0KWyeLkn2VVARRMTGM0xz47XAW9LvjQfh4NRpYCBiBh0Kzxi2cexn8vZY7ajoi/yB4FpcZRzvpfoBpgT8Cxrj5a05plAEOymH2ehqd5Mv8nfp7N6UbcLUPstVF5dvuPDK0b2QpPDnTMgYv6Fd0smnd41dzHB0duW4e30fzy6nzK9t1kHKvcOFiEVKBntRVMaZ8jI0xnHawcc3HEB/TJZNV5Nq4HKaxmXy5Rd8mXP+JTf18MydBU5dbuanQQTYvCgKroIi7+5cmjEPylKYSCWG9ce5Vc4vubJqlqQrUq/NUNtISNqbWIEmeyinfWKzPU63tjw4BhGSq53qA6E19bEz7/A= 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)(376002)(136003)(346002)(396003)(39860400002)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(36756003)(4326008)(8936002)(8676002)(2906002)(5660300002)(7416002)(41300700001)(38350700005)(2616005)(6666004)(6506007)(52116002)(6512007)(83380400001)(478600001)(45080400002)(1076003)(26005)(966005)(66946007)(316002)(6486002)(66556008)(66476007)(6916009)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WcLvwdnCXiYiMTdSuAJ/21nkzdHIXFHFzQk+a6gLxnOYZF3P0uOTErt3cp0/XpdlPvPyRk8HnBchL5LiiR5nPEe5qFwERNIssmyE6Zl1x0tVyvIdEVZAkYAX45bDt6WwMFckTXpRFxhzr4wMFd3Pr6GFR+/JQ32bboizOcNnhT77zYTKQHPs5RB4RJCFs1cCFWBaoEj/42X60u+90Yc/2i8b/Z8wQ8RlO4LDl+89UiMJ4zxqThTLCtT/Hivqk4hMBGZTxMUK9K3ydlLvzD274356/awDy9jRvXjr5jGfhmgz9j9thk8/cxxD/+wyxkJGkAN6wvXwSTcBPy4T0BnWaGnE1tFpN2vTJaEPv3r2po7oC0yKckGvBaJU3d0luwYh7MEooiAmaZV48ItROrcU5scn5KKUTKA9seoU21qg5dxkFHgRq8t4tnHvf8865NrhRo8cO5VzjerKjjlskgNToK34525R2wgF7foGixzFIfSjAcqOHACpGH92C8XWPmZPiSVkdGLLB8eS2zq2ShrGnoh6vZF/EittMk0rH6HAdnepxqUX0sCdmwcWp9XRZqB6g57z6PwLgYMOiW//NhFGOmEru/ELnHLGcRolfXRFPkl71vg8bfS35y0D/4zAk+0w6FtRPSMeQ+biDAwMcexLFXTuvdjlOCN30WhNrygUrXFCC+9b2spPajbnfeBTjysMqAy9H4n5zIO2YptfGcK906yzQCPQg1tDy/jbbMx5BJrx91Sx8PCyxgpwxX/5F/xeE9F7AwlL73CjUzI3ZFoqAQ+3tlQC1/V2tOFQSVrWc5ZgBDNYzYkr2VZMRWYGyOxCvBg+r+m8+QRE4u9TuQx529CX6Lra6rZ9N/QV/S7KyqAyVl37voAMied+dF3zts4pktKYEvhxLc5gZemNLwVgoElF9fTqRgiotXGv6VLGpkGRttP074ybrJyEZhL2208CfT2hakOCWkOR3N0Rm8V2oOy/EAftdHO3wxgwSbthYhsrK5cK4L8d7zdy7HQSBIfYzwWsZabcXMtsddWuZdnwWim9VI1mhTTOILfGzU6D2UJsFGbf5LnNYKGySlTSEoKH9YIlMW8dee5bwCCy9ItfsrQVdlhFZOtZ7vPqrIMmrVy43ni+zyW6KOGUH0LXqZXqn3gorwnrSZvulWKsJ1nSB8h87djZ+1u9TVOHi+7N8O0d3sna4NV5S05kAusWQ1QD4wrNF5x61wWWggazoJf0rG5ziP9KI37WwsjIBHRYNSdwwh1YAMqa+eDI5zMyz9Vui/R1Mlvy03CGVtKjhhCJ/+4FPXB0ltqm5bcTxvK1S0EmYwZPcE+3cCHitX1mNf6bzlAQSouPUZknItkGV15YLHlfHu59l9j2S1jhwYRqHNJfUBol5mhrJ7OMwLgGymq5e+vnqxeiHLDLISBrcj16qORlkrItDreWPXtHazohtesOhhmYsKS3PQe8MmZXGF3ohkRx2T4YB8NbLxr4LTKVLP18IGfb6TBXlspxDGo1IaUpYt86wjBaXFp0UZHixXXGSjZ1DSF4aMf5rihlKaUhOSSrlRwyTJ+XW5WXaLzkWug= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: da837f37-49a5-47b7-b69b-08dc1c3261eb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 16:43:09.8964 (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: Rwp5+wRMQ6UlU9me3JTZLhv/lkr69UNF3gLbh08Th2VaP8xjPEnc05/xNhT//PB1p+Eg5zRxoPvI+AkzC26FOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7929 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 Acked-by: Thinh Nguyen --- Notes: Change from v2 to v3 - reversed christmas tree - please move major change hunk to the top - Reword "We have to ..." to "Some platforms need to ... " Change from v1 to v2: - split xhci.h 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 | 3 +++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/host.c | 51 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 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..952d73d05dffa 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -11,8 +11,52 @@ #include #include +#include "../host/xhci-port.h" +#include "../host/xhci-ext-caps.h" +#include "../host/xhci-caps.h" #include "core.h" +#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) +{ + void __iomem *xhci_regs; + u32 op_regs_base; + int port_num; + u32 offset; + u32 reg; + int i; + + /* 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 void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc, int irq, char *name) { @@ -66,6 +110,13 @@ int dwc3_host_init(struct dwc3 *dwc) int ret, irq; int prop_idx = 0; + /* + * Some platforms need 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;