summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2017-01-04 09:19:03 +0000
committerRussell King <rmk+kernel@armlinux.org.uk>2019-07-09 16:42:08 +0100
commit76e534a0594e19add944a6133dacb8a12ab0d39f (patch)
tree96654f3f8b7d8435dcafa14d04676e7286651611
parentcfbdfed91906a59c61b55187ebf707653c1efc5f (diff)
net: marvell: mvpp2x: add eee support
Add EEE support to the Marvell PP2x ethernet driver. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h5
-rw-r--r--drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c36
-rw-r--r--drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c1
3 files changed, 42 insertions, 0 deletions
diff --git a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h
index c24f1ad22d40..b981853bf95a 100644
--- a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h
+++ b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h
@@ -264,6 +264,11 @@ struct mv_mac_data {
u32 link;
u32 duplex;
u32 speed;
+
+ bool eee_enabled;
+ bool eee_active;
+ bool tx_lpi_enabled;
+ u32 tx_lpi_timer;
};
/* Masks used for pp3_emac flags */
diff --git a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c
index 3f8a6831de85..d4142d61d9e3 100644
--- a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c
+++ b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c
@@ -1265,6 +1265,40 @@ static int mv_pp2x_ethtool_pl_set_pauseparam(struct net_device *dev,
return phylink_ethtool_set_pauseparam(port->mac_data.phylink, pause);
}
+static int mv_pp2x_ethtool_pl_get_eee(struct net_device *dev,
+ struct ethtool_eee *eee)
+{
+ struct mv_pp2x_port *port = netdev_priv(dev);
+
+ eee->eee_enabled = port->mac_data.eee_enabled;
+ eee->eee_active = port->mac_data.eee_active;
+ eee->tx_lpi_enabled = port->mac_data.tx_lpi_enabled;
+ eee->tx_lpi_timer = port->mac_data.tx_lpi_timer;
+
+ return phylink_ethtool_get_eee(port->mac_data.phylink, eee);
+}
+
+static int mv_pp2x_ethtool_pl_set_eee(struct net_device *dev,
+ struct ethtool_eee *eee)
+{
+ struct mv_pp2x_port *port = netdev_priv(dev);
+
+ port->mac_data.eee_enabled = eee->eee_enabled;
+ port->mac_data.tx_lpi_enabled = eee->tx_lpi_enabled;
+ port->mac_data.tx_lpi_timer = eee->tx_lpi_timer;
+
+ if (port->mac_data.phy_mode == PHY_INTERFACE_MODE_RGMII ||
+ port->mac_data.phy_mode == PHY_INTERFACE_MODE_SGMII ||
+ port->mac_data.phy_mode == PHY_INTERFACE_MODE_QSGMII) {
+ mvgmac_set_eee(&port->gmac, false);
+ mvgmac_set_lpi_ts(&port->gmac, eee->tx_lpi_timer);
+ mvgmac_set_eee(&port->gmac, port->mac_data.tx_lpi_enabled &&
+ port->mac_data.eee_active);
+ }
+
+ return phylink_ethtool_set_eee(port->mac_data.phylink, eee);
+}
+
static int mv_pp2x_ethtool_pl_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *kset)
{
@@ -1302,6 +1336,8 @@ static const struct ethtool_ops mv_pp2x_eth_tool_phylink_ops = {
.get_regs_len = mv_pp2x_ethtool_get_regs_len,
.get_regs = mv_pp2x_ethtool_get_regs,
.self_test = mv_pp2x_eth_tool_diag_test,
+ .get_eee = mv_pp2x_ethtool_pl_get_eee,
+ .set_eee = mv_pp2x_ethtool_pl_set_eee,
.get_link_ksettings = mv_pp2x_ethtool_pl_get_link_ksettings,
.set_link_ksettings = mv_pp2x_ethtool_pl_set_link_ksettings,
};
diff --git a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c
index 68f7970c3189..3f5dcd2196ec 100644
--- a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c
@@ -4429,6 +4429,7 @@ static int mv_pp2_init_emac_data(struct mv_pp2x_port *port,
port->mac_data.gop_index = id;
port->mac_data.link_irq = irq_of_parse_and_map(emac_node, 0);
+ port->mac_data.tx_lpi_timer = 16;
phy_mode = of_get_phy_mode(emac_node);