Commit 04aca993 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

dsa: mv88e6xxx: Enable/Disable SERDES on port enable/disable

Implement the port enable/disable callbacks, which enable/disable the
SERDES interfaces, if applicable. This should save a bit of
power/heat.

We also need to enable SERDES on CPU and DSA ports, so keep the
existing call to the op, but make it conditional.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6335e9f2
...@@ -1806,10 +1806,16 @@ static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) ...@@ -1806,10 +1806,16 @@ static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
bool on) bool on)
{ {
if (chip->info->ops->serdes_power) int err = 0;
return chip->info->ops->serdes_power(chip, port, on);
return 0; if (chip->info->ops->serdes_power) {
err = chip->info->ops->serdes_power(chip, port, on);
if (err)
dev_err(chip->dev,
"Failed to change SERDES power: %d\n", err);
}
return err;
} }
static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
...@@ -1862,12 +1868,15 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) ...@@ -1862,12 +1868,15 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
if (err) if (err)
return err; return err;
/* If this port is connected to a SerDes, make sure the SerDes is /* Enable the SERDES interface for DSA and CPU ports. Normal
* powered up. * ports SERDES are enabled when the port is enabled, thus
* saving a bit of power.
*/ */
if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
err = mv88e6xxx_serdes_power(chip, port, true); err = mv88e6xxx_serdes_power(chip, port, true);
if (err) if (err)
return err; return err;
}
/* Port Control 2: don't force a good FCS, set the maximum frame size to /* Port Control 2: don't force a good FCS, set the maximum frame size to
* 10240 bytes, disable 802.1q tags checking, don't discard tagged or * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
...@@ -1969,6 +1978,29 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) ...@@ -1969,6 +1978,29 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
return mv88e6xxx_port_write(chip, port, PORT_DEFAULT_VLAN, 0x0000); return mv88e6xxx_port_write(chip, port, PORT_DEFAULT_VLAN, 0x0000);
} }
static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
struct phy_device *phydev)
{
struct mv88e6xxx_chip *chip = ds->priv;
int err = 0;
mutex_lock(&chip->reg_lock);
mv88e6xxx_serdes_power(chip, port, true);
mutex_unlock(&chip->reg_lock);
return err;
}
static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
struct phy_device *phydev)
{
struct mv88e6xxx_chip *chip = ds->priv;
mutex_lock(&chip->reg_lock);
mv88e6xxx_serdes_power(chip, port, false);
mutex_unlock(&chip->reg_lock);
}
static int mv88e6xxx_g1_set_switch_mac(struct mv88e6xxx_chip *chip, u8 *addr) static int mv88e6xxx_g1_set_switch_mac(struct mv88e6xxx_chip *chip, u8 *addr)
{ {
int err; int err;
...@@ -3809,6 +3841,8 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { ...@@ -3809,6 +3841,8 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
.get_strings = mv88e6xxx_get_strings, .get_strings = mv88e6xxx_get_strings,
.get_ethtool_stats = mv88e6xxx_get_ethtool_stats, .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count, .get_sset_count = mv88e6xxx_get_sset_count,
.port_enable = mv88e6xxx_port_enable,
.port_disable = mv88e6xxx_port_disable,
.set_eee = mv88e6xxx_set_eee, .set_eee = mv88e6xxx_set_eee,
.get_eee = mv88e6xxx_get_eee, .get_eee = mv88e6xxx_get_eee,
.get_eeprom_len = mv88e6xxx_get_eeprom_len, .get_eeprom_len = mv88e6xxx_get_eeprom_len,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment