Commit 7812da81 authored by David S. Miller's avatar David S. Miller

Merge branch 'phy-cleanup-EEE'

Andrew Lunn says:

====================
net: Clean up some EEE code

Previous patches have reworked the API between phylib and MAC drivers
with respect to EEE, pushing most of the work into phylib. These two
patches rework two drivers to make use of the new API, and fix their
EEE implementation, so that EEE is configured in the MAC based on what
is actually negotiated during autoneg.

Compile tested only.
====================
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 382c6001 ef460a89
...@@ -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);
} }
} }
......
...@@ -1692,15 +1692,10 @@ static int lan78xx_get_eee(struct net_device *net, struct ethtool_keee *edata) ...@@ -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); ret = lan78xx_read_reg(dev, MAC_CR, &buf);
if (buf & MAC_CR_EEE_EN_) { 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 */ /* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */
ret = lan78xx_read_reg(dev, EEE_TX_LPI_REQ_DLY, &buf); ret = lan78xx_read_reg(dev, EEE_TX_LPI_REQ_DLY, &buf);
edata->tx_lpi_timer = buf; edata->tx_lpi_timer = buf;
} else { } else {
edata->eee_enabled = false;
edata->eee_active = false;
edata->tx_lpi_enabled = false;
edata->tx_lpi_timer = 0; edata->tx_lpi_timer = 0;
} }
...@@ -1721,24 +1716,16 @@ static int lan78xx_set_eee(struct net_device *net, struct ethtool_keee *edata) ...@@ -1721,24 +1716,16 @@ static int lan78xx_set_eee(struct net_device *net, struct ethtool_keee *edata)
if (ret < 0) if (ret < 0)
return ret; return ret;
if (edata->eee_enabled) { ret = phy_ethtool_set_eee(net->phydev, edata);
ret = lan78xx_read_reg(dev, MAC_CR, &buf); if (ret < 0)
buf |= MAC_CR_EEE_EN_; goto out;
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);
}
buf = (u32)edata->tx_lpi_timer;
ret = lan78xx_write_reg(dev, EEE_TX_LPI_REQ_DLY, buf);
out:
usb_autopm_put_interface(dev->intf); usb_autopm_put_interface(dev->intf);
return 0; return ret;
} }
static u32 lan78xx_get_link(struct net_device *net) static u32 lan78xx_get_link(struct net_device *net)
...@@ -2114,7 +2101,20 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev) ...@@ -2114,7 +2101,20 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev)
static void lan78xx_link_status_change(struct net_device *net) static void lan78xx_link_status_change(struct net_device *net)
{ {
struct lan78xx_net *dev = netdev_priv(net);
struct phy_device *phydev = net->phydev; 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); phy_print_status(phydev);
} }
...@@ -2408,6 +2408,8 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) ...@@ -2408,6 +2408,8 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
mii_adv_to_linkmode_adv_t(fc, mii_adv); mii_adv_to_linkmode_adv_t(fc, mii_adv);
linkmode_or(phydev->advertising, fc, phydev->advertising); linkmode_or(phydev->advertising, fc, phydev->advertising);
phy_support_eee(phydev);
if (phydev->mdio.dev.of_node) { if (phydev->mdio.dev.of_node) {
u32 reg; u32 reg;
int len; int len;
......
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