From: John-Michael Mulesa Commit 5befa3728b85 ("net: phy: realtek: add support for RTL8126A-integrated 5Gbps PHY") added the stand-alone PHY with ID 0x001cc862 as the RTL8251B. Realtek's own PHY driver, as shipped in their SDK, names this ID RTL8251BE and marks it as an engineering sample. The mass production RTL8251B reports 0x001cc86a instead. Rename the define, the Clause 45 match function and the driver to RTL8251BE, so that the RTL8251B name is free for the production part. The RTL8126A-integrated PHY reports the same ID and is still matched by the internal NBASE-T driver. Apart from the driver name, there is no functional change. The code and this changelog were drafted with the help of an AI coding assistant (Claude, claude-opus-5-5). Suggested-by: Markus Stockhausen Signed-off-by: John-Michael Mulesa --- drivers/net/phy/realtek/realtek_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c index a39ad1838..ece327d3c 100644 --- a/drivers/net/phy/realtek/realtek_main.c +++ b/drivers/net/phy/realtek/realtek_main.c @@ -264,7 +264,7 @@ #define RTL_8221B 0x001cc840 #define RTL_8221B_VB_CG 0x001cc849 #define RTL_8221B_VM_CG 0x001cc84a -#define RTL_8251B 0x001cc862 +#define RTL_8251BE 0x001cc862 #define RTL_8261C 0x001cc890 #define RTL_8261C_CG 0x001cc898 #define RTL_8261CE_CG 0x001cc899 @@ -2907,7 +2907,7 @@ static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev, switch (phydev->phy_id) { case RTL_GENERIC_PHYID: case RTL_8221B: - case RTL_8251B: + case RTL_8251BE: case RTL_8261C: case 0x001cc841: break; @@ -2918,10 +2918,10 @@ static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev, return rtlgen_supports_2_5gbps(phydev) && !rtlgen_supports_mmd(phydev); } -static int rtl8251b_c45_match_phy_device(struct phy_device *phydev, - const struct phy_driver *phydrv) +static int rtl8251be_c45_match_phy_device(struct phy_device *phydev, + const struct phy_driver *phydrv) { - return rtlgen_is_c45_match(phydev, RTL_8251B, true); + return rtlgen_is_c45_match(phydev, RTL_8251BE, true); } static int rtlgen_resume(struct phy_device *phydev) @@ -3399,8 +3399,8 @@ static struct phy_driver realtek_drvs[] = { .led_hw_control_get = rtl822xb_led_hw_control_get, .led_hw_control_set = rtl822xb_led_hw_control_set, }, { - .match_phy_device = rtl8251b_c45_match_phy_device, - .name = "RTL8251B 5Gbps PHY", + .match_phy_device = rtl8251be_c45_match_phy_device, + .name = "RTL8251BE 5Gbps PHY", .probe = rtl822x_probe, .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, -- 2.56.1 From: John-Michael Mulesa The mass production RTL8251B reports the PHY ID 0x001cc86a, unlike the RTL8251BE engineering sample (0x001cc862) the driver already supports. On the Sirivision SR-S5G3008, an RTL9303 switch with eight RTL8251B, the switch's MDIO buses run Clause 45 only and Clause 22 accesses fail. Without a matching driver the PHYs bind to the generic Clause 45 driver. As devices-in-package bit 0 is set, phylib then falls back to Clause 22 autonegotiation, which fails and leaves the PHY in the error state. Add a Clause 45 driver built from the helpers the RTL8224 driver already uses: standard MMD 7 advertisement and link status, with the 1000BASE-T registers and the resolved speed read through the vendor register mirror in MMD 31. Clear devices-in-package bit 0 in probe, because phy_restart_aneg() also falls back to Clause 22 when it is set, which breaks "ethtool -r" and EEE changes. The driver doesn't configure the host SerDes. On this board it comes up in USXGMII mode, which doesn't change with the link speed. Tested on the SR-S5G3008 with OpenWrt's 6.18 kernel. All eight PHYs bind to the driver. On the connected port the link comes up and passes ping traffic at 5, 2.5 and 1 Gbit/s, and "ethtool -r" and EEE changes work. The code and this changelog were drafted with the help of an AI coding assistant (Claude, claude-opus-5-5). Signed-off-by: John-Michael Mulesa --- drivers/net/phy/realtek/realtek_main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c index ece327d3c..460184e1e 100644 --- a/drivers/net/phy/realtek/realtek_main.c +++ b/drivers/net/phy/realtek/realtek_main.c @@ -265,6 +265,7 @@ #define RTL_8221B_VB_CG 0x001cc849 #define RTL_8221B_VM_CG 0x001cc84a #define RTL_8251BE 0x001cc862 +#define RTL_8251B 0x001cc86a #define RTL_8261C 0x001cc890 #define RTL_8261C_CG 0x001cc898 #define RTL_8261CE_CG 0x001cc899 @@ -2924,6 +2925,23 @@ static int rtl8251be_c45_match_phy_device(struct phy_device *phydev, return rtlgen_is_c45_match(phydev, RTL_8251BE, true); } +static int rtl8251b_c45_match_phy_device(struct phy_device *phydev, + const struct phy_driver *phydrv) +{ + return rtlgen_is_c45_match(phydev, RTL_8251B, true); +} + +static int rtl8251b_c45_probe(struct phy_device *phydev) +{ + /* The PHY reports Clause 22 registers in devices-in-package, but the + * MDIO bus may only support Clause 45. Clear the bit so that phylib + * restarts autonegotiation through MMD 7. + */ + phydev->c45_ids.devices_in_package &= ~MDIO_DEVS_C22PRESENT; + + return 0; +} + static int rtlgen_resume(struct phy_device *phydev) { int ret = genphy_resume(phydev); @@ -3409,6 +3427,15 @@ static struct phy_driver realtek_drvs[] = { .resume = rtlgen_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + }, { + .match_phy_device = rtl8251b_c45_match_phy_device, + .name = "RTL8251B 5Gbps PHY", + .probe = rtl8251b_c45_probe, + .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, }, { .match_phy_device = rtl_internal_nbaset_match_phy_device, .name = "Realtek Internal NBASE-T PHY", -- 2.56.1