708-v6.8-01-net-phy-at803x-move-specific-qca808x-config_aneg-to-.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From 8e732f1c6f2dc5e18f766d0f1b11df9db2dd044a Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Thu, 14 Dec 2023 01:44:31 +0100
  4. Subject: [PATCH 1/2] net: phy: at803x: move specific qca808x config_aneg to
  5. dedicated function
  6. Move specific qca808x config_aneg to dedicated function to permit easier
  7. split of qca808x portion from at803x driver.
  8. Signed-off-by: Christian Marangi <[email protected]>
  9. Signed-off-by: David S. Miller <[email protected]>
  10. ---
  11. drivers/net/phy/at803x.c | 66 ++++++++++++++++++++++++----------------
  12. 1 file changed, 40 insertions(+), 26 deletions(-)
  13. --- a/drivers/net/phy/at803x.c
  14. +++ b/drivers/net/phy/at803x.c
  15. @@ -1045,9 +1045,8 @@ static int at803x_config_mdix(struct phy
  16. FIELD_PREP(AT803X_SFC_MDI_CROSSOVER_MODE_M, val));
  17. }
  18. -static int at803x_config_aneg(struct phy_device *phydev)
  19. +static int at803x_prepare_config_aneg(struct phy_device *phydev)
  20. {
  21. - struct at803x_priv *priv = phydev->priv;
  22. int ret;
  23. ret = at803x_config_mdix(phydev, phydev->mdix_ctrl);
  24. @@ -1064,33 +1063,22 @@ static int at803x_config_aneg(struct phy
  25. return ret;
  26. }
  27. - if (priv->is_1000basex)
  28. - return genphy_c37_config_aneg(phydev);
  29. -
  30. - /* Do not restart auto-negotiation by setting ret to 0 defautly,
  31. - * when calling __genphy_config_aneg later.
  32. - */
  33. - ret = 0;
  34. -
  35. - if (phydev->drv->phy_id == QCA8081_PHY_ID) {
  36. - int phy_ctrl = 0;
  37. + return 0;
  38. +}
  39. - /* The reg MII_BMCR also needs to be configured for force mode, the
  40. - * genphy_config_aneg is also needed.
  41. - */
  42. - if (phydev->autoneg == AUTONEG_DISABLE)
  43. - genphy_c45_pma_setup_forced(phydev);
  44. +static int at803x_config_aneg(struct phy_device *phydev)
  45. +{
  46. + struct at803x_priv *priv = phydev->priv;
  47. + int ret;
  48. - if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising))
  49. - phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;
  50. + ret = at803x_prepare_config_aneg(phydev);
  51. + if (ret)
  52. + return ret;
  53. - ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
  54. - MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);
  55. - if (ret < 0)
  56. - return ret;
  57. - }
  58. + if (priv->is_1000basex)
  59. + return genphy_c37_config_aneg(phydev);
  60. - return __genphy_config_aneg(phydev, ret);
  61. + return genphy_config_aneg(phydev);
  62. }
  63. static int at803x_get_downshift(struct phy_device *phydev, u8 *d)
  64. @@ -2118,6 +2106,32 @@ static int qca808x_get_features(struct p
  65. return 0;
  66. }
  67. +static int qca808x_config_aneg(struct phy_device *phydev)
  68. +{
  69. + int phy_ctrl = 0;
  70. + int ret;
  71. +
  72. + ret = at803x_prepare_config_aneg(phydev);
  73. + if (ret)
  74. + return ret;
  75. +
  76. + /* The reg MII_BMCR also needs to be configured for force mode, the
  77. + * genphy_config_aneg is also needed.
  78. + */
  79. + if (phydev->autoneg == AUTONEG_DISABLE)
  80. + genphy_c45_pma_setup_forced(phydev);
  81. +
  82. + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising))
  83. + phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;
  84. +
  85. + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
  86. + MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);
  87. + if (ret < 0)
  88. + return ret;
  89. +
  90. + return __genphy_config_aneg(phydev, ret);
  91. +}
  92. +
  93. static void qca808x_link_change_notify(struct phy_device *phydev)
  94. {
  95. /* Assert interface sgmii fifo on link down, deassert it on link up,
  96. @@ -2295,7 +2309,7 @@ static struct phy_driver at803x_driver[]
  97. .set_wol = at803x_set_wol,
  98. .get_wol = at803x_get_wol,
  99. .get_features = qca808x_get_features,
  100. - .config_aneg = at803x_config_aneg,
  101. + .config_aneg = qca808x_config_aneg,
  102. .suspend = genphy_suspend,
  103. .resume = genphy_resume,
  104. .read_status = qca808x_read_status,