diff options
author | Andrew Lunn <andrew@lunn.ch> | 2024-04-06 15:15:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2024-04-08 14:04:16 +0100 |
commit | a00bbd15a5af98d310792d3a7e052168ba088f08 (patch) | |
tree | 68e1342c2af4d0a0c77c0ca77f05109f846958a9 | |
parent | 382c60019ee769a8f3743e8340c063e4aa71231e (diff) |
net: usb: lan78xx: Fixup EEE
The enabling/disabling of EEE in the MAC should happen as a result of
auto negotiation. So move the enable/disable into
lan783xx_phy_link_status_change() which gets called by phylib when
there is a change in link status.
lan78xx_set_eee() now just programs the hardware with the LPI
timer value, and passed everything else to phylib, so it can correctly
setup the PHY.
lan743x_get_eee() relies on phylib doing most of the work, the
MAC driver just adds the LPI timer value.
Call phy_support_eee() to indicate the MAC does actually support EEE.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/usb/lan78xx.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 80ee4fcdfb36..0030be502daa 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1692,15 +1692,10 @@ static int lan78xx_get_eee(struct net_device *net, struct ethtool_keee *edata) ret = lan78xx_read_reg(dev, MAC_CR, &buf); if (buf & MAC_CR_EEE_EN_) { - edata->eee_enabled = true; - edata->tx_lpi_enabled = true; /* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */ ret = lan78xx_read_reg(dev, EEE_TX_LPI_REQ_DLY, &buf); edata->tx_lpi_timer = buf; } else { - edata->eee_enabled = false; - edata->eee_active = false; - edata->tx_lpi_enabled = false; edata->tx_lpi_timer = 0; } @@ -1721,24 +1716,16 @@ static int lan78xx_set_eee(struct net_device *net, struct ethtool_keee *edata) if (ret < 0) return ret; - if (edata->eee_enabled) { - ret = lan78xx_read_reg(dev, MAC_CR, &buf); - buf |= MAC_CR_EEE_EN_; - ret = lan78xx_write_reg(dev, MAC_CR, buf); - - phy_ethtool_set_eee(net->phydev, edata); - - buf = (u32)edata->tx_lpi_timer; - ret = lan78xx_write_reg(dev, EEE_TX_LPI_REQ_DLY, buf); - } else { - ret = lan78xx_read_reg(dev, MAC_CR, &buf); - buf &= ~MAC_CR_EEE_EN_; - ret = lan78xx_write_reg(dev, MAC_CR, buf); - } + ret = phy_ethtool_set_eee(net->phydev, edata); + if (ret < 0) + goto out; + buf = (u32)edata->tx_lpi_timer; + ret = lan78xx_write_reg(dev, EEE_TX_LPI_REQ_DLY, buf); +out: usb_autopm_put_interface(dev->intf); - return 0; + return ret; } static u32 lan78xx_get_link(struct net_device *net) @@ -2114,7 +2101,20 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev) static void lan78xx_link_status_change(struct net_device *net) { + struct lan78xx_net *dev = netdev_priv(net); struct phy_device *phydev = net->phydev; + u32 data; + int ret; + + ret = lan78xx_read_reg(dev, MAC_CR, &data); + if (ret < 0) + return; + + if (phydev->enable_tx_lpi) + data |= MAC_CR_EEE_EN_; + else + data &= ~MAC_CR_EEE_EN_; + lan78xx_write_reg(dev, MAC_CR, data); phy_print_status(phydev); } @@ -2408,6 +2408,8 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) mii_adv_to_linkmode_adv_t(fc, mii_adv); linkmode_or(phydev->advertising, fc, phydev->advertising); + phy_support_eee(phydev); + if (phydev->mdio.dev.of_node) { u32 reg; int len; |