netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: realtek: convert RTL8226-CG to c45 only
@ 2025-06-17 15:01 Markus Stockhausen
  2025-06-17 15:36 ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Stockhausen @ 2025-06-17 15:01 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, michael,
	daniel, netdev
  Cc: Markus Stockhausen

The RTL8226-CG can be found on devices like the Zyxel XGS1210-12. These
are driven by a RTL9302B SoC that has active phy hardware polling in
the background. As soon as this is active and set to c45 most c22
register accesses are blocked and will stop working. Convert the
phy to a c45-only function set.

For documentation purposes some register extracts that where taken to
verify proper detection.

phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1) = 0x0008
phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT2) = 0x8200
phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE) = 0x41a0
phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE) = 0x0001

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
---
 drivers/net/phy/realtek/realtek_main.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
index c3dcb6257430..16568f74f5a2 100644
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -1274,6 +1274,21 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
 	return 0;
 }
 
+static int rtl822x_c45_soft_reset(struct phy_device *phydev)
+{
+	int ret, val;
+
+	ret = phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1,
+			     MDIO_CTRL1_RESET, MDIO_CTRL1_RESET);
+	if (ret < 0)
+		return ret;
+
+	return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PMAPMD,
+					 MDIO_CTRL1, val,
+					 !(val & MDIO_CTRL1_RESET),
+					 5000, 100000, true);
+}
+
 static int rtl822xb_c45_read_status(struct phy_device *phydev)
 {
 	int ret;
@@ -1669,11 +1684,12 @@ static struct phy_driver realtek_drvs[] = {
 	}, {
 		PHY_ID_MATCH_EXACT(0x001cc838),
 		.name           = "RTL8226-CG 2.5Gbps PHY",
-		.get_features   = rtl822x_get_features,
-		.config_aneg    = rtl822x_config_aneg,
-		.read_status    = rtl822x_read_status,
-		.suspend        = genphy_suspend,
-		.resume         = rtlgen_resume,
+		.soft_reset     = rtl822x_c45_soft_reset,
+		.get_features   = rtl822x_c45_get_features,
+		.config_aneg    = rtl822x_c45_config_aneg,
+		.read_status    = rtl822x_c45_read_status,
+		.suspend        = genphy_c45_pma_suspend,
+		.resume         = rtlgen_c45_resume,
 		.read_page      = rtl821x_read_page,
 		.write_page     = rtl821x_write_page,
 	}, {
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-03  6:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 15:01 [PATCH] net: phy: realtek: convert RTL8226-CG to c45 only Markus Stockhausen
2025-06-17 15:36 ` Andrew Lunn
2025-06-18  6:03   ` AW: " markus.stockhausen
2025-06-18 21:27     ` Chris Packham
2025-06-19  2:47       ` Chris Packham
2025-06-19  6:23         ` AW: " markus.stockhausen
2025-07-03  6:18         ` markus.stockhausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).