aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0370-Revert-net-mscc-ocelot-convert-to-PHYLINK.patch
blob: 14231041f4e9cfedf4d08bea8d4e4ef73f6a73be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
From 74e550d54d7c8142aefc06d1f00c506cd9039b6d Mon Sep 17 00:00:00 2001
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: Mon, 6 Jan 2020 14:30:48 +0200
Subject: [PATCH] Revert "net: mscc: ocelot: convert to PHYLINK"

This reverts commit e51cc023c37902e10d1e0109ff0c6ddcce3d5c03.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/ocelot/felix.c           |  65 ++++---------
 drivers/net/ethernet/mscc/Kconfig        |   2 +-
 drivers/net/ethernet/mscc/ocelot.c       | 150 ++++++++++++++----------------
 drivers/net/ethernet/mscc/ocelot.h       |  13 ++-
 drivers/net/ethernet/mscc/ocelot_board.c | 154 ++++---------------------------
 include/soc/mscc/ocelot.h                |  22 +----
 6 files changed, 117 insertions(+), 289 deletions(-)

--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -58,6 +58,14 @@ static int felix_set_ageing_time(struct
 	return 0;
 }
 
+static void felix_adjust_link(struct dsa_switch *ds, int port,
+			      struct phy_device *phydev)
+{
+	struct ocelot *ocelot = ds->priv;
+
+	ocelot_adjust_link(ocelot, port, phydev);
+}
+
 static int felix_fdb_dump(struct dsa_switch *ds, int port,
 			  dsa_fdb_dump_cb_t *cb, void *data)
 {
@@ -177,59 +185,21 @@ static int felix_tsn_enable(struct dsa_p
 }
 #endif
 
-static void felix_phylink_validate(struct dsa_switch *ds, int port,
-				   unsigned long *supported,
-				   struct phylink_link_state *state)
+static int felix_port_enable(struct dsa_switch *ds, int port,
+			     struct phy_device *phy)
 {
 	struct ocelot *ocelot = ds->priv;
 
-	ocelot_phylink_validate(ocelot, port, supported, state);
-}
-
-static int felix_phylink_mac_pcs_get_state(struct dsa_switch *ds, int port,
-					   struct phylink_link_state *state)
-{
-	struct ocelot *ocelot = ds->priv;
-
-	ocelot_phylink_mac_pcs_get_state(ocelot, port, state);
+	ocelot_port_enable(ocelot, port, phy);
 
 	return 0;
 }
 
-static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
-				     unsigned int link_an_mode,
-				     const struct phylink_link_state *state)
-{
-	struct ocelot *ocelot = ds->priv;
-
-	ocelot_phylink_mac_config(ocelot, port, link_an_mode, state);
-}
-
-static void felix_phylink_mac_an_restart(struct dsa_switch *ds, int port)
-{
-	struct ocelot *ocelot = ds->priv;
-
-	ocelot_phylink_mac_an_restart(ocelot, port);
-}
-
-static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
-					unsigned int link_an_mode,
-					phy_interface_t interface)
-{
-	struct ocelot *ocelot = ds->priv;
-
-	ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface);
-}
-
-static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
-				      unsigned int link_an_mode,
-				      phy_interface_t interface,
-				      struct phy_device *phydev)
+static void felix_port_disable(struct dsa_switch *ds, int port)
 {
 	struct ocelot *ocelot = ds->priv;
 
-	ocelot_phylink_mac_link_up(ocelot, port, link_an_mode, interface,
-				   phydev);
+	return ocelot_port_disable(ocelot, port);
 }
 
 static void felix_get_strings(struct dsa_switch *ds, int port,
@@ -447,12 +417,9 @@ static const struct dsa_switch_ops felix
 	.get_ethtool_stats	= felix_get_ethtool_stats,
 	.get_sset_count		= felix_get_sset_count,
 	.get_ts_info		= felix_get_ts_info,
-	.phylink_validate	= felix_phylink_validate,
-	.phylink_mac_link_state	= felix_phylink_mac_pcs_get_state,
-	.phylink_mac_config	= felix_phylink_mac_config,
-	.phylink_mac_an_restart	= felix_phylink_mac_an_restart,
-	.phylink_mac_link_down	= felix_phylink_mac_link_down,
-	.phylink_mac_link_up	= felix_phylink_mac_link_up,
+	.adjust_link		= felix_adjust_link,
+	.port_enable		= felix_port_enable,
+	.port_disable		= felix_port_disable,
 	.port_fdb_dump		= felix_fdb_dump,
 	.port_fdb_add		= felix_fdb_add,
 	.port_fdb_del		= felix_fdb_del,
--- a/drivers/net/ethernet/mscc/Kconfig
+++ b/drivers/net/ethernet/mscc/Kconfig
@@ -15,7 +15,7 @@ config MSCC_OCELOT_SWITCH
 	tristate "Ocelot switch driver"
 	depends on NET_SWITCHDEV
 	depends on HAS_IOMEM
-	select PHYLINK
+	select PHYLIB
 	select REGMAP_MMIO
 	help
 	  This driver supports the Ocelot network switch device.
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
-#include <linux/phylink.h>
+#include <linux/phy.h>
 #include <linux/ptp_clock_kernel.h>
 #include <linux/skbuff.h>
 #include <linux/iopoll.h>
@@ -406,66 +406,18 @@ static u16 ocelot_wm_enc(u16 value)
 	return value;
 }
 
-void ocelot_phylink_validate(struct ocelot *ocelot, int port,
-			     unsigned long *supported,
-			     struct phylink_link_state *state)
-{
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
-
-	if (state->interface != PHY_INTERFACE_MODE_NA &&
-	    state->interface != PHY_INTERFACE_MODE_GMII &&
-	    state->interface != PHY_INTERFACE_MODE_SGMII &&
-	    state->interface != PHY_INTERFACE_MODE_QSGMII) {
-		bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
-		return;
-	}
-
-	/* No half-duplex. */
-	phylink_set_port_modes(mask);
-	phylink_set(mask, Autoneg);
-	phylink_set(mask, Pause);
-	phylink_set(mask, Asym_Pause);
-	phylink_set(mask, 10baseT_Full);
-	phylink_set(mask, 100baseT_Full);
-	phylink_set(mask, 1000baseT_Full);
-	phylink_set(mask, 2500baseT_Full);
-
-	bitmap_and(supported, supported, mask,
-		   __ETHTOOL_LINK_MODE_MASK_NBITS);
-	bitmap_and(state->advertising, state->advertising, mask,
-		   __ETHTOOL_LINK_MODE_MASK_NBITS);
-}
-EXPORT_SYMBOL(ocelot_phylink_validate);
-
-void ocelot_phylink_mac_pcs_get_state(struct ocelot *ocelot, int port,
-				      struct phylink_link_state *state)
-{
-	state->link = 1;
-}
-EXPORT_SYMBOL(ocelot_phylink_mac_pcs_get_state);
-
-void ocelot_phylink_mac_an_restart(struct ocelot *ocelot, int port)
-{
-	/* Not supported */
-}
-EXPORT_SYMBOL(ocelot_phylink_mac_an_restart);
-
-void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
-			       unsigned int link_an_mode,
-			       const struct phylink_link_state *state)
+void ocelot_adjust_link(struct ocelot *ocelot, int port,
+			struct phy_device *phydev)
 {
 	int speed, mac_speed, mac_mode = DEV_MAC_MODE_CFG_FDX_ENA;
 	struct ocelot_port *ocelot_port = ocelot->ports[port];
-	u32 mac_fc_cfg;
 
 	if (ocelot->quirks & OCELOT_PCS_PERFORMS_RATE_ADAPTATION)
 		speed = SPEED_1000;
 	else
-		speed = state->speed;
+		speed = phydev->speed;
 
 	switch (speed) {
-	case SPEED_UNKNOWN:
-		return;
 	case SPEED_10:
 		mac_speed = OCELOT_SPEED_10;
 		break;
@@ -481,11 +433,16 @@ void ocelot_phylink_mac_config(struct oc
 		mac_mode |= DEV_MAC_MODE_CFG_GIGA_MODE_ENA;
 		break;
 	default:
-		dev_err(ocelot->dev, "Unsupported speed on port %d: %d\n",
+		dev_err(ocelot->dev, "Unsupported PHY speed on port %d: %d\n",
 			port, speed);
 		return;
 	}
 
+	phy_print_status(phydev);
+
+	if (!phydev->link)
+		return;
+
 	/* Only full duplex supported for now */
 	ocelot_port_writel(ocelot_port, mac_mode, DEV_MAC_MODE_CFG);
 
@@ -512,36 +469,27 @@ void ocelot_phylink_mac_config(struct oc
 			 QSYS_SWITCH_PORT_MODE, port);
 
 	/* Flow control */
-	mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(mac_speed);
-	if (state->pause & MLO_PAUSE_RX)
-		mac_fc_cfg |= SYS_MAC_FC_CFG_RX_FC_ENA;
-	if (state->pause & MLO_PAUSE_TX)
-		mac_fc_cfg |= SYS_MAC_FC_CFG_TX_FC_ENA |
-			      SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
-			      SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
-			      SYS_MAC_FC_CFG_ZERO_PAUSE_ENA;
-	ocelot_write_rix(ocelot, mac_fc_cfg, SYS_MAC_FC_CFG, port);
-
+	ocelot_write_rix(ocelot, SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
+			 SYS_MAC_FC_CFG_RX_FC_ENA | SYS_MAC_FC_CFG_TX_FC_ENA |
+			 SYS_MAC_FC_CFG_ZERO_PAUSE_ENA |
+			 SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
+			 SYS_MAC_FC_CFG_FC_LINK_SPEED(mac_speed),
+			 SYS_MAC_FC_CFG, port);
 	ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port);
 }
-EXPORT_SYMBOL(ocelot_phylink_mac_config);
+EXPORT_SYMBOL(ocelot_adjust_link);
 
-void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
-				  unsigned int link_an_mode,
-				  phy_interface_t interface)
+static void ocelot_port_adjust_link(struct net_device *dev)
 {
-	struct ocelot_port *ocelot_port = ocelot->ports[port];
+	struct ocelot_port_private *priv = netdev_priv(dev);
+	struct ocelot *ocelot = priv->port.ocelot;
+	int port = priv->chip_port;
 
-	ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
-	ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
-		       QSYS_SWITCH_PORT_MODE, port);
+	ocelot_adjust_link(ocelot, port, dev->phydev);
 }
-EXPORT_SYMBOL(ocelot_phylink_mac_link_down);
 
-void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
-				unsigned int link_an_mode,
-				phy_interface_t interface,
-				struct phy_device *phy)
+void ocelot_port_enable(struct ocelot *ocelot, int port,
+			struct phy_device *phy)
 {
 	/* Enable receiving frames on the port, and activate auto-learning of
 	 * MAC addresses.
@@ -551,22 +499,62 @@ void ocelot_phylink_mac_link_up(struct o
 			 ANA_PORT_PORT_CFG_PORTID_VAL(port),
 			 ANA_PORT_PORT_CFG, port);
 }
-EXPORT_SYMBOL(ocelot_phylink_mac_link_up);
+EXPORT_SYMBOL(ocelot_port_enable);
 
 static int ocelot_port_open(struct net_device *dev)
 {
 	struct ocelot_port_private *priv = netdev_priv(dev);
+	struct ocelot *ocelot = priv->port.ocelot;
+	int port = priv->chip_port;
+	int err;
+
+	if (priv->serdes) {
+		err = phy_set_mode_ext(priv->serdes, PHY_MODE_ETHERNET,
+				       priv->phy_mode);
+		if (err) {
+			netdev_err(dev, "Could not set mode of SerDes\n");
+			return err;
+		}
+	}
+
+	err = phy_connect_direct(dev, priv->phy, &ocelot_port_adjust_link,
+				 priv->phy_mode);
+	if (err) {
+		netdev_err(dev, "Could not attach to PHY\n");
+		return err;
+	}
 
-	phylink_start(priv->phylink);
+	dev->phydev = priv->phy;
+
+	phy_attached_info(priv->phy);
+	phy_start(priv->phy);
+
+	ocelot_port_enable(ocelot, port, priv->phy);
 
 	return 0;
 }
 
+void ocelot_port_disable(struct ocelot *ocelot, int port)
+{
+	struct ocelot_port *ocelot_port = ocelot->ports[port];
+
+	ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
+	ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
+		       QSYS_SWITCH_PORT_MODE, port);
+}
+EXPORT_SYMBOL(ocelot_port_disable);
+
 static int ocelot_port_stop(struct net_device *dev)
 {
 	struct ocelot_port_private *priv = netdev_priv(dev);
+	struct ocelot *ocelot = priv->port.ocelot;
+	int port = priv->chip_port;
+
+	phy_disconnect(priv->phy);
+
+	dev->phydev = NULL;
 
-	phylink_stop(priv->phylink);
+	ocelot_port_disable(ocelot, port);
 
 	return 0;
 }
@@ -2263,7 +2251,8 @@ void ocelot_init_port(struct ocelot *oce
 EXPORT_SYMBOL(ocelot_init_port);
 
 int ocelot_probe_port(struct ocelot *ocelot, u8 port,
-		      void __iomem *regs)
+		      void __iomem *regs,
+		      struct phy_device *phy)
 {
 	struct ocelot_port_private *priv;
 	struct ocelot_port *ocelot_port;
@@ -2276,6 +2265,7 @@ int ocelot_probe_port(struct ocelot *oce
 	SET_NETDEV_DEV(dev, ocelot->dev);
 	priv = netdev_priv(dev);
 	priv->dev = dev;
+	priv->phy = phy;
 	priv->chip_port = port;
 	ocelot_port = &priv->port;
 	ocelot_port->ocelot = ocelot;
--- a/drivers/net/ethernet/mscc/ocelot.h
+++ b/drivers/net/ethernet/mscc/ocelot.h
@@ -12,7 +12,8 @@
 #include <linux/etherdevice.h>
 #include <linux/if_vlan.h>
 #include <linux/net_tstamp.h>
-#include <linux/phylink.h>
+#include <linux/phy.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/ptp_clock_kernel.h>
 #include <linux/regmap.h>
@@ -64,12 +65,14 @@ struct ocelot_multicast {
 struct ocelot_port_private {
 	struct ocelot_port port;
 	struct net_device *dev;
-	struct phylink *phylink;
-	struct phylink_config phylink_config;
+	struct phy_device *phy;
 	u8 chip_port;
 
 	u8 vlan_aware;
 
+	phy_interface_t phy_mode;
+	struct phy *serdes;
+
 	struct ocelot_port_tc tc;
 };
 
@@ -80,7 +83,9 @@ void ocelot_port_writel(struct ocelot_po
 #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
 
 int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops);
-int ocelot_probe_port(struct ocelot *ocelot, u8 port, void __iomem *regs);
+int ocelot_probe_port(struct ocelot *ocelot, u8 port,
+		      void __iomem *regs,
+		      struct phy_device *phy);
 
 void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu,
 			 enum ocelot_tag_prefix injection,
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -13,7 +13,6 @@
 #include <linux/mfd/syscon.h>
 #include <linux/skbuff.h>
 #include <net/switchdev.h>
-#include <linux/phy/phy.h>
 
 #include "ocelot.h"
 
@@ -263,91 +262,6 @@ static const struct ocelot_ops ocelot_op
 	.reset			= ocelot_reset,
 };
 
-static void ocelot_port_phylink_validate(struct phylink_config *config,
-					 unsigned long *supported,
-					 struct phylink_link_state *state)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct ocelot_port_private *priv = netdev_priv(ndev);
-	struct ocelot *ocelot = priv->port.ocelot;
-	int port = priv->chip_port;
-
-	ocelot_phylink_validate(ocelot, port, supported, state);
-}
-
-static int
-ocelot_port_phylink_mac_pcs_get_state(struct phylink_config *config,
-				      struct phylink_link_state *state)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct ocelot_port_private *priv = netdev_priv(ndev);
-	struct ocelot *ocelot = priv->port.ocelot;
-	int port = priv->chip_port;
-
-	ocelot_phylink_mac_pcs_get_state(ocelot, port, state);
-
-	return 0;
-}
-
-static void ocelot_port_phylink_mac_an_restart(struct phylink_config *config)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct ocelot_port_private *priv = netdev_priv(ndev);
-	struct ocelot *ocelot = priv->port.ocelot;
-	int port = priv->chip_port;
-
-	ocelot_phylink_mac_an_restart(ocelot, port);
-}
-
-static void
-ocelot_port_phylink_mac_config(struct phylink_config *config,
-			       unsigned int link_an_mode,
-			       const struct phylink_link_state *state)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct ocelot_port_private *priv = netdev_priv(ndev);
-	struct ocelot *ocelot = priv->port.ocelot;
-	int port = priv->chip_port;
-
-	ocelot_phylink_mac_config(ocelot, port, link_an_mode, state);
-}
-
-static void ocelot_port_phylink_mac_link_down(struct phylink_config *config,
-					      unsigned int link_an_mode,
-					      phy_interface_t interface)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct ocelot_port_private *priv = netdev_priv(ndev);
-	struct ocelot *ocelot = priv->port.ocelot;
-	int port = priv->chip_port;
-
-	return ocelot_phylink_mac_link_down(ocelot, port, link_an_mode,
-					    interface);
-}
-
-static void ocelot_port_phylink_mac_link_up(struct phylink_config *config,
-					    unsigned int link_an_mode,
-					    phy_interface_t interface,
-					    struct phy_device *phy)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct ocelot_port_private *priv = netdev_priv(ndev);
-	struct ocelot *ocelot = priv->port.ocelot;
-	int port = priv->chip_port;
-
-	return ocelot_phylink_mac_link_up(ocelot, port, link_an_mode,
-					  interface, phy);
-}
-
-static const struct phylink_mac_ops ocelot_phylink_ops = {
-	.validate		= ocelot_port_phylink_validate,
-	.mac_link_state		= ocelot_port_phylink_mac_pcs_get_state,
-	.mac_an_restart		= ocelot_port_phylink_mac_an_restart,
-	.mac_config		= ocelot_port_phylink_mac_config,
-	.mac_link_down		= ocelot_port_phylink_mac_link_down,
-	.mac_link_up		= ocelot_port_phylink_mac_link_up,
-};
-
 static int mscc_ocelot_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -455,6 +369,8 @@ static int mscc_ocelot_probe(struct plat
 	for_each_available_child_of_node(ports, portnp) {
 		struct ocelot_port_private *priv;
 		struct ocelot_port *ocelot_port;
+		struct device_node *phy_node;
+		struct phy_device *phy;
 		struct resource *res;
 		struct phy *serdes;
 		void __iomem *regs;
@@ -473,7 +389,16 @@ static int mscc_ocelot_probe(struct plat
 		if (IS_ERR(regs))
 			continue;
 
-		err = ocelot_probe_port(ocelot, port, regs);
+		phy_node = of_parse_phandle(portnp, "phy-handle", 0);
+		if (!phy_node)
+			continue;
+
+		phy = of_phy_find_device(phy_node);
+		of_node_put(phy_node);
+		if (!phy)
+			continue;
+
+		err = ocelot_probe_port(ocelot, port, regs, phy);
 		if (err) {
 			of_node_put(portnp);
 			goto out_put_ports;
@@ -487,7 +412,9 @@ static int mscc_ocelot_probe(struct plat
 		if (phy_mode < 0)
 			phy_mode = PHY_INTERFACE_MODE_NA;
 
-		switch (phy_mode) {
+		priv->phy_mode = phy_mode;
+
+		switch (priv->phy_mode) {
 		case PHY_INTERFACE_MODE_NA:
 			continue;
 		case PHY_INTERFACE_MODE_SGMII:
@@ -524,41 +451,7 @@ static int mscc_ocelot_probe(struct plat
 			goto out_put_ports;
 		}
 
-		if (serdes) {
-			err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET,
-					       phy_mode);
-			if (err) {
-				dev_err(ocelot->dev,
-					"Could not set mode of SerDes\n");
-				of_node_put(portnp);
-				goto out_put_ports;
-			}
-		}
-
-		priv->phylink_config.dev = &priv->dev->dev;
-		priv->phylink_config.type = PHYLINK_NETDEV;
-
-		priv->phylink = phylink_create(&priv->phylink_config,
-					       of_fwnode_handle(portnp),
-					       phy_mode, &ocelot_phylink_ops);
-		if (IS_ERR(priv->phylink)) {
-			dev_err(ocelot->dev,
-				"Could not create a phylink instance (%ld)\n",
-				PTR_ERR(priv->phylink));
-			err = PTR_ERR(priv->phylink);
-			priv->phylink = NULL;
-			of_node_put(portnp);
-			goto out_put_ports;
-		}
-
-		err = phylink_of_phy_connect(priv->phylink, portnp, 0);
-		if (err) {
-			dev_err(ocelot->dev, "Could not connect to PHY: %d\n",
-				err);
-			phylink_destroy(priv->phylink);
-			of_node_put(portnp);
-			goto out_put_ports;
-		}
+		priv->serdes = serdes;
 	}
 
 	register_netdevice_notifier(&ocelot_netdevice_nb);
@@ -575,27 +468,12 @@ out_put_ports:
 static int mscc_ocelot_remove(struct platform_device *pdev)
 {
 	struct ocelot *ocelot = platform_get_drvdata(pdev);
-	int port;
 
 	ocelot_deinit(ocelot);
 	unregister_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
 	unregister_switchdev_notifier(&ocelot_switchdev_nb);
 	unregister_netdevice_notifier(&ocelot_netdevice_nb);
 
-	for (port = 0; port < ocelot->num_phys_ports; port++) {
-		struct ocelot_port_private *priv;
-
-		priv = container_of(ocelot->ports[port],
-				    struct ocelot_port_private,
-				    port);
-
-		if (priv->phylink) {
-			rtnl_lock();
-			phylink_destroy(priv->phylink);
-			rtnl_unlock();
-		}
-	}
-
 	return 0;
 }
 
--- a/include/soc/mscc/ocelot.h
+++ b/include/soc/mscc/ocelot.h
@@ -518,12 +518,17 @@ void ocelot_deinit(struct ocelot *ocelot
 void ocelot_init_port(struct ocelot *ocelot, int port);
 
 /* DSA callbacks */
+void ocelot_port_enable(struct ocelot *ocelot, int port,
+			struct phy_device *phy);
+void ocelot_port_disable(struct ocelot *ocelot, int port);
 void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
 void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
 int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
 int ocelot_get_ts_info(struct ocelot *ocelot, int port,
 		       struct ethtool_ts_info *info);
 void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
+void ocelot_adjust_link(struct ocelot *ocelot, int port,
+			struct phy_device *phydev);
 void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port,
 				bool vlan_aware);
 void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
@@ -592,21 +597,4 @@ int ocelot_rtag_parse_enable(struct ocel
 int ocelot_dscp_set(struct ocelot *ocelot, int port,
 		    bool enable, const u8 dscp_ix,
 		    struct tsn_qos_switch_dscp_conf *c);
-void ocelot_phylink_validate(struct ocelot *ocelot, int port,
-			     unsigned long *supported,
-			     struct phylink_link_state *state);
-void ocelot_phylink_mac_pcs_get_state(struct ocelot *ocelot, int port,
-				      struct phylink_link_state *state);
-void ocelot_phylink_mac_an_restart(struct ocelot *ocelot, int port);
-void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
-			       unsigned int link_an_mode,
-			       const struct phylink_link_state *state);
-void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
-				  unsigned int link_an_mode,
-				  phy_interface_t interface);
-void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
-				unsigned int link_an_mode,
-				phy_interface_t interface,
-				struct phy_device *phy);
-
 #endif