Skip to content

Commit 72d8b4f

Browse files
hkallweitdavem330
authored andcommitted
net: dsa: mv88e6xxx: support in-band signalling on SGMII ports with external PHYs
If an external PHY is connected via SGMII and uses in-band signalling then the auto-negotiated values aren't propagated to the port, resulting in a broken link. See discussion in [0]. This patch adds this propagation. We need to call mv88e6xxx_port_setup_mac(), therefore export it from chip.c. Successfully tested on a ZII DTU with 88E6390 switch and an Aquantia AQCS109 PHY connected via SGMII to port 9. [0] https://marc.info/?t=155130287200001&r=1&w=2 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 80f61f1 commit 72d8b4f

4 files changed

Lines changed: 52 additions & 14 deletions

File tree

‎drivers/net/dsa/mv88e6xxx/chip.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,9 @@ int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
549549
return mv88e6xxx_write(chip, addr, reg, val);
550550
}
551551

552-
static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
553-
int link, int speed, int duplex, int pause,
554-
phy_interface_t mode)
552+
int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
553+
int speed, int duplex, int pause,
554+
phy_interface_t mode)
555555
{
556556
int err;
557557

‎drivers/net/dsa/mv88e6xxx/chip.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
579579
int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg,
580580
u16 update);
581581
int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask);
582+
int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
583+
int speed, int duplex, int pause,
584+
phy_interface_t mode);
582585
struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);
583586

584587
#endif /* _MV88E6XXX_CHIP_H */

‎drivers/net/dsa/mv88e6xxx/serdes.c‎

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,21 +510,48 @@ static void mv88e6390_serdes_irq_link_sgmii(struct mv88e6xxx_chip *chip,
510510
int port, int lane)
511511
{
512512
struct dsa_switch *ds = chip->ds;
513+
int duplex = DUPLEX_UNKNOWN;
514+
int speed = SPEED_UNKNOWN;
515+
int link, err;
513516
u16 status;
514-
bool up;
515517

516-
mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
517-
MV88E6390_SGMII_STATUS, &status);
518+
err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
519+
MV88E6390_SGMII_PHY_STATUS, &status);
520+
if (err) {
521+
dev_err(chip->dev, "can't read SGMII PHY status: %d\n", err);
522+
return;
523+
}
518524

519-
/* Status must be read twice in order to give the current link
520-
* status. Otherwise the change in link status since the last
521-
* read of the register is returned.
522-
*/
523-
mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
524-
MV88E6390_SGMII_STATUS, &status);
525-
up = status & MV88E6390_SGMII_STATUS_LINK;
525+
link = status & MV88E6390_SGMII_PHY_STATUS_LINK ?
526+
LINK_FORCED_UP : LINK_FORCED_DOWN;
527+
528+
if (status & MV88E6390_SGMII_PHY_STATUS_SPD_DPL_VALID) {
529+
duplex = status & MV88E6390_SGMII_PHY_STATUS_DUPLEX_FULL ?
530+
DUPLEX_FULL : DUPLEX_HALF;
531+
532+
switch (status & MV88E6390_SGMII_PHY_STATUS_SPEED_MASK) {
533+
case MV88E6390_SGMII_PHY_STATUS_SPEED_1000:
534+
speed = SPEED_1000;
535+
break;
536+
case MV88E6390_SGMII_PHY_STATUS_SPEED_100:
537+
speed = SPEED_100;
538+
break;
539+
case MV88E6390_SGMII_PHY_STATUS_SPEED_10:
540+
speed = SPEED_10;
541+
break;
542+
default:
543+
dev_err(chip->dev, "invalid PHY speed\n");
544+
return;
545+
}
546+
}
526547

527-
dsa_port_phylink_mac_change(ds, port, up);
548+
err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex,
549+
PAUSE_OFF, PHY_INTERFACE_MODE_NA);
550+
if (err)
551+
dev_err(chip->dev, "can't propagate PHY settings to MAC: %d\n",
552+
err);
553+
else
554+
dsa_port_phylink_mac_change(ds, port, link == LINK_FORCED_UP);
528555
}
529556

530557
static int mv88e6390_serdes_irq_enable_sgmii(struct mv88e6xxx_chip *chip,

‎drivers/net/dsa/mv88e6xxx/serdes.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@
6969
#define MV88E6390_SGMII_INT_SYMBOL_ERROR BIT(8)
7070
#define MV88E6390_SGMII_INT_FALSE_CARRIER BIT(7)
7171
#define MV88E6390_SGMII_INT_STATUS 0xa002
72+
#define MV88E6390_SGMII_PHY_STATUS 0xa003
73+
#define MV88E6390_SGMII_PHY_STATUS_SPEED_MASK GENMASK(15, 14)
74+
#define MV88E6390_SGMII_PHY_STATUS_SPEED_1000 0x8000
75+
#define MV88E6390_SGMII_PHY_STATUS_SPEED_100 0x4000
76+
#define MV88E6390_SGMII_PHY_STATUS_SPEED_10 0x0000
77+
#define MV88E6390_SGMII_PHY_STATUS_DUPLEX_FULL BIT(13)
78+
#define MV88E6390_SGMII_PHY_STATUS_SPD_DPL_VALID BIT(11)
79+
#define MV88E6390_SGMII_PHY_STATUS_LINK BIT(10)
7280

7381
int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
7482
int mv88e6341_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on);

0 commit comments

Comments
 (0)