summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2023-08-17 16:32:32 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2024-02-27 15:37:56 +0000
commiteb79e9c8f19825fcdd95954af80892cb2eed4acd (patch)
tree5f16a91d666e3e1887fca628d3cd76251a8760cb
parent5ee25e83ce1b78805cb4b15923c4431f7de39f25 (diff)
net: dsa: mv88e6xxx: add EEE controls
Add phylink EEE control methods to allow EEE to be configured. When LPI is to be disabled, we force the port to have EEE disabled, but when enabling EEE, if the port is under the control of the PPU, we stop forcing it, otherwise we force-enable EEE. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 07a22c74fe81..eae578b35ebf 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -941,6 +941,47 @@ error:
"p%d: failed to configure MAC link up\n", port);
}
+static void mv88e6xxx_mac_disable_tx_lpi(struct dsa_switch *ds, int port)
+{
+ struct mv88e6xxx_chip *chip = ds->priv;
+ int err;
+
+ if (!chip->info->ops->port_set_eee)
+ return;
+
+ mv88e6xxx_reg_lock(chip);
+ err = chip->info->ops->port_set_eee(chip, port, EEE_FORCE_DISABLE);
+ mv88e6xxx_reg_unlock(chip);
+
+ if (err)
+ dev_err(ds->dev,
+ "p%d: failed to set EEE mode: %pe\n", port,
+ ERR_PTR(err));
+}
+
+static void mv88e6xxx_mac_enable_tx_lpi(struct dsa_switch *ds, int port,
+ u32 timer)
+{
+ struct mv88e6xxx_chip *chip = ds->priv;
+ int eee, err;
+
+ if (!chip->info->ops->port_set_eee)
+ return;
+
+ mv88e6xxx_reg_lock(chip);
+ if (mv88e6xxx_port_ppu_updates(chip, port))
+ eee = EEE_UNFORCED;
+ else
+ eee = EEE_FORCE_DISABLE;
+ err = chip->info->ops->port_set_eee(chip, port, eee);
+ mv88e6xxx_reg_unlock(chip);
+
+ if (err)
+ dev_err(ds->dev,
+ "p%d: failed to set EEE mode: %pe\n", port,
+ ERR_PTR(err));
+}
+
static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
{
if (!chip->info->ops->stats_snapshot)
@@ -6815,6 +6856,8 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
.phylink_mac_finish = mv88e6xxx_mac_finish,
.phylink_mac_link_down = mv88e6xxx_mac_link_down,
.phylink_mac_link_up = mv88e6xxx_mac_link_up,
+ .phylink_mac_disable_tx_lpi = mv88e6xxx_mac_disable_tx_lpi,
+ .phylink_mac_enable_tx_lpi = mv88e6xxx_mac_enable_tx_lpi,
.get_strings = mv88e6xxx_get_strings,
.get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count,