1
0

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. From: Birger Koblitz <git@birger-koblitz.de>
  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 <git@birger-koblitz.de>
  7. --- a/drivers/net/phy/aquantia_main.c
  8. +++ b/drivers/net/phy/aquantia_main.c
  9. @@ -20,8 +20,10 @@
  10. #define PHY_ID_AQR105 0x03a1b4a2
  11. #define PHY_ID_AQR106 0x03a1b4d0
  12. #define PHY_ID_AQR107 0x03a1b4e0
  13. +#define PHY_ID_AQR113C 0x31c31c12
  14. #define PHY_ID_AQCS109 0x03a1b5c2
  15. #define PHY_ID_AQR405 0x03a1b4b0
  16. +#define PHY_ID_AQR813 0x31c31cb2
  17. #define MDIO_PHYXS_VEND_IF_STATUS 0xe812
  18. #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3)
  19. @@ -381,6 +383,49 @@ static int aqr107_read_rate(struct phy_d
  20. return 0;
  21. }
  22. +static int aqr113c_read_status(struct phy_device *phydev)
  23. +{
  24. + int val, ret;
  25. +
  26. + ret = aqr_read_status(phydev);
  27. + if (ret)
  28. + return ret;
  29. +
  30. + if (!phydev->link || phydev->autoneg == AUTONEG_DISABLE)
  31. + return 0;
  32. +
  33. + // On AQR113C, the speed returned by aqr_read_status is wrong
  34. + aqr107_read_rate(phydev);
  35. +
  36. + val = phy_read_mmd(phydev, MDIO_MMD_PHYXS, MDIO_PHYXS_VEND_IF_STATUS);
  37. + if (val < 0)
  38. + return val;
  39. +
  40. + switch (FIELD_GET(MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK, val)) {
  41. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR:
  42. + phydev->interface = PHY_INTERFACE_MODE_10GKR;
  43. + break;
  44. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_XFI:
  45. + phydev->interface = PHY_INTERFACE_MODE_10GBASER;
  46. + break;
  47. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_USXGMII:
  48. + phydev->interface = PHY_INTERFACE_MODE_USXGMII;
  49. + break;
  50. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_SGMII:
  51. + phydev->interface = PHY_INTERFACE_MODE_SGMII;
  52. + break;
  53. + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_OCSGMII:
  54. + phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
  55. + break;
  56. + default:
  57. + phydev->interface = PHY_INTERFACE_MODE_NA;
  58. + break;
  59. + }
  60. +
  61. + /* Read downshifted rate from vendor register */
  62. + return aqr107_read_rate(phydev);
  63. +}
  64. +
  65. static int aqr107_read_status(struct phy_device *phydev)
  66. {
  67. int val, ret;
  68. @@ -511,7 +556,7 @@ static void aqr107_chip_info(struct phy_
  69. build_id = FIELD_GET(VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID, val);
  70. prov_id = FIELD_GET(VEND1_GLOBAL_RSVD_STAT1_PROV_ID, val);
  71. - phydev_dbg(phydev, "FW %u.%u, Build %u, Provisioning %u\n",
  72. + phydev_info(phydev, "FW %u.%u, Build %u, Provisioning %u\n",
  73. fw_major, fw_minor, build_id, prov_id);
  74. }
  75. @@ -719,6 +764,24 @@ static struct phy_driver aqr_driver[] =
  76. .link_change_notify = aqr107_link_change_notify,
  77. },
  78. {
  79. + PHY_ID_MATCH_MODEL(PHY_ID_AQR113C),
  80. + .name = "Aquantia AQR113C",
  81. + .probe = aqr107_probe,
  82. + .config_init = aqr107_config_init,
  83. + .config_aneg = aqr_config_aneg,
  84. + .config_intr = aqr_config_intr,
  85. + .handle_interrupt = aqr_handle_interrupt,
  86. + .read_status = aqr113c_read_status,
  87. + .get_tunable = aqr107_get_tunable,
  88. + .set_tunable = aqr107_set_tunable,
  89. + .suspend = aqr107_suspend,
  90. + .resume = aqr107_resume,
  91. + .get_sset_count = aqr107_get_sset_count,
  92. + .get_strings = aqr107_get_strings,
  93. + .get_stats = aqr107_get_stats,
  94. + .link_change_notify = aqr107_link_change_notify,
  95. +},
  96. +{
  97. PHY_ID_MATCH_MODEL(PHY_ID_AQCS109),
  98. .name = "Aquantia AQCS109",
  99. .probe = aqr107_probe,
  100. @@ -744,6 +807,24 @@ static struct phy_driver aqr_driver[] =
  101. .handle_interrupt = aqr_handle_interrupt,
  102. .read_status = aqr_read_status,
  103. },
  104. +{
  105. + PHY_ID_MATCH_MODEL(PHY_ID_AQR813),
  106. + .name = "Aquantia AQR813",
  107. + .probe = aqr107_probe,
  108. + .config_init = aqr107_config_init,
  109. + .config_aneg = aqr_config_aneg,
  110. + .config_intr = aqr_config_intr,
  111. + .handle_interrupt = aqr_handle_interrupt,
  112. + .read_status = aqr113c_read_status,
  113. + .get_tunable = aqr107_get_tunable,
  114. + .set_tunable = aqr107_set_tunable,
  115. + .suspend = aqr107_suspend,
  116. + .resume = aqr107_resume,
  117. + .get_sset_count = aqr107_get_sset_count,
  118. + .get_strings = aqr107_get_strings,
  119. + .get_stats = aqr107_get_stats,
  120. + .link_change_notify = aqr107_link_change_notify,
  121. +},
  122. };
  123. module_phy_driver(aqr_driver);
  124. @@ -754,8 +835,10 @@ static struct mdio_device_id __maybe_unu
  125. { PHY_ID_MATCH_MODEL(PHY_ID_AQR105) },
  126. { PHY_ID_MATCH_MODEL(PHY_ID_AQR106) },
  127. { PHY_ID_MATCH_MODEL(PHY_ID_AQR107) },
  128. + { PHY_ID_MATCH_MODEL(PHY_ID_AQR113C) },
  129. { PHY_ID_MATCH_MODEL(PHY_ID_AQCS109) },
  130. { PHY_ID_MATCH_MODEL(PHY_ID_AQR405) },
  131. + { PHY_ID_MATCH_MODEL(PHY_ID_AQR813) },
  132. { }
  133. };