720-net-phy-add-aqr-phys.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. From: Birger Koblitz <[email protected]>
  2. Date: Sun, 5 Sep 2021 15:13:10 +0200
  3. Subject: [PATCH] kernel: Add AQR113C and AQR813 support
  4. This hack adds support for the Aquantia 4th generation, 10GBit
  5. PHYs AQR113C and AQR813.
  6. Signed-off-by: Birger Koblitz <[email protected]>
  7. --- a/drivers/net/phy/aquantia/aquantia_main.c
  8. +++ b/drivers/net/phy/aquantia/aquantia_main.c
  9. @@ -23,6 +23,7 @@
  10. #define PHY_ID_AQCS109 0x03a1b5c2
  11. #define PHY_ID_AQR405 0x03a1b4b0
  12. #define PHY_ID_AQR113C 0x31c31c12
  13. +#define PHY_ID_AQR813 0x31c31cb2
  14. #define MDIO_PHYXS_VEND_IF_STATUS 0xe812
  15. #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3)
  16. @@ -360,6 +361,49 @@ static int aqr107_read_rate(struct phy_d
  17. return 0;
  18. }
  19. +static int aqr113c_read_status(struct phy_device *phydev)
  20. +{
  21. + int val, ret;
  22. +
  23. + ret = aqr_read_status(phydev);
  24. + if (ret)
  25. + return ret;
  26. +
  27. + if (!phydev->link || phydev->autoneg == AUTONEG_DISABLE)
  28. + return 0;
  29. +
  30. + // On AQR113C, the speed returned by aqr_read_status is wrong
  31. + aqr107_read_rate(phydev);
  32. +
  33. + val = phy_read_mmd(phydev, MDIO_MMD_PHYXS, MDIO_PHYXS_VEND_IF_STATUS);
  34. + if (val < 0)
  35. + return val;
  36. +
  37. + switch (FIELD_GET(MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK, val)) {
  38. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR:
  39. + phydev->interface = PHY_INTERFACE_MODE_10GKR;
  40. + break;
  41. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_XFI:
  42. + phydev->interface = PHY_INTERFACE_MODE_10GBASER;
  43. + break;
  44. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_USXGMII:
  45. + phydev->interface = PHY_INTERFACE_MODE_USXGMII;
  46. + break;
  47. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_SGMII:
  48. + phydev->interface = PHY_INTERFACE_MODE_SGMII;
  49. + break;
  50. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_OCSGMII:
  51. + phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
  52. + break;
  53. + default:
  54. + phydev->interface = PHY_INTERFACE_MODE_NA;
  55. + break;
  56. + }
  57. +
  58. + /* Read downshifted rate from vendor register */
  59. + return aqr107_read_rate(phydev);
  60. +}
  61. +
  62. static int aqr107_read_status(struct phy_device *phydev)
  63. {
  64. int val, ret;
  65. @@ -499,7 +543,7 @@ static void aqr107_chip_info(struct phy_
  66. build_id = FIELD_GET(VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID, val);
  67. prov_id = FIELD_GET(VEND1_GLOBAL_RSVD_STAT1_PROV_ID, val);
  68. - phydev_dbg(phydev, "FW %u.%u, Build %u, Provisioning %u\n",
  69. + phydev_info(phydev, "FW %u.%u, Build %u, Provisioning %u\n",
  70. fw_major, fw_minor, build_id, prov_id);
  71. }
  72. @@ -760,7 +804,7 @@ static struct phy_driver aqr_driver[] =
  73. .config_aneg = aqr_config_aneg,
  74. .config_intr = aqr_config_intr,
  75. .handle_interrupt = aqr_handle_interrupt,
  76. - .read_status = aqr107_read_status,
  77. + .read_status = aqr113c_read_status,
  78. .get_tunable = aqr107_get_tunable,
  79. .set_tunable = aqr107_set_tunable,
  80. .suspend = aqr107_suspend,
  81. @@ -770,6 +814,24 @@ static struct phy_driver aqr_driver[] =
  82. .get_stats = aqr107_get_stats,
  83. .link_change_notify = aqr107_link_change_notify,
  84. },
  85. +{
  86. + PHY_ID_MATCH_MODEL(PHY_ID_AQR813),
  87. + .name = "Aquantia AQR813",
  88. + .probe = aqr107_probe,
  89. + .config_init = aqr107_config_init,
  90. + .config_aneg = aqr_config_aneg,
  91. + .config_intr = aqr_config_intr,
  92. + .handle_interrupt = aqr_handle_interrupt,
  93. + .read_status = aqr113c_read_status,
  94. + .get_tunable = aqr107_get_tunable,
  95. + .set_tunable = aqr107_set_tunable,
  96. + .suspend = aqr107_suspend,
  97. + .resume = aqr107_resume,
  98. + .get_sset_count = aqr107_get_sset_count,
  99. + .get_strings = aqr107_get_strings,
  100. + .get_stats = aqr107_get_stats,
  101. + .link_change_notify = aqr107_link_change_notify,
  102. +},
  103. };
  104. module_phy_driver(aqr_driver);
  105. @@ -783,6 +845,7 @@ static struct mdio_device_id __maybe_unu
  106. { PHY_ID_MATCH_MODEL(PHY_ID_AQCS109) },
  107. { PHY_ID_MATCH_MODEL(PHY_ID_AQR405) },
  108. { PHY_ID_MATCH_MODEL(PHY_ID_AQR113C) },
  109. + { PHY_ID_MATCH_MODEL(PHY_ID_AQR813) },
  110. { }
  111. };