705-06-v5.19-net-dsa-mt7530-switch-to-use-phylink_get_linkmodes.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. From 1c2211cb15dd3957fb26c0e1615eceb5db851ad6 Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Mon, 11 Apr 2022 10:46:22 +0100
  4. Subject: [PATCH 06/13] net: dsa: mt7530: switch to use phylink_get_linkmodes()
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Switch mt7530 to use phylink_get_linkmodes() to generate the ethtool
  9. linkmodes that can be supported. We are unable to use the generic
  10. helper for this as pause modes are dependent on the interface as
  11. the Autoneg bit depends on the interface mode.
  12. Tested-by: Marek Behún <[email protected]>
  13. Signed-off-by: Russell King (Oracle) <[email protected]>
  14. Signed-off-by: Paolo Abeni <[email protected]>
  15. ---
  16. drivers/net/dsa/mt7530.c | 57 ++++------------------------------------
  17. 1 file changed, 5 insertions(+), 52 deletions(-)
  18. --- a/drivers/net/dsa/mt7530.c
  19. +++ b/drivers/net/dsa/mt7530.c
  20. @@ -2631,19 +2631,6 @@ static int mt7531_rgmii_setup(struct mt7
  21. return 0;
  22. }
  23. -static void mt7531_sgmii_validate(struct mt7530_priv *priv, int port,
  24. - phy_interface_t interface,
  25. - unsigned long *supported)
  26. -{
  27. - /* Port5 supports ethier RGMII or SGMII.
  28. - * Port6 supports SGMII only.
  29. - */
  30. - if (port == 6 && interface == PHY_INTERFACE_MODE_2500BASEX) {
  31. - phylink_set(supported, 2500baseX_Full);
  32. - phylink_set(supported, 2500baseT_Full);
  33. - }
  34. -}
  35. -
  36. static void
  37. mt7531_sgmii_link_up_force(struct dsa_switch *ds, int port,
  38. unsigned int mode, phy_interface_t interface,
  39. @@ -3010,51 +2997,21 @@ static void mt753x_phylink_get_caps(stru
  40. }
  41. static void
  42. -mt7530_mac_port_validate(struct dsa_switch *ds, int port,
  43. - phy_interface_t interface,
  44. - unsigned long *supported)
  45. -{
  46. -}
  47. -
  48. -static void mt7531_mac_port_validate(struct dsa_switch *ds, int port,
  49. - phy_interface_t interface,
  50. - unsigned long *supported)
  51. -{
  52. - struct mt7530_priv *priv = ds->priv;
  53. -
  54. - mt7531_sgmii_validate(priv, port, interface, supported);
  55. -}
  56. -
  57. -static void
  58. mt753x_phylink_validate(struct dsa_switch *ds, int port,
  59. unsigned long *supported,
  60. struct phylink_link_state *state)
  61. {
  62. __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
  63. - struct mt7530_priv *priv = ds->priv;
  64. + u32 caps;
  65. +
  66. + caps = dsa_to_port(ds, port)->pl_config.mac_capabilities;
  67. phylink_set_port_modes(mask);
  68. + phylink_get_linkmodes(mask, state->interface, caps);
  69. if (state->interface != PHY_INTERFACE_MODE_TRGMII &&
  70. - !phy_interface_mode_is_8023z(state->interface)) {
  71. - phylink_set(mask, 10baseT_Half);
  72. - phylink_set(mask, 10baseT_Full);
  73. - phylink_set(mask, 100baseT_Half);
  74. - phylink_set(mask, 100baseT_Full);
  75. + !phy_interface_mode_is_8023z(state->interface))
  76. phylink_set(mask, Autoneg);
  77. - }
  78. -
  79. - /* This switch only supports 1G full-duplex. */
  80. - if (state->interface != PHY_INTERFACE_MODE_MII &&
  81. - state->interface != PHY_INTERFACE_MODE_2500BASEX) {
  82. - phylink_set(mask, 1000baseT_Full);
  83. - phylink_set(mask, 1000baseX_Full);
  84. - }
  85. -
  86. - priv->info->mac_port_validate(ds, port, state->interface, mask);
  87. -
  88. - phylink_set(mask, Pause);
  89. - phylink_set(mask, Asym_Pause);
  90. linkmode_and(supported, supported, mask);
  91. linkmode_and(state->advertising, state->advertising, mask);
  92. @@ -3255,7 +3212,6 @@ static const struct mt753x_info mt753x_t
  93. .phy_write = mt7530_phy_write,
  94. .pad_setup = mt7530_pad_clk_setup,
  95. .mac_port_get_caps = mt7530_mac_port_get_caps,
  96. - .mac_port_validate = mt7530_mac_port_validate,
  97. .mac_port_get_state = mt7530_phylink_mac_link_state,
  98. .mac_port_config = mt7530_mac_config,
  99. },
  100. @@ -3266,7 +3222,6 @@ static const struct mt753x_info mt753x_t
  101. .phy_write = mt7530_phy_write,
  102. .pad_setup = mt7530_pad_clk_setup,
  103. .mac_port_get_caps = mt7530_mac_port_get_caps,
  104. - .mac_port_validate = mt7530_mac_port_validate,
  105. .mac_port_get_state = mt7530_phylink_mac_link_state,
  106. .mac_port_config = mt7530_mac_config,
  107. },
  108. @@ -3278,7 +3233,6 @@ static const struct mt753x_info mt753x_t
  109. .pad_setup = mt7531_pad_setup,
  110. .cpu_port_config = mt7531_cpu_port_config,
  111. .mac_port_get_caps = mt7531_mac_port_get_caps,
  112. - .mac_port_validate = mt7531_mac_port_validate,
  113. .mac_port_get_state = mt7531_phylink_mac_link_state,
  114. .mac_port_config = mt7531_mac_config,
  115. .mac_pcs_an_restart = mt7531_sgmii_restart_an,
  116. @@ -3340,7 +3294,6 @@ mt7530_probe(struct mdio_device *mdiodev
  117. if (!priv->info->sw_setup || !priv->info->pad_setup ||
  118. !priv->info->phy_read || !priv->info->phy_write ||
  119. !priv->info->mac_port_get_caps ||
  120. - !priv->info->mac_port_validate ||
  121. !priv->info->mac_port_get_state || !priv->info->mac_port_config)
  122. return -EINVAL;