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

net: lan743x: Fixup EEE

The enabling/disabling of EEE in the MAC should happen as a result of
auto negotiation. So move the enable/disable into
lan743x_phy_link_status_change() which gets called by phylib when
there is a change in link status.

lan743x_ethtool_set_eee() now just programs the hardware with the LTI
timer value, and passed everything else to phylib, so it can correctly
setup the PHY.

lan743x_ethtool_get_eee() relies on phylib doing most of the work, the
MAC driver just adds the LTI timer value.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a00bbd15
...@@ -1076,15 +1076,10 @@ static int lan743x_ethtool_get_eee(struct net_device *netdev, ...@@ -1076,15 +1076,10 @@ static int lan743x_ethtool_get_eee(struct net_device *netdev,
buf = lan743x_csr_read(adapter, MAC_CR); buf = lan743x_csr_read(adapter, MAC_CR);
if (buf & MAC_CR_EEE_EN_) { if (buf & MAC_CR_EEE_EN_) {
eee->eee_enabled = true;
eee->tx_lpi_enabled = true;
/* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */ /* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */
buf = lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT); buf = lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT);
eee->tx_lpi_timer = buf; eee->tx_lpi_timer = buf;
} else { } else {
eee->eee_enabled = false;
eee->eee_active = false;
eee->tx_lpi_enabled = false;
eee->tx_lpi_timer = 0; eee->tx_lpi_timer = 0;
} }
...@@ -1097,7 +1092,6 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev, ...@@ -1097,7 +1092,6 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,
struct lan743x_adapter *adapter; struct lan743x_adapter *adapter;
struct phy_device *phydev; struct phy_device *phydev;
u32 buf = 0; u32 buf = 0;
int ret = 0;
if (!netdev) if (!netdev)
return -EINVAL; return -EINVAL;
...@@ -1114,23 +1108,8 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev, ...@@ -1114,23 +1108,8 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,
} }
if (eee->eee_enabled) { if (eee->eee_enabled) {
ret = phy_init_eee(phydev, false);
if (ret) {
netif_err(adapter, drv, adapter->netdev,
"EEE initialization failed\n");
return ret;
}
buf = (u32)eee->tx_lpi_timer; buf = (u32)eee->tx_lpi_timer;
lan743x_csr_write(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT, buf); lan743x_csr_write(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT, buf);
buf = lan743x_csr_read(adapter, MAC_CR);
buf |= MAC_CR_EEE_EN_;
lan743x_csr_write(adapter, MAC_CR, buf);
} else {
buf = lan743x_csr_read(adapter, MAC_CR);
buf &= ~MAC_CR_EEE_EN_;
lan743x_csr_write(adapter, MAC_CR, buf);
} }
return phy_ethtool_set_eee(phydev, eee); return phy_ethtool_set_eee(phydev, eee);
......
...@@ -1462,6 +1462,13 @@ static void lan743x_phy_link_status_change(struct net_device *netdev) ...@@ -1462,6 +1462,13 @@ static void lan743x_phy_link_status_change(struct net_device *netdev)
phydev->interface == PHY_INTERFACE_MODE_1000BASEX || phydev->interface == PHY_INTERFACE_MODE_1000BASEX ||
phydev->interface == PHY_INTERFACE_MODE_2500BASEX) phydev->interface == PHY_INTERFACE_MODE_2500BASEX)
lan743x_sgmii_config(adapter); lan743x_sgmii_config(adapter);
data = lan743x_csr_read(adapter, MAC_CR);
if (phydev->enable_tx_lpi)
data |= MAC_CR_EEE_EN_;
else
data &= ~MAC_CR_EEE_EN_;
lan743x_csr_write(adapter, MAC_CR, data);
} }
} }
......
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