1 From 0de82310d2b32e78ff79d42c08b1122a6ede3778 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Sun, 30 Apr 2023 00:15:41 +0100
4 Subject: [PATCH] net: phy: realtek: detect early version of RTL8221B
6 Early versions (?) of the RTL8221B PHY cannot be identified in a regular
7 Clause-45 bus scan as the PHY doesn't report the implemented MMDs
8 correctly but returns 0 instead.
9 Implement custom identify function using the PKGID instead of iterating
10 over the implemented MMDs.
12 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
14 --- a/drivers/net/phy/realtek.c
15 +++ b/drivers/net/phy/realtek.c
16 @@ -782,6 +782,38 @@ static int rtl8226_match_phy_device(stru
17 rtlgen_supports_2_5gbps(phydev);
20 +static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev)
25 + if (phydev->drv->read_mmd) {
26 + val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID1);
31 + val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID2);
37 + val = phy_read(phydev, MII_PHYSID1);
42 + val = phy_read(phydev, MII_PHYSID2);
49 + return (id == 0x001cc849);
52 static int rtl822x_probe(struct phy_device *phydev)
54 struct device *dev = &phydev->mdio.dev;
55 @@ -1134,7 +1166,7 @@ static struct phy_driver realtek_drvs[]
56 .write_page = rtl821x_write_page,
57 .soft_reset = genphy_soft_reset,
59 - PHY_ID_MATCH_EXACT(0x001cc849),
60 + .match_phy_device = rtl8221b_vb_cg_match_phy_device,
61 .name = "RTL8221B-VB-CG 2.5Gbps PHY",
62 .get_features = rtl822x_get_features,
63 .config_init = rtl8221b_config_init,