diff --git a/target/linux/realtek/files-6.18/drivers/net/phy/realtek/realtek_multiport.c b/target/linux/realtek/files-6.18/drivers/net/phy/realtek/realtek_multiport.c index 29b5cce4c1a..3406242d698 100644 --- a/target/linux/realtek/files-6.18/drivers/net/phy/realtek/realtek_multiport.c +++ b/target/linux/realtek/files-6.18/drivers/net/phy/realtek/realtek_multiport.c @@ -449,6 +449,48 @@ static int rtl821x_config_init(struct phy_device *phydev) return 0; } +static int rtl8218e_config_init(struct phy_device *phydev) +{ + int oldpage, oldxpage; + bool is_xsgmii; + + rtl821x_config_init(phydev); + + if (phydev->mdio.addr % 8) + return 0; + + oldpage = phy_read(phydev, RTL821x_PAGE_SELECT); + oldxpage = phy_read(phydev, RTL821x_EXT_PAGE_SELECT); + + phy_write(phydev, RTL821x_EXT_PAGE_SELECT, 0x8); + is_xsgmii = (phy_read_paged(phydev, 0x260, 0x12) & 0xf0) == 0xb0; + + /* QSGMII configuration is not currently supported. */ + if (!is_xsgmii) + goto restore; + + /* Apply the minimal vendor XSGMII configuration, undocumented magic. */ + phy_write_paged(phydev, 0x4b8, 0x10, 0x8714); + phy_write_paged(phydev, 0x4b8, 0x12, 0x7230); + phy_write_paged(phydev, 0x4be, 0x16, 0x1000); + phy_write_paged(phydev, 0x4bf, 0x11, 0x7000); + phy_write_paged(phydev, 0x4bf, 0x16, 0x0042); + phy_write_paged(phydev, 0x4ba, 0x14, 0x9d04); + + /* Reset SerDes 0. */ + phy_write_paged(phydev, 0x400, 0x10, 0x1700); + phy_write_paged(phydev, 0x400, 0x10, 0x1703); + + /* Disable SerDes 0 XSGMII autonegotiation. */ + phy_modify_paged(phydev, 0x400, 0x12, GENMASK(9, 8), BIT(8)); + +restore: + phy_write(phydev, RTL821x_EXT_PAGE_SELECT, oldxpage); + phy_write(phydev, RTL821x_PAGE_SELECT, oldpage); + + return 0; +} + static int rtl8218d_config_init(struct phy_device *phydev) { int oldpage, oldxpage; @@ -681,7 +723,7 @@ static struct phy_driver rtl83xx_phy_driver[] = { { PHY_ID_MATCH_EXACT(PHY_ID_RTL8218E), .name = "REALTEK RTL8218E", - .config_init = rtl821x_config_init, + .config_init = rtl8218e_config_init, .features = PHY_GBIT_FEATURES, .probe = rtl8218x_phy_probe, .read_mmd = rtl821x_read_mmd,