blob: 5841992866fb16807c4a467d67acbc058830278a [file] [log] [blame]
developerc9bd9ae2022-12-23 16:54:36 +08001--- a/drivers/net/phy/mdio-i2c.c
2+++ b/drivers/net/phy/mdio-i2c.c
developer90020932023-03-10 18:51:34 +08003@@ -12,6 +12,7 @@
developerc9bd9ae2022-12-23 16:54:36 +08004 #include <linux/i2c.h>
developer90020932023-03-10 18:51:34 +08005 #include <linux/mdio/mdio-i2c.h>
developerc9bd9ae2022-12-23 16:54:36 +08006 #include <linux/phy.h>
7+#include <linux/sfp.h>
8
developer90020932023-03-10 18:51:34 +08009 /*
10 * I2C bus addresses 0x50 and 0x51 are normally an EEPROM, which is
11@@ -28,7 +29,7 @@ static unsigned int i2c_mii_phy_addr(int
developerc9bd9ae2022-12-23 16:54:36 +080012 return phy_id + 0x40;
13 }
14
15-static int i2c_mii_read(struct mii_bus *bus, int phy_id, int reg)
16+static int i2c_mii_read_default(struct mii_bus *bus, int phy_id, int reg)
17 {
18 struct i2c_adapter *i2c = bus->priv;
19 struct i2c_msg msgs[2];
developer90020932023-03-10 18:51:34 +080020@@ -62,7 +63,8 @@ static int i2c_mii_read(struct mii_bus *
developerc9bd9ae2022-12-23 16:54:36 +080021 return data[0] << 8 | data[1];
22 }
23
24-static int i2c_mii_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
25+static int i2c_mii_write_default(struct mii_bus *bus, int phy_id, int reg,
26+ u16 val)
27 {
28 struct i2c_adapter *i2c = bus->priv;
29 struct i2c_msg msg;
developer90020932023-03-10 18:51:34 +080030@@ -91,9 +93,288 @@ static int i2c_mii_write(struct mii_bus
developerc9bd9ae2022-12-23 16:54:36 +080031 return ret < 0 ? ret : 0;
32 }
33
34-struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c)
35+/* RollBall SFPs do not access internal PHY via I2C address 0x56, but
36+ * instead via address 0x51, when SFP page is set to 0x03 and password to
37+ * 0xffffffff.
38+ *
39+ * address size contents description
40+ * ------- ---- -------- -----------
41+ * 0x80 1 CMD 0x01/0x02/0x04 for write/read/done
42+ * 0x81 1 DEV Clause 45 device
43+ * 0x82 2 REG Clause 45 register
44+ * 0x84 2 VAL Register value
45+ */
46+#define ROLLBALL_PHY_I2C_ADDR 0x51
47+
48+#define ROLLBALL_PASSWORD (SFP_VSL + 3)
49+
50+#define ROLLBALL_CMD_ADDR 0x80
51+#define ROLLBALL_DATA_ADDR 0x81
52+
53+#define ROLLBALL_CMD_WRITE 0x01
54+#define ROLLBALL_CMD_READ 0x02
55+#define ROLLBALL_CMD_DONE 0x04
56+
57+#define SFP_PAGE_ROLLBALL_MDIO 3
58+
59+static int __i2c_transfer_err(struct i2c_adapter *i2c, struct i2c_msg *msgs,
60+ int num)
61+{
62+ int ret;
63+
64+ ret = __i2c_transfer(i2c, msgs, num);
65+ if (ret < 0)
66+ return ret;
67+ else if (ret != num)
68+ return -EIO;
69+ else
70+ return 0;
71+}
72+
73+static int __i2c_rollball_get_page(struct i2c_adapter *i2c, int bus_addr,
74+ u8 *page)
75+{
76+ struct i2c_msg msgs[2];
77+ u8 addr = SFP_PAGE;
78+
79+ msgs[0].addr = bus_addr;
80+ msgs[0].flags = 0;
81+ msgs[0].len = 1;
82+ msgs[0].buf = &addr;
83+
84+ msgs[1].addr = bus_addr;
85+ msgs[1].flags = I2C_M_RD;
86+ msgs[1].len = 1;
87+ msgs[1].buf = page;
88+
89+ return __i2c_transfer_err(i2c, msgs, 2);
90+}
91+
92+static int __i2c_rollball_set_page(struct i2c_adapter *i2c, int bus_addr,
93+ u8 page)
94+{
95+ struct i2c_msg msg;
96+ u8 buf[2];
97+
98+ buf[0] = SFP_PAGE;
99+ buf[1] = page;
100+
101+ msg.addr = bus_addr;
102+ msg.flags = 0;
103+ msg.len = 2;
104+ msg.buf = buf;
105+
106+ return __i2c_transfer_err(i2c, &msg, 1);
107+}
108+
109+/* In order to not interfere with other SFP code (which possibly may manipulate
110+ * SFP_PAGE), for every transfer we do this:
111+ * 1. lock the bus
112+ * 2. save content of SFP_PAGE
113+ * 3. set SFP_PAGE to 3
114+ * 4. do the transfer
115+ * 5. restore original SFP_PAGE
116+ * 6. unlock the bus
117+ * Note that one might think that steps 2 to 5 could be theoretically done all
118+ * in one call to i2c_transfer (by constructing msgs array in such a way), but
119+ * unfortunately tests show that this does not work :-( Changed SFP_PAGE does
120+ * not take into account until i2c_transfer() is done.
121+ */
122+static int i2c_transfer_rollball(struct i2c_adapter *i2c,
123+ struct i2c_msg *msgs, int num)
124+{
125+ int ret, main_err = 0;
126+ u8 saved_page;
127+
128+ i2c_lock_bus(i2c, I2C_LOCK_SEGMENT);
129+
130+ /* save original page */
131+ ret = __i2c_rollball_get_page(i2c, msgs->addr, &saved_page);
132+ if (ret)
133+ goto unlock;
134+
135+ /* change to RollBall MDIO page */
136+ ret = __i2c_rollball_set_page(i2c, msgs->addr, SFP_PAGE_ROLLBALL_MDIO);
137+ if (ret)
138+ goto unlock;
139+
140+ /* do the transfer; we try to restore original page if this fails */
141+ ret = __i2c_transfer_err(i2c, msgs, num);
142+ if (ret)
143+ main_err = ret;
144+
145+ /* restore original page */
146+ ret = __i2c_rollball_set_page(i2c, msgs->addr, saved_page);
147+
148+unlock:
149+ i2c_unlock_bus(i2c, I2C_LOCK_SEGMENT);
150+
151+ return main_err ? : ret;
152+}
153+
154+static int i2c_rollball_mii_poll(struct mii_bus *bus, int bus_addr, u8 *buf,
155+ size_t len)
156+{
157+ struct i2c_adapter *i2c = bus->priv;
158+ struct i2c_msg msgs[2];
159+ u8 cmd_addr, tmp, *res;
160+ int i, ret;
161+
162+ cmd_addr = ROLLBALL_CMD_ADDR;
163+
164+ res = buf ? buf : &tmp;
165+ len = buf ? len : 1;
166+
167+ msgs[0].addr = bus_addr;
168+ msgs[0].flags = 0;
169+ msgs[0].len = 1;
170+ msgs[0].buf = &cmd_addr;
171+
172+ msgs[1].addr = bus_addr;
173+ msgs[1].flags = I2C_M_RD;
174+ msgs[1].len = len;
175+ msgs[1].buf = res;
176+
177+ /* By experiment it takes up to 70 ms to access a register for these
178+ * SFPs. Sleep 20ms between iterations and try 10 times.
179+ */
180+ i = 10;
181+ do {
182+ msleep(20);
183+
184+ ret = i2c_transfer_rollball(i2c, msgs, ARRAY_SIZE(msgs));
185+ if (ret)
186+ return ret;
187+
188+ if (*res == ROLLBALL_CMD_DONE)
189+ return 0;
190+ } while (i-- > 0);
191+
192+ dev_info(&bus->dev, "poll timed out\n");
193+
194+ return -ETIMEDOUT;
195+}
196+
197+static int i2c_rollball_mii_cmd(struct mii_bus *bus, int bus_addr, u8 cmd,
198+ u8 *data, size_t len)
199+{
200+ struct i2c_adapter *i2c = bus->priv;
201+ struct i2c_msg msgs[2];
202+ u8 cmdbuf[2];
203+
204+ cmdbuf[0] = ROLLBALL_CMD_ADDR;
205+ cmdbuf[1] = cmd;
206+
207+ msgs[0].addr = bus_addr;
208+ msgs[0].flags = 0;
209+ msgs[0].len = len;
210+ msgs[0].buf = data;
211+
212+ msgs[1].addr = bus_addr;
213+ msgs[1].flags = 0;
214+ msgs[1].len = sizeof(cmdbuf);
215+ msgs[1].buf = cmdbuf;
216+
217+ return i2c_transfer_rollball(i2c, msgs, ARRAY_SIZE(msgs));
218+}
219+
220+static int i2c_mii_read_rollball(struct mii_bus *bus, int phy_id, int reg)
221+{
222+ u8 buf[4], res[6];
223+ int bus_addr, ret;
224+ u16 val;
225+
226+ if (!(reg & MII_ADDR_C45))
227+ return -EOPNOTSUPP;
228+
229+ bus_addr = i2c_mii_phy_addr(phy_id);
230+ if (bus_addr != ROLLBALL_PHY_I2C_ADDR)
231+ return 0xffff;
232+
233+ buf[0] = ROLLBALL_DATA_ADDR;
234+ buf[1] = (reg >> 16) & 0x1f;
235+ buf[2] = (reg >> 8) & 0xff;
236+ buf[3] = reg & 0xff;
237+
238+ ret = i2c_rollball_mii_cmd(bus, bus_addr, ROLLBALL_CMD_READ, buf,
239+ sizeof(buf));
240+ if (ret < 0)
241+ return ret;
242+
243+ ret = i2c_rollball_mii_poll(bus, bus_addr, res, sizeof(res));
244+ if (ret == -ETIMEDOUT)
245+ return 0xffff;
246+ else if (ret < 0)
247+ return ret;
248+
249+ val = res[4] << 8 | res[5];
250+
251+ return val;
252+}
253+
254+static int i2c_mii_write_rollball(struct mii_bus *bus, int phy_id, int reg,
255+ u16 val)
256+{
257+ int bus_addr, ret;
258+ u8 buf[6];
259+
260+ if (!(reg & MII_ADDR_C45))
261+ return -EOPNOTSUPP;
262+
263+ bus_addr = i2c_mii_phy_addr(phy_id);
264+ if (bus_addr != ROLLBALL_PHY_I2C_ADDR)
265+ return 0;
266+
267+ buf[0] = ROLLBALL_DATA_ADDR;
268+ buf[1] = (reg >> 16) & 0x1f;
269+ buf[2] = (reg >> 8) & 0xff;
270+ buf[3] = reg & 0xff;
271+ buf[4] = val >> 8;
272+ buf[5] = val & 0xff;
273+
274+ ret = i2c_rollball_mii_cmd(bus, bus_addr, ROLLBALL_CMD_WRITE, buf,
275+ sizeof(buf));
276+ if (ret < 0)
277+ return ret;
278+
279+ ret = i2c_rollball_mii_poll(bus, bus_addr, NULL, 0);
280+ if (ret < 0)
281+ return ret;
282+
283+ return 0;
284+}
285+
286+static int i2c_mii_init_rollball(struct i2c_adapter *i2c)
287+{
288+ struct i2c_msg msg;
289+ u8 pw[5];
290+ int ret;
291+
292+ pw[0] = ROLLBALL_PASSWORD;
293+ pw[1] = 0xff;
294+ pw[2] = 0xff;
295+ pw[3] = 0xff;
296+ pw[4] = 0xff;
297+
298+ msg.addr = ROLLBALL_PHY_I2C_ADDR;
299+ msg.flags = 0;
300+ msg.len = sizeof(pw);
301+ msg.buf = pw;
302+
303+ ret = i2c_transfer(i2c, &msg, 1);
304+ if (ret < 0)
305+ return ret;
306+ else if (ret != 1)
307+ return -EIO;
308+ else
309+ return 0;
310+}
311+
312+struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c,
313+ enum mdio_i2c_proto protocol)
314 {
315 struct mii_bus *mii;
316+ int ret;
317
318 if (!i2c_check_functionality(i2c, I2C_FUNC_I2C))
319 return ERR_PTR(-EINVAL);
developer90020932023-03-10 18:51:34 +0800320@@ -104,10 +385,28 @@ struct mii_bus *mdio_i2c_alloc(struct de
developerc9bd9ae2022-12-23 16:54:36 +0800321
322 snprintf(mii->id, MII_BUS_ID_SIZE, "i2c:%s", dev_name(parent));
323 mii->parent = parent;
324- mii->read = i2c_mii_read;
325- mii->write = i2c_mii_write;
326 mii->priv = i2c;
327
328+ switch (protocol) {
329+ case MDIO_I2C_ROLLBALL:
330+ ret = i2c_mii_init_rollball(i2c);
331+ if (ret < 0) {
332+ dev_err(parent,
333+ "Cannot initialize RollBall MDIO I2C protocol: %d\n",
334+ ret);
335+ mdiobus_free(mii);
336+ return ERR_PTR(ret);
337+ }
338+
339+ mii->read = i2c_mii_read_rollball;
340+ mii->write = i2c_mii_write_rollball;
341+ break;
342+ default:
343+ mii->read = i2c_mii_read_default;
344+ mii->write = i2c_mii_write_default;
345+ break;
346+ }
347+
348 return mii;
349 }
350 EXPORT_SYMBOL_GPL(mdio_i2c_alloc);
developer45b00642023-02-20 10:32:20 +0800351--- a/include/linux/mdio/mdio-i2c.h
352+++ b/include/linux/mdio/mdio-i2c.h
developerc9bd9ae2022-12-23 16:54:36 +0800353@@ -11,6 +11,14 @@ struct device;
354 struct i2c_adapter;
355 struct mii_bus;
356
357-struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c);
358+enum mdio_i2c_proto {
359+ MDIO_I2C_NONE,
360+ MDIO_I2C_MARVELL_C22,
361+ MDIO_I2C_C45,
362+ MDIO_I2C_ROLLBALL,
363+};
364+
365+struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c,
366+ enum mdio_i2c_proto protocol);
367
368 #endif
developer82eae452023-02-13 10:04:09 +0800369--- a/drivers/net/phy/phylink.c
370+++ b/drivers/net/phy/phylink.c
developer90020932023-03-10 18:51:34 +0800371@@ -483,62 +483,105 @@ static void phylink_resolve(struct work_
developer82eae452023-02-13 10:04:09 +0800372 struct phylink *pl = container_of(w, struct phylink, resolve);
373 struct phylink_link_state link_state;
374 struct net_device *ndev = pl->netdev;
375- int link_changed;
376+ bool mac_config = false;
377+ bool retrigger = false;
378+ bool cur_link_state;
379
380 mutex_lock(&pl->state_mutex);
381+ if (pl->netdev)
382+ cur_link_state = netif_carrier_ok(ndev);
383+ else
384+ cur_link_state = pl->old_link_state;
385+
386 if (pl->phylink_disable_state) {
387 pl->mac_link_dropped = false;
388 link_state.link = false;
389 } else if (pl->mac_link_dropped) {
390 link_state.link = false;
391+ retrigger = true;
392 } else {
393 switch (pl->cur_link_an_mode) {
394 case MLO_AN_PHY:
395 link_state = pl->phy_state;
396 phylink_resolve_flow(pl, &link_state);
397- phylink_mac_config_up(pl, &link_state);
398+ mac_config = link_state.link;
399 break;
400
401 case MLO_AN_FIXED:
402 phylink_get_fixed_state(pl, &link_state);
403- phylink_mac_config_up(pl, &link_state);
404+ mac_config = link_state.link;
405 break;
406
407 case MLO_AN_INBAND:
408 phylink_get_mac_state(pl, &link_state);
409
410+ /* The PCS may have a latching link-fail indicator.
411+ * If the link was up, bring the link down and
412+ * re-trigger the resolve. Otherwise, re-read the
413+ * PCS state to get the current status of the link.
414+ */
415+ if (!link_state.link) {
416+ if (cur_link_state)
417+ retrigger = true;
418+ else
419+ phylink_get_mac_state(pl,
420+ &link_state);
421+ }
422+
423 /* If we have a phy, the "up" state is the union of
424- * both the PHY and the MAC */
425+ * both the PHY and the MAC
426+ */
427 if (pl->phydev)
428 link_state.link &= pl->phy_state.link;
429
430 /* Only update if the PHY link is up */
431 if (pl->phydev && pl->phy_state.link) {
432+ /* If the interface has changed, force a
433+ * link down event if the link isn't already
434+ * down, and re-resolve.
435+ */
436+ if (link_state.interface !=
437+ pl->phy_state.interface) {
438+ retrigger = true;
439+ link_state.link = false;
440+ }
441 link_state.interface = pl->phy_state.interface;
442
443 /* If we have a PHY, we need to update with
444- * the pause mode bits. */
445- link_state.pause |= pl->phy_state.pause;
446- phylink_resolve_flow(pl, &link_state);
447- phylink_mac_config(pl, &link_state);
448+ * the PHY flow control bits.
449+ */
450+ link_state.pause = pl->phy_state.pause;
451+ mac_config = true;
452 }
453+ phylink_resolve_flow(pl, &link_state);
454 break;
455 }
456 }
457
458- if (pl->netdev)
459- link_changed = (link_state.link != netif_carrier_ok(ndev));
460- else
461- link_changed = (link_state.link != pl->old_link_state);
462+ if (mac_config) {
463+ if (link_state.interface != pl->link_config.interface) {
464+ /* The interface has changed, force the link down and
465+ * then reconfigure.
466+ */
467+ if (cur_link_state) {
468+ phylink_mac_link_down(pl);
469+ cur_link_state = false;
470+ }
471+ phylink_mac_config(pl, &link_state);
472+ pl->link_config.interface = link_state.interface;
473+ } else {
474+ phylink_mac_config(pl, &link_state);
475+ }
476+ }
477
478- if (link_changed) {
479+ if (link_state.link != cur_link_state) {
480 pl->old_link_state = link_state.link;
481 if (!link_state.link)
482 phylink_mac_link_down(pl);
483 else
484 phylink_mac_link_up(pl, link_state);
485 }
486- if (!link_state.link && pl->mac_link_dropped) {
487+ if (!link_state.link && retrigger) {
488 pl->mac_link_dropped = false;
489 queue_work(system_power_efficient_wq, &pl->resolve);
490 }
491@@ -1014,7 +1057,8 @@ void phylink_start(struct phylink *pl)
492 if (irq <= 0)
493 mod_timer(&pl->link_poll, jiffies + HZ);
494 }
495- if (pl->cfg_link_an_mode == MLO_AN_FIXED && pl->get_fixed_state)
496+ if ((pl->cfg_link_an_mode == MLO_AN_FIXED && pl->get_fixed_state) ||
497+ (pl->cfg_link_an_mode == MLO_AN_INBAND))
498 mod_timer(&pl->link_poll, jiffies + HZ);
499 if (pl->phydev)
500 phy_start(pl->phydev);
developerc9bd9ae2022-12-23 16:54:36 +0800501--- a/drivers/net/phy/sfp-bus.c
502+++ b/drivers/net/phy/sfp-bus.c
503@@ -10,12 +10,6 @@
504
505 #include "sfp.h"
506
507-struct sfp_quirk {
508- const char *vendor;
509- const char *part;
510- void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes);
511-};
512-
513 /**
514 * struct sfp_bus - internal representation of a sfp bus
515 */
516@@ -38,87 +32,6 @@ struct sfp_bus {
517 bool started;
518 };
519
520-static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
521- unsigned long *modes)
522-{
523- phylink_set(modes, 2500baseX_Full);
524-}
525-
526-static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,
527- unsigned long *modes)
528-{
529- /* Ubiquiti U-Fiber Instant module claims that support all transceiver
530- * types including 10G Ethernet which is not truth. So clear all claimed
531- * modes and set only one mode which module supports: 1000baseX_Full.
532- */
533- phylink_zero(modes);
534- phylink_set(modes, 1000baseX_Full);
535-}
536-
537-static const struct sfp_quirk sfp_quirks[] = {
538- {
539- // Alcatel Lucent G-010S-P can operate at 2500base-X, but
540- // incorrectly report 2500MBd NRZ in their EEPROM
541- .vendor = "ALCATELLUCENT",
542- .part = "G010SP",
543- .modes = sfp_quirk_2500basex,
544- }, {
545- // Alcatel Lucent G-010S-A can operate at 2500base-X, but
546- // report 3.2GBd NRZ in their EEPROM
547- .vendor = "ALCATELLUCENT",
548- .part = "3FE46541AA",
549- .modes = sfp_quirk_2500basex,
550- }, {
551- // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
552- // NRZ in their EEPROM
553- .vendor = "HUAWEI",
554- .part = "MA5671A",
555- .modes = sfp_quirk_2500basex,
556- }, {
557- .vendor = "UBNT",
558- .part = "UF-INSTANT",
559- .modes = sfp_quirk_ubnt_uf_instant,
560- },
561-};
562-
563-static size_t sfp_strlen(const char *str, size_t maxlen)
564-{
565- size_t size, i;
566-
567- /* Trailing characters should be filled with space chars */
568- for (i = 0, size = 0; i < maxlen; i++)
569- if (str[i] != ' ')
570- size = i + 1;
571-
572- return size;
573-}
574-
575-static bool sfp_match(const char *qs, const char *str, size_t len)
576-{
577- if (!qs)
578- return true;
579- if (strlen(qs) != len)
580- return false;
581- return !strncmp(qs, str, len);
582-}
583-
584-static const struct sfp_quirk *sfp_lookup_quirk(const struct sfp_eeprom_id *id)
585-{
586- const struct sfp_quirk *q;
587- unsigned int i;
588- size_t vs, ps;
589-
590- vs = sfp_strlen(id->base.vendor_name, ARRAY_SIZE(id->base.vendor_name));
591- ps = sfp_strlen(id->base.vendor_pn, ARRAY_SIZE(id->base.vendor_pn));
592-
593- for (i = 0, q = sfp_quirks; i < ARRAY_SIZE(sfp_quirks); i++, q++)
594- if (sfp_match(q->vendor, id->base.vendor_name, vs) &&
595- sfp_match(q->part, id->base.vendor_pn, ps))
596- return q;
597-
598- return NULL;
599-}
600-
601 /**
602 * sfp_parse_port() - Parse the EEPROM base ID, setting the port type
603 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
developer14340702023-05-30 16:48:14 +0800604@@ -236,6 +149,10 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
605 unsigned int br_min, br_nom, br_max;
606 __ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = { 0, };
607
608+ phylink_set(modes, Autoneg);
609+ phylink_set(modes, Pause);
610+ phylink_set(modes, Asym_Pause);
611+
612 /* Decode the bitrate information to MBd */
613 br_min = br_nom = br_max = 0;
614 if (id->base.br_nominal) {
615@@ -359,14 +276,10 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
developerc9bd9ae2022-12-23 16:54:36 +0800616 phylink_set(modes, 1000baseX_Full);
617 }
618
619- if (bus->sfp_quirk)
620+ if (bus->sfp_quirk && bus->sfp_quirk->modes)
621 bus->sfp_quirk->modes(id, modes);
622
623 bitmap_or(support, support, modes, __ETHTOOL_LINK_MODE_MASK_NBITS);
developer14340702023-05-30 16:48:14 +0800624-
625- phylink_set(support, Autoneg);
626- phylink_set(support, Pause);
627- phylink_set(support, Asym_Pause);
628 }
629 EXPORT_SYMBOL_GPL(sfp_parse_support);
630
developer90020932023-03-10 18:51:34 +0800631@@ -737,12 +650,13 @@ void sfp_link_down(struct sfp_bus *bus)
developerc9bd9ae2022-12-23 16:54:36 +0800632 }
633 EXPORT_SYMBOL_GPL(sfp_link_down);
634
635-int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id)
636+int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
637+ const struct sfp_quirk *quirk)
638 {
639 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus);
640 int ret = 0;
641
642- bus->sfp_quirk = sfp_lookup_quirk(id);
643+ bus->sfp_quirk = quirk;
644
645 if (ops && ops->module_insert)
646 ret = ops->module_insert(bus->upstream, id);
developer14340702023-05-30 16:48:14 +0800647diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
648index f8d1742..4d07752 100644
developerc9bd9ae2022-12-23 16:54:36 +0800649--- a/drivers/net/phy/sfp.c
650+++ b/drivers/net/phy/sfp.c
developer14340702023-05-30 16:48:14 +0800651@@ -165,6 +165,7 @@ static const enum gpiod_flags gpio_flags[] = {
developerc9bd9ae2022-12-23 16:54:36 +0800652 * on board (for a copper SFP) time to initialise.
653 */
654 #define T_WAIT msecs_to_jiffies(50)
655+#define T_WAIT_ROLLBALL msecs_to_jiffies(25000)
656 #define T_START_UP msecs_to_jiffies(300)
657 #define T_START_UP_BAD_GPON msecs_to_jiffies(60000)
658
developer14340702023-05-30 16:48:14 +0800659@@ -204,8 +205,11 @@ static const enum gpiod_flags gpio_flags[] = {
developerc9bd9ae2022-12-23 16:54:36 +0800660
661 /* SFP modules appear to always have their PHY configured for bus address
662 * 0x56 (which with mdio-i2c, translates to a PHY address of 22).
663+ * RollBall SFPs access phy via SFP Enhanced Digital Diagnostic Interface
664+ * via address 0x51 (mdio-i2c will use RollBall protocol on this address).
665 */
666-#define SFP_PHY_ADDR 22
667+#define SFP_PHY_ADDR 22
668+#define SFP_PHY_ADDR_ROLLBALL 17
669
670 struct sff_data {
671 unsigned int gpios;
672@@ -217,6 +221,7 @@ struct sfp {
673 struct i2c_adapter *i2c;
674 struct mii_bus *i2c_mii;
675 struct sfp_bus *sfp_bus;
676+ enum mdio_i2c_proto mdio_protocol;
677 struct phy_device *mod_phy;
678 const struct sff_data *type;
679 size_t i2c_block_size;
680@@ -233,6 +238,7 @@ struct sfp {
681 bool need_poll;
682
683 struct mutex st_mutex; /* Protects state */
684+ unsigned int state_hw_mask;
685 unsigned int state_soft_mask;
686 unsigned int state;
687 struct delayed_work poll;
688@@ -249,6 +255,10 @@ struct sfp {
689 struct sfp_eeprom_id id;
690 unsigned int module_power_mW;
691 unsigned int module_t_start_up;
692+ unsigned int module_t_wait;
693+ bool tx_fault_ignore;
694+
695+ const struct sfp_quirk *quirk;
696
697 #if IS_ENABLED(CONFIG_HWMON)
698 struct sfp_diag diag;
developer14340702023-05-30 16:48:14 +0800699@@ -287,6 +297,18 @@ static bool sfp_module_supported(const struct sfp_eeprom_id *id)
700 !memcmp(id->base.vendor_pn, "UF-INSTANT ", 16))
701 return true;
702
703+ /* SFP GPON module SK-LiNK SFP-GE-LX20 SM1310 and SM1550 Instant
704+ * has in its EEPROM stored phys id UNK instead of SFP. Therefore
705+ * mark this module explicitly as supported based on vendor name
706+ * and pn match.
707+ */
708+ if (id->base.phys_id == SFF8024_ID_UNK &&
709+ id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP &&
710+ !memcmp(id->base.vendor_name, "SK-LINK ", 16) &&
711+ (!memcmp(id->base.vendor_pn, "SFP-GE-LX20-SM13", 16) ||
712+ !memcmp(id->base.vendor_pn, "SFP-GE-LX-SM1550", 16)))
713+ return true;
714+
715 return false;
716 }
717
718@@ -303,6 +334,180 @@ static const struct of_device_id sfp_of_match[] = {
developerc9bd9ae2022-12-23 16:54:36 +0800719 };
720 MODULE_DEVICE_TABLE(of, sfp_of_match);
721
722+static void sfp_fixup_long_startup(struct sfp *sfp)
723+{
724+ sfp->module_t_start_up = T_START_UP_BAD_GPON;
725+}
726+
727+static void sfp_fixup_ignore_tx_fault(struct sfp *sfp)
728+{
729+ sfp->tx_fault_ignore = true;
730+}
731+
developer6059eb22023-05-10 21:48:10 +0800732+static void sfp_fixup_ruijie_gbic(struct sfp *sfp)
733+{
734+ sfp->mdio_protocol = MDIO_I2C_NONE;
735+}
736+
developerc9bd9ae2022-12-23 16:54:36 +0800737+static void sfp_fixup_halny_gsfp(struct sfp *sfp)
738+{
739+ /* Ignore the TX_FAULT and LOS signals on this module.
740+ * these are possibly used for other purposes on this
741+ * module, e.g. a serial port.
742+ */
743+ sfp->state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS);
744+}
745+
746+static void sfp_fixup_rollball(struct sfp *sfp)
747+{
748+ sfp->mdio_protocol = MDIO_I2C_ROLLBALL;
749+ sfp->module_t_wait = T_WAIT_ROLLBALL;
750+}
751+
752+static void sfp_fixup_rollball_cc(struct sfp *sfp)
753+{
754+ sfp_fixup_rollball(sfp);
755+
756+ /* Some RollBall SFPs may have wrong (zero) extended compliance code
757+ * burned in EEPROM. For PHY probing we need the correct one.
758+ */
759+ sfp->id.base.extended_cc = SFF8024_ECC_10GBASE_T_SFI;
760+}
761+
762+static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
763+ unsigned long *modes)
764+{
765+ linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, modes);
766+}
767+
developer82185b72023-04-10 22:59:38 +0800768+static void sfp_quirk_10000baseSR(const struct sfp_eeprom_id *id,
769+ unsigned long *modes)
770+{
771+ linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseSR_Full_BIT, modes);
772+}
773+
developer14340702023-05-30 16:48:14 +0800774+static void sfp_quirk_disable_autoneg(const struct sfp_eeprom_id *id,
775+ unsigned long *modes)
776+{
777+ linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, modes);
778+}
779+
780+static void sfp_quirk_oem_2_5g(const struct sfp_eeprom_id *id,
781+ unsigned long *modes)
782+{
783+ /* Copper 2.5G SFP */
784+ linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, modes);
785+ linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, modes);
786+ sfp_quirk_disable_autoneg(id, modes);
787+}
788+
developerc9bd9ae2022-12-23 16:54:36 +0800789+static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,
790+ unsigned long *modes)
791+{
792+ /* Ubiquiti U-Fiber Instant module claims that support all transceiver
793+ * types including 10G Ethernet which is not truth. So clear all claimed
794+ * modes and set only one mode which module supports: 1000baseX_Full.
795+ */
796+ linkmode_zero(modes);
797+ linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, modes);
798+}
799+
developer6059eb22023-05-10 21:48:10 +0800800+#define SFP_QUIRK(_v, _p, _r, _m, _f) \
801+ { .vendor = _v, .part = _p, .revision = _r, .modes = _m, .fixup = _f, }
802+#define SFP_QUIRK_M(_v, _p, _r, _m) SFP_QUIRK(_v, _p, _r, _m, NULL)
803+#define SFP_QUIRK_F(_v, _p, _r, _f) SFP_QUIRK(_v, _p, _r, NULL, _f)
developerc9bd9ae2022-12-23 16:54:36 +0800804+
805+static const struct sfp_quirk sfp_quirks[] = {
developer6059eb22023-05-10 21:48:10 +0800806+ // Ruijie MINI-GBIC-GT81 has a RL8211F PHY device, but it cannot
807+ // reflect correct BMSR/ADVERTISE from the PHY.
808+ SFP_QUIRK_F("RUIJIE", "MINI-GBIC-GT", "81", sfp_fixup_ruijie_gbic),
809+
developerc9bd9ae2022-12-23 16:54:36 +0800810+ // Alcatel Lucent G-010S-P can operate at 2500base-X, but incorrectly
811+ // report 2500MBd NRZ in their EEPROM
developer6059eb22023-05-10 21:48:10 +0800812+ SFP_QUIRK_M("ALCATELLUCENT", "G010SP", '\0', sfp_quirk_2500basex),
developerc9bd9ae2022-12-23 16:54:36 +0800813+
814+ // Alcatel Lucent G-010S-A can operate at 2500base-X, but report 3.2GBd
815+ // NRZ in their EEPROM
developer6059eb22023-05-10 21:48:10 +0800816+ SFP_QUIRK("ALCATELLUCENT", "3FE46541AA", '\0', sfp_quirk_2500basex,
developerc9bd9ae2022-12-23 16:54:36 +0800817+ sfp_fixup_long_startup),
818+
developer6059eb22023-05-10 21:48:10 +0800819+ SFP_QUIRK_F("HALNy", "HL-GSFP", '\0', sfp_fixup_halny_gsfp),
developerc9bd9ae2022-12-23 16:54:36 +0800820+
821+ // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd NRZ in
822+ // their EEPROM
developer6059eb22023-05-10 21:48:10 +0800823+ SFP_QUIRK("HUAWEI", "MA5671A", '\0', sfp_quirk_2500basex,
developerc9bd9ae2022-12-23 16:54:36 +0800824+ sfp_fixup_ignore_tx_fault),
825+
826+ // Lantech 8330-262D-E can operate at 2500base-X, but incorrectly report
827+ // 2500MBd NRZ in their EEPROM
developer6059eb22023-05-10 21:48:10 +0800828+ SFP_QUIRK_M("Lantech", "8330-262D-E", '\0', sfp_quirk_2500basex),
developerc9bd9ae2022-12-23 16:54:36 +0800829+
developer14340702023-05-30 16:48:14 +0800830+ // CISCO PLRXPL-VC-S43-CG can operate at 10000baseSR, but not report
831+ // in their EEPROM
developer6059eb22023-05-10 21:48:10 +0800832+ SFP_QUIRK_M("CISCO-JDSU", "PLRXPL-VC-S43-CG", '\0', sfp_quirk_10000baseSR),
developer82185b72023-04-10 22:59:38 +0800833+
developer6059eb22023-05-10 21:48:10 +0800834+ SFP_QUIRK_M("UBNT", "UF-INSTANT", '\0', sfp_quirk_ubnt_uf_instant),
developerc9bd9ae2022-12-23 16:54:36 +0800835+
developer14340702023-05-30 16:48:14 +0800836+ // OEM SFP-2.5G-T can operate at 2500base-T, but not report
837+ // in their EEPROM
838+ SFP_QUIRK_M("OEM", "SFP-2.5G-T", '\0', sfp_quirk_oem_2_5g),
839+ // TP-LINK TL-SM410U can operate at 2500base-T, but not report
840+ // in their EEPROM
841+ SFP_QUIRK_M("TP-LINK", "TL-SM410U", '\0', sfp_quirk_oem_2_5g),
842+
developer6059eb22023-05-10 21:48:10 +0800843+ SFP_QUIRK_F("ETU", "ESP-T5-R", '\0', sfp_fixup_rollball_cc),
844+ SFP_QUIRK_F("OEM", "SFP-10G-T", '\0', sfp_fixup_rollball_cc),
845+ SFP_QUIRK_F("OEM", "RTSFP-10", '\0', sfp_fixup_rollball_cc),
846+ SFP_QUIRK_F("OEM", "RTSFP-10G", '\0', sfp_fixup_rollball_cc),
847+ SFP_QUIRK_F("OEM", "TNBYV02-C0X-C3", '\0', sfp_fixup_rollball_cc),
848+ SFP_QUIRK_F("Turris", "RTSFP-10", '\0', sfp_fixup_rollball),
849+ SFP_QUIRK_F("Turris", "RTSFP-10G", '\0', sfp_fixup_rollball),
developer89127622023-05-12 17:42:25 +0800850+ SFP_QUIRK_F("MIKE", "P60000BBC001-1", '\0', sfp_fixup_rollball),
developer6059eb22023-05-10 21:48:10 +0800851+ SFP_QUIRK_F("JESS-LINK", "P60000BBC001-1", '\0', sfp_fixup_rollball),
developerc9bd9ae2022-12-23 16:54:36 +0800852+};
853+
854+static size_t sfp_strlen(const char *str, size_t maxlen)
855+{
856+ size_t size, i;
857+
858+ /* Trailing characters should be filled with space chars, but
859+ * some manufacturers can't read SFF-8472 and use NUL.
860+ */
861+ for (i = 0, size = 0; i < maxlen; i++)
862+ if (str[i] != ' ' && str[i] != '\0')
863+ size = i + 1;
864+
865+ return size;
866+}
867+
868+static bool sfp_match(const char *qs, const char *str, size_t len)
869+{
870+ if (!qs)
871+ return true;
872+ if (strlen(qs) != len)
873+ return false;
874+ return !strncmp(qs, str, len);
875+}
876+
877+static const struct sfp_quirk *sfp_lookup_quirk(const struct sfp_eeprom_id *id)
878+{
879+ const struct sfp_quirk *q;
880+ unsigned int i;
developer6059eb22023-05-10 21:48:10 +0800881+ size_t vs, ps, rs;
developerc9bd9ae2022-12-23 16:54:36 +0800882+
883+ vs = sfp_strlen(id->base.vendor_name, ARRAY_SIZE(id->base.vendor_name));
884+ ps = sfp_strlen(id->base.vendor_pn, ARRAY_SIZE(id->base.vendor_pn));
developer6059eb22023-05-10 21:48:10 +0800885+ rs = sfp_strlen(id->base.vendor_rev, ARRAY_SIZE(id->base.vendor_rev));
developerc9bd9ae2022-12-23 16:54:36 +0800886+
887+ for (i = 0, q = sfp_quirks; i < ARRAY_SIZE(sfp_quirks); i++, q++)
888+ if (sfp_match(q->vendor, id->base.vendor_name, vs) &&
developer6059eb22023-05-10 21:48:10 +0800889+ sfp_match(q->part, id->base.vendor_pn, ps) &&
890+ sfp_match(q->revision, id->base.vendor_rev, rs))
developerc9bd9ae2022-12-23 16:54:36 +0800891+ return q;
892+
893+ return NULL;
894+}
895+
896 static unsigned long poll_jiffies;
897
898 static unsigned int sfp_gpio_get_state(struct sfp *sfp)
developer14340702023-05-30 16:48:14 +0800899@@ -414,9 +619,6 @@ static int sfp_i2c_write(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
developerc9bd9ae2022-12-23 16:54:36 +0800900
901 static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
902 {
903- struct mii_bus *i2c_mii;
904- int ret;
905-
906 if (!i2c_check_functionality(i2c, I2C_FUNC_I2C))
907 return -EINVAL;
908
developer14340702023-05-30 16:48:14 +0800909@@ -424,7 +626,15 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
developerc9bd9ae2022-12-23 16:54:36 +0800910 sfp->read = sfp_i2c_read;
911 sfp->write = sfp_i2c_write;
912
913- i2c_mii = mdio_i2c_alloc(sfp->dev, i2c);
914+ return 0;
915+}
916+
917+static int sfp_i2c_mdiobus_create(struct sfp *sfp)
918+{
919+ struct mii_bus *i2c_mii;
920+ int ret;
921+
922+ i2c_mii = mdio_i2c_alloc(sfp->dev, sfp->i2c, sfp->mdio_protocol);
923 if (IS_ERR(i2c_mii))
924 return PTR_ERR(i2c_mii);
925
developer14340702023-05-30 16:48:14 +0800926@@ -442,6 +652,12 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
developerc9bd9ae2022-12-23 16:54:36 +0800927 return 0;
928 }
929
930+static void sfp_i2c_mdiobus_destroy(struct sfp *sfp)
931+{
932+ mdiobus_unregister(sfp->i2c_mii);
933+ sfp->i2c_mii = NULL;
934+}
935+
936 /* Interface */
937 static int sfp_read(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len)
938 {
developer14340702023-05-30 16:48:14 +0800939@@ -487,17 +703,18 @@ static void sfp_soft_set_state(struct sfp *sfp, unsigned int state)
developerc9bd9ae2022-12-23 16:54:36 +0800940 static void sfp_soft_start_poll(struct sfp *sfp)
941 {
942 const struct sfp_eeprom_id *id = &sfp->id;
943+ unsigned int mask = 0;
944
945 sfp->state_soft_mask = 0;
946- if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_DISABLE &&
947- !sfp->gpio[GPIO_TX_DISABLE])
948- sfp->state_soft_mask |= SFP_F_TX_DISABLE;
949- if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_FAULT &&
950- !sfp->gpio[GPIO_TX_FAULT])
951- sfp->state_soft_mask |= SFP_F_TX_FAULT;
952- if (id->ext.enhopts & SFP_ENHOPTS_SOFT_RX_LOS &&
953- !sfp->gpio[GPIO_LOS])
954- sfp->state_soft_mask |= SFP_F_LOS;
955+ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_DISABLE)
956+ mask |= SFP_F_TX_DISABLE;
957+ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_FAULT)
958+ mask |= SFP_F_TX_FAULT;
959+ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_RX_LOS)
960+ mask |= SFP_F_LOS;
961+
962+ // Poll the soft state for hardware pins we want to ignore
963+ sfp->state_soft_mask = ~sfp->state_hw_mask & mask;
964
965 if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) &&
966 !sfp->need_poll)
developer14340702023-05-30 16:48:14 +0800967@@ -511,10 +728,11 @@ static void sfp_soft_stop_poll(struct sfp *sfp)
developerc9bd9ae2022-12-23 16:54:36 +0800968
969 static unsigned int sfp_get_state(struct sfp *sfp)
970 {
971- unsigned int state = sfp->get_state(sfp);
972+ unsigned int soft = sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT);
973+ unsigned int state;
974
975- if (state & SFP_F_PRESENT &&
976- sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT))
977+ state = sfp->get_state(sfp) & sfp->state_hw_mask;
978+ if (state & SFP_F_PRESENT && soft)
979 state |= sfp_soft_get_state(sfp);
980
981 return state;
developer14340702023-05-30 16:48:14 +0800982@@ -1448,12 +1666,12 @@ static void sfp_sm_phy_detach(struct sfp *sfp)
developerc9bd9ae2022-12-23 16:54:36 +0800983 sfp->mod_phy = NULL;
984 }
985
986-static int sfp_sm_probe_phy(struct sfp *sfp, bool is_c45)
987+static int sfp_sm_probe_phy(struct sfp *sfp, int addr, bool is_c45)
988 {
989 struct phy_device *phy;
990 int err;
991
992- phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45);
993+ phy = get_phy_device(sfp->i2c_mii, addr, is_c45);
994 if (phy == ERR_PTR(-ENODEV))
995 return PTR_ERR(phy);
996 if (IS_ERR(phy)) {
developer14340702023-05-30 16:48:14 +0800997@@ -1548,6 +1766,14 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn)
developerc9bd9ae2022-12-23 16:54:36 +0800998 }
999 }
1000
1001+static int sfp_sm_add_mdio_bus(struct sfp *sfp)
1002+{
1003+ if (sfp->mdio_protocol != MDIO_I2C_NONE)
1004+ return sfp_i2c_mdiobus_create(sfp);
1005+
1006+ return 0;
1007+}
1008+
1009 /* Probe a SFP for a PHY device if the module supports copper - the PHY
1010 * normally sits at I2C bus address 0x56, and may either be a clause 22
1011 * or clause 45 PHY.
developer14340702023-05-30 16:48:14 +08001012@@ -1563,36 +1789,52 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
developerc9bd9ae2022-12-23 16:54:36 +08001013 {
1014 int err = 0;
1015
1016- switch (sfp->id.base.extended_cc) {
1017- case SFF8024_ECC_10GBASE_T_SFI:
1018- case SFF8024_ECC_10GBASE_T_SR:
1019- case SFF8024_ECC_5GBASE_T:
1020- case SFF8024_ECC_2_5GBASE_T:
1021- err = sfp_sm_probe_phy(sfp, true);
1022+ switch (sfp->mdio_protocol) {
1023+ case MDIO_I2C_NONE:
1024 break;
1025
1026- default:
1027- if (sfp->id.base.e1000_base_t)
1028- err = sfp_sm_probe_phy(sfp, false);
1029+ case MDIO_I2C_MARVELL_C22:
1030+ err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR, false);
1031+ break;
1032+
1033+ case MDIO_I2C_C45:
1034+ err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR, true);
1035+ break;
1036+
1037+ case MDIO_I2C_ROLLBALL:
1038+ err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR_ROLLBALL, true);
1039 break;
1040 }
1041+
1042 return err;
1043 }
1044
developer0d8565e2023-05-11 13:34:51 +08001045 static int sfp_module_parse_power(struct sfp *sfp)
1046 {
1047 u32 power_mW = 1000;
1048+ bool supports_a2;
1049
1050- if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL))
1051+ if (sfp->id.ext.sff8472_compliance >= SFP_SFF8472_COMPLIANCE_REV10_2 &&
1052+ sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL))
1053 power_mW = 1500;
1054- if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL))
1055+ /* Added in Rev 11.9, but there is no compliance code for this */
1056+ if (sfp->id.ext.sff8472_compliance >= SFP_SFF8472_COMPLIANCE_REV11_4 &&
1057+ sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL))
1058 power_mW = 2000;
1059
1060+ /* Power level 1 modules (max. 1W) are always supported. */
1061+ if (power_mW <= 1000) {
1062+ sfp->module_power_mW = power_mW;
1063+ return 0;
1064+ }
1065+
1066+ supports_a2 = sfp->id.ext.sff8472_compliance !=
1067+ SFP_SFF8472_COMPLIANCE_NONE ||
1068+ sfp->id.ext.diagmon & SFP_DIAGMON_DDM;
1069+
1070 if (power_mW > sfp->max_power_mW) {
1071 /* Module power specification exceeds the allowed maximum. */
1072- if (sfp->id.ext.sff8472_compliance ==
1073- SFP_SFF8472_COMPLIANCE_NONE &&
1074- !(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) {
1075+ if (!supports_a2) {
1076 /* The module appears not to implement bus address
1077 * 0xa2, so assume that the module powers up in the
1078 * indicated mode.
developer14340702023-05-30 16:48:14 +08001079@@ -1609,13 +1851,21 @@ static int sfp_module_parse_power(struct sfp *sfp)
developer0d8565e2023-05-11 13:34:51 +08001080 }
1081 }
1082
1083+ if (!supports_a2) {
1084+ /* The module power level is below the host maximum and the
1085+ * module appears not to implement bus address 0xa2, so assume
1086+ * that the module powers up in the indicated mode.
1087+ */
1088+ return 0;
1089+ }
1090+
1091 /* If the module requires a higher power mode, but also requires
1092 * an address change sequence, warn the user that the module may
1093 * not be functional.
1094 */
1095- if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE && power_mW > 1000) {
1096+ if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE) {
1097 dev_warn(sfp->dev,
1098- "Address Change Sequence not supported but module requies %u.%uW, module may not be functional\n",
1099+ "Address Change Sequence not supported but module requires %u.%uW, module may not be functional\n",
1100 power_mW / 1000, (power_mW / 100) % 10);
1101 return 0;
1102 }
developer14340702023-05-30 16:48:14 +08001103@@ -1692,7 +1942,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
1104 {
1105 /* SFP module inserted - read I2C data */
1106 struct sfp_eeprom_id id;
1107- bool cotsworks;
1108+ bool cotsworks, sklink;
1109 u8 check;
1110 int ret;
1111
1112@@ -1747,10 +1997,16 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
1113 */
1114 cotsworks = !memcmp(id.base.vendor_name, "COTSWORKS ", 16);
1115
1116+ /* SK-LiNK do not seem to update the checksums when they
1117+ * do the final programming with the final module part number,
1118+ * serial number and date code.
1119+ */
1120+ sklink = !memcmp(id.base.vendor_name, "SK-LINK ", 16);
1121+
1122 /* Validate the checksum over the base structure */
1123 check = sfp_check(&id.base, sizeof(id.base) - 1);
1124 if (check != id.base.cc_base) {
1125- if (cotsworks) {
1126+ if (cotsworks || sklink) {
1127 dev_warn(sfp->dev,
1128 "EEPROM base structure checksum failure (0x%02x != 0x%02x)\n",
1129 check, id.base.cc_base);
1130@@ -1819,11 +2075,33 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
developerc9bd9ae2022-12-23 16:54:36 +08001131 if (ret < 0)
1132 return ret;
1133
1134- if (!memcmp(id.base.vendor_name, "ALCATELLUCENT ", 16) &&
1135- !memcmp(id.base.vendor_pn, "3FE46541AA ", 16))
1136- sfp->module_t_start_up = T_START_UP_BAD_GPON;
1137+ /* Initialise state bits to use from hardware */
1138+ sfp->state_hw_mask = SFP_F_PRESENT;
1139+ if (sfp->gpio[GPIO_TX_DISABLE])
1140+ sfp->state_hw_mask |= SFP_F_TX_DISABLE;
1141+ if (sfp->gpio[GPIO_TX_FAULT])
1142+ sfp->state_hw_mask |= SFP_F_TX_FAULT;
1143+ if (sfp->gpio[GPIO_LOS])
1144+ sfp->state_hw_mask |= SFP_F_LOS;
1145+
1146+ sfp->module_t_start_up = T_START_UP;
1147+ sfp->module_t_wait = T_WAIT;
1148+
1149+ sfp->tx_fault_ignore = false;
1150+
1151+ if (sfp->id.base.extended_cc == SFF8024_ECC_10GBASE_T_SFI ||
1152+ sfp->id.base.extended_cc == SFF8024_ECC_10GBASE_T_SR ||
1153+ sfp->id.base.extended_cc == SFF8024_ECC_5GBASE_T ||
1154+ sfp->id.base.extended_cc == SFF8024_ECC_2_5GBASE_T)
1155+ sfp->mdio_protocol = MDIO_I2C_C45;
1156+ else if (sfp->id.base.e1000_base_t)
1157+ sfp->mdio_protocol = MDIO_I2C_MARVELL_C22;
1158 else
1159- sfp->module_t_start_up = T_START_UP;
1160+ sfp->mdio_protocol = MDIO_I2C_NONE;
1161+
1162+ sfp->quirk = sfp_lookup_quirk(&id);
1163+ if (sfp->quirk && sfp->quirk->fixup)
1164+ sfp->quirk->fixup(sfp);
1165
1166 return 0;
1167 }
developer14340702023-05-30 16:48:14 +08001168@@ -1936,7 +2214,8 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
developerc9bd9ae2022-12-23 16:54:36 +08001169 break;
1170
1171 /* Report the module insertion to the upstream device */
1172- err = sfp_module_insert(sfp->sfp_bus, &sfp->id);
1173+ err = sfp_module_insert(sfp->sfp_bus, &sfp->id,
1174+ sfp->quirk);
1175 if (err < 0) {
1176 sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0);
1177 break;
developer14340702023-05-30 16:48:14 +08001178@@ -1995,6 +2274,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
developerc9bd9ae2022-12-23 16:54:36 +08001179 sfp_module_stop(sfp->sfp_bus);
1180 if (sfp->mod_phy)
1181 sfp_sm_phy_detach(sfp);
1182+ if (sfp->i2c_mii)
1183+ sfp_i2c_mdiobus_destroy(sfp);
1184 sfp_module_tx_disable(sfp);
1185 sfp_soft_stop_poll(sfp);
1186 sfp_sm_next(sfp, SFP_S_DOWN, 0);
developer14340702023-05-30 16:48:14 +08001187@@ -2018,9 +2299,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
developerc9bd9ae2022-12-23 16:54:36 +08001188
1189 /* We need to check the TX_FAULT state, which is not defined
1190 * while TX_DISABLE is asserted. The earliest we want to do
1191- * anything (such as probe for a PHY) is 50ms.
1192+ * anything (such as probe for a PHY) is 50ms (or more on
1193+ * specific modules).
1194 */
1195- sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT);
1196+ sfp_sm_next(sfp, SFP_S_WAIT, sfp->module_t_wait);
1197 break;
1198
1199 case SFP_S_WAIT:
developer14340702023-05-30 16:48:14 +08001200@@ -2034,8 +2316,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
developerc9bd9ae2022-12-23 16:54:36 +08001201 * deasserting.
1202 */
1203 timeout = sfp->module_t_start_up;
1204- if (timeout > T_WAIT)
1205- timeout -= T_WAIT;
1206+ if (timeout > sfp->module_t_wait)
1207+ timeout -= sfp->module_t_wait;
1208 else
1209 timeout = 1;
1210
developer14340702023-05-30 16:48:14 +08001211@@ -2057,6 +2339,12 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
developerc9bd9ae2022-12-23 16:54:36 +08001212 sfp->sm_fault_retries == N_FAULT_INIT);
1213 } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
1214 init_done:
1215+ /* Create mdiobus and start trying for PHY */
1216+ ret = sfp_sm_add_mdio_bus(sfp);
1217+ if (ret < 0) {
1218+ sfp_sm_next(sfp, SFP_S_FAIL, 0);
1219+ break;
1220+ }
1221 sfp->sm_phy_retries = R_PHY_RETRY;
1222 goto phy_probe;
1223 }
developer14340702023-05-30 16:48:14 +08001224@@ -2409,6 +2697,8 @@ static int sfp_probe(struct platform_device *pdev)
developerc9bd9ae2022-12-23 16:54:36 +08001225 return PTR_ERR(sfp->gpio[i]);
1226 }
1227
1228+ sfp->state_hw_mask = SFP_F_PRESENT;
1229+
1230 sfp->get_state = sfp_gpio_get_state;
1231 sfp->set_state = sfp_gpio_set_state;
1232
developerc9bd9ae2022-12-23 16:54:36 +08001233--- a/drivers/net/phy/sfp.h
1234+++ b/drivers/net/phy/sfp.h
developer6059eb22023-05-10 21:48:10 +08001235@@ -6,6 +6,14 @@
developerc9bd9ae2022-12-23 16:54:36 +08001236
1237 struct sfp;
1238
1239+struct sfp_quirk {
1240+ const char *vendor;
1241+ const char *part;
developer6059eb22023-05-10 21:48:10 +08001242+ const char *revision;
developerc9bd9ae2022-12-23 16:54:36 +08001243+ void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes);
1244+ void (*fixup)(struct sfp *sfp);
1245+};
1246+
1247 struct sfp_socket_ops {
1248 void (*attach)(struct sfp *sfp);
1249 void (*detach)(struct sfp *sfp);
developer90020932023-03-10 18:51:34 +08001250@@ -20,7 +27,8 @@ int sfp_add_phy(struct sfp_bus *bus, str
developerc9bd9ae2022-12-23 16:54:36 +08001251 void sfp_remove_phy(struct sfp_bus *bus);
1252 void sfp_link_up(struct sfp_bus *bus);
1253 void sfp_link_down(struct sfp_bus *bus);
1254-int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id);
1255+int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
1256+ const struct sfp_quirk *quirk);
1257 void sfp_module_remove(struct sfp_bus *bus);
1258 int sfp_module_start(struct sfp_bus *bus);
1259 void sfp_module_stop(struct sfp_bus *bus);
developer14340702023-05-30 16:48:14 +08001260 --- a/drivers/net/phy/marvell.c
1261+++ b/drivers/net/phy/marvell.c
1262@@ -2175,7 +2175,7 @@ static struct phy_driver marvell_drivers[] = {
1263 .phy_id = MARVELL_PHY_ID_88E1111,
1264 .phy_id_mask = MARVELL_PHY_ID_MASK,
1265 .name = "Marvell 88E1111",
1266- /* PHY_GBIT_FEATURES */
1267+ .features = PHY_GBIT_FEATURES,
1268 .probe = marvell_probe,
1269 .config_init = &m88e1111_config_init,
1270 .config_aneg = &marvell_config_aneg,
developerc9bd9ae2022-12-23 16:54:36 +08001271--- a/drivers/net/phy/marvell10g.c
1272+++ b/drivers/net/phy/marvell10g.c
developerf1e143b2023-01-09 16:25:59 +08001273@@ -32,6 +32,15 @@
1274 #define MV_PHY_ALASKA_NBT_QUIRK_REV (MARVELL_PHY_ID_88X3310 | 0xa)
1275
1276 enum {
1277+ MV_PMA_21X0_PORT_CTRL = 0xc04a,
1278+ MV_PMA_21X0_PORT_CTRL_SWRST = BIT(15),
1279+ MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK = 0x7,
1280+ MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII = 0x0,
1281+ MV_PMA_2180_PORT_CTRL_MACTYPE_DXGMII = 0x1,
1282+ MV_PMA_2180_PORT_CTRL_MACTYPE_QXGMII = 0x2,
1283+ MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER = 0x4,
1284+ MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN = 0x5,
1285+ MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH = 0x6,
1286 MV_PMA_BOOT = 0xc050,
1287 MV_PMA_BOOT_FATAL = BIT(0),
1288
1289@@ -53,7 +62,18 @@ enum {
1290
1291 /* Vendor2 MMD registers */
1292 MV_V2_PORT_CTRL = 0xf001,
1293- MV_V2_PORT_CTRL_PWRDOWN = 0x0800,
1294+ MV_V2_PORT_CTRL_PWRDOWN = BIT(11),
1295+ MV_V2_33X0_PORT_CTRL_SWRST = BIT(15),
1296+ MV_V2_33X0_PORT_CTRL_MACTYPE_MASK = 0x7,
1297+ MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI = 0x0,
1298+ MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH = 0x1,
1299+ MV_V2_3340_PORT_CTRL_MACTYPE_RXAUI_NO_SGMII_AN = 0x1,
1300+ MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH = 0x2,
1301+ MV_V2_3310_PORT_CTRL_MACTYPE_XAUI = 0x3,
1302+ MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER = 0x4,
1303+ MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_NO_SGMII_AN = 0x5,
1304+ MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH = 0x6,
1305+ MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII = 0x7,
1306 MV_V2_TEMP_CTRL = 0xf08a,
1307 MV_V2_TEMP_CTRL_MASK = 0xc000,
1308 MV_V2_TEMP_CTRL_SAMPLE = 0x0000,
1309@@ -62,11 +82,24 @@ enum {
1310 MV_V2_TEMP_UNKNOWN = 0x9600, /* unknown function */
1311 };
1312
1313+struct mv3310_chip {
1314+ int (*get_mactype)(struct phy_device *phydev);
1315+ int (*init_interface)(struct phy_device *phydev, int mactype);
1316+};
1317+
1318 struct mv3310_priv {
1319+ bool rate_match;
1320+ phy_interface_t const_interface;
1321+
1322 struct device *hwmon_dev;
1323 char *hwmon_name;
1324 };
1325
1326+static const struct mv3310_chip *to_mv3310_chip(struct phy_device *phydev)
1327+{
1328+ return phydev->drv->driver_data;
1329+}
1330+
1331 #ifdef CONFIG_HWMON
1332 static umode_t mv3310_hwmon_is_visible(const void *data,
1333 enum hwmon_sensor_types type,
developer90020932023-03-10 18:51:34 +08001334@@ -155,13 +188,6 @@ static int mv3310_hwmon_config(struct ph
developerc9bd9ae2022-12-23 16:54:36 +08001335 MV_V2_TEMP_CTRL_MASK, val);
1336 }
1337
1338-static void mv3310_hwmon_disable(void *data)
1339-{
1340- struct phy_device *phydev = data;
1341-
1342- mv3310_hwmon_config(phydev, false);
1343-}
1344-
1345 static int mv3310_hwmon_probe(struct phy_device *phydev)
1346 {
1347 struct device *dev = &phydev->mdio.dev;
developer90020932023-03-10 18:51:34 +08001348@@ -185,10 +211,6 @@ static int mv3310_hwmon_probe(struct phy
developerc9bd9ae2022-12-23 16:54:36 +08001349 if (ret)
1350 return ret;
1351
1352- ret = devm_add_action_or_reset(dev, mv3310_hwmon_disable, phydev);
1353- if (ret)
1354- return ret;
1355-
1356 priv->hwmon_dev = devm_hwmon_device_register_with_info(dev,
1357 priv->hwmon_name, phydev,
1358 &mv3310_hwmon_chip_info, NULL);
developer90020932023-03-10 18:51:34 +08001359@@ -262,6 +284,11 @@ static int mv3310_probe(struct phy_devic
developerc9bd9ae2022-12-23 16:54:36 +08001360 return phy_sfp_probe(phydev, &mv3310_sfp_ops);
1361 }
1362
1363+static void mv3310_remove(struct phy_device *phydev)
1364+{
1365+ mv3310_hwmon_config(phydev, false);
1366+}
1367+
1368 static int mv3310_suspend(struct phy_device *phydev)
1369 {
1370 return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL,
developer90020932023-03-10 18:51:34 +08001371@@ -297,8 +324,84 @@ static bool mv3310_has_pma_ngbaset_quirk
developerf1e143b2023-01-09 16:25:59 +08001372 MV_PHY_ALASKA_NBT_QUIRK_MASK) == MV_PHY_ALASKA_NBT_QUIRK_REV;
1373 }
1374
1375+static int mv2110_get_mactype(struct phy_device *phydev)
1376+{
1377+ int mactype;
1378+
1379+ mactype = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_21X0_PORT_CTRL);
1380+ if (mactype < 0)
1381+ return mactype;
1382+
1383+ return mactype & MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK;
1384+}
1385+
1386+static int mv3310_get_mactype(struct phy_device *phydev)
1387+{
1388+ int mactype;
1389+
1390+ mactype = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL);
1391+ if (mactype < 0)
1392+ return mactype;
1393+
1394+ return mactype & MV_V2_33X0_PORT_CTRL_MACTYPE_MASK;
1395+}
1396+
1397+static int mv2110_init_interface(struct phy_device *phydev, int mactype)
1398+{
1399+ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev);
1400+
1401+ priv->rate_match = false;
1402+
1403+ if (mactype == MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH)
1404+ priv->rate_match = true;
1405+
1406+ if (mactype == MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII)
1407+ priv->const_interface = PHY_INTERFACE_MODE_USXGMII;
1408+ else if (mactype == MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH)
1409+ priv->const_interface = PHY_INTERFACE_MODE_10GKR;
1410+ else if (mactype == MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER ||
1411+ mactype == MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN)
1412+ priv->const_interface = PHY_INTERFACE_MODE_NA;
1413+ else
1414+ return -EINVAL;
1415+
1416+ return 0;
1417+}
1418+
1419+static int mv3310_init_interface(struct phy_device *phydev, int mactype)
1420+{
1421+ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev);
1422+
1423+ priv->rate_match = false;
1424+
1425+ if (mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ||
1426+ mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH ||
1427+ mactype == MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH)
1428+ priv->rate_match = true;
1429+
1430+ if (mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII)
1431+ priv->const_interface = PHY_INTERFACE_MODE_USXGMII;
1432+ else if (mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ||
1433+ mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_NO_SGMII_AN ||
1434+ mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER)
1435+ priv->const_interface = PHY_INTERFACE_MODE_10GKR;
1436+ else if (mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH ||
1437+ mactype == MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI)
1438+ priv->const_interface = PHY_INTERFACE_MODE_RXAUI;
1439+ else if (mactype == MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH ||
1440+ mactype == MV_V2_3310_PORT_CTRL_MACTYPE_XAUI)
1441+ priv->const_interface = PHY_INTERFACE_MODE_XAUI;
1442+ else
1443+ return -EINVAL;
1444+
1445+ return 0;
1446+}
1447+
1448 static int mv3310_config_init(struct phy_device *phydev)
1449 {
1450+ const struct mv3310_chip *chip = to_mv3310_chip(phydev);
1451+ int err, mactype;
1452+
1453 /* Check that the PHY interface type is compatible */
1454 if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
1455 phydev->interface != PHY_INTERFACE_MODE_2500BASEX &&
developer90020932023-03-10 18:51:34 +08001456@@ -307,6 +410,16 @@ static int mv3310_config_init(struct phy
developerf1e143b2023-01-09 16:25:59 +08001457 phydev->interface != PHY_INTERFACE_MODE_10GKR)
1458 return -ENODEV;
1459
1460+ mactype = chip->get_mactype(phydev);
1461+ if (mactype < 0)
1462+ return mactype;
1463+
1464+ err = chip->init_interface(phydev, mactype);
1465+ if (err) {
1466+ phydev_err(phydev, "MACTYPE configuration invalid\n");
1467+ return err;
1468+ }
1469+
1470 return 0;
1471 }
1472
developer90020932023-03-10 18:51:34 +08001473@@ -384,6 +497,23 @@ static int mv3310_aneg_done(struct phy_d
developerf1e143b2023-01-09 16:25:59 +08001474
1475 static void mv3310_update_interface(struct phy_device *phydev)
1476 {
1477+ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev);
1478+
1479+ if (!phydev->link)
1480+ return;
1481+
1482+ /* In all of the "* with Rate Matching" modes the PHY interface is fixed
1483+ * at 10Gb. The PHY adapts the rate to actual wire speed with help of
1484+ * internal 16KB buffer.
1485+ *
1486+ * In USXGMII mode the PHY interface mode is also fixed.
1487+ */
1488+ if (priv->rate_match ||
1489+ priv->const_interface == PHY_INTERFACE_MODE_USXGMII) {
1490+ phydev->interface = priv->const_interface;
1491+ return;
1492+ }
1493+
1494 if ((phydev->interface == PHY_INTERFACE_MODE_SGMII ||
1495 phydev->interface == PHY_INTERFACE_MODE_2500BASEX ||
developer90020932023-03-10 18:51:34 +08001496 phydev->interface == PHY_INTERFACE_MODE_5GBASER ||
1497@@ -503,11 +633,22 @@ static int mv3310_read_status(struct phy
developerf1e143b2023-01-09 16:25:59 +08001498 return 0;
1499 }
1500
1501+static const struct mv3310_chip mv3310_type = {
1502+ .get_mactype = mv3310_get_mactype,
1503+ .init_interface = mv3310_init_interface,
1504+};
1505+
1506+static const struct mv3310_chip mv2111_type = {
1507+ .get_mactype = mv2110_get_mactype,
1508+ .init_interface = mv2110_init_interface,
1509+};
1510+
1511 static struct phy_driver mv3310_drivers[] = {
1512 {
1513 .phy_id = MARVELL_PHY_ID_88X3310,
1514 .phy_id_mask = MARVELL_PHY_ID_MASK,
1515 .name = "mv88x3310",
1516+ .driver_data = &mv3310_type,
1517 .get_features = mv3310_get_features,
1518 .soft_reset = genphy_no_soft_reset,
1519 .config_init = mv3310_config_init,
developer90020932023-03-10 18:51:34 +08001520@@ -517,11 +658,13 @@ static struct phy_driver mv3310_drivers[
developerc9bd9ae2022-12-23 16:54:36 +08001521 .config_aneg = mv3310_config_aneg,
1522 .aneg_done = mv3310_aneg_done,
1523 .read_status = mv3310_read_status,
1524+ .remove = mv3310_remove,
1525 },
1526 {
1527 .phy_id = MARVELL_PHY_ID_88E2110,
developerf1e143b2023-01-09 16:25:59 +08001528 .phy_id_mask = MARVELL_PHY_ID_MASK,
1529 .name = "mv88x2110",
1530+ .driver_data = &mv2111_type,
1531 .probe = mv3310_probe,
1532 .suspend = mv3310_suspend,
1533 .resume = mv3310_resume,
developer90020932023-03-10 18:51:34 +08001534@@ -530,6 +673,7 @@ static struct phy_driver mv3310_drivers[
developerc9bd9ae2022-12-23 16:54:36 +08001535 .config_aneg = mv3310_config_aneg,
1536 .aneg_done = mv3310_aneg_done,
1537 .read_status = mv3310_read_status,
1538+ .remove = mv3310_remove,
1539 },
1540 };
1541