730-net-phy-realtek-detect-early-version-of-RTL8221B.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 0de82310d2b32e78ff79d42c08b1122a6ede3778 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Sun, 30 Apr 2023 00:15:41 +0100
  4. Subject: [PATCH] net: phy: realtek: detect early version of RTL8221B
  5. Early versions (?) of the RTL8221B PHY cannot be identified in a regular
  6. Clause-45 bus scan as the PHY doesn't report the implemented MMDs
  7. correctly but returns 0 instead.
  8. Implement custom identify function using the PKGID instead of iterating
  9. over the implemented MMDs.
  10. Signed-off-by: Daniel Golle <[email protected]>
  11. --- a/drivers/net/phy/realtek.c
  12. +++ b/drivers/net/phy/realtek.c
  13. @@ -744,6 +744,38 @@ static int rtl8226_match_phy_device(stru
  14. rtlgen_supports_2_5gbps(phydev);
  15. }
  16. +static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev)
  17. +{
  18. + int val;
  19. + u32 id;
  20. +
  21. + if (phydev->mdio.bus->probe_capabilities >= MDIOBUS_C45) {
  22. + val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID1);
  23. + if (val < 0)
  24. + return 0;
  25. +
  26. + id = val << 16;
  27. + val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID2);
  28. + if (val < 0)
  29. + return 0;
  30. +
  31. + id |= val;
  32. + } else {
  33. + val = phy_read(phydev, MII_PHYSID1);
  34. + if (val < 0)
  35. + return 0;
  36. +
  37. + id = val << 16;
  38. + val = phy_read(phydev, MII_PHYSID2);
  39. + if (val < 0)
  40. + return 0;
  41. +
  42. + id |= val;
  43. + }
  44. +
  45. + return (id == 0x001cc849);
  46. +}
  47. +
  48. static int rtl822x_probe(struct phy_device *phydev)
  49. {
  50. struct device *dev = &phydev->mdio.dev;
  51. @@ -1082,7 +1114,7 @@ static struct phy_driver realtek_drvs[]
  52. .write_page = rtl821x_write_page,
  53. .soft_reset = genphy_soft_reset,
  54. }, {
  55. - PHY_ID_MATCH_EXACT(0x001cc849),
  56. + .match_phy_device = rtl8221b_vb_cg_match_phy_device,
  57. .name = "RTL8221B-VB-CG 2.5Gbps PHY",
  58. .get_features = rtl822x_get_features,
  59. .config_init = rtl8221b_config_init,