From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 06B3743E9C8; Tue, 9 Jun 2026 15:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781018890; cv=none; b=rqO4Zkg0+J7Ngkxf3xcF17rxXiC7EiyICJ4fbxvARcLhtwS/QvgmV23U7SmFJCaNuuMtPyL89t3nRHQ+2FA+eijPNWcqtT3ZCzbEIiTbHh5sO3D/CEpWFE80Xtiz5+gkU1zNgwBtCTMUZ048dSC57xC41yiM2ktpqC/nWoS+X9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781018890; c=relaxed/simple; bh=0PoyS8TaDySwROS+c9soPDbetkiSCozHg26VGtBAXHs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dNLxpbsNFJOAoTzucJL6zpHmh58ZOp9/JN49n6zAQWEkmAIF+y5f05vn0D8FtlXzBqtJ7FlqK30vtogWmJ13bvC1UPHUB8Z4AqvdWXOFw/QK7yNhN0mGejmdsex120eQ6Di9q/DMC56tf6pd96NNsDExWzEFAPX9xEt085eNC04= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RCtmRZGp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RCtmRZGp" Received: by smtp.kernel.org (Postfix) with ESMTPS id DC1A5C4AF10; Tue, 9 Jun 2026 15:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1781018889; bh=0PoyS8TaDySwROS+c9soPDbetkiSCozHg26VGtBAXHs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RCtmRZGp4ePgUvPcTs84q52ya6MRcLMwAApbgKOFq0JXjfu3pWC/W4sOjcF6ptS7F iJ/y2HWPVFGrYozXW3UKPSgVrktOVvM5AETRwd+thdT19QTteXeoKKgj/V1oWjQ5Zi Cai3v6x41LlCj2pOYlUcLhS8H/bzEPBIsMlCv6ZEe308i37pb3si8bv0IF48cO/htK DDqjoUky37MY++bV1FzOjqT7fSMWOr2DtQCEw2kE+yNqcSJjQXbhdwD5oTqPYk9nSG Gk8i+QQxCuixLNH+BcLXFsCpSHxoafsvFa1FaVPbSbq8LCiMF/YDFk7CloXf9Gat5V YWJM2vh8bDzGQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3334CD8CB9; Tue, 9 Jun 2026 15:28:09 +0000 (UTC) From: Ciprian Regus via B4 Relay Date: Tue, 09 Jun 2026 18:28:09 +0300 Subject: [PATCH net-next v4 10/13] net: phy: add generic helpers for direct C45 MMD access Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260609-adin1140-driver-v4-10-0753e28ee004@analog.com> References: <20260609-adin1140-driver-v4-0-0753e28ee004@analog.com> In-Reply-To: <20260609-adin1140-driver-v4-0-0753e28ee004@analog.com> To: Parthiban Veerasooran , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Andrew Lunn , Heiner Kallweit , Russell King , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, Ciprian Regus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1781018886; l=2711; i=ciprian.regus@analog.com; s=20260330; h=from:subject:message-id; bh=3vFOSyANNQzVtl2h405gheiZ2BA6Gw0e9c/c/C0Yj6Q=; b=kNKvs/VFFFNxVRCsc0nJ9NcVa/S0gy/Yxyo2sW1fOLc6QfKe/smPHysoIKzacQb4xn+09M4xw vt3c2PaHxtGB/3HRadupUa11qKp4jSOsokHIn9Vnx7oywcdX9EJgql3 X-Developer-Key: i=ciprian.regus@analog.com; a=ed25519; pk=8WoNhI0kQcQUl8YqJO5ZevROYk9HP8lOIeIgIYgjfbc= X-Endpoint-Received: by B4 Relay for ciprian.regus@analog.com/20260330 with auth_id=703 X-Original-From: Ciprian Regus Reply-To: ciprian.regus@analog.com From: Ciprian Regus Some PHYs support direct C45 register access but not C22 indirect MMD access (registers 0xD and 0xE). When discovered via C22, phylib routes MMD access through the indirect path, which won't work on these devices. Add genphy_read_mmd_c45() and genphy_write_mmd_c45() as read_mmd/ write_mmd callbacks that bypass the C22 indirect path and use the bus C45 accessors directly. Reviewed-by: Andrew Lunn Signed-off-by: Ciprian Regus --- v4 changelog: - no change v3 changelog: - no change v2 changelog: - New patch --- drivers/net/phy/phy_device.c | 25 +++++++++++++++++++++++++ include/linux/phy.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 3370eb822017..d33d096e700d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2764,6 +2764,31 @@ int genphy_read_abilities(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_read_abilities); +/* Some PHYs support direct C45 register access but not C22 indirect + * MMD access (registers 13 and 14). When discovered via C22, phylib + * routes MMD access through the indirect path, which won't work on + * these devices. These helpers bypass indirect access and use the bus + * C45 accessors directly. + */ +int genphy_read_mmd_c45(struct phy_device *phydev, int devnum, u16 regnum) +{ + struct mii_bus *bus = phydev->mdio.bus; + int addr = phydev->mdio.addr; + + return __mdiobus_c45_read(bus, addr, devnum, regnum); +} +EXPORT_SYMBOL(genphy_read_mmd_c45); + +int genphy_write_mmd_c45(struct phy_device *phydev, int devnum, u16 regnum, + u16 val) +{ + struct mii_bus *bus = phydev->mdio.bus; + int addr = phydev->mdio.addr; + + return __mdiobus_c45_write(bus, addr, devnum, regnum, val); +} +EXPORT_SYMBOL(genphy_write_mmd_c45); + /* This is used for the phy device which doesn't support the MMD extended * register access, but it does have side effect when we are trying to access * the MMD register via indirect method. diff --git a/include/linux/phy.h b/include/linux/phy.h index 199a7aaa341b..432d44188dbc 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -2297,6 +2297,9 @@ static inline int genphy_no_config_intr(struct phy_device *phydev) { return 0; } +int genphy_read_mmd_c45(struct phy_device *phydev, int devnum, u16 regnum); +int genphy_write_mmd_c45(struct phy_device *phydev, int devnum, u16 regnum, + u16 val); int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, u16 regnum); int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, -- 2.43.0