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

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
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -1076,15 +1076,10 @@ static int lan743x_ethtool_get_eee(struct net_device *netdev,

	buf = lan743x_csr_read(adapter, MAC_CR);
	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 */
		buf = lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT);
		eee->tx_lpi_timer = buf;
	} else {
		eee->eee_enabled = false;
		eee->eee_active = false;
		eee->tx_lpi_enabled = false;
		eee->tx_lpi_timer = 0;
	}

@@ -1097,7 +1092,6 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,
	struct lan743x_adapter *adapter;
	struct phy_device *phydev;
	u32 buf = 0;
	int ret = 0;

	if (!netdev)
		return -EINVAL;
@@ -1114,23 +1108,8 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,
	}

	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;
		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);
+7 −0
Original line number Diff line number Diff line
@@ -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_2500BASEX)
			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);
	}
}