705-03-v5.19-net-dsa-mt7530-remove-interface-checks.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. From e3f6719e2269868ca129b05da50cd55786848954 Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Mon, 11 Apr 2022 10:46:06 +0100
  4. Subject: [PATCH 03/13] net: dsa: mt7530: remove interface checks
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. As phylink checks the interface mode against the supported_interfaces
  9. bitmap, we no longer need to validate the interface mode, nor handle
  10. PHY_INTERFACE_MODE_NA in the validation function. Remove these to
  11. simplify the implementation.
  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 | 82 ----------------------------------------
  17. drivers/net/dsa/mt7530.h | 2 -
  18. 2 files changed, 84 deletions(-)
  19. --- a/drivers/net/dsa/mt7530.c
  20. +++ b/drivers/net/dsa/mt7530.c
  21. @@ -2525,37 +2525,6 @@ static void mt7530_mac_port_get_caps(str
  22. }
  23. }
  24. -static bool
  25. -mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
  26. - const struct phylink_link_state *state)
  27. -{
  28. - struct mt7530_priv *priv = ds->priv;
  29. -
  30. - switch (port) {
  31. - case 0 ... 4: /* Internal phy */
  32. - if (state->interface != PHY_INTERFACE_MODE_GMII)
  33. - return false;
  34. - break;
  35. - case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
  36. - if (!phy_interface_mode_is_rgmii(state->interface) &&
  37. - state->interface != PHY_INTERFACE_MODE_MII &&
  38. - state->interface != PHY_INTERFACE_MODE_GMII)
  39. - return false;
  40. - break;
  41. - case 6: /* 1st cpu port */
  42. - if (state->interface != PHY_INTERFACE_MODE_RGMII &&
  43. - state->interface != PHY_INTERFACE_MODE_TRGMII)
  44. - return false;
  45. - break;
  46. - default:
  47. - dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
  48. - port);
  49. - return false;
  50. - }
  51. -
  52. - return true;
  53. -}
  54. -
  55. static bool mt7531_is_rgmii_port(struct mt7530_priv *priv, u32 port)
  56. {
  57. return (port == 5) && (priv->p5_intf_sel != P5_INTF_SEL_GMAC5_SGMII);
  58. @@ -2592,44 +2561,6 @@ static void mt7531_mac_port_get_caps(str
  59. }
  60. }
  61. -static bool
  62. -mt7531_phy_mode_supported(struct dsa_switch *ds, int port,
  63. - const struct phylink_link_state *state)
  64. -{
  65. - struct mt7530_priv *priv = ds->priv;
  66. -
  67. - switch (port) {
  68. - case 0 ... 4: /* Internal phy */
  69. - if (state->interface != PHY_INTERFACE_MODE_GMII)
  70. - return false;
  71. - break;
  72. - case 5: /* 2nd cpu port supports either rgmii or sgmii/8023z */
  73. - if (mt7531_is_rgmii_port(priv, port))
  74. - return phy_interface_mode_is_rgmii(state->interface);
  75. - fallthrough;
  76. - case 6: /* 1st cpu port supports sgmii/8023z only */
  77. - if (state->interface != PHY_INTERFACE_MODE_SGMII &&
  78. - !phy_interface_mode_is_8023z(state->interface))
  79. - return false;
  80. - break;
  81. - default:
  82. - dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
  83. - port);
  84. - return false;
  85. - }
  86. -
  87. - return true;
  88. -}
  89. -
  90. -static bool
  91. -mt753x_phy_mode_supported(struct dsa_switch *ds, int port,
  92. - const struct phylink_link_state *state)
  93. -{
  94. - struct mt7530_priv *priv = ds->priv;
  95. -
  96. - return priv->info->phy_mode_supported(ds, port, state);
  97. -}
  98. -
  99. static int
  100. mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
  101. {
  102. @@ -2884,9 +2815,6 @@ mt753x_phylink_mac_config(struct dsa_swi
  103. struct mt7530_priv *priv = ds->priv;
  104. u32 mcr_cur, mcr_new;
  105. - if (!mt753x_phy_mode_supported(ds, port, state))
  106. - goto unsupported;
  107. -
  108. switch (port) {
  109. case 0 ... 4: /* Internal phy */
  110. if (state->interface != PHY_INTERFACE_MODE_GMII)
  111. @@ -3102,12 +3030,6 @@ mt753x_phylink_validate(struct dsa_switc
  112. __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
  113. struct mt7530_priv *priv = ds->priv;
  114. - if (state->interface != PHY_INTERFACE_MODE_NA &&
  115. - !mt753x_phy_mode_supported(ds, port, state)) {
  116. - linkmode_zero(supported);
  117. - return;
  118. - }
  119. -
  120. phylink_set_port_modes(mask);
  121. if (state->interface != PHY_INTERFACE_MODE_TRGMII &&
  122. @@ -3334,7 +3256,6 @@ static const struct mt753x_info mt753x_t
  123. .phy_write = mt7530_phy_write,
  124. .pad_setup = mt7530_pad_clk_setup,
  125. .mac_port_get_caps = mt7530_mac_port_get_caps,
  126. - .phy_mode_supported = mt7530_phy_mode_supported,
  127. .mac_port_validate = mt7530_mac_port_validate,
  128. .mac_port_get_state = mt7530_phylink_mac_link_state,
  129. .mac_port_config = mt7530_mac_config,
  130. @@ -3346,7 +3267,6 @@ static const struct mt753x_info mt753x_t
  131. .phy_write = mt7530_phy_write,
  132. .pad_setup = mt7530_pad_clk_setup,
  133. .mac_port_get_caps = mt7530_mac_port_get_caps,
  134. - .phy_mode_supported = mt7530_phy_mode_supported,
  135. .mac_port_validate = mt7530_mac_port_validate,
  136. .mac_port_get_state = mt7530_phylink_mac_link_state,
  137. .mac_port_config = mt7530_mac_config,
  138. @@ -3359,7 +3279,6 @@ static const struct mt753x_info mt753x_t
  139. .pad_setup = mt7531_pad_setup,
  140. .cpu_port_config = mt7531_cpu_port_config,
  141. .mac_port_get_caps = mt7531_mac_port_get_caps,
  142. - .phy_mode_supported = mt7531_phy_mode_supported,
  143. .mac_port_validate = mt7531_mac_port_validate,
  144. .mac_port_get_state = mt7531_phylink_mac_link_state,
  145. .mac_port_config = mt7531_mac_config,
  146. @@ -3422,7 +3341,6 @@ mt7530_probe(struct mdio_device *mdiodev
  147. if (!priv->info->sw_setup || !priv->info->pad_setup ||
  148. !priv->info->phy_read || !priv->info->phy_write ||
  149. !priv->info->mac_port_get_caps ||
  150. - !priv->info->phy_mode_supported ||
  151. !priv->info->mac_port_validate ||
  152. !priv->info->mac_port_get_state || !priv->info->mac_port_config)
  153. return -EINVAL;
  154. --- a/drivers/net/dsa/mt7530.h
  155. +++ b/drivers/net/dsa/mt7530.h
  156. @@ -798,8 +798,6 @@ struct mt753x_info {
  157. int (*cpu_port_config)(struct dsa_switch *ds, int port);
  158. void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
  159. struct phylink_config *config);
  160. - bool (*phy_mode_supported)(struct dsa_switch *ds, int port,
  161. - const struct phylink_link_state *state);
  162. void (*mac_port_validate)(struct dsa_switch *ds, int port,
  163. unsigned long *supported);
  164. int (*mac_port_get_state)(struct dsa_switch *ds, int port,