Skip to content

Commit 64d47d5

Browse files
Russell Kingdavem330
authored andcommitted
net: dsa: mv88e6xxx: configure interface settings in mac_config
Only configure the interface settings in mac_config(), leaving the speed and duplex settings to mac_link_up to deal with. Signed-off-by: Russell King <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4c8b735 commit 64d47d5

File tree

1 file changed

+35
-32
lines changed
  • drivers/net/dsa/mv88e6xxx

1 file changed

+35
-32
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,28 @@ static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
397397
mv88e6xxx_reg_unlock(chip);
398398
}
399399

400+
static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
401+
int port, phy_interface_t interface)
402+
{
403+
int err;
404+
405+
if (chip->info->ops->port_set_rgmii_delay) {
406+
err = chip->info->ops->port_set_rgmii_delay(chip, port,
407+
interface);
408+
if (err && err != -EOPNOTSUPP)
409+
return err;
410+
}
411+
412+
if (chip->info->ops->port_set_cmode) {
413+
err = chip->info->ops->port_set_cmode(chip, port,
414+
interface);
415+
if (err && err != -EOPNOTSUPP)
416+
return err;
417+
}
418+
419+
return 0;
420+
}
421+
400422
int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
401423
int speed, int duplex, int pause,
402424
phy_interface_t mode)
@@ -451,19 +473,7 @@ int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
451473
goto restore_link;
452474
}
453475

454-
if (chip->info->ops->port_set_rgmii_delay) {
455-
err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
456-
if (err && err != -EOPNOTSUPP)
457-
goto restore_link;
458-
}
459-
460-
if (chip->info->ops->port_set_cmode) {
461-
err = chip->info->ops->port_set_cmode(chip, port, mode);
462-
if (err && err != -EOPNOTSUPP)
463-
goto restore_link;
464-
}
465-
466-
err = 0;
476+
err = mv88e6xxx_port_config_interface(chip, port, mode);
467477
restore_link:
468478
if (chip->info->ops->port_set_link(chip, port, link))
469479
dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
@@ -603,33 +613,26 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
603613
const struct phylink_link_state *state)
604614
{
605615
struct mv88e6xxx_chip *chip = ds->priv;
606-
int speed, duplex, link, pause, err;
616+
int err;
607617

618+
/* FIXME: is this the correct test? If we're in fixed mode on an
619+
* internal port, why should we process this any different from
620+
* PHY mode? On the other hand, the port may be automedia between
621+
* an internal PHY and the serdes...
622+
*/
608623
if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
609624
return;
610625

611-
if (mode == MLO_AN_FIXED) {
612-
link = LINK_FORCED_UP;
613-
speed = state->speed;
614-
duplex = state->duplex;
615-
} else if (!mv88e6xxx_phy_is_internal(ds, port)) {
616-
link = state->link;
617-
speed = state->speed;
618-
duplex = state->duplex;
619-
} else {
620-
speed = SPEED_UNFORCED;
621-
duplex = DUPLEX_UNFORCED;
622-
link = LINK_UNFORCED;
623-
}
624-
pause = !!phylink_test(state->advertising, Pause);
625-
626626
mv88e6xxx_reg_lock(chip);
627-
err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
628-
state->interface);
627+
/* FIXME: should we force the link down here - but if we do, how
628+
* do we restore the link force/unforce state? The driver layering
629+
* gets in the way.
630+
*/
631+
err = mv88e6xxx_port_config_interface(chip, port, state->interface);
629632
mv88e6xxx_reg_unlock(chip);
630633

631634
if (err && err != -EOPNOTSUPP)
632-
dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
635+
dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
633636
}
634637

635638
static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,

0 commit comments

Comments
 (0)