From patchwork Wed Oct 2 14:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 13819843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87A5FCF6D2D for ; Wed, 2 Oct 2024 14:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:Message-Id:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=w+CjzJWgu4kMqQoW3jhZQp5abmAt8rBxOBqWFbp4w3Y=; b=dq7wt+3AroDg88 8JvVWHcfgaAnF0GLjHRaVMdVcCTrG8PbuLSAJCgpFFVqgX/E/nMsFknnl2qtpMUUNbzmd1pT3KY1/ bGUmJUWlN6GMf5xsZFL+tzJUUymNhCrUz+DwLWiycP2Ay2+LOMRstrjWyHPtL137BWP3meHNyjwfx 6z+p0uU2CgKnb0job5OhXt/m6hple9AnZZE2K6GdkxsXOe1f1KjowS5uS/iMyN8AJnC/7EZ1ivIxn ZA9snrO4ixy6zNKUTTaHYuMuPa9hX60vhGqvymG7MW/Wtdu+WeaWFx0ld+nrXSZTzwcX/3tnHBKJm 8m5jM5wVxD9XNtxL0Ayw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sw02W-00000006JZS-0UNp; Wed, 02 Oct 2024 14:09:16 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svzyI-00000006ICz-2BBr for linux-phy@lists.infradead.org; Wed, 02 Oct 2024 14:04:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RxjGZgzCFeTfd0/MoI5CMqMI4CfcXqtF6ZisbvZKPemDjL18q2UggfRWkHDz+1QOjCBQp/YBBeoO0/CyBqaYOxIZykffDpcAXB/LsisOHeN15n1eTIELC9I2wlNALfHuGCRGnaY2Y8wDAuM6i7VsBKolUbKKpd9XBXhKThM7GglhB0dT76qyfZyGarRb82QLY/yekbR02/FGw9DBJM4zY9q4ID7tBJM0OnyqQFjAPsyquV8AoSE1NhUbaczobg5GPQ1j/Ns41dRXAiwRvssNkhht6marwhYPepuvZgrCSOjBQ9EihYT/wfbyGG0gWUBP8ALLh7NmxE1aWFfB4CMnlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=QXn8zHlDp5tAHfmcC6ozjulSVRSZR5lEJb2jT4EQMn4=; b=KTMMZGYeTP1YSBO2CdYl8aiZj75Jf4IThrzgyjgy4Za4s5PeUa0zX81FU0i/s7IUv4fOwysw/+6p9rjvHTMbAtDcD11aRrVsw3ZnV4tsV/W760jYpp8VDfgVMIz+R6tvIV3XPZLDKUNFEdyNPBU+0fOXUGL+g10LwDXjQPnH+SffscUbTv0XEyR0o45us8bMRP8dhzaUMjJN3Qh/FUMrJzbY7I+XMiISWbhT9on4uy/YFTYzSBKmBOs3QtDkSmlGDN1U8s3jbX4Sr7/EyMQKFdM+yQ0TTRtJwPzGk+i8oiLztVuicQ/9UBWh28rLcbTE908LnbLa47cxdM7Fch7/mQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=solid-run.com; dmarc=pass action=none header.from=solid-run.com; dkim=pass header.d=solid-run.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solidrn.onmicrosoft.com; s=selector1-solidrn-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QXn8zHlDp5tAHfmcC6ozjulSVRSZR5lEJb2jT4EQMn4=; b=GEXxaDkjBK8Y0kwZz6eflwXiPg3+TjNjAsfC0oGWIoJ11v9zqKhQPDRsae9ybr3opqavaJy6zq7PK1ELP4D6OCGEK6fhjiUFHb8Vk1+Vj+LP77JtSOGivhA2HZ/A8mFZo+8276MZ1mSkhD/Z60kD5dd93ZGYqhSmqE/kpn7eR+0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=solid-run.com; Received: from AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) by VI0PR04MB10095.eurprd04.prod.outlook.com (2603:10a6:800:246::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 14:04:45 +0000 Received: from AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529]) by AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529%6]) with mapi id 15.20.8026.016; Wed, 2 Oct 2024 14:04:45 +0000 From: Josua Mayer Date: Wed, 02 Oct 2024 17:04:40 +0300 Subject: [PATCH v4] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property Message-Id: <20241002-mvebu-utmi-phy-v4-1-83783dc89b9d@solid-run.com> X-B4-Tracking: v=1; b=H4sIAPdS/WYC/3XMSw6CMBSF4a2Qjq3pC2kduQ/joLQXaSKPtNBIC Hu3MNGIDv+TnG9GAbyDgM7ZjDxEF1zXphCHDJlat3fAzqZGjDBBCiJwE6Ec8Tg0Dvf1hKXQmpc VV3lhUTr1Hir33MDrLXXtwtD5afMjXde/VKSYYmW5kQBanCC/hO7hLPZjezRdg1YusjehCN8RL BFFJZShnFbakl8E/yTkjuCJkNLkROUECsu+iWVZXnQEejs2AQAA To: Vinod Koul , Kishon Vijay Abraham I Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Josua Mayer X-Mailer: b4 0.14.1 X-ClientProxiedBy: FR0P281CA0194.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::18) To AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB7586:EE_|VI0PR04MB10095:EE_ X-MS-Office365-Filtering-Correlation-Id: 3791fec9-40de-48d3-241d-08dce2eb2b7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1P168wAMZrHzcO6W5hs3IbsFL0wG+lh?= =?utf-8?q?bPRGDxrSFOqkcNbkNVjcHrsrSK5SZdMjBE+yF4WjN+SDBZW+RNESYhWEHlMpRC2Wl?= =?utf-8?q?xxIFDFBJkaG4/DSKC9VSuC0kdWJs4TcGvy/XEqp+yAy3ZEqNeGNer13eulndHiS2e?= =?utf-8?q?ObtHyLmgMYAGIp0iREhJAhXfkdX1tjJK6svcZriBFDp2FDche7bRXgWQxfM0NbxSA?= =?utf-8?q?B9/5KzzW+twpTGbkmatIU6fi5Ap7dn6E+/iBFy6w9HGeE++eF139DpxO4pRMduLXC?= =?utf-8?q?tsqtc9yQXY9rb7w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TA4+BKiNbtVT3Tn33MtpYjYs5DE082mIca7PcI+4lxukb13ajNVBhfoCa?= =?utf-8?q?NcvGOLbU8OlOKKU5C6LpDjZIwtklV332ka+hD0jMuyQ6m5P9DBPxtaldRBQI7T4Yk?= =?utf-8?q?lc7+uqg90WyDCZtHM9COn9DfZGSvBSzyAxQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB7586.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?h4e8AHxM8S3s42Rtf2o7+kh/qep/?= =?utf-8?q?5Xj6/oUo8+XqWwNR9q16VwAIGToMRvNG+Xy8EWk/oyJYDUGQhLme+BY1Eut9aqcAl?= =?utf-8?q?72nUD2kErzJCKJ1AFh17+BFat6yURbVqwwAWSWNX5GxlamrJTAY/f4aBpTz7j9rsW?= =?utf-8?q?dsVqxnxc3Ewz9SK0a43YG6P3u9R+BwThy8pEgdxDCNteLFDZZMFX3nVf/CQa0d+8G?= =?utf-8?q?JjuqiBNPZNnCNhMiQj9e+4A6gS/Cjn1s+v3N9qMCcusBKwjo8OabZ7xbl0DB8n6rG?= =?utf-8?q?IV7VXBa7fFXqU+MrVMKSBH6+lTFHP98azsuLlfyOBANbVpZOIvIDJtDVFm6tJlA4l?= =?utf-8?q?suNELpV7YpW08uPh+TsFBVx9UYIOYWFYFvhQJog+YA4x0sCuqSLK4Eh96NKwspBgv?= =?utf-8?q?y7QvtOiO22DNmzSGs3OIAxknxJUeJzPipVSk25mda3EkN5K7SI7A5ZTcQHn0l9qrK?= =?utf-8?q?WBBMvRLQOttkP2qKjXShVbVoD+BnFRQdGw0E2EwqFpgOsvQ+CbDsisiOi9p1ptMZi?= =?utf-8?q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r3NUMf3DT?= =?utf-8?q?6laVur1rUbi/ljgyNJrOBIiAQe8PuFNxs83G6jtZeNx5EU30D0QbWsFgIJYu7b1Jf?= =?utf-8?q?mQ2KyVS68QTXzTMdd03Qcc6B4CgLF58klRi/oBjm6HmHCsQKQkAXjvwu4+CrustMx?= =?utf-8?q?e57qwzkHHvHd?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3791fec9-40de-48d3-241d-08dce2eb2b7b X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB7586.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:04:45.5460 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a4a8aaf3-fd27-4e27-add2-604707ce5b82 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GzovsyoKUESYU9SUOqSSGdut/noHz448IFfqaNtk2qMZK906m+xGEOJ2AFIJOzJ7dWXpU6i+U65B4gyNMtL8gA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10095 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241002_070454_979268_22F67F5E X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org CP11x UTMI PHY supports swapping D+/D- signals via digital control register 1. Add support for the "swap-dx-lanes" device-tree property, which lists the port-ids that should swap D+ and D-. The property is evaluated in probe and applied before power-on during mvebu_cp110_utmi_port_setup. Signed-off-by: Josua Mayer --- Changes in v4: - rebased on v6.12-rc1 - Link to v3: https://lore.kernel.org/r/20240908-mvebu-utmi-phy-v3-1-88c50950e7d2@solid-run.com Changes in v3: - add description for new struct member (Reported-by: kernel test robot ) - Link to v2: https://lore.kernel.org/r/20240903-mvebu-utmi-phy-v2-1-7f49c131fad0@solid-run.com Changes in v2: - fixed compile error introduced with v6.11-rc1: parameters of of_property_for_each_u32 were changed from 5 to 3. (Reported-by: Vinod Koul ) - rebased on v6.11-rc1 - Link to v1: https://lore.kernel.org/r/20240704-mvebu-utmi-phy-v1-1-9d3c8eea46e5@solid-run.com --- drivers/phy/marvell/phy-mvebu-cp110-utmi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc change-id: 20240704-mvebu-utmi-phy-84aa3bf3957d Best regards, diff --git a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c index 4922a5f3327d..59903f86b13f 100644 --- a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c +++ b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c @@ -62,6 +62,8 @@ #define SQ_AMP_CAL_MASK GENMASK(2, 0) #define SQ_AMP_CAL_VAL 1 #define SQ_AMP_CAL_EN BIT(3) +#define UTMI_DIG_CTRL1_REG 0x20 +#define SWAP_DPDM BIT(15) #define UTMI_CTRL_STATUS0_REG 0x24 #define SUSPENDM BIT(22) #define TEST_SEL BIT(25) @@ -99,11 +101,13 @@ struct mvebu_cp110_utmi { * @priv: PHY driver data * @id: PHY port ID * @dr_mode: PHY connection: USB_DR_MODE_HOST or USB_DR_MODE_PERIPHERAL + * @swap_dx: whether to swap d+/d- signals */ struct mvebu_cp110_utmi_port { struct mvebu_cp110_utmi *priv; u32 id; enum usb_dr_mode dr_mode; + bool swap_dx; }; static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port) @@ -159,6 +163,13 @@ static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port) reg &= ~(VDAT_MASK | VSRC_MASK); reg |= (VDAT_VAL << VDAT_OFFSET) | (VSRC_VAL << VSRC_OFFSET); writel(reg, PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG); + + /* Swap D+/D- */ + reg = readl(PORT_REGS(port) + UTMI_DIG_CTRL1_REG); + reg &= ~(SWAP_DPDM); + if (port->swap_dx) + reg |= SWAP_DPDM; + writel(reg, PORT_REGS(port) + UTMI_DIG_CTRL1_REG); } static int mvebu_cp110_utmi_phy_power_off(struct phy *phy) @@ -286,6 +297,7 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev) struct phy_provider *provider; struct device_node *child; u32 usb_devices = 0; + u32 swap_dx = 0; utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL); if (!utmi) @@ -345,6 +357,10 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev) } } + of_property_for_each_u32(dev->of_node, "swap-dx-lanes", swap_dx) + if (swap_dx == port_id) + port->swap_dx = 1; + /* Retrieve PHY capabilities */ utmi->ops = &mvebu_cp110_utmi_phy_ops;