From patchwork Tue Mar 5 16:11:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Chang X-Patchwork-Id: 13582662 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2045.outbound.protection.outlook.com [40.107.92.45]) (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 D1F64128835; Tue, 5 Mar 2024 16:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709655113; cv=fail; b=eelysK8nhm8Q7jjdDJ0ncEU4ifujV33ID9TWGq/e1R45EGCDJ1XWKoDi+N/w3p/jaVSTQkZYkv8v1TOCDx6bmqyO+SIf7kgtNa4RBSYap9JDTjByWjYZQ1/2bN2wfTAVqmoSudupGz4G1d7R3gmgaS4j5OP/8BEPPgLwAz5elh0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709655113; c=relaxed/simple; bh=uQH63O7FyeOFltkdI1lRGKiBK+NR56mKzOJn3CPCs+I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WNdgKBwdk/tZYeeudDniAmIDEYZB4s65ryOTDL/fFTjptVR9MHp3Z1iV+cnMcM5V2qx8NdehSNJTb+4CgobU7keF5GUvNgxesBbMtk3+5TWXLiFN0z4WIodcIc/vI6xG4MAclHMT8km8RZvd5U4ibHOg0RzuNKDqnA1xoidKMHA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=OKwp8mTf; arc=fail smtp.client-ip=40.107.92.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="OKwp8mTf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iBgGsec7vghJ52515lo1tqUxEVonOi3G2s9YntshVnEVbxhNIBK40OeWIqz1FRhelbyjrCCliXcZoKlkH0z/hxBwscrZQHU2rEjLqMZAthMppXMZ8s7keQkGszVFLh7vn7iOI+mg8m+8QD2c11Fkurlsq1Rn1qBydflJs5P0ERh8f8jggsh9yIUcm9U8xsvzv9AF0lQQDkAAVKVzsrY9yPlM2aoz9paMyhUiN/NA+5oz8lFbbtU9L8R+aBCqaHgm52XzGQI4xXnIlobakfwKF4ozHoaFJsjrGP+x9Xp8VU5AvIHYi7GVEPZ2w6wCfX24buQi5OiwrppgRAeV7DpmLg== 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=SHxsVm1RFsmXOLFGOp9HnzYMEHtmYcu7o+CS2B9gfbk=; b=ZeibOkHy7z5noVFXPVqGhqWfqfMNP6xSEkdwQ48S3967JUFAtWGBelQBW9JgZKS0bPM2iKzH9zaiOEoCty0rCI6o59j0LRagWVoyFg9W1dWDzuOJeSKf0e6vAHXiogW6mN/9AQhFNW2Mf2l8iLAZbbs/STuGoEmxl2P+wLSNfzBV6ekcJPCCNZZzJ0/1ZIuF0ElQKiy5yR0NTwhAYSCSicefUe0DAZAHi5OlrA0LRpZa+9LxVaY101wSKYDQTyn7xS/b9o99O0O08zoEMo+mmOP8YQ6HMGi4dKiDLdLJkH/R9Ki3p/Wrs9uDFccTaTlfSj5arHJ0PCjGN6CMl4vJnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SHxsVm1RFsmXOLFGOp9HnzYMEHtmYcu7o+CS2B9gfbk=; b=OKwp8mTfGid2tIV4rJj10lO7F+NmQAeNYLjONgleGvKfTTf16dY7/QMc1T/S+4Ts7KLxnRHglCOkdgAgKj1BuHnpOxELIqDne1P/K9gRHDTsjYQjsHOAorjTqKUazil9mYdz0k/sA1p6g5WaP7gfOfZ4DCuLU0wREnd5osOSWrDLF4e/kdlWo8rUmAAge64oPuNUAmLOqRdruTj5Xmrb26u68iGtCZqNPmaeNRvfSKlPAWkVVwf0p+YoaUlMuNxTPmjBaQIqk+73EajQkOE/uu3aPZcILgMsPnBY4DuBUf+bJRSz2Ak9KuYafWOxpx1FqMKVXiCelDNiyEz3KM5Hng== Received: from SN6PR05CA0035.namprd05.prod.outlook.com (2603:10b6:805:de::48) by MN0PR12MB5955.namprd12.prod.outlook.com (2603:10b6:208:37e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24; Tue, 5 Mar 2024 16:11:39 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:805:de:cafe::81) by SN6PR05CA0035.outlook.office365.com (2603:10b6:805:de::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24 via Frontend Transport; Tue, 5 Mar 2024 16:11:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 16:11:39 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 5 Mar 2024 08:11:29 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 5 Mar 2024 08:11:28 -0800 Received: from waynec-Precision-5760.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 5 Mar 2024 08:11:26 -0800 From: Wayne Chang To: , , , , , , CC: , , , Subject: [PATCH 1/2] phy: tegra: xusb: Add API to retrieve the port number of phy Date: Wed, 6 Mar 2024 00:11:21 +0800 Message-ID: <20240305161122.1254099-2-waynec@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240305161122.1254099-1-waynec@nvidia.com> References: <20240305161122.1254099-1-waynec@nvidia.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|MN0PR12MB5955:EE_ X-MS-Office365-Filtering-Correlation-Id: b6c22762-6409-4b92-5379-08dc3d2ef0c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7rE4cPRhM3XRq/lIKGXrFhbYpVxZTH3ufDZsJ6WfROiQjlqwnKLZVfK6dXo33tehhrHHIeUVNOpImmDd57TjJYLMdPZvF5/1NypbclzxD0VRd1tFA2n1OuSUC2i0bIcOd//MM7xTlbpR38EtiIocOsxpV7f0g75cjX9Jik9UEL6Mk6f+xE0USLdPtgHLD7SFY4afMFbm4ePI5s6Q0fBm9g5AclyiclzOmzIE6ccsZAHUCkd1Kp+9rAkpXvxDEcdWFUqWaCAfgkOStGeVssU2FX0hUE3IB2LD/zKcXzyZZEQF9BpLokLPTKPHWVwvpkqZXHVFgqPUHrNNoE3ImdkViwLOpXMUSWEajZGxcol7kLfJTUwGQf8AFn1kN9GFLMh8x4GkeO+JggdpCt26/RnsUOPA/BnN7lm5bgTOWUShEXlBvXin0/t/oRVAvLyV99BtdPfFZMJm8WqJItvBju6tmBKI7pxJD2Ok5f9S19ECL7B8WEz6dHVWshR8ihW1kJ6Uh2H0vioGCayAnVUB1oooHbOiqwVczZkpZj5f7/3faDLN1njH5qQ5FfjwxFlWZAISpPrkSaPBMIk5zMQWIc8jv23vnttckKbC5cvC5uggzAC9t9H/KGhxffM3ISKjSyujjCsO5x7E/JBuA8Ff68DsWwmjZna8P8i3W/qccuQmuxxCJ6ZMzplva8G0GnjuRN9voTV2ebsMbkW4v0My1qMlbGhKMOWdKb37q8vAdEFCEuxZz5qLCu6G54Kbx3u2cQVa X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 16:11:39.5993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6c22762-6409-4b92-5379-08dc3d2ef0c6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5955 This patch introduces a new API, tegra_xusb_padctl_get_port_number, to the Tegra XUSB Pad Controller driver. This API is used to identify the USB port that is associated with a given PHY. The function takes a PHY pointer for either a USB2 PHY or USB3 PHY as input and returns the corresponding port number. If the PHY pointer is invalid, it returns -ENODEV. Signed-off-by: Wayne Chang --- drivers/phy/tegra/xusb.c | 13 +++++++++++++ include/linux/phy/tegra/xusb.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index 142ebe0247cc..983a6e6173bd 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -1531,6 +1531,19 @@ int tegra_xusb_padctl_get_usb3_companion(struct tegra_xusb_padctl *padctl, } EXPORT_SYMBOL_GPL(tegra_xusb_padctl_get_usb3_companion); +int tegra_xusb_padctl_get_port_number(struct phy *phy) +{ + struct tegra_xusb_lane *lane; + + if (!phy) + return -ENODEV; + + lane = phy_get_drvdata(phy); + + return lane->index; +} +EXPORT_SYMBOL_GPL(tegra_xusb_padctl_get_port_number); + MODULE_AUTHOR("Thierry Reding "); MODULE_DESCRIPTION("Tegra XUSB Pad Controller driver"); MODULE_LICENSE("GPL v2"); diff --git a/include/linux/phy/tegra/xusb.h b/include/linux/phy/tegra/xusb.h index 70998e6dd6fd..6ca51e0080ec 100644 --- a/include/linux/phy/tegra/xusb.h +++ b/include/linux/phy/tegra/xusb.h @@ -26,6 +26,7 @@ void tegra_phy_xusb_utmi_pad_power_down(struct phy *phy); int tegra_phy_xusb_utmi_port_reset(struct phy *phy); int tegra_xusb_padctl_get_usb3_companion(struct tegra_xusb_padctl *padctl, unsigned int port); +int tegra_xusb_padctl_get_port_number(struct phy *phy); int tegra_xusb_padctl_enable_phy_sleepwalk(struct tegra_xusb_padctl *padctl, struct phy *phy, enum usb_device_speed speed); int tegra_xusb_padctl_disable_phy_sleepwalk(struct tegra_xusb_padctl *padctl, struct phy *phy); From patchwork Tue Mar 5 16:11:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Chang X-Patchwork-Id: 13582663 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2059.outbound.protection.outlook.com [40.107.100.59]) (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 EC8A51292F2; Tue, 5 Mar 2024 16:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709655115; cv=fail; b=rAaIxYJzaKX4sYzNb2tm3Ls0OYt57ceZF51EnO9Q/HF7BV1cKXYxD6ZTwDsovLmTdHY+xMV4oQc+2qUKU861ZzirgU8AosvBFiyX+8arCD35cD8NCsOQ4BSo3n1YKMb1Ki8GEe1tScqXppGdh5yRhLQGZbOFfeVlhNSTxf5UfAg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709655115; c=relaxed/simple; bh=c8lyXzF+OX4yn8gwmnFD5NSoL7Rj6FGxVdF9S9mOieM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q432kFBOPUVAuf6gEVcrPhXEzKn+qHD0ZrFvbJ/q/roaVSvXy9h0Qbw2zJpPIn/xLZWeQSBc63LDh+a6Ac+gc0airbk4DBEK316I5Y3kEPUjOn76My6qXYt0LNgpcEfnvTbh1n3CdLepkglW371oIwQlqoQ3FMSW3XaynK7A+wU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=GRc3FK2B; arc=fail smtp.client-ip=40.107.100.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="GRc3FK2B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mEztvqIp05zI2ch+oiYEF5w8DBOZ7LixLKEHgt74mBsMfalL0duyK2dzdTzy5oDjVdSfSr/00lGnzNy/YW6V4D3dlTD3mvrrWSJH17dKvDNJRR6gE2M4Ft2oLz3xzrUXa5S9NU3iCMJ9tp8S5eeR5C52gxxF6hmFBWL6BqzvR/4cbVvxtMjy+rtJU1kE6VwbaxA2mXe1jMEtEjvtf8YzuKY94KK4+d+yaCJX7oCHUjTH9qEJz5rVl8/SaAPPrsnmoR5T/yvTR1+ooIiX3FWMVAP3f0/r2LvSpeJOPOKuqXElN9IEL76wbQvtb70Sgr+qbKifV9MMRYF9bT5YkLlYSw== 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=L+09M14IRLI3n9a7Q7htbZ/uODfxUfA5y9XELnT5hyY=; b=nxL5IOsYyKYN8uuSWfksIlXKeIXFwb6LtObe2XE/i+5AwUokiMYqlx6zq9ARyVDo27u8anNerEzkRHG/jMfOTWpwsu2mfuu7iiKndh5VUFHIA9CbjuVn0mT/yHjjDWhqTEJbMPKV24ZrhNJC8fJZ5a//sYcc2aAqVUJSIU4UskC+gFgzcdZHT8u/eLU4QUW0O/cAbgjfJtjp+8DXdztK9PntHEZD95qGxAYzxuWNccVyye6omFlHAO2bmEBgiV/owcBmUQDHemRBUjtmihovvSLsnkDmET118IKJyMbfbFn/zw+KfmGX6Heq2T52F1uqsgxrg5hsp3ybwuklgu0pzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L+09M14IRLI3n9a7Q7htbZ/uODfxUfA5y9XELnT5hyY=; b=GRc3FK2BOn8rRRWVdH6OFbsnZoZl/E5fVvxL/PXAKrquNIffZgZRfKB7r+jxQABxZIU46duZjWb3MbtqVY5uYjNFSHmeGJZF/aIcUDMxRxeK6btHtr8fg8NsET6jEtn9PehuLLsJZS4leQlZ/TuWj8sVTeD2/wbH6PvhxAM+2gvcK9Dh5LX6orw8y91uMfdADXEPzaD0gX79GZelcqpdCvlmB4eSZPLv3jmW99r1gI2Ak5+yO1U2RqmfQkyjoAbbUfnFp8l2IqYAk7SwztGJMW1NWfduLpmosMtTlPnSeX4YDiHNvsCuqk6AMdquCFY34hoXuzVI2capQ1kx+Jffzg== Received: from SA9P223CA0022.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::27) by SN7PR12MB6837.namprd12.prod.outlook.com (2603:10b6:806:267::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Tue, 5 Mar 2024 16:11:49 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:26:cafe::f) by SA9P223CA0022.outlook.office365.com (2603:10b6:806:26::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39 via Frontend Transport; Tue, 5 Mar 2024 16:11:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 16:11:49 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 5 Mar 2024 08:11:31 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 5 Mar 2024 08:11:30 -0800 Received: from waynec-Precision-5760.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 5 Mar 2024 08:11:28 -0800 From: Wayne Chang To: , , , , , , CC: , , , , Subject: [PATCH 2/2] usb: gadget: tegra-xudc: Fix USB3 PHY retrieval logic Date: Wed, 6 Mar 2024 00:11:22 +0800 Message-ID: <20240305161122.1254099-3-waynec@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240305161122.1254099-1-waynec@nvidia.com> References: <20240305161122.1254099-1-waynec@nvidia.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636A:EE_|SN7PR12MB6837:EE_ X-MS-Office365-Filtering-Correlation-Id: e0c21c61-3690-415c-5dc1-08dc3d2ef663 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: orIsIax+F1njox/cuhWGy1E6+lqjHWA82hPdRyZ9cj+UsqnalWcCnYMoAsgEq0FC2YwiYa+gAtaKKVQy/GBSA3grGSKvFARJ4RY00DSYzw3iYHrFalkAti5zTJxpJPjb0l43YzmbCT2sBCeoZD0bGYVMG07PdcNuyUoj/Rjt019W59vAe6b/uOd9es6BZ8n5Xv9W1k00erz0CpK8FXQpG10QdL0AFmp0wTYrik9Q6OKunXuYh3QIhdzqweNEtIHuuU/IHzAsCIIQrcyzSpOr2T5+TAAIE2KFPRg1HHnFKa4xIRRbVSLccAXcxZm9MhnF6rD7dN0UWRRowIqWPtQViUebLNsLK2nL1PqYFFvYRsyero0YdmjJwkhHtXlmHcKLsQHLbcG15k4R2jI3rKlJB7E8LZxHcl5YDZqHxNSQyzDj1700/ZiGteZsWb6jDUSKkZ1pxV2G3ifhs4vKnHhdgTPzkeV+fY/nd4zz2qv0ZVOR49K+d+jQ+CGQnvxVVH+6Qq9okpcgDn3M/93nIS8wR6jRATSqh9D8e1EEGHjDK0CXPa2kFmetz1BICui2gZnbqw2X6wYpYW1CrsWBAzd9FY1BG/c4Apx1HBFqwWMzXhr3Zn6zfAJynkikEdNVoeghaxYv2NdekMPJ+pEpx3JisDfQryQGgPJP6032TRQL2ntqapCttu79psF2fqx/Fo1GrZgSGPrfMnFEy/3imqlbJ1j+7Kn2OCmomaRtEhtwn7TkyPqWoXBfGjcApH1geAkT X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 16:11:49.0013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0c21c61-3690-415c-5dc1-08dc3d2ef663 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6837 This commit resolves an issue in the tegra-xudc USB gadget driver that incorrectly fetched USB3 PHY instances. The problem stemmed from the assumption of a one-to-one correspondence between USB2 and USB3 PHY names and their association with physical USB ports in the device tree. Previously, the driver associated USB3 PHY names directly with the USB3 instance number, leading to mismatches when mapping the physical USB ports. For instance, if using USB3-1 PHY, the driver expect the corresponding PHY name as 'usb3-1'. However, the physical USB ports in the device tree were designated as USB2-0 and USB3-0 as we only have one device controller, causing a misalignment. This commit rectifies the issue by adjusting the PHY naming logic. Now, the driver correctly correlates the USB2 and USB3 PHY instances, allowing the USB2-0 and USB3-1 PHYs to form a physical USB port pair while accurately reflecting their configuration in the device tree by naming them USB2-0 and USB3-0, respectively. The change ensures that the PHY and PHY names align appropriately, resolving the mismatch between physical USB ports and their associated names in the device tree. Fixes: b4e19931c98a ("usb: gadget: tegra-xudc: Support multiple device modes") Cc: stable@vger.kernel.org Signed-off-by: Wayne Chang --- drivers/usb/gadget/udc/tegra-xudc.c | 39 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c index cb85168fd00c..7aa46d426f31 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -3491,8 +3491,8 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc) static int tegra_xudc_phy_get(struct tegra_xudc *xudc) { - int err = 0, usb3; - unsigned int i; + int err = 0, usb3_companion_port; + unsigned int i, j; xudc->utmi_phy = devm_kcalloc(xudc->dev, xudc->soc->num_phys, sizeof(*xudc->utmi_phy), GFP_KERNEL); @@ -3520,7 +3520,7 @@ static int tegra_xudc_phy_get(struct tegra_xudc *xudc) if (IS_ERR(xudc->utmi_phy[i])) { err = PTR_ERR(xudc->utmi_phy[i]); dev_err_probe(xudc->dev, err, - "failed to get usb2-%d PHY\n", i); + "failed to get PHY for phy-name usb2-%d\n", i); goto clean_up; } else if (xudc->utmi_phy[i]) { /* Get usb-phy, if utmi phy is available */ @@ -3539,19 +3539,30 @@ static int tegra_xudc_phy_get(struct tegra_xudc *xudc) } /* Get USB3 phy */ - usb3 = tegra_xusb_padctl_get_usb3_companion(xudc->padctl, i); - if (usb3 < 0) + usb3_companion_port = tegra_xusb_padctl_get_usb3_companion(xudc->padctl, i); + if (usb3_companion_port < 0) continue; - snprintf(phy_name, sizeof(phy_name), "usb3-%d", usb3); - xudc->usb3_phy[i] = devm_phy_optional_get(xudc->dev, phy_name); - if (IS_ERR(xudc->usb3_phy[i])) { - err = PTR_ERR(xudc->usb3_phy[i]); - dev_err_probe(xudc->dev, err, - "failed to get usb3-%d PHY\n", usb3); - goto clean_up; - } else if (xudc->usb3_phy[i]) - dev_dbg(xudc->dev, "usb3-%d PHY registered", usb3); + for (j = 0; j < xudc->soc->num_phys; j++) { + snprintf(phy_name, sizeof(phy_name), "usb3-%d", j); + xudc->usb3_phy[i] = devm_phy_optional_get(xudc->dev, phy_name); + if (IS_ERR(xudc->usb3_phy[i])) { + err = PTR_ERR(xudc->usb3_phy[i]); + dev_err_probe(xudc->dev, err, + "failed to get PHY for phy-name usb3-%d\n", j); + goto clean_up; + } else if (xudc->usb3_phy[i]) { + int usb2_port = + tegra_xusb_padctl_get_port_number(xudc->utmi_phy[i]); + int usb3_port = + tegra_xusb_padctl_get_port_number(xudc->usb3_phy[i]); + if (usb3_port == usb3_companion_port) { + dev_dbg(xudc->dev, "USB2 port %d is paired with USB3 port %d for device mode port %d\n", + usb2_port, usb3_port, i); + break; + } + } + } } return err;