]> git.ipfire.org Git - thirdparty/openwrt.git/blob
b50a33590be02f46eb74b3ae493c43bb25c82b20
[thirdparty/openwrt.git] /
1 From bba140a566ed075304c49c52ab32c0016cab624a Mon Sep 17 00:00:00 2001
2 From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
3 Date: Fri, 9 Feb 2024 02:03:46 -0300
4 Subject: net: dsa: realtek: use the same mii bus driver for
5 both interfaces
6
7 The realtek-mdio will now use this driver instead of the generic DSA
8 driver ("dsa user smi"), which should not be used with OF[1].
9
10 With a single ds_ops for both interfaces, the ds_ops in realtek_priv is
11 no longer necessary. Now, the realtek_variant.ds_ops can be used
12 directly.
13
14 The realtek_priv.setup_interface() has been removed as we can directly
15 call the new common function.
16
17 [1] https://lkml.kernel.org/netdev/20220630200423.tieprdu5fpabflj7@bang-olufsen.dk/T/
18
19 Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
20 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
21 Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
22 Signed-off-by: David S. Miller <davem@davemloft.net>
23 ---
24 drivers/net/dsa/realtek/realtek-mdio.c | 1 -
25 drivers/net/dsa/realtek/realtek-smi.c | 2 -
26 drivers/net/dsa/realtek/realtek.h | 5 +--
27 drivers/net/dsa/realtek/rtl8365mb.c | 49 +++---------------------
28 drivers/net/dsa/realtek/rtl8366rb.c | 52 +++-----------------------
29 drivers/net/dsa/realtek/rtl83xx.c | 2 +-
30 6 files changed, 14 insertions(+), 97 deletions(-)
31
32 --- a/drivers/net/dsa/realtek/realtek-mdio.c
33 +++ b/drivers/net/dsa/realtek/realtek-mdio.c
34 @@ -131,7 +131,6 @@ int realtek_mdio_probe(struct mdio_devic
35 priv->bus = mdiodev->bus;
36 priv->mdio_addr = mdiodev->addr;
37 priv->write_reg_noack = realtek_mdio_write;
38 - priv->ds_ops = priv->variant->ds_ops_mdio;
39
40 ret = rtl83xx_register_switch(priv);
41 if (ret) {
42 --- a/drivers/net/dsa/realtek/realtek-smi.c
43 +++ b/drivers/net/dsa/realtek/realtek-smi.c
44 @@ -352,8 +352,6 @@ int realtek_smi_probe(struct platform_de
45 }
46
47 priv->write_reg_noack = realtek_smi_write_reg_noack;
48 - priv->setup_interface = rtl83xx_setup_user_mdio;
49 - priv->ds_ops = priv->variant->ds_ops_smi;
50
51 ret = rtl83xx_register_switch(priv);
52 if (ret) {
53 --- a/drivers/net/dsa/realtek/realtek.h
54 +++ b/drivers/net/dsa/realtek/realtek.h
55 @@ -62,7 +62,6 @@ struct realtek_priv {
56
57 spinlock_t lock; /* Locks around command writes */
58 struct dsa_switch *ds;
59 - const struct dsa_switch_ops *ds_ops;
60 struct irq_domain *irqdomain;
61 bool leds_disabled;
62
63 @@ -73,7 +72,6 @@ struct realtek_priv {
64 struct rtl8366_mib_counter *mib_counters;
65
66 const struct realtek_ops *ops;
67 - int (*setup_interface)(struct dsa_switch *ds);
68 int (*write_reg_noack)(void *ctx, u32 addr, u32 data);
69
70 int vlan_enabled;
71 @@ -115,8 +113,7 @@ struct realtek_ops {
72 };
73
74 struct realtek_variant {
75 - const struct dsa_switch_ops *ds_ops_smi;
76 - const struct dsa_switch_ops *ds_ops_mdio;
77 + const struct dsa_switch_ops *ds_ops;
78 const struct realtek_ops *ops;
79 unsigned int clk_delay;
80 u8 cmd_read;
81 --- a/drivers/net/dsa/realtek/rtl8365mb.c
82 +++ b/drivers/net/dsa/realtek/rtl8365mb.c
83 @@ -828,17 +828,6 @@ static int rtl8365mb_phy_write(struct re
84 return 0;
85 }
86
87 -static int rtl8365mb_dsa_phy_read(struct dsa_switch *ds, int phy, int regnum)
88 -{
89 - return rtl8365mb_phy_read(ds->priv, phy, regnum);
90 -}
91 -
92 -static int rtl8365mb_dsa_phy_write(struct dsa_switch *ds, int phy, int regnum,
93 - u16 val)
94 -{
95 - return rtl8365mb_phy_write(ds->priv, phy, regnum, val);
96 -}
97 -
98 static const struct rtl8365mb_extint *
99 rtl8365mb_get_port_extint(struct realtek_priv *priv, int port)
100 {
101 @@ -2018,12 +2007,10 @@ static int rtl8365mb_setup(struct dsa_sw
102 if (ret)
103 goto out_teardown_irq;
104
105 - if (priv->setup_interface) {
106 - ret = priv->setup_interface(ds);
107 - if (ret) {
108 - dev_err(priv->dev, "could not set up MDIO bus\n");
109 - goto out_teardown_irq;
110 - }
111 + ret = rtl83xx_setup_user_mdio(ds);
112 + if (ret) {
113 + dev_err(priv->dev, "could not set up MDIO bus\n");
114 + goto out_teardown_irq;
115 }
116
117 /* Start statistics counter polling */
118 @@ -2117,28 +2104,7 @@ static int rtl8365mb_detect(struct realt
119 return 0;
120 }
121
122 -static const struct dsa_switch_ops rtl8365mb_switch_ops_smi = {
123 - .get_tag_protocol = rtl8365mb_get_tag_protocol,
124 - .change_tag_protocol = rtl8365mb_change_tag_protocol,
125 - .setup = rtl8365mb_setup,
126 - .teardown = rtl8365mb_teardown,
127 - .phylink_get_caps = rtl8365mb_phylink_get_caps,
128 - .phylink_mac_config = rtl8365mb_phylink_mac_config,
129 - .phylink_mac_link_down = rtl8365mb_phylink_mac_link_down,
130 - .phylink_mac_link_up = rtl8365mb_phylink_mac_link_up,
131 - .port_stp_state_set = rtl8365mb_port_stp_state_set,
132 - .get_strings = rtl8365mb_get_strings,
133 - .get_ethtool_stats = rtl8365mb_get_ethtool_stats,
134 - .get_sset_count = rtl8365mb_get_sset_count,
135 - .get_eth_phy_stats = rtl8365mb_get_phy_stats,
136 - .get_eth_mac_stats = rtl8365mb_get_mac_stats,
137 - .get_eth_ctrl_stats = rtl8365mb_get_ctrl_stats,
138 - .get_stats64 = rtl8365mb_get_stats64,
139 - .port_change_mtu = rtl8365mb_port_change_mtu,
140 - .port_max_mtu = rtl8365mb_port_max_mtu,
141 -};
142 -
143 -static const struct dsa_switch_ops rtl8365mb_switch_ops_mdio = {
144 +static const struct dsa_switch_ops rtl8365mb_switch_ops = {
145 .get_tag_protocol = rtl8365mb_get_tag_protocol,
146 .change_tag_protocol = rtl8365mb_change_tag_protocol,
147 .setup = rtl8365mb_setup,
148 @@ -2147,8 +2113,6 @@ static const struct dsa_switch_ops rtl83
149 .phylink_mac_config = rtl8365mb_phylink_mac_config,
150 .phylink_mac_link_down = rtl8365mb_phylink_mac_link_down,
151 .phylink_mac_link_up = rtl8365mb_phylink_mac_link_up,
152 - .phy_read = rtl8365mb_dsa_phy_read,
153 - .phy_write = rtl8365mb_dsa_phy_write,
154 .port_stp_state_set = rtl8365mb_port_stp_state_set,
155 .get_strings = rtl8365mb_get_strings,
156 .get_ethtool_stats = rtl8365mb_get_ethtool_stats,
157 @@ -2168,8 +2132,7 @@ static const struct realtek_ops rtl8365m
158 };
159
160 const struct realtek_variant rtl8365mb_variant = {
161 - .ds_ops_smi = &rtl8365mb_switch_ops_smi,
162 - .ds_ops_mdio = &rtl8365mb_switch_ops_mdio,
163 + .ds_ops = &rtl8365mb_switch_ops,
164 .ops = &rtl8365mb_ops,
165 .clk_delay = 10,
166 .cmd_read = 0xb9,
167 --- a/drivers/net/dsa/realtek/rtl8366rb.c
168 +++ b/drivers/net/dsa/realtek/rtl8366rb.c
169 @@ -1035,12 +1035,10 @@ static int rtl8366rb_setup(struct dsa_sw
170 if (ret)
171 dev_info(priv->dev, "no interrupt support\n");
172
173 - if (priv->setup_interface) {
174 - ret = priv->setup_interface(ds);
175 - if (ret) {
176 - dev_err(priv->dev, "could not set up MDIO bus\n");
177 - return -ENODEV;
178 - }
179 + ret = rtl83xx_setup_user_mdio(ds);
180 + if (ret) {
181 + dev_err(priv->dev, "could not set up MDIO bus\n");
182 + return -ENODEV;
183 }
184
185 return 0;
186 @@ -1699,17 +1697,6 @@ out:
187 return ret;
188 }
189
190 -static int rtl8366rb_dsa_phy_read(struct dsa_switch *ds, int phy, int regnum)
191 -{
192 - return rtl8366rb_phy_read(ds->priv, phy, regnum);
193 -}
194 -
195 -static int rtl8366rb_dsa_phy_write(struct dsa_switch *ds, int phy, int regnum,
196 - u16 val)
197 -{
198 - return rtl8366rb_phy_write(ds->priv, phy, regnum, val);
199 -}
200 -
201 static int rtl8366rb_reset_chip(struct realtek_priv *priv)
202 {
203 int timeout = 10;
204 @@ -1775,35 +1762,9 @@ static int rtl8366rb_detect(struct realt
205 return 0;
206 }
207
208 -static const struct dsa_switch_ops rtl8366rb_switch_ops_smi = {
209 - .get_tag_protocol = rtl8366_get_tag_protocol,
210 - .setup = rtl8366rb_setup,
211 - .phylink_get_caps = rtl8366rb_phylink_get_caps,
212 - .phylink_mac_link_up = rtl8366rb_mac_link_up,
213 - .phylink_mac_link_down = rtl8366rb_mac_link_down,
214 - .get_strings = rtl8366_get_strings,
215 - .get_ethtool_stats = rtl8366_get_ethtool_stats,
216 - .get_sset_count = rtl8366_get_sset_count,
217 - .port_bridge_join = rtl8366rb_port_bridge_join,
218 - .port_bridge_leave = rtl8366rb_port_bridge_leave,
219 - .port_vlan_filtering = rtl8366rb_vlan_filtering,
220 - .port_vlan_add = rtl8366_vlan_add,
221 - .port_vlan_del = rtl8366_vlan_del,
222 - .port_enable = rtl8366rb_port_enable,
223 - .port_disable = rtl8366rb_port_disable,
224 - .port_pre_bridge_flags = rtl8366rb_port_pre_bridge_flags,
225 - .port_bridge_flags = rtl8366rb_port_bridge_flags,
226 - .port_stp_state_set = rtl8366rb_port_stp_state_set,
227 - .port_fast_age = rtl8366rb_port_fast_age,
228 - .port_change_mtu = rtl8366rb_change_mtu,
229 - .port_max_mtu = rtl8366rb_max_mtu,
230 -};
231 -
232 -static const struct dsa_switch_ops rtl8366rb_switch_ops_mdio = {
233 +static const struct dsa_switch_ops rtl8366rb_switch_ops = {
234 .get_tag_protocol = rtl8366_get_tag_protocol,
235 .setup = rtl8366rb_setup,
236 - .phy_read = rtl8366rb_dsa_phy_read,
237 - .phy_write = rtl8366rb_dsa_phy_write,
238 .phylink_get_caps = rtl8366rb_phylink_get_caps,
239 .phylink_mac_link_up = rtl8366rb_mac_link_up,
240 .phylink_mac_link_down = rtl8366rb_mac_link_down,
241 @@ -1842,8 +1803,7 @@ static const struct realtek_ops rtl8366r
242 };
243
244 const struct realtek_variant rtl8366rb_variant = {
245 - .ds_ops_smi = &rtl8366rb_switch_ops_smi,
246 - .ds_ops_mdio = &rtl8366rb_switch_ops_mdio,
247 + .ds_ops = &rtl8366rb_switch_ops,
248 .ops = &rtl8366rb_ops,
249 .clk_delay = 10,
250 .cmd_read = 0xa9,
251 --- a/drivers/net/dsa/realtek/rtl83xx.c
252 +++ b/drivers/net/dsa/realtek/rtl83xx.c
253 @@ -233,7 +233,7 @@ int rtl83xx_register_switch(struct realt
254
255 ds->priv = priv;
256 ds->dev = priv->dev;
257 - ds->ops = priv->ds_ops;
258 + ds->ops = priv->variant->ds_ops;
259 ds->num_ports = priv->num_ports;
260 priv->ds = ds;
261