From patchwork Sun Sep 8 08:34:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 13795347 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 72DD5E6FE49 for ; Sun, 8 Sep 2024 08:35:09 +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=ESb1zIu45OQm6gc5O2zuFYDJas40/Ys9ouIpyX3FYAc=; b=pWzmW9S0DueZYj +qARE5UZqMZKse7WLAmMSJeZdMEgyRfM+MYzt3xAjVcAhlte30Q1U4sLPWV62AjI+vK7UjRNmDL0k IxpdSdpLYT6XPS6RmcGtooRQX67O90+3oEII6TzWcg1bGd44YI2bV650QyUW7tNo+iBpUJZOfsBNX SRmjYbsr84FHzgHU3y6JiMaGLOGnaSbUBromDrirkbiq2YM8ET0AE91VilD/B27TuXLYE7MHIeBYb rVFxIhK3CeC5xaXO/m5EennfOCbO5xjqcp9AnByyk8xREHKpSf3VKaGeLHRqpTbeSSVo0tKBAx2Yh cugpXifm/v2ECHG+6QBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snDO1-0000000GPFL-07cw; Sun, 08 Sep 2024 08:35:09 +0000 Received: from mail-northeuropeazlp170130004.outbound.protection.outlook.com ([2a01:111:f403:c200::4] helo=DUZPR83CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snDNy-0000000GPE2-0cBb for linux-phy@lists.infradead.org; Sun, 08 Sep 2024 08:35:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Sei67z7tO+3kXjoybhxd9/f/0UZPfhXb1izchPNY4aWsE2Tuu2UnK9phSgZsSEhCO8xs0sqNNwfYVTqMZedNgHf54FHqCceqS6ezRYNU+qfv5lnWck8fH6PkpsnfJtaQjeDJUciAO5UvIoHYg5bAfZDlaYSuzI8O6AwaGv04nIimkZlG3sWTqEQYnRX27yFZuXO3diizFPAeJqD2xj/HcAYDMXOVrEyfBTN3PR2UcX50f1o5zmcOfhv6MImeHO/P+Km3001LuK4pCjwX7pYEecw2vWKl6oDe5tZVzlJjA+Zc/5Alq4RDNIIoatNzu27TSzr6L2dDsPc9udSbETp+WA== 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=KWbMLrJxLHF5B33ecxAb1m5DKvW0aLf6ACPrU/C8F30=; b=wpYAals/VRA33q73RATZtdLmn0z3ZKVmSbbNOa3ec0PJqrMc1FuqwRMzfK48j7RFbJrAOWpOHYz2Uc/VgNqZ608gpIYSqZmNAsU3/CMFK6qnXODpqWvoZgI/hfN6gOf8vS9XIr82xjyIaU6a4+Ig+c+pIBDQNsEVlIi7ax8gv0+2rJtR52MdFbesv+0yu46mLYQLT5SA4p8IWxSNb7AKpdEpcNccdwtL8a/OAXus5Ywdp38Zcb/0u1xkfyZp5XZdZBNt5P4r4tga+94aN8M45wt/0q5Bclp04RuG8B0SPy8nKvLCDrJjNUfQItndaZofwoh7MU8S2vZGZiZjjFT49w== 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=KWbMLrJxLHF5B33ecxAb1m5DKvW0aLf6ACPrU/C8F30=; b=pS7K94UWrqpUzS6IfvZN9jCJP04/hqlCs+OBGIr78s8p1KknRc+fmsNI9AxtdS3iCq8PY/qb1p3vFj8oT7f5rwe/0XzvDvndAES/50OSTfCF931YCHFHfh9WL35DTRtDyTAg9DT7On446h585p7vRBfJjt+it7pMnvVcVxFTIWk= 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 DU2PR04MB8855.eurprd04.prod.outlook.com (2603:10a6:10:2e2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Sun, 8 Sep 2024 08:34:53 +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.7939.022; Sun, 8 Sep 2024 08:34:53 +0000 From: Josua Mayer Date: Sun, 08 Sep 2024 11:34:48 +0300 Subject: [PATCH v3] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property Message-Id: <20240908-mvebu-utmi-phy-v3-1-88c50950e7d2@solid-run.com> X-B4-Tracking: v=1; b=H4sIAKdh3WYC/3XMSw6CMBSF4a2Yjr2mLwQcuQ/joLS30kQoaaGRE PZuYWKicfif5HwLiRgcRnI5LCRgctH5Poc4HohuVf9AcCY34ZRLWlIJXcJmgmnsHAztDJVUSjR W1EVpSD4NAa177eDtnrt1cfRh3v3EtvUvlRgwqI3QFaKSZyyu0T+dgTD1J+07snGJf4iaih+CZ 6K0stZMMKsM/SbWdX0DgbIzRPMAAAA= 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: TL2P290CA0011.ISRP290.PROD.OUTLOOK.COM (2603:1096:950:2::14) To AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB7586:EE_|DU2PR04MB8855:EE_ X-MS-Office365-Filtering-Correlation-Id: a5912bbb-45a2-42a3-618f-08dccfe11c85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ByR9G37jpv2kWXWbGS+A3l/k9BHN/FK?= =?utf-8?q?iq6UdZuwsTqUEH/MAJ63dgGwfk6rujMyuIgrgFzo7hZQxrn5tv7WVwj69hHsuehV3?= =?utf-8?q?UZoyqvtMG/iKxsVOBK9q2v0fGl9KtWhorh4qgeXKzIg3PVGyme1juQE1XbzVZxUnL?= =?utf-8?q?qyZOdp0B5IPCe4loYIsLCOkHn8JizlWiwx8eyH5+3DjEj+INCJ3bXjXqOUcPqYWQk?= =?utf-8?q?rMMqGiN/Px+u/WT2jKRdwzU+yZ/UAdjISBKPPfQ3C760m2iyFdO1hisABbfGSjfLE?= =?utf-8?q?pMyZ0h+Ow/hFnKpWRUttzsgaecPeIgGec7LdH9bu+4EEdEwvivmD2gXso12LKPa+q?= =?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o+W9r2nsvj/Rpo9nM9I6BCdpC5BMc02qXxLqzFFWZOFbVddm4aF97syYU2O?= =?utf-8?q?AU9SG3X7SI4fPe3e8jQAOoLzqq/A41qChjUKJNoTAGTfW1Z2IsXvNWr7zPc/sGckf?= =?utf-8?q?ju6mGnWt+ZpOSdIlTJqmdrYOdelJHYlEjQ=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)(1800799024)(366016)(376014)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?q+yJAfSPa4qW6zGo1epenKZPLdpH?= =?utf-8?q?VSLRla7T1q+arw8FIl7b5dCY/s0wjAdfjbwZM7dtBP31oMnM1tuvrgsg1pdw9jb5J?= =?utf-8?q?cCtggJqH+TOdNJAJd44WWWXy6z8PMWdXwGPETD9Il8ZLMMUCZGKfEbhaE9PfYU5tN?= =?utf-8?q?yHXmnQ2/PrnW/5G7N5Ly5eKiaeVkkoED7pzRmVZDXaG8D4hoNZZOGtwhdr7hL8KKi?= =?utf-8?q?ambkjq/dfKHN2+U6uHdeBlXN+Jd3kZDSBf8zZbhW0S1hJuJMSqK/C5Uzwk/mvbNCN?= =?utf-8?q?GUZY3+m8Tm+46tsGg9B7IWkMkDppTdPTdwMN3VFab6ufvUecPoTUQXd882MffPH+c?= =?utf-8?q?9eovCJ47fRAyi5LKCZN3rbPgtd29gsHasVKjoKqcOtG4+Z1A35mEsw89dNgYm5LXn?= =?utf-8?q?ALym9tUkfjVz9rWC0gliIPfTDwjwyC59i5AM1nThJPnqEvBwhEvMT2Jwvt3c1p2nV?= =?utf-8?q?UWBVPJJxxts7UWw7P135SIYvq8PlJM4NidTry7nWUhUP3nN4dBZpdsGacP2lndhKX?= =?utf-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?NbRq5RKcsG5DayUmcdgzyk91U8gCtv24BK2h3QQK3NOWRokYqyz6x8MC/PdrvHdyF?= =?utf-8?q?yvL1qbtF/2kl2jCz6LYkkv1QFmQGGMSSaHu0PMClbV45O31pEOC7el34WlIjtN8Tc?= =?utf-8?q?/XRbdIuVod2I?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5912bbb-45a2-42a3-618f-08dccfe11c85 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB7586.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2024 08:34:53.3912 (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: RqluUMxlVxJgCFU0a0HUULm5bg/2Byf2exsirfeegyXGSdZzaeg9SjIpBaaYtxYDViEcjRQrLPi5RnYhfizupg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8855 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240908_013506_201436_53E4C33A X-CRM114-Status: GOOD ( 12.53 ) 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 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: 8400291e289ee6b2bf9779ff1c83a291501f017b 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;