layerscape: add patches-5.4
[openwrt/staging/mkresin.git] / target / linux / layerscape / patches-5.4 / 701-net-0370-Revert-net-mscc-ocelot-convert-to-PHYLINK.patch
1 From 74e550d54d7c8142aefc06d1f00c506cd9039b6d Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Mon, 6 Jan 2020 14:30:48 +0200
4 Subject: [PATCH] Revert "net: mscc: ocelot: convert to PHYLINK"
5
6 This reverts commit e51cc023c37902e10d1e0109ff0c6ddcce3d5c03.
7
8 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
9 ---
10 drivers/net/dsa/ocelot/felix.c | 65 ++++---------
11 drivers/net/ethernet/mscc/Kconfig | 2 +-
12 drivers/net/ethernet/mscc/ocelot.c | 150 ++++++++++++++----------------
13 drivers/net/ethernet/mscc/ocelot.h | 13 ++-
14 drivers/net/ethernet/mscc/ocelot_board.c | 154 ++++---------------------------
15 include/soc/mscc/ocelot.h | 22 +----
16 6 files changed, 117 insertions(+), 289 deletions(-)
17
18 --- a/drivers/net/dsa/ocelot/felix.c
19 +++ b/drivers/net/dsa/ocelot/felix.c
20 @@ -58,6 +58,14 @@ static int felix_set_ageing_time(struct
21 return 0;
22 }
23
24 +static void felix_adjust_link(struct dsa_switch *ds, int port,
25 + struct phy_device *phydev)
26 +{
27 + struct ocelot *ocelot = ds->priv;
28 +
29 + ocelot_adjust_link(ocelot, port, phydev);
30 +}
31 +
32 static int felix_fdb_dump(struct dsa_switch *ds, int port,
33 dsa_fdb_dump_cb_t *cb, void *data)
34 {
35 @@ -177,59 +185,21 @@ static int felix_tsn_enable(struct dsa_p
36 }
37 #endif
38
39 -static void felix_phylink_validate(struct dsa_switch *ds, int port,
40 - unsigned long *supported,
41 - struct phylink_link_state *state)
42 +static int felix_port_enable(struct dsa_switch *ds, int port,
43 + struct phy_device *phy)
44 {
45 struct ocelot *ocelot = ds->priv;
46
47 - ocelot_phylink_validate(ocelot, port, supported, state);
48 -}
49 -
50 -static int felix_phylink_mac_pcs_get_state(struct dsa_switch *ds, int port,
51 - struct phylink_link_state *state)
52 -{
53 - struct ocelot *ocelot = ds->priv;
54 -
55 - ocelot_phylink_mac_pcs_get_state(ocelot, port, state);
56 + ocelot_port_enable(ocelot, port, phy);
57
58 return 0;
59 }
60
61 -static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
62 - unsigned int link_an_mode,
63 - const struct phylink_link_state *state)
64 -{
65 - struct ocelot *ocelot = ds->priv;
66 -
67 - ocelot_phylink_mac_config(ocelot, port, link_an_mode, state);
68 -}
69 -
70 -static void felix_phylink_mac_an_restart(struct dsa_switch *ds, int port)
71 -{
72 - struct ocelot *ocelot = ds->priv;
73 -
74 - ocelot_phylink_mac_an_restart(ocelot, port);
75 -}
76 -
77 -static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
78 - unsigned int link_an_mode,
79 - phy_interface_t interface)
80 -{
81 - struct ocelot *ocelot = ds->priv;
82 -
83 - ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface);
84 -}
85 -
86 -static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
87 - unsigned int link_an_mode,
88 - phy_interface_t interface,
89 - struct phy_device *phydev)
90 +static void felix_port_disable(struct dsa_switch *ds, int port)
91 {
92 struct ocelot *ocelot = ds->priv;
93
94 - ocelot_phylink_mac_link_up(ocelot, port, link_an_mode, interface,
95 - phydev);
96 + return ocelot_port_disable(ocelot, port);
97 }
98
99 static void felix_get_strings(struct dsa_switch *ds, int port,
100 @@ -447,12 +417,9 @@ static const struct dsa_switch_ops felix
101 .get_ethtool_stats = felix_get_ethtool_stats,
102 .get_sset_count = felix_get_sset_count,
103 .get_ts_info = felix_get_ts_info,
104 - .phylink_validate = felix_phylink_validate,
105 - .phylink_mac_link_state = felix_phylink_mac_pcs_get_state,
106 - .phylink_mac_config = felix_phylink_mac_config,
107 - .phylink_mac_an_restart = felix_phylink_mac_an_restart,
108 - .phylink_mac_link_down = felix_phylink_mac_link_down,
109 - .phylink_mac_link_up = felix_phylink_mac_link_up,
110 + .adjust_link = felix_adjust_link,
111 + .port_enable = felix_port_enable,
112 + .port_disable = felix_port_disable,
113 .port_fdb_dump = felix_fdb_dump,
114 .port_fdb_add = felix_fdb_add,
115 .port_fdb_del = felix_fdb_del,
116 --- a/drivers/net/ethernet/mscc/Kconfig
117 +++ b/drivers/net/ethernet/mscc/Kconfig
118 @@ -15,7 +15,7 @@ config MSCC_OCELOT_SWITCH
119 tristate "Ocelot switch driver"
120 depends on NET_SWITCHDEV
121 depends on HAS_IOMEM
122 - select PHYLINK
123 + select PHYLIB
124 select REGMAP_MMIO
125 help
126 This driver supports the Ocelot network switch device.
127 --- a/drivers/net/ethernet/mscc/ocelot.c
128 +++ b/drivers/net/ethernet/mscc/ocelot.c
129 @@ -13,7 +13,7 @@
130 #include <linux/kernel.h>
131 #include <linux/module.h>
132 #include <linux/netdevice.h>
133 -#include <linux/phylink.h>
134 +#include <linux/phy.h>
135 #include <linux/ptp_clock_kernel.h>
136 #include <linux/skbuff.h>
137 #include <linux/iopoll.h>
138 @@ -406,66 +406,18 @@ static u16 ocelot_wm_enc(u16 value)
139 return value;
140 }
141
142 -void ocelot_phylink_validate(struct ocelot *ocelot, int port,
143 - unsigned long *supported,
144 - struct phylink_link_state *state)
145 -{
146 - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
147 -
148 - if (state->interface != PHY_INTERFACE_MODE_NA &&
149 - state->interface != PHY_INTERFACE_MODE_GMII &&
150 - state->interface != PHY_INTERFACE_MODE_SGMII &&
151 - state->interface != PHY_INTERFACE_MODE_QSGMII) {
152 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
153 - return;
154 - }
155 -
156 - /* No half-duplex. */
157 - phylink_set_port_modes(mask);
158 - phylink_set(mask, Autoneg);
159 - phylink_set(mask, Pause);
160 - phylink_set(mask, Asym_Pause);
161 - phylink_set(mask, 10baseT_Full);
162 - phylink_set(mask, 100baseT_Full);
163 - phylink_set(mask, 1000baseT_Full);
164 - phylink_set(mask, 2500baseT_Full);
165 -
166 - bitmap_and(supported, supported, mask,
167 - __ETHTOOL_LINK_MODE_MASK_NBITS);
168 - bitmap_and(state->advertising, state->advertising, mask,
169 - __ETHTOOL_LINK_MODE_MASK_NBITS);
170 -}
171 -EXPORT_SYMBOL(ocelot_phylink_validate);
172 -
173 -void ocelot_phylink_mac_pcs_get_state(struct ocelot *ocelot, int port,
174 - struct phylink_link_state *state)
175 -{
176 - state->link = 1;
177 -}
178 -EXPORT_SYMBOL(ocelot_phylink_mac_pcs_get_state);
179 -
180 -void ocelot_phylink_mac_an_restart(struct ocelot *ocelot, int port)
181 -{
182 - /* Not supported */
183 -}
184 -EXPORT_SYMBOL(ocelot_phylink_mac_an_restart);
185 -
186 -void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
187 - unsigned int link_an_mode,
188 - const struct phylink_link_state *state)
189 +void ocelot_adjust_link(struct ocelot *ocelot, int port,
190 + struct phy_device *phydev)
191 {
192 int speed, mac_speed, mac_mode = DEV_MAC_MODE_CFG_FDX_ENA;
193 struct ocelot_port *ocelot_port = ocelot->ports[port];
194 - u32 mac_fc_cfg;
195
196 if (ocelot->quirks & OCELOT_PCS_PERFORMS_RATE_ADAPTATION)
197 speed = SPEED_1000;
198 else
199 - speed = state->speed;
200 + speed = phydev->speed;
201
202 switch (speed) {
203 - case SPEED_UNKNOWN:
204 - return;
205 case SPEED_10:
206 mac_speed = OCELOT_SPEED_10;
207 break;
208 @@ -481,11 +433,16 @@ void ocelot_phylink_mac_config(struct oc
209 mac_mode |= DEV_MAC_MODE_CFG_GIGA_MODE_ENA;
210 break;
211 default:
212 - dev_err(ocelot->dev, "Unsupported speed on port %d: %d\n",
213 + dev_err(ocelot->dev, "Unsupported PHY speed on port %d: %d\n",
214 port, speed);
215 return;
216 }
217
218 + phy_print_status(phydev);
219 +
220 + if (!phydev->link)
221 + return;
222 +
223 /* Only full duplex supported for now */
224 ocelot_port_writel(ocelot_port, mac_mode, DEV_MAC_MODE_CFG);
225
226 @@ -512,36 +469,27 @@ void ocelot_phylink_mac_config(struct oc
227 QSYS_SWITCH_PORT_MODE, port);
228
229 /* Flow control */
230 - mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(mac_speed);
231 - if (state->pause & MLO_PAUSE_RX)
232 - mac_fc_cfg |= SYS_MAC_FC_CFG_RX_FC_ENA;
233 - if (state->pause & MLO_PAUSE_TX)
234 - mac_fc_cfg |= SYS_MAC_FC_CFG_TX_FC_ENA |
235 - SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
236 - SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
237 - SYS_MAC_FC_CFG_ZERO_PAUSE_ENA;
238 - ocelot_write_rix(ocelot, mac_fc_cfg, SYS_MAC_FC_CFG, port);
239 -
240 + ocelot_write_rix(ocelot, SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
241 + SYS_MAC_FC_CFG_RX_FC_ENA | SYS_MAC_FC_CFG_TX_FC_ENA |
242 + SYS_MAC_FC_CFG_ZERO_PAUSE_ENA |
243 + SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
244 + SYS_MAC_FC_CFG_FC_LINK_SPEED(mac_speed),
245 + SYS_MAC_FC_CFG, port);
246 ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port);
247 }
248 -EXPORT_SYMBOL(ocelot_phylink_mac_config);
249 +EXPORT_SYMBOL(ocelot_adjust_link);
250
251 -void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
252 - unsigned int link_an_mode,
253 - phy_interface_t interface)
254 +static void ocelot_port_adjust_link(struct net_device *dev)
255 {
256 - struct ocelot_port *ocelot_port = ocelot->ports[port];
257 + struct ocelot_port_private *priv = netdev_priv(dev);
258 + struct ocelot *ocelot = priv->port.ocelot;
259 + int port = priv->chip_port;
260
261 - ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
262 - ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
263 - QSYS_SWITCH_PORT_MODE, port);
264 + ocelot_adjust_link(ocelot, port, dev->phydev);
265 }
266 -EXPORT_SYMBOL(ocelot_phylink_mac_link_down);
267
268 -void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
269 - unsigned int link_an_mode,
270 - phy_interface_t interface,
271 - struct phy_device *phy)
272 +void ocelot_port_enable(struct ocelot *ocelot, int port,
273 + struct phy_device *phy)
274 {
275 /* Enable receiving frames on the port, and activate auto-learning of
276 * MAC addresses.
277 @@ -551,22 +499,62 @@ void ocelot_phylink_mac_link_up(struct o
278 ANA_PORT_PORT_CFG_PORTID_VAL(port),
279 ANA_PORT_PORT_CFG, port);
280 }
281 -EXPORT_SYMBOL(ocelot_phylink_mac_link_up);
282 +EXPORT_SYMBOL(ocelot_port_enable);
283
284 static int ocelot_port_open(struct net_device *dev)
285 {
286 struct ocelot_port_private *priv = netdev_priv(dev);
287 + struct ocelot *ocelot = priv->port.ocelot;
288 + int port = priv->chip_port;
289 + int err;
290 +
291 + if (priv->serdes) {
292 + err = phy_set_mode_ext(priv->serdes, PHY_MODE_ETHERNET,
293 + priv->phy_mode);
294 + if (err) {
295 + netdev_err(dev, "Could not set mode of SerDes\n");
296 + return err;
297 + }
298 + }
299 +
300 + err = phy_connect_direct(dev, priv->phy, &ocelot_port_adjust_link,
301 + priv->phy_mode);
302 + if (err) {
303 + netdev_err(dev, "Could not attach to PHY\n");
304 + return err;
305 + }
306
307 - phylink_start(priv->phylink);
308 + dev->phydev = priv->phy;
309 +
310 + phy_attached_info(priv->phy);
311 + phy_start(priv->phy);
312 +
313 + ocelot_port_enable(ocelot, port, priv->phy);
314
315 return 0;
316 }
317
318 +void ocelot_port_disable(struct ocelot *ocelot, int port)
319 +{
320 + struct ocelot_port *ocelot_port = ocelot->ports[port];
321 +
322 + ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
323 + ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
324 + QSYS_SWITCH_PORT_MODE, port);
325 +}
326 +EXPORT_SYMBOL(ocelot_port_disable);
327 +
328 static int ocelot_port_stop(struct net_device *dev)
329 {
330 struct ocelot_port_private *priv = netdev_priv(dev);
331 + struct ocelot *ocelot = priv->port.ocelot;
332 + int port = priv->chip_port;
333 +
334 + phy_disconnect(priv->phy);
335 +
336 + dev->phydev = NULL;
337
338 - phylink_stop(priv->phylink);
339 + ocelot_port_disable(ocelot, port);
340
341 return 0;
342 }
343 @@ -2263,7 +2251,8 @@ void ocelot_init_port(struct ocelot *oce
344 EXPORT_SYMBOL(ocelot_init_port);
345
346 int ocelot_probe_port(struct ocelot *ocelot, u8 port,
347 - void __iomem *regs)
348 + void __iomem *regs,
349 + struct phy_device *phy)
350 {
351 struct ocelot_port_private *priv;
352 struct ocelot_port *ocelot_port;
353 @@ -2276,6 +2265,7 @@ int ocelot_probe_port(struct ocelot *oce
354 SET_NETDEV_DEV(dev, ocelot->dev);
355 priv = netdev_priv(dev);
356 priv->dev = dev;
357 + priv->phy = phy;
358 priv->chip_port = port;
359 ocelot_port = &priv->port;
360 ocelot_port->ocelot = ocelot;
361 --- a/drivers/net/ethernet/mscc/ocelot.h
362 +++ b/drivers/net/ethernet/mscc/ocelot.h
363 @@ -12,7 +12,8 @@
364 #include <linux/etherdevice.h>
365 #include <linux/if_vlan.h>
366 #include <linux/net_tstamp.h>
367 -#include <linux/phylink.h>
368 +#include <linux/phy.h>
369 +#include <linux/phy/phy.h>
370 #include <linux/platform_device.h>
371 #include <linux/ptp_clock_kernel.h>
372 #include <linux/regmap.h>
373 @@ -64,12 +65,14 @@ struct ocelot_multicast {
374 struct ocelot_port_private {
375 struct ocelot_port port;
376 struct net_device *dev;
377 - struct phylink *phylink;
378 - struct phylink_config phylink_config;
379 + struct phy_device *phy;
380 u8 chip_port;
381
382 u8 vlan_aware;
383
384 + phy_interface_t phy_mode;
385 + struct phy *serdes;
386 +
387 struct ocelot_port_tc tc;
388 };
389
390 @@ -80,7 +83,9 @@ void ocelot_port_writel(struct ocelot_po
391 #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
392
393 int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops);
394 -int ocelot_probe_port(struct ocelot *ocelot, u8 port, void __iomem *regs);
395 +int ocelot_probe_port(struct ocelot *ocelot, u8 port,
396 + void __iomem *regs,
397 + struct phy_device *phy);
398
399 void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu,
400 enum ocelot_tag_prefix injection,
401 --- a/drivers/net/ethernet/mscc/ocelot_board.c
402 +++ b/drivers/net/ethernet/mscc/ocelot_board.c
403 @@ -13,7 +13,6 @@
404 #include <linux/mfd/syscon.h>
405 #include <linux/skbuff.h>
406 #include <net/switchdev.h>
407 -#include <linux/phy/phy.h>
408
409 #include "ocelot.h"
410
411 @@ -263,91 +262,6 @@ static const struct ocelot_ops ocelot_op
412 .reset = ocelot_reset,
413 };
414
415 -static void ocelot_port_phylink_validate(struct phylink_config *config,
416 - unsigned long *supported,
417 - struct phylink_link_state *state)
418 -{
419 - struct net_device *ndev = to_net_dev(config->dev);
420 - struct ocelot_port_private *priv = netdev_priv(ndev);
421 - struct ocelot *ocelot = priv->port.ocelot;
422 - int port = priv->chip_port;
423 -
424 - ocelot_phylink_validate(ocelot, port, supported, state);
425 -}
426 -
427 -static int
428 -ocelot_port_phylink_mac_pcs_get_state(struct phylink_config *config,
429 - struct phylink_link_state *state)
430 -{
431 - struct net_device *ndev = to_net_dev(config->dev);
432 - struct ocelot_port_private *priv = netdev_priv(ndev);
433 - struct ocelot *ocelot = priv->port.ocelot;
434 - int port = priv->chip_port;
435 -
436 - ocelot_phylink_mac_pcs_get_state(ocelot, port, state);
437 -
438 - return 0;
439 -}
440 -
441 -static void ocelot_port_phylink_mac_an_restart(struct phylink_config *config)
442 -{
443 - struct net_device *ndev = to_net_dev(config->dev);
444 - struct ocelot_port_private *priv = netdev_priv(ndev);
445 - struct ocelot *ocelot = priv->port.ocelot;
446 - int port = priv->chip_port;
447 -
448 - ocelot_phylink_mac_an_restart(ocelot, port);
449 -}
450 -
451 -static void
452 -ocelot_port_phylink_mac_config(struct phylink_config *config,
453 - unsigned int link_an_mode,
454 - const struct phylink_link_state *state)
455 -{
456 - struct net_device *ndev = to_net_dev(config->dev);
457 - struct ocelot_port_private *priv = netdev_priv(ndev);
458 - struct ocelot *ocelot = priv->port.ocelot;
459 - int port = priv->chip_port;
460 -
461 - ocelot_phylink_mac_config(ocelot, port, link_an_mode, state);
462 -}
463 -
464 -static void ocelot_port_phylink_mac_link_down(struct phylink_config *config,
465 - unsigned int link_an_mode,
466 - phy_interface_t interface)
467 -{
468 - struct net_device *ndev = to_net_dev(config->dev);
469 - struct ocelot_port_private *priv = netdev_priv(ndev);
470 - struct ocelot *ocelot = priv->port.ocelot;
471 - int port = priv->chip_port;
472 -
473 - return ocelot_phylink_mac_link_down(ocelot, port, link_an_mode,
474 - interface);
475 -}
476 -
477 -static void ocelot_port_phylink_mac_link_up(struct phylink_config *config,
478 - unsigned int link_an_mode,
479 - phy_interface_t interface,
480 - struct phy_device *phy)
481 -{
482 - struct net_device *ndev = to_net_dev(config->dev);
483 - struct ocelot_port_private *priv = netdev_priv(ndev);
484 - struct ocelot *ocelot = priv->port.ocelot;
485 - int port = priv->chip_port;
486 -
487 - return ocelot_phylink_mac_link_up(ocelot, port, link_an_mode,
488 - interface, phy);
489 -}
490 -
491 -static const struct phylink_mac_ops ocelot_phylink_ops = {
492 - .validate = ocelot_port_phylink_validate,
493 - .mac_link_state = ocelot_port_phylink_mac_pcs_get_state,
494 - .mac_an_restart = ocelot_port_phylink_mac_an_restart,
495 - .mac_config = ocelot_port_phylink_mac_config,
496 - .mac_link_down = ocelot_port_phylink_mac_link_down,
497 - .mac_link_up = ocelot_port_phylink_mac_link_up,
498 -};
499 -
500 static int mscc_ocelot_probe(struct platform_device *pdev)
501 {
502 struct device_node *np = pdev->dev.of_node;
503 @@ -455,6 +369,8 @@ static int mscc_ocelot_probe(struct plat
504 for_each_available_child_of_node(ports, portnp) {
505 struct ocelot_port_private *priv;
506 struct ocelot_port *ocelot_port;
507 + struct device_node *phy_node;
508 + struct phy_device *phy;
509 struct resource *res;
510 struct phy *serdes;
511 void __iomem *regs;
512 @@ -473,7 +389,16 @@ static int mscc_ocelot_probe(struct plat
513 if (IS_ERR(regs))
514 continue;
515
516 - err = ocelot_probe_port(ocelot, port, regs);
517 + phy_node = of_parse_phandle(portnp, "phy-handle", 0);
518 + if (!phy_node)
519 + continue;
520 +
521 + phy = of_phy_find_device(phy_node);
522 + of_node_put(phy_node);
523 + if (!phy)
524 + continue;
525 +
526 + err = ocelot_probe_port(ocelot, port, regs, phy);
527 if (err) {
528 of_node_put(portnp);
529 goto out_put_ports;
530 @@ -487,7 +412,9 @@ static int mscc_ocelot_probe(struct plat
531 if (phy_mode < 0)
532 phy_mode = PHY_INTERFACE_MODE_NA;
533
534 - switch (phy_mode) {
535 + priv->phy_mode = phy_mode;
536 +
537 + switch (priv->phy_mode) {
538 case PHY_INTERFACE_MODE_NA:
539 continue;
540 case PHY_INTERFACE_MODE_SGMII:
541 @@ -524,41 +451,7 @@ static int mscc_ocelot_probe(struct plat
542 goto out_put_ports;
543 }
544
545 - if (serdes) {
546 - err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET,
547 - phy_mode);
548 - if (err) {
549 - dev_err(ocelot->dev,
550 - "Could not set mode of SerDes\n");
551 - of_node_put(portnp);
552 - goto out_put_ports;
553 - }
554 - }
555 -
556 - priv->phylink_config.dev = &priv->dev->dev;
557 - priv->phylink_config.type = PHYLINK_NETDEV;
558 -
559 - priv->phylink = phylink_create(&priv->phylink_config,
560 - of_fwnode_handle(portnp),
561 - phy_mode, &ocelot_phylink_ops);
562 - if (IS_ERR(priv->phylink)) {
563 - dev_err(ocelot->dev,
564 - "Could not create a phylink instance (%ld)\n",
565 - PTR_ERR(priv->phylink));
566 - err = PTR_ERR(priv->phylink);
567 - priv->phylink = NULL;
568 - of_node_put(portnp);
569 - goto out_put_ports;
570 - }
571 -
572 - err = phylink_of_phy_connect(priv->phylink, portnp, 0);
573 - if (err) {
574 - dev_err(ocelot->dev, "Could not connect to PHY: %d\n",
575 - err);
576 - phylink_destroy(priv->phylink);
577 - of_node_put(portnp);
578 - goto out_put_ports;
579 - }
580 + priv->serdes = serdes;
581 }
582
583 register_netdevice_notifier(&ocelot_netdevice_nb);
584 @@ -575,27 +468,12 @@ out_put_ports:
585 static int mscc_ocelot_remove(struct platform_device *pdev)
586 {
587 struct ocelot *ocelot = platform_get_drvdata(pdev);
588 - int port;
589
590 ocelot_deinit(ocelot);
591 unregister_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
592 unregister_switchdev_notifier(&ocelot_switchdev_nb);
593 unregister_netdevice_notifier(&ocelot_netdevice_nb);
594
595 - for (port = 0; port < ocelot->num_phys_ports; port++) {
596 - struct ocelot_port_private *priv;
597 -
598 - priv = container_of(ocelot->ports[port],
599 - struct ocelot_port_private,
600 - port);
601 -
602 - if (priv->phylink) {
603 - rtnl_lock();
604 - phylink_destroy(priv->phylink);
605 - rtnl_unlock();
606 - }
607 - }
608 -
609 return 0;
610 }
611
612 --- a/include/soc/mscc/ocelot.h
613 +++ b/include/soc/mscc/ocelot.h
614 @@ -518,12 +518,17 @@ void ocelot_deinit(struct ocelot *ocelot
615 void ocelot_init_port(struct ocelot *ocelot, int port);
616
617 /* DSA callbacks */
618 +void ocelot_port_enable(struct ocelot *ocelot, int port,
619 + struct phy_device *phy);
620 +void ocelot_port_disable(struct ocelot *ocelot, int port);
621 void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
622 void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
623 int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
624 int ocelot_get_ts_info(struct ocelot *ocelot, int port,
625 struct ethtool_ts_info *info);
626 void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
627 +void ocelot_adjust_link(struct ocelot *ocelot, int port,
628 + struct phy_device *phydev);
629 void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port,
630 bool vlan_aware);
631 void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
632 @@ -592,21 +597,4 @@ int ocelot_rtag_parse_enable(struct ocel
633 int ocelot_dscp_set(struct ocelot *ocelot, int port,
634 bool enable, const u8 dscp_ix,
635 struct tsn_qos_switch_dscp_conf *c);
636 -void ocelot_phylink_validate(struct ocelot *ocelot, int port,
637 - unsigned long *supported,
638 - struct phylink_link_state *state);
639 -void ocelot_phylink_mac_pcs_get_state(struct ocelot *ocelot, int port,
640 - struct phylink_link_state *state);
641 -void ocelot_phylink_mac_an_restart(struct ocelot *ocelot, int port);
642 -void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
643 - unsigned int link_an_mode,
644 - const struct phylink_link_state *state);
645 -void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
646 - unsigned int link_an_mode,
647 - phy_interface_t interface);
648 -void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
649 - unsigned int link_an_mode,
650 - phy_interface_t interface,
651 - struct phy_device *phy);
652 -
653 #endif