0309-net-phy-qca808x-Add-link_change_notify-function-for-.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From d1f2a1810af1833196934977f57607432fda46b4 Mon Sep 17 00:00:00 2001
  2. From: Luo Jie <[email protected]>
  3. Date: Wed, 8 Nov 2023 18:01:14 +0800
  4. Subject: [PATCH] net: phy: qca808x: Add link_change_notify function for
  5. QCA8084
  6. When the link is changed, QCA8084 needs to do the fifo reset and
  7. adjust the IPG level for the 10G-QXGMII link on the speed 1000M.
  8. Change-Id: I21de802c78496fb95f1c5119fe3894c9fdebbd65
  9. Signed-off-by: Luo Jie <[email protected]>
  10. ---
  11. drivers/net/phy/qcom/qca808x.c | 52 ++++++++++++++++++++++++++++++++++
  12. 1 file changed, 52 insertions(+)
  13. --- a/drivers/net/phy/qcom/qca808x.c
  14. +++ b/drivers/net/phy/qcom/qca808x.c
  15. @@ -103,6 +103,14 @@
  16. #define QCA8084_MSE_THRESHOLD 0x800a
  17. #define QCA8084_MSE_THRESHOLD_2P5G_VAL 0x51c6
  18. +/* QCA8084 FIFO reset control */
  19. +#define QCA8084_FIFO_CONTROL 0x19
  20. +#define QCA8084_FIFO_MAC_2_PHY BIT(1)
  21. +#define QCA8084_FIFO_PHY_2_MAC BIT(0)
  22. +
  23. +#define QCA8084_MMD7_IPG_OP 0x901d
  24. +#define QCA8084_IPG_10_TO_11_EN BIT(0)
  25. +
  26. MODULE_DESCRIPTION("Qualcomm Atheros QCA808X PHY driver");
  27. MODULE_AUTHOR("Matus Ujhelyi, Luo Jie");
  28. MODULE_LICENSE("GPL");
  29. @@ -697,6 +705,49 @@ static int qca8084_config_init(struct ph
  30. QCA8084_MSE_THRESHOLD_2P5G_VAL);
  31. }
  32. +static void qca8084_link_change_notify(struct phy_device *phydev)
  33. +{
  34. + int ret;
  35. +
  36. + /* Assert the FIFO between PHY and MAC. */
  37. + ret = phy_modify(phydev, QCA8084_FIFO_CONTROL,
  38. + QCA8084_FIFO_MAC_2_PHY | QCA8084_FIFO_PHY_2_MAC,
  39. + 0);
  40. + if (ret) {
  41. + phydev_err(phydev, "Asserting PHY FIFO failed\n");
  42. + return;
  43. + }
  44. +
  45. + /* If the PHY is in 10G_QXGMII mode, the FIFO needs to be kept in
  46. + * reset state when link is down, otherwise the FIFO needs to be
  47. + * de-asserted after waiting 50 ms to make the assert completed.
  48. + */
  49. + if (phydev->interface != PHY_INTERFACE_MODE_10G_QXGMII ||
  50. + phydev->link) {
  51. + msleep(50);
  52. +
  53. + /* Deassert the FIFO between PHY and MAC. */
  54. + ret = phy_modify(phydev, QCA8084_FIFO_CONTROL,
  55. + QCA8084_FIFO_MAC_2_PHY |
  56. + QCA8084_FIFO_PHY_2_MAC,
  57. + QCA8084_FIFO_MAC_2_PHY |
  58. + QCA8084_FIFO_PHY_2_MAC);
  59. + if (ret) {
  60. + phydev_err(phydev, "De-asserting PHY FIFO failed\n");
  61. + return;
  62. + }
  63. + }
  64. +
  65. + /* Enable IPG level 10 to 11 tuning for link speed 1000M in the
  66. + * 10G_QXGMII mode.
  67. + */
  68. + if (phydev->interface == PHY_INTERFACE_MODE_10G_QXGMII)
  69. + phy_modify_mmd(phydev, MDIO_MMD_AN, QCA8084_MMD7_IPG_OP,
  70. + QCA8084_IPG_10_TO_11_EN,
  71. + phydev->speed == SPEED_1000 ?
  72. + QCA8084_IPG_10_TO_11_EN : 0);
  73. +}
  74. +
  75. static struct phy_driver qca808x_driver[] = {
  76. {
  77. /* Qualcomm QCA8081 */
  78. @@ -746,6 +797,7 @@ static struct phy_driver qca808x_driver[
  79. .cable_test_start = qca808x_cable_test_start,
  80. .cable_test_get_status = qca808x_cable_test_get_status,
  81. .config_init = qca8084_config_init,
  82. + .link_change_notify = qca8084_link_change_notify,
  83. }, };
  84. module_phy_driver(qca808x_driver);