From patchwork Sat Apr 20 11:23:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 13637121 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2138.outbound.protection.outlook.com [40.107.20.138]) (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 1B6CD383A9; Sat, 20 Apr 2024 11:23:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.138 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713612196; cv=fail; b=i6XMO6JFFb6oRLmUXMMrFEsmNWHP9DgXwPpk3MErRmayIfP+IwlgPfSBTZQ4sNZraT1kyGCX7VunG2ggcmBAK0z1yhSJlcqYmkEMkiFGQf4z4zlT6LeEV6WzgSfKoIpapx9H1ILoMniGif5SkipIWt4U9nl2hwBtPnB+vdO1U7E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713612196; c=relaxed/simple; bh=FOsSHF9Sb+4GwiYHI3dstzCiSYA2cpTrl0HbCkVLbWk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=jlpwl6KpC8nxoL5Jc2v22rB7EIuYpP+po6xn7x+2P494KzsUPWQ+n3A9qPKAJmTZyfTnECYhy8+3b8+JK5heMBh95hDK1Xc1L7vLLPx+XE+gcf0WoMx5C2pEzpWXBkyH5LZG72pLhgEQKnT5+1bnTKtu3VAIRHgJJRqVtOpKqfc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=solid-run.com; spf=pass smtp.mailfrom=solid-run.com; dkim=pass (1024-bit key) header.d=solidrn.onmicrosoft.com header.i=@solidrn.onmicrosoft.com header.b=FTb0cmBG; arc=fail smtp.client-ip=40.107.20.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=solid-run.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=solid-run.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=solidrn.onmicrosoft.com header.i=@solidrn.onmicrosoft.com header.b="FTb0cmBG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FzEkFJMTIOk5j71MFZl5dugpZEIVmESOwVSDngLMGWzdzpGr0ihyVWVUUZi4lX4mXfIPWC4qMXfW1Xra5C0QgrxFpkmdwkfGd9vqnVA/8KWKZ0VbOtSernrVEFSgzLalfsdaplbiRcZbQ6bq5s4Yo769LHDCCUTIjI9q9wrCCQ4FZZLWQd+9CuQC8rtpZPMF2BETD+mvjcpvMKjzO4Vg72ckVKiP9o6MN0rX64R9Ph/E2qP/VvsN+sD1CgmON0LcUCLPYVemX+csrLRuXUKDW1ffhr83yxYNLak28y+J86Z/HkSY2y3OeefYhA16aB7YnLNvHuP82vkmJ0zN99OvZA== 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=Vh0X3VbLkcxkQr3MsxBzuzXI3LwXJ76XQtAmp5TTwVU=; b=SK8yio28Qr5gFWCUSS1OBds12m8eb53OVWSOAJN80qN1tD5ZZGkA1t6NmzLspEC9BfJkwHMhHhm6OGHqDnl11XtFctOdb98XJvhUM4mAZi89atfGFJJg+404y6McKrwMw8V+jeQh7iHiA+Hf+phnk0JOz2t8JE1Ph9jaSreHnRMScYJLE7ASwpHvA3HanCqrLDEFHr3MpLdbEHlzsCrC4MRvEz/B3d7/uH0Shbq1Rg1YTYSg1VyPvXYrg+7XoSdmvLTTAUnk5G9BJkUY0LvwK9qyZyzQ2CVURxONHbe1RRr29Qh/gL+2qgxFAj6+cVzF3rY8md4zHyUky//E+S3oQg== 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=Vh0X3VbLkcxkQr3MsxBzuzXI3LwXJ76XQtAmp5TTwVU=; b=FTb0cmBGKloNray8dXERHR+gF9GJN4/+7wVu88e3HhlCrH56HQbLzIwrgHMdLD93Ll3dnegI9KBX6jQSVsNNX1BkEo4YxU/cZo10PagOmVjw/fiQdtc2bPTUFxVX8G/bbXMX8GkqwhxsCWfLO9lJ25Q0tXhA4WCu2z2nk/5lGJM= 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 AM9PR04MB7588.eurprd04.prod.outlook.com (2603:10a6:20b:2dd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Sat, 20 Apr 2024 11:23:09 +0000 Received: from AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529]) by AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529%7]) with mapi id 15.20.7472.044; Sat, 20 Apr 2024 11:23:09 +0000 From: Josua Mayer Date: Sat, 20 Apr 2024 13:23:01 +0200 Subject: [PATCH net-next v2 2/2] net: phy: adin: add support for setting link-status-pin polarity Message-Id: <20240420-adin-pin-polarity-v2-2-bf9714da7648@solid-run.com> References: <20240420-adin-pin-polarity-v2-0-bf9714da7648@solid-run.com> In-Reply-To: <20240420-adin-pin-polarity-v2-0-bf9714da7648@solid-run.com> To: Michael Hennerich , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandru Tachici , Andrew Lunn , Heiner Kallweit , Russell King Cc: Jon Nettleton , Yazan Shhady , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Josua Mayer X-Mailer: b4 0.12.4 X-ClientProxiedBy: FR0P281CA0109.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::9) To AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB7586:EE_|AM9PR04MB7588:EE_ X-MS-Office365-Filtering-Correlation-Id: 034ee085-5dd0-43b8-c5c9-08dc612c4133 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?UF+C4FDu0TaN+MwHHEMSXYQ0ZyPfzHh?= =?utf-8?q?BVkcsvE9udN2sjhWJIOPU60IL0qqCM9ZnBthevoUDuXveJsrceUhiNh++HWvcN2XP?= =?utf-8?q?kCl4taWI1WiI9tUAT7FJPW4NrhuU8xIFVzO6s070Rf80d0g2QcWe7c/efoGmLL9JO?= =?utf-8?q?wafbZ5I+xRWISwd4i4inzxqY70jZjGobHnu41DOsWvYh0fAlMIh8nFAdXEUepdSQf?= =?utf-8?q?MJhPs2/Xl49xXPeWn5Hy6Hmqmobk6NvpDa36WseZ8smO+N4CAtGQlzkH6LfwJL2WG?= =?utf-8?q?Yk98wWn+T3yQ6mvOMyXyuHbjsOFtCIorlz4YPHWZ+Px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SvzsicMoBz5q+CHs3c?= =?utf-8?q?tbh2l27LSmti5A6B7B/AwjmEKCfo2ntikS7l1pL8Htr+ShkDpTXyTzgjRa0U3NTVL?= =?utf-8?q?9js2Q7KNelD8b0tnNL6Uao1Wc2zuJWJw+CQ=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:(13230031)(366007)(1800799015)(52116005)(7416005)(376005)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wbZWsAlNJvxnEp81ywK8Je7AIHA6?= =?utf-8?q?XswQ26qSt2TrCBVTHCaxOq1KEngvc7IkFpRECLwN2DNgEQOCRUyl/x22fXUl2c5pM?= =?utf-8?q?oExDzrnOB8WFxUbqOP2WrdxqDteP4KN0hThqpzKnLacdRa6yDZlYNqjEp0Hp7VNwi?= =?utf-8?q?p1sRG/FhmqYyucJXyBZWGhWGFRSyrVu+7rLTJgrLQtAp3oHk5+Fmvq98qWTKAdKVv?= =?utf-8?q?XJC8ZXxsUmJq5HuopHYhMe3ZHh9Pj8M6bIhdvuLcFGdd0iikr9qbJdnEmdZVmxIBD?= =?utf-8?q?6mmfhUAFYZXvKerk0x/VjMQBzJ3IdK4HHeXPOFApGOYEpzxmNqZZ28IQyysdDtAlc?= =?utf-8?q?JRjB0hOxhxKOLQitMFb6kTomHxblTjuSZtzN++lp128DwJH6ESl4jWp+RDRXVrBwV?= =?utf-8?q?CCaI8Sk0XpkVza7p1BxzFlqNKzT5cEE91DyQig7fa1qd3FYz1cauK9PYlkb3pJ5Ue?= =?utf-8?q?EMKAHUd8bXLkOvyRuEAcQIBr/ukdjqprNGg4eOgrlAfY6a7QxWzUN67iqPXkVeP9B?= =?utf-8?q?CM+G8Joypdk8pu8O7XH89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QweblWzhpDu28xA6BeChnIuU3aRnuRZ2ol7Soq?= =?utf-8?q?P6kj1FRiBGmwi21bPFruSwT4shO9WIOxS+miAFZte8AFDICVaLuYKfvPjv5q7i0Y9?= =?utf-8?q?1njJ1Bg+ZAld?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: 034ee085-5dd0-43b8-c5c9-08dc612c4133 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB7586.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2024 11:23:08.1284 (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: Ue5glX+Q2IEpZsTtLwJiwlC/TSe7mbx8wn7r0GyhiNH22NGLWoSmdSS2CTbn8DCnb/5V5YZ79A3iGDfffNYQOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7588 X-Patchwork-Delegate: kuba@kernel.org ADIN1300/1200 support software control over pin polarity for LINK_ST (link-status) pin. Configure the polarity during config_init based on device-tree property. Polarity is only set if specified in device-tree, otherwise the phy defaults to active-high during reset. Signed-off-by: Josua Mayer --- drivers/net/phy/adin.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c index 2e1a46e121d9..a533932afcb8 100644 --- a/drivers/net/phy/adin.c +++ b/drivers/net/phy/adin.c @@ -158,6 +158,9 @@ #define ADIN1300_RMII_20_BITS 0x0004 #define ADIN1300_RMII_24_BITS 0x0005 +#define ADIN1300_GE_LNK_STAT_INV_EN_REG 0xff3c +#define ADIN1300_GE_LNK_STAT_INV_EN BIT(0) + /** * struct adin_cfg_reg_map - map a config value to aregister value * @cfg: value in device configuration @@ -522,6 +525,28 @@ static int adin_config_clk_out(struct phy_device *phydev) ADIN1300_GE_CLK_CFG_MASK, sel); } +static int adin_config_link_status_pin_polarity(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + int ret; + u32 val; + + if (!device_property_present(dev, "adi,link-st-polarity")) + return 0; + + ret = device_property_read_u32(dev, "adi,link-st-polarity", &val); + if (ret) { + return ret; + } else if (val > 1) { + phydev_err(phydev, "invalid adi,link-st-polarity\n"); + return -EINVAL; + } + + return phy_modify_mmd(phydev, MDIO_MMD_VEND1, + ADIN1300_GE_LNK_STAT_INV_EN_REG, + ADIN1300_GE_LNK_STAT_INV_EN, val); +} + static int adin_config_init(struct phy_device *phydev) { int rc; @@ -548,6 +573,10 @@ static int adin_config_init(struct phy_device *phydev) if (rc < 0) return rc; + rc = adin_config_link_status_pin_polarity(phydev); + if (rc < 0) + return rc; + phydev_dbg(phydev, "PHY is using mode '%s'\n", phy_modes(phydev->interface));