mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
net: lan743x: convert to phylink managed EEE
Convert lan743x to phylink managed EEE: - Set the lpi_capabilties. - Move the call to lan743x_mac_eee_enable() into the enable/disable tx_lpi functions. - Ensure that EEEEN is clear during probe. - Move the setting of the LPI timer into mac_enable_tx_lpi(). - Move reading of LPI timer to phylink initialisation to set the default timer value. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/E1tYAEB-0014QB-4s@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
a66447966f
commit
bd691d5ca9
|
|
@ -1055,9 +1055,6 @@ static int lan743x_ethtool_get_eee(struct net_device *netdev,
|
|||
{
|
||||
struct lan743x_adapter *adapter = netdev_priv(netdev);
|
||||
|
||||
eee->tx_lpi_timer = lan743x_csr_read(adapter,
|
||||
MAC_EEE_TX_LPI_REQ_DLY_CNT);
|
||||
|
||||
return phylink_ethtool_get_eee(adapter->phylink, eee);
|
||||
}
|
||||
|
||||
|
|
@ -1065,24 +1062,6 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,
|
|||
struct ethtool_keee *eee)
|
||||
{
|
||||
struct lan743x_adapter *adapter = netdev_priv(netdev);
|
||||
u32 tx_lpi_timer;
|
||||
|
||||
tx_lpi_timer = lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT);
|
||||
if (tx_lpi_timer != eee->tx_lpi_timer) {
|
||||
u32 mac_cr = lan743x_csr_read(adapter, MAC_CR);
|
||||
|
||||
/* Software should only change this field when Energy Efficient
|
||||
* Ethernet Enable (EEEEN) is cleared.
|
||||
* This function will trigger an autonegotiation restart and
|
||||
* eee will be reenabled during link up if eee was negotiated.
|
||||
*/
|
||||
lan743x_mac_eee_enable(adapter, false);
|
||||
lan743x_csr_write(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT,
|
||||
eee->tx_lpi_timer);
|
||||
|
||||
if (mac_cr & MAC_CR_EEE_EN_)
|
||||
lan743x_mac_eee_enable(adapter, true);
|
||||
}
|
||||
|
||||
return phylink_ethtool_set_eee(adapter->phylink, eee);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2966,7 +2966,7 @@ static int lan743x_phylink_2500basex_config(struct lan743x_adapter *adapter)
|
|||
return lan743x_pcs_power_reset(adapter);
|
||||
}
|
||||
|
||||
void lan743x_mac_eee_enable(struct lan743x_adapter *adapter, bool enable)
|
||||
static void lan743x_mac_eee_enable(struct lan743x_adapter *adapter, bool enable)
|
||||
{
|
||||
u32 mac_cr;
|
||||
|
||||
|
|
@ -3027,10 +3027,8 @@ static void lan743x_phylink_mac_link_down(struct phylink_config *config,
|
|||
phy_interface_t interface)
|
||||
{
|
||||
struct net_device *netdev = to_net_dev(config->dev);
|
||||
struct lan743x_adapter *adapter = netdev_priv(netdev);
|
||||
|
||||
netif_tx_stop_all_queues(netdev);
|
||||
lan743x_mac_eee_enable(adapter, false);
|
||||
}
|
||||
|
||||
static void lan743x_phylink_mac_link_up(struct phylink_config *config,
|
||||
|
|
@ -3072,16 +3070,40 @@ static void lan743x_phylink_mac_link_up(struct phylink_config *config,
|
|||
cap & FLOW_CTRL_TX,
|
||||
cap & FLOW_CTRL_RX);
|
||||
|
||||
if (phydev)
|
||||
lan743x_mac_eee_enable(adapter, phydev->enable_tx_lpi);
|
||||
|
||||
netif_tx_wake_all_queues(netdev);
|
||||
}
|
||||
|
||||
static void lan743x_mac_disable_tx_lpi(struct phylink_config *config)
|
||||
{
|
||||
struct net_device *netdev = to_net_dev(config->dev);
|
||||
struct lan743x_adapter *adapter = netdev_priv(netdev);
|
||||
|
||||
lan743x_mac_eee_enable(adapter, false);
|
||||
}
|
||||
|
||||
static int lan743x_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,
|
||||
bool tx_clk_stop)
|
||||
{
|
||||
struct net_device *netdev = to_net_dev(config->dev);
|
||||
struct lan743x_adapter *adapter = netdev_priv(netdev);
|
||||
|
||||
/* Software should only change this field when Energy Efficient
|
||||
* Ethernet Enable (EEEEN) is cleared. We ensure that by clearing
|
||||
* EEEEN during probe, and phylink itself guarantees that
|
||||
* mac_disable_tx_lpi() will have been previously called.
|
||||
*/
|
||||
lan743x_csr_write(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT, timer);
|
||||
lan743x_mac_eee_enable(adapter, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct phylink_mac_ops lan743x_phylink_mac_ops = {
|
||||
.mac_config = lan743x_phylink_mac_config,
|
||||
.mac_link_down = lan743x_phylink_mac_link_down,
|
||||
.mac_link_up = lan743x_phylink_mac_link_up,
|
||||
.mac_disable_tx_lpi = lan743x_mac_disable_tx_lpi,
|
||||
.mac_enable_tx_lpi = lan743x_mac_enable_tx_lpi,
|
||||
};
|
||||
|
||||
static int lan743x_phylink_create(struct lan743x_adapter *adapter)
|
||||
|
|
@ -3095,6 +3117,9 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
|
|||
|
||||
adapter->phylink_config.mac_capabilities = MAC_ASYM_PAUSE |
|
||||
MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD;
|
||||
adapter->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD;
|
||||
adapter->phylink_config.lpi_timer_default =
|
||||
lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT);
|
||||
|
||||
lan743x_phy_interface_select(adapter);
|
||||
|
||||
|
|
@ -3120,6 +3145,10 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
|
|||
phy_interface_set_rgmii(adapter->phylink_config.supported_interfaces);
|
||||
}
|
||||
|
||||
memcpy(adapter->phylink_config.lpi_interfaces,
|
||||
adapter->phylink_config.supported_interfaces,
|
||||
sizeof(adapter->phylink_config.lpi_interfaces));
|
||||
|
||||
pl = phylink_create(&adapter->phylink_config, NULL,
|
||||
adapter->phy_interface, &lan743x_phylink_mac_ops);
|
||||
|
||||
|
|
@ -3517,6 +3546,9 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
|
|||
spin_lock_init(&tx->ring_lock);
|
||||
}
|
||||
|
||||
/* Ensure EEEEN is clear */
|
||||
lan743x_mac_eee_enable(adapter, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1206,6 +1206,5 @@ void lan743x_hs_syslock_release(struct lan743x_adapter *adapter);
|
|||
void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter,
|
||||
bool tx_enable, bool rx_enable);
|
||||
int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr);
|
||||
void lan743x_mac_eee_enable(struct lan743x_adapter *adapter, bool enable);
|
||||
|
||||
#endif /* _LAN743X_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user