net: lan743x: Fixup EEE
authorAndrew Lunn <andrew@lunn.ch>
Sat, 6 Apr 2024 20:16:00 +0000 (15:16 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Apr 2024 13:04:16 +0000 (14:04 +0100)
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: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/microchip/lan743x_ethtool.c
drivers/net/ethernet/microchip/lan743x_main.c

index 8a6ae171e375b852919d8cbe3cd13983c2c16767..d0f4ff4ee075944c885ffba39bcba556b2b2d96d 100644 (file)
@@ -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);
index 75a988c0bd794a83bd31d04b7072e841884ee986..d37a49cd5c690c4e34a615f93b61f326cadcac18 100644 (file)
@@ -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);
        }
 }