Skip to content

Commit 5d5b231

Browse files
Russell Kingdavem330
authored andcommitted
net: dsa: mv88e6xxx: use PHY_DETECT in mac_link_up/mac_link_down
Use the status of the PHY_DETECT bit to determine whether we need to force the MAC settings in mac_link_up() and mac_link_down(). Signed-off-by: Russell King <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dc745ec commit 5d5b231

File tree

1 file changed

+29
-24
lines changed
  • drivers/net/dsa/mv88e6xxx

1 file changed

+29
-24
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,22 @@ static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
464464
return port < chip->info->num_internal_phys;
465465
}
466466

467+
static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
468+
{
469+
u16 reg;
470+
int err;
471+
472+
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
473+
if (err) {
474+
dev_err(chip->dev,
475+
"p%d: %s: failed to read port status\n",
476+
port, __func__);
477+
return err;
478+
}
479+
480+
return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
481+
}
482+
467483
static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
468484
struct phylink_link_state *state)
469485
{
@@ -692,20 +708,14 @@ static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
692708

693709
ops = chip->info->ops;
694710

695-
/* Internal PHYs propagate their configuration directly to the MAC.
696-
* External PHYs depend on whether the PPU is enabled for this port.
697-
* FIXME: we should be using the PPU enable state here. What about
698-
* an automedia port?
699-
*/
700-
if (!mv88e6xxx_phy_is_internal(ds, port) && ops->port_set_link) {
701-
mv88e6xxx_reg_lock(chip);
711+
mv88e6xxx_reg_lock(chip);
712+
if (!mv88e6xxx_port_ppu_updates(chip, port) && ops->port_set_link)
702713
err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
703-
mv88e6xxx_reg_unlock(chip);
714+
mv88e6xxx_reg_unlock(chip);
704715

705-
if (err)
706-
dev_err(chip->dev,
707-
"p%d: failed to force MAC link down\n", port);
708-
}
716+
if (err)
717+
dev_err(chip->dev,
718+
"p%d: failed to force MAC link down\n", port);
709719
}
710720

711721
static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
@@ -720,13 +730,8 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
720730

721731
ops = chip->info->ops;
722732

723-
/* Internal PHYs propagate their configuration directly to the MAC.
724-
* External PHYs depend on whether the PPU is enabled for this port.
725-
* FIXME: we should be using the PPU enable state here. What about
726-
* an automedia port?
727-
*/
728-
if (!mv88e6xxx_phy_is_internal(ds, port)) {
729-
mv88e6xxx_reg_lock(chip);
733+
mv88e6xxx_reg_lock(chip);
734+
if (!mv88e6xxx_port_ppu_updates(chip, port)) {
730735
/* FIXME: for an automedia port, should we force the link
731736
* down here - what if the link comes up due to "other" media
732737
* while we're bringing the port up, how is the exclusivity
@@ -747,13 +752,13 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
747752

748753
if (ops->port_set_link)
749754
err = ops->port_set_link(chip, port, LINK_FORCED_UP);
755+
}
750756
error:
751-
mv88e6xxx_reg_unlock(chip);
757+
mv88e6xxx_reg_unlock(chip);
752758

753-
if (err && err != -EOPNOTSUPP)
754-
dev_err(ds->dev,
755-
"p%d: failed to configure MAC link up\n", port);
756-
}
759+
if (err && err != -EOPNOTSUPP)
760+
dev_err(ds->dev,
761+
"p%d: failed to configure MAC link up\n", port);
757762
}
758763

759764
static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)

0 commit comments

Comments
 (0)