2
0

725-net-phy-realtek-disable-SGMII-in-band-AN-for-2-5G-PHYs.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From 2b1b8c4c215af7988136401c902338d091d408a1 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Mon, 3 Apr 2023 01:21:57 +0300
  4. Subject: [PATCH 2/2] net: phy: realtek: disable SGMII in-band AN for 2.5G PHYs
  5. MAC drivers don't use SGMII in-band autonegotiation unless told to do so
  6. in device tree using 'managed = "in-band-status"'. When using MDIO to
  7. access a PHY, in-band-status is unneeded as we have link-status via
  8. MDIO. Switch off SGMII in-band autonegotiation using magic values.
  9. Reported-by: Chen Minqiang <[email protected]>
  10. Reported-by: Chukun Pan <[email protected]>
  11. Reported-by: Yevhen Kolomeiko <[email protected]>
  12. Tested-by: Yevhen Kolomeiko <[email protected]>
  13. Signed-off-by: Daniel Golle <[email protected]>
  14. ---
  15. drivers/net/phy/realtek.c | 8 ++++++++
  16. 1 file changed, 8 insertions(+)
  17. --- a/drivers/net/phy/realtek.c
  18. +++ b/drivers/net/phy/realtek.c
  19. @@ -885,6 +885,7 @@ static irqreturn_t rtl9000a_handle_inter
  20. static int rtl8221b_config_init(struct phy_device *phydev)
  21. {
  22. u16 option_mode;
  23. + int val;
  24. switch (phydev->interface) {
  25. case PHY_INTERFACE_MODE_2500BASEX:
  26. @@ -921,6 +922,13 @@ static int rtl8221b_config_init(struct p
  27. break;
  28. }
  29. + /* Disable SGMII AN */
  30. + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7588, 0x2);
  31. + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7589, 0x71d0);
  32. + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, 0x3);
  33. + phy_read_mmd_poll_timeout(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587,
  34. + val, !(val & BIT(0)), 500, 100000, false);
  35. +
  36. return 0;
  37. }