707-v6.8-07-net-phy-at803x-move-specific-at8031-config_init-to-d.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From 3ae3bc426eaf57ca8f53d75777d9a5ef779bc7b7 Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Fri, 8 Dec 2023 15:51:54 +0100
  4. Subject: [PATCH 07/13] net: phy: at803x: move specific at8031 config_init to
  5. dedicated function
  6. Move specific at8031 config_init to dedicated function to make
  7. at803x_config_init more generic and tidy things up.
  8. Signed-off-by: Christian Marangi <[email protected]>
  9. Reviewed-by: Andrew Lunn <[email protected]>
  10. Signed-off-by: David S. Miller <[email protected]>
  11. ---
  12. drivers/net/phy/at803x.c | 45 ++++++++++++++++++++++------------------
  13. 1 file changed, 25 insertions(+), 20 deletions(-)
  14. --- a/drivers/net/phy/at803x.c
  15. +++ b/drivers/net/phy/at803x.c
  16. @@ -951,27 +951,8 @@ static int at803x_hibernation_mode_confi
  17. static int at803x_config_init(struct phy_device *phydev)
  18. {
  19. - struct at803x_priv *priv = phydev->priv;
  20. int ret;
  21. - if (phydev->drv->phy_id == ATH8031_PHY_ID) {
  22. - /* Some bootloaders leave the fiber page selected.
  23. - * Switch to the appropriate page (fiber or copper), as otherwise we
  24. - * read the PHY capabilities from the wrong page.
  25. - */
  26. - phy_lock_mdio_bus(phydev);
  27. - ret = at803x_write_page(phydev,
  28. - priv->is_fiber ? AT803X_PAGE_FIBER :
  29. - AT803X_PAGE_COPPER);
  30. - phy_unlock_mdio_bus(phydev);
  31. - if (ret)
  32. - return ret;
  33. -
  34. - ret = at8031_pll_config(phydev);
  35. - if (ret < 0)
  36. - return ret;
  37. - }
  38. -
  39. /* The RX and TX delay default is:
  40. * after HW reset: RX delay enabled and TX delay disabled
  41. * after SW reset: RX delay enabled, while TX delay retains the
  42. @@ -1604,6 +1585,30 @@ static int at8031_probe(struct phy_devic
  43. AT803X_WOL_EN, 0);
  44. }
  45. +static int at8031_config_init(struct phy_device *phydev)
  46. +{
  47. + struct at803x_priv *priv = phydev->priv;
  48. + int ret;
  49. +
  50. + /* Some bootloaders leave the fiber page selected.
  51. + * Switch to the appropriate page (fiber or copper), as otherwise we
  52. + * read the PHY capabilities from the wrong page.
  53. + */
  54. + phy_lock_mdio_bus(phydev);
  55. + ret = at803x_write_page(phydev,
  56. + priv->is_fiber ? AT803X_PAGE_FIBER :
  57. + AT803X_PAGE_COPPER);
  58. + phy_unlock_mdio_bus(phydev);
  59. + if (ret)
  60. + return ret;
  61. +
  62. + ret = at8031_pll_config(phydev);
  63. + if (ret < 0)
  64. + return ret;
  65. +
  66. + return at803x_config_init(phydev);
  67. +}
  68. +
  69. static int qca83xx_config_init(struct phy_device *phydev)
  70. {
  71. u8 switch_revision;
  72. @@ -2113,7 +2118,7 @@ static struct phy_driver at803x_driver[]
  73. .name = "Qualcomm Atheros AR8031/AR8033",
  74. .flags = PHY_POLL_CABLE_TEST,
  75. .probe = at8031_probe,
  76. - .config_init = at803x_config_init,
  77. + .config_init = at8031_config_init,
  78. .config_aneg = at803x_config_aneg,
  79. .soft_reset = genphy_soft_reset,
  80. .set_wol = at803x_set_wol,