707-v6.8-04-net-phy-at803x-move-qca83xx-specific-check-in-dedica.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. From d43cff3f82336c0bd965ea552232d9f4ddac71a6 Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Fri, 8 Dec 2023 15:51:51 +0100
  4. Subject: [PATCH 04/13] net: phy: at803x: move qca83xx specific check in
  5. dedicated functions
  6. Rework qca83xx specific check to dedicated function to tidy things up
  7. and drop useless phy_id check.
  8. Also drop an useless link_change_notify for QCA8337 as it did nothing an
  9. returned early.
  10. Signed-off-by: Christian Marangi <[email protected]>
  11. Reviewed-by: Andrew Lunn <[email protected]>
  12. Signed-off-by: David S. Miller <[email protected]>
  13. ---
  14. drivers/net/phy/at803x.c | 68 ++++++++++++++++++++++------------------
  15. 1 file changed, 37 insertions(+), 31 deletions(-)
  16. --- a/drivers/net/phy/at803x.c
  17. +++ b/drivers/net/phy/at803x.c
  18. @@ -1623,27 +1623,26 @@ static int qca83xx_config_init(struct ph
  19. break;
  20. }
  21. + /* Following original QCA sourcecode set port to prefer master */
  22. + phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER);
  23. +
  24. + return 0;
  25. +}
  26. +
  27. +static int qca8327_config_init(struct phy_device *phydev)
  28. +{
  29. /* QCA8327 require DAC amplitude adjustment for 100m set to +6%.
  30. * Disable on init and enable only with 100m speed following
  31. * qca original source code.
  32. */
  33. - if (phydev->drv->phy_id == QCA8327_A_PHY_ID ||
  34. - phydev->drv->phy_id == QCA8327_B_PHY_ID)
  35. - at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL,
  36. - QCA8327_DEBUG_MANU_CTRL_EN, 0);
  37. + at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL,
  38. + QCA8327_DEBUG_MANU_CTRL_EN, 0);
  39. - /* Following original QCA sourcecode set port to prefer master */
  40. - phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER);
  41. -
  42. - return 0;
  43. + return qca83xx_config_init(phydev);
  44. }
  45. static void qca83xx_link_change_notify(struct phy_device *phydev)
  46. {
  47. - /* QCA8337 doesn't require DAC Amplitude adjustement */
  48. - if (phydev->drv->phy_id == QCA8337_PHY_ID)
  49. - return;
  50. -
  51. /* Set DAC Amplitude adjustment to +6% for 100m on link running */
  52. if (phydev->state == PHY_RUNNING) {
  53. if (phydev->speed == SPEED_100)
  54. @@ -1686,19 +1685,6 @@ static int qca83xx_resume(struct phy_dev
  55. static int qca83xx_suspend(struct phy_device *phydev)
  56. {
  57. - u16 mask = 0;
  58. -
  59. - /* Only QCA8337 support actual suspend.
  60. - * QCA8327 cause port unreliability when phy suspend
  61. - * is set.
  62. - */
  63. - if (phydev->drv->phy_id == QCA8337_PHY_ID) {
  64. - genphy_suspend(phydev);
  65. - } else {
  66. - mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX);
  67. - phy_modify(phydev, MII_BMCR, mask, 0);
  68. - }
  69. -
  70. at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN,
  71. AT803X_DEBUG_GATE_CLK_IN1000, 0);
  72. @@ -1709,6 +1695,27 @@ static int qca83xx_suspend(struct phy_de
  73. return 0;
  74. }
  75. +static int qca8337_suspend(struct phy_device *phydev)
  76. +{
  77. + /* Only QCA8337 support actual suspend. */
  78. + genphy_suspend(phydev);
  79. +
  80. + return qca83xx_suspend(phydev);
  81. +}
  82. +
  83. +static int qca8327_suspend(struct phy_device *phydev)
  84. +{
  85. + u16 mask = 0;
  86. +
  87. + /* QCA8327 cause port unreliability when phy suspend
  88. + * is set.
  89. + */
  90. + mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX);
  91. + phy_modify(phydev, MII_BMCR, mask, 0);
  92. +
  93. + return qca83xx_suspend(phydev);
  94. +}
  95. +
  96. static int qca808x_phy_fast_retrain_config(struct phy_device *phydev)
  97. {
  98. int ret;
  99. @@ -2170,7 +2177,6 @@ static struct phy_driver at803x_driver[]
  100. .phy_id_mask = QCA8K_PHY_ID_MASK,
  101. .name = "Qualcomm Atheros 8337 internal PHY",
  102. /* PHY_GBIT_FEATURES */
  103. - .link_change_notify = qca83xx_link_change_notify,
  104. .probe = at803x_probe,
  105. .flags = PHY_IS_INTERNAL,
  106. .config_init = qca83xx_config_init,
  107. @@ -2178,7 +2184,7 @@ static struct phy_driver at803x_driver[]
  108. .get_sset_count = qca83xx_get_sset_count,
  109. .get_strings = qca83xx_get_strings,
  110. .get_stats = qca83xx_get_stats,
  111. - .suspend = qca83xx_suspend,
  112. + .suspend = qca8337_suspend,
  113. .resume = qca83xx_resume,
  114. }, {
  115. /* QCA8327-A from switch QCA8327-AL1A */
  116. @@ -2189,12 +2195,12 @@ static struct phy_driver at803x_driver[]
  117. .link_change_notify = qca83xx_link_change_notify,
  118. .probe = at803x_probe,
  119. .flags = PHY_IS_INTERNAL,
  120. - .config_init = qca83xx_config_init,
  121. + .config_init = qca8327_config_init,
  122. .soft_reset = genphy_soft_reset,
  123. .get_sset_count = qca83xx_get_sset_count,
  124. .get_strings = qca83xx_get_strings,
  125. .get_stats = qca83xx_get_stats,
  126. - .suspend = qca83xx_suspend,
  127. + .suspend = qca8327_suspend,
  128. .resume = qca83xx_resume,
  129. }, {
  130. /* QCA8327-B from switch QCA8327-BL1A */
  131. @@ -2205,12 +2211,12 @@ static struct phy_driver at803x_driver[]
  132. .link_change_notify = qca83xx_link_change_notify,
  133. .probe = at803x_probe,
  134. .flags = PHY_IS_INTERNAL,
  135. - .config_init = qca83xx_config_init,
  136. + .config_init = qca8327_config_init,
  137. .soft_reset = genphy_soft_reset,
  138. .get_sset_count = qca83xx_get_sset_count,
  139. .get_strings = qca83xx_get_strings,
  140. .get_stats = qca83xx_get_stats,
  141. - .suspend = qca83xx_suspend,
  142. + .suspend = qca8327_suspend,
  143. .resume = qca83xx_resume,
  144. }, {
  145. /* Qualcomm QCA8081 */