From patchwork Tue Sep 3 08:41:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 13788288 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 46908CD3420 for ; Tue, 3 Sep 2024 08:42:38 +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=3qRji44adn2NxUSSNXeQ7rIAcDsCdzHyfBBld79jSc4=; b=hVeWyxqVUN0pTl cSE5lnLgXioza5xoeBwIMRtwl0UuSZQjzIbgNWafecdinYby38w04tD2rT31FQco/vhlXPetJoBmn 06T7NqyLrVPbpMmEb3ufFZoYRtqU32t/Kxl42CoXMceP17nvF4kFSVyF0rriWQ9uz5B37QQmPTW00 lWdERsoJucKsLINZ8iKDgW6gbK+tOxkj+ASbXRWTQD7ZQ+wmWSfebenk8gU95KtSU22k1lAqQsDAn lnmd70ssCxA72BqDRcBDzsHZw8MKHSwjWTyoyC33+x8IElCLTLB2mEyKyLd6br49w012+YEAGnddg x3EPJ+QdZwINBP2wU8Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slP7W-0000000GxNw-00Rm; Tue, 03 Sep 2024 08:42:38 +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 1slP7R-0000000GxLu-3oAX for linux-phy@lists.infradead.org; Tue, 03 Sep 2024 08:42:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DjSvxhSV1iG8Br8RcQdQrHNDhiPSeplwVKWwEsOx+Xl/lUPgmnL+Lm48r/qeXpGcytQlngVRU9/pEJYrJVqBcSqmup1AooddrwAtcrUzRKEmuiSRmCEU88/FF0cg17vGTA1G1nUngdbnyCBUO0mWP9I6QH5j9aF/Xo0hNQg5OFYNiyoYnlTOs9Z04XgpXS3IPl3bDOs61uwej/cxphY4TejBns3dxb1anU2DFnDjK/yPBtq8fV/IECpCBJxZeEjP3cBQE4rCOhKqadnmEjI8G705TGAs0MYB/SGb2jXf9mmdhFuXk9IOe4rXb5jyeVHxhVJ8LPu15nZ1xtb4htleyw== 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=DGY+Z/fwqXfPlvTjOWRA139gBrn+2QMrMxqImcidDXo=; b=SVE7zYAFE/qmUiGTsOjKvnCAG0wO966n03p6h/WNlBoVRDzdhXlYGA1naXITPcSO5udD0cGAPBDHZD+CinPZSYMUTyiFUuO6uUDTUXZJVwiKQiN69VY8Aog1xP2aHNe7LhdxHxEdAeBZYsfEF28rLQA7o4hLqT8vKX/D+l9yXdljHGI1LuQox9mrplBWOdWcMTFr0Z6sZE1jDa7M7yyXF3WUJnJY4lv7MQlDLZAb+f1EF2vAWpz7TwQSikqU5Vxx2PqSVbpR5MZ4ZPDDoRMBi1OCvPs+uwrrJBet6mDbZVpBt6oGpt+6arNP0pSXfhkNWPjT+ZOsj8qPIOm4hflU5g== 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=DGY+Z/fwqXfPlvTjOWRA139gBrn+2QMrMxqImcidDXo=; b=S7d/0kUSGLdTzMIqDvMhG0nOMoHIUlskgK2cf4YiB/l+H3sIL7KPn0hsr3mx3bvDkMbhaMsfbA+cP38KUoKZRlsqRNJRICpK7bteCDcsg/SX9LTkOT8R0SS0FHb/NgIJ7umgxgJXiBleqeXp76bIbHmTNLqfDhHBBJ7Fz/0v0y4= 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 VI0PR04MB10734.eurprd04.prod.outlook.com (2603:10a6:800:25e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 08:42:24 +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.7918.024; Tue, 3 Sep 2024 08:42:24 +0000 From: Josua Mayer Date: Tue, 03 Sep 2024 11:41:54 +0300 Subject: [PATCH v2] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property Message-Id: <20240903-mvebu-utmi-phy-v2-1-7f49c131fad0@solid-run.com> X-B4-Tracking: v=1; b=H4sIANHL1mYC/3XMQQ6CMBCF4auQWTsGShFw5T0Mi9IOMolQ0kIjI b27lb3L/yXvO8CTY/Jwzw5wFNiznVOISwZ6VPOLkE1qELmQeZ1LnAL1G27rxLiMOzZSqbIfyra qDaTT4mjgzwk+u9Qj+9W6/fRD8Vv/UqHAAltT6oZIyRtVD2/fbNBt81XbCboY4xeq/YWgsAAAA A== 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: TL0P290CA0014.ISRP290.PROD.OUTLOOK.COM (2603:1096:950:5::8) To AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB7586:EE_|VI0PR04MB10734:EE_ X-MS-Office365-Filtering-Correlation-Id: bb9d3689-96e3-4766-ae8f-08dccbf45537 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?KPuUGLqFEZv2x2N4dKshwtskshjoAu/?= =?utf-8?q?2TfHoQh0YCbIijCqyLqDLznMfYJrWEPO40bTyTZM2faaj0gppDBEZvA1Sij0E74lA?= =?utf-8?q?l3+ws83A6uGd/ojQqA9oEptkvBuqpw2YTyJWALk0lM5w6UylGSWtcMrjKKjqhwCVi?= =?utf-8?q?tPYXLhuc1YV2/NRrGR4agl0Qy9P7XNgyYsgfbkTJOiSYRh1kd0sgF9bgOw0h2opdK?= =?utf-8?q?t8AO9vaQvbTY+hNfl1mTkjy+BETtxjUgQFOe/h4dofDyXnAYGS3Js98N95Mn9zmTN?= =?utf-8?q?CItdinNk8BrJ+pOwfu3pnvmxSZ/5koMQV+WAqvAgYJGJKQFq6TyxYJOr1/x/bGbee?= =?utf-8?q?3oD5CZA3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NqxPrsEt6Lga+0KA3fbYHqB1sIQXrHNlwoWPWuJf6439lJilCnop?= =?utf-8?q?52jAwK115i4kofeBzfuy2Uaexrm3kGqTBjzF7k/B1uNuGjNrbY0dEVY0JscFkcqdF?= =?utf-8?q?y5epfKMwKcZsLhMWs/QT8IJdmu/QROviGA=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?x/VHP3F/kqqSL5Hea5sqHLUd1vU6?= =?utf-8?q?5zrwNh19ddBQwQ3BL1OECGoJq4R7yODvWWgkXAnqmC14s8e/kiqYynINOTw4WQVXl?= =?utf-8?q?sGzbX1mxJaTY+Gkdos22zBE2VxU03iDDajCjJ2AUlOtUU/62cNTEU6+sO5Ln2kgzU?= =?utf-8?q?L33vHAVfDs1qXZ/cfV5NN9IcCmx/MJAblg9WOysuyJjRAuOL8Wkk4+/OLNJlgikBH?= =?utf-8?q?0fE6742jBY7IaSdW4R4aVDN6qquh8rQeWj/6xRI3wXJZ6mot91aDwiVSYP1JzcBpj?= =?utf-8?q?QlHSEDYIFU8PpKHkKvqg+H/8IFeEmk4qx6wqwO1ccIAw9MvG/SAKQeqvlLV2KoWD7?= =?utf-8?q?imDifr2gAsIH7nLqyrXlMO4AvYxgXBok4C99dTFynVw4tTWca9h6FUk8tOtzYiNSU?= =?utf-8?q?E+NELaw4iVEJNMryPdC4f+BXn2YasNQWFW+KFjWSdzxdniBwWGWruYWSDoJuIYyr4?= =?utf-8?q?eIWuNEaLqfP6iiAiIbgYwiDxGDU6fKKA+xj8oS/NkZSqgZViiQi/b2YFmjNLbuO2H?= =?utf-8?q?W7Huw5lD+bG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l2ljDMRAFY67aojVOTr2TrTurb+bdwGSfSbaHZfqzG0MPtYHBINvge8H9Yqj/?= =?utf-8?q?aojy3IPWn+SXOY8DGW/LuRo6yqY9GtRN+r6uv+NwcC1bIoQETJN8ewdL2ifIKGbbV?= =?utf-8?q?s1KiJR5d5p00?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb9d3689-96e3-4766-ae8f-08dccbf45537 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB7586.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 08:42:24.4177 (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: 2EdmNkLyXi9KPUxNGQuIoPSqz/WvC2n+vvZ26+0vg5dVxycQyGGnV5YXM0+Jp2r/gQdun9qBOJtvhVFxlpVsLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10734 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_014233_993475_1DABAC47 X-CRM114-Status: GOOD ( 12.45 ) 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 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 | 15 +++++++++++++++ 1 file changed, 15 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..12d619d9cf97 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) @@ -104,6 +106,7 @@ 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 +162,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 +296,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 +356,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;