38a24dc46b0db7ff5d5f554f49446747a45098b6
[openwrt/staging/hauke.git] / target / linux / generic / backport-5.15 / 705-03-v5.19-net-dsa-mt7530-remove-interface-checks.patch
1 From e3f6719e2269868ca129b05da50cd55786848954 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
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
9 As phylink checks the interface mode against the supported_interfaces
10 bitmap, we no longer need to validate the interface mode, nor handle
11 PHY_INTERFACE_MODE_NA in the validation function. Remove these to
12 simplify the implementation.
13
14 Tested-by: Marek BehĂșn <kabel@kernel.org>
15 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
16 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
17 ---
18 drivers/net/dsa/mt7530.c | 82 ----------------------------------------
19 drivers/net/dsa/mt7530.h | 2 -
20 2 files changed, 84 deletions(-)
21
22 --- a/drivers/net/dsa/mt7530.c
23 +++ b/drivers/net/dsa/mt7530.c
24 @@ -2438,37 +2438,6 @@ static void mt7530_mac_port_get_caps(str
25 }
26 }
27
28 -static bool
29 -mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
30 - const struct phylink_link_state *state)
31 -{
32 - struct mt7530_priv *priv = ds->priv;
33 -
34 - switch (port) {
35 - case 0 ... 4: /* Internal phy */
36 - if (state->interface != PHY_INTERFACE_MODE_GMII)
37 - return false;
38 - break;
39 - case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
40 - if (!phy_interface_mode_is_rgmii(state->interface) &&
41 - state->interface != PHY_INTERFACE_MODE_MII &&
42 - state->interface != PHY_INTERFACE_MODE_GMII)
43 - return false;
44 - break;
45 - case 6: /* 1st cpu port */
46 - if (state->interface != PHY_INTERFACE_MODE_RGMII &&
47 - state->interface != PHY_INTERFACE_MODE_TRGMII)
48 - return false;
49 - break;
50 - default:
51 - dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
52 - port);
53 - return false;
54 - }
55 -
56 - return true;
57 -}
58 -
59 static bool mt7531_is_rgmii_port(struct mt7530_priv *priv, u32 port)
60 {
61 return (port == 5) && (priv->p5_intf_sel != P5_INTF_SEL_GMAC5_SGMII);
62 @@ -2505,44 +2474,6 @@ static void mt7531_mac_port_get_caps(str
63 }
64 }
65
66 -static bool
67 -mt7531_phy_mode_supported(struct dsa_switch *ds, int port,
68 - const struct phylink_link_state *state)
69 -{
70 - struct mt7530_priv *priv = ds->priv;
71 -
72 - switch (port) {
73 - case 0 ... 4: /* Internal phy */
74 - if (state->interface != PHY_INTERFACE_MODE_GMII)
75 - return false;
76 - break;
77 - case 5: /* 2nd cpu port supports either rgmii or sgmii/8023z */
78 - if (mt7531_is_rgmii_port(priv, port))
79 - return phy_interface_mode_is_rgmii(state->interface);
80 - fallthrough;
81 - case 6: /* 1st cpu port supports sgmii/8023z only */
82 - if (state->interface != PHY_INTERFACE_MODE_SGMII &&
83 - !phy_interface_mode_is_8023z(state->interface))
84 - return false;
85 - break;
86 - default:
87 - dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
88 - port);
89 - return false;
90 - }
91 -
92 - return true;
93 -}
94 -
95 -static bool
96 -mt753x_phy_mode_supported(struct dsa_switch *ds, int port,
97 - const struct phylink_link_state *state)
98 -{
99 - struct mt7530_priv *priv = ds->priv;
100 -
101 - return priv->info->phy_mode_supported(ds, port, state);
102 -}
103 -
104 static int
105 mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
106 {
107 @@ -2797,9 +2728,6 @@ mt753x_phylink_mac_config(struct dsa_swi
108 struct mt7530_priv *priv = ds->priv;
109 u32 mcr_cur, mcr_new;
110
111 - if (!mt753x_phy_mode_supported(ds, port, state))
112 - goto unsupported;
113 -
114 switch (port) {
115 case 0 ... 4: /* Internal phy */
116 if (state->interface != PHY_INTERFACE_MODE_GMII)
117 @@ -3015,12 +2943,6 @@ mt753x_phylink_validate(struct dsa_switc
118 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
119 struct mt7530_priv *priv = ds->priv;
120
121 - if (state->interface != PHY_INTERFACE_MODE_NA &&
122 - !mt753x_phy_mode_supported(ds, port, state)) {
123 - linkmode_zero(supported);
124 - return;
125 - }
126 -
127 phylink_set_port_modes(mask);
128
129 if (state->interface != PHY_INTERFACE_MODE_TRGMII &&
130 @@ -3247,7 +3169,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 @@ -3259,7 +3180,6 @@ static const struct mt753x_info mt753x_t
139 .phy_write = mt7530_phy_write,
140 .pad_setup = mt7530_pad_clk_setup,
141 .mac_port_get_caps = mt7530_mac_port_get_caps,
142 - .phy_mode_supported = mt7530_phy_mode_supported,
143 .mac_port_validate = mt7530_mac_port_validate,
144 .mac_port_get_state = mt7530_phylink_mac_link_state,
145 .mac_port_config = mt7530_mac_config,
146 @@ -3272,7 +3192,6 @@ static const struct mt753x_info mt753x_t
147 .pad_setup = mt7531_pad_setup,
148 .cpu_port_config = mt7531_cpu_port_config,
149 .mac_port_get_caps = mt7531_mac_port_get_caps,
150 - .phy_mode_supported = mt7531_phy_mode_supported,
151 .mac_port_validate = mt7531_mac_port_validate,
152 .mac_port_get_state = mt7531_phylink_mac_link_state,
153 .mac_port_config = mt7531_mac_config,
154 @@ -3335,7 +3254,6 @@ mt7530_probe(struct mdio_device *mdiodev
155 if (!priv->info->sw_setup || !priv->info->pad_setup ||
156 !priv->info->phy_read || !priv->info->phy_write ||
157 !priv->info->mac_port_get_caps ||
158 - !priv->info->phy_mode_supported ||
159 !priv->info->mac_port_validate ||
160 !priv->info->mac_port_get_state || !priv->info->mac_port_config)
161 return -EINVAL;
162 --- a/drivers/net/dsa/mt7530.h
163 +++ b/drivers/net/dsa/mt7530.h
164 @@ -771,8 +771,6 @@ struct mt753x_info {
165 int (*cpu_port_config)(struct dsa_switch *ds, int port);
166 void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
167 struct phylink_config *config);
168 - bool (*phy_mode_supported)(struct dsa_switch *ds, int port,
169 - const struct phylink_link_state *state);
170 void (*mac_port_validate)(struct dsa_switch *ds, int port,
171 unsigned long *supported);
172 int (*mac_port_get_state)(struct dsa_switch *ds, int port,