summaryrefslogtreecommitdiff
path: root/drivers/net/dsa/mv88e6xxx/chip.c
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-04-27 16:54:56 +0100
commit01b2de1345a8a1e28d1079954f4de41c374899c7 (patch)
tree66f7367d2d6810e960f0911c208dc2a4ef142a87 /drivers/net/dsa/mv88e6xxx/chip.c
parent53964dd05189150489a379bb3fca40b74a58bb2a (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>
Diffstat (limited to 'drivers/net/dsa/mv88e6xxx/chip.c')
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index f3f278a17658..82cf99680cfe 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -952,6 +952,49 @@ error:
"p%d: failed to configure MAC link up\n", port);
}
+static void mv88e6xxx_mac_disable_tx_lpi(struct phylink_config *config)
+{
+ struct dsa_port *dp = dsa_phylink_to_port(config);
+ struct mv88e6xxx_chip *chip = dp->ds->priv;
+ int port = dp->index;
+ 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(chip->dev, "p%d: failed to set EEE mode: %pe\n", port,
+ ERR_PTR(err));
+}
+
+static void mv88e6xxx_mac_enable_tx_lpi(struct phylink_config *config,
+ u32 timer)
+{
+ struct dsa_port *dp = dsa_phylink_to_port(config);
+ struct mv88e6xxx_chip *chip = dp->ds->priv;
+ int port = dp->index;
+ 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(chip->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)
{
int err;
@@ -6933,6 +6976,8 @@ static const struct phylink_mac_ops mv88e6xxx_phylink_mac_ops = {
.mac_finish = mv88e6xxx_mac_finish,
.mac_link_down = mv88e6xxx_mac_link_down,
.mac_link_up = mv88e6xxx_mac_link_up,
+ .mac_disable_tx_lpi = mv88e6xxx_mac_disable_tx_lpi,
+ .mac_enable_tx_lpi = mv88e6xxx_mac_enable_tx_lpi,
};
static const struct dsa_switch_ops mv88e6xxx_switch_ops = {