diff options
author | Woojung Huh <woojung.huh@microchip.com> | 2016-11-17 23:10:02 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-18 19:57:33 +0100 |
commit | f6e3ef3e4d3546b17e9901925276b70a9ea02d94 (patch) | |
tree | 5507a5d63ecd5a8f7431fb03ecc5523c42030792 /drivers/net/usb | |
parent | Merge branch 'net-marvell-freescale-compile-test' (diff) | |
download | linux-f6e3ef3e4d3546b17e9901925276b70a9ea02d94.tar.xz linux-f6e3ef3e4d3546b17e9901925276b70a9ea02d94.zip |
lan78xx: relocate mdix setting to phy driver
Relocate mdix code to phy driver to be called at config_init().
Signed-off-by: Woojung Huh <woojung.huh@microchip.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r-- | drivers/net/usb/lan78xx.c | 73 |
1 files changed, 3 insertions, 70 deletions
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index cf2857fa938f..0c459e92f1b3 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1471,62 +1471,12 @@ static void lan78xx_set_msglevel(struct net_device *net, u32 level) dev->msg_enable = level; } -static int lan78xx_get_mdix_status(struct net_device *net) -{ - struct phy_device *phydev = net->phydev; - int buf; - - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, LAN88XX_EXT_PAGE_SPACE_1); - buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, LAN88XX_EXT_PAGE_SPACE_0); - - return buf; -} - -static void lan78xx_set_mdix_status(struct net_device *net, __u8 mdix_ctrl) -{ - struct lan78xx_net *dev = netdev_priv(net); - struct phy_device *phydev = net->phydev; - int buf; - - if (mdix_ctrl == ETH_TP_MDI) { - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, - LAN88XX_EXT_PAGE_SPACE_1); - buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); - buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; - phy_write(phydev, LAN88XX_EXT_MODE_CTRL, - buf | LAN88XX_EXT_MODE_CTRL_MDI_); - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, - LAN88XX_EXT_PAGE_SPACE_0); - } else if (mdix_ctrl == ETH_TP_MDI_X) { - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, - LAN88XX_EXT_PAGE_SPACE_1); - buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); - buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; - phy_write(phydev, LAN88XX_EXT_MODE_CTRL, - buf | LAN88XX_EXT_MODE_CTRL_MDI_X_); - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, - LAN88XX_EXT_PAGE_SPACE_0); - } else if (mdix_ctrl == ETH_TP_MDI_AUTO) { - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, - LAN88XX_EXT_PAGE_SPACE_1); - buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); - buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; - phy_write(phydev, LAN88XX_EXT_MODE_CTRL, - buf | LAN88XX_EXT_MODE_CTRL_AUTO_MDIX_); - phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, - LAN88XX_EXT_PAGE_SPACE_0); - } - dev->mdix_ctrl = mdix_ctrl; -} - static int lan78xx_get_link_ksettings(struct net_device *net, struct ethtool_link_ksettings *cmd) { struct lan78xx_net *dev = netdev_priv(net); struct phy_device *phydev = net->phydev; int ret; - int buf; ret = usb_autopm_get_interface(dev->intf); if (ret < 0) @@ -1534,20 +1484,6 @@ static int lan78xx_get_link_ksettings(struct net_device *net, ret = phy_ethtool_ksettings_get(phydev, cmd); - buf = lan78xx_get_mdix_status(net); - - buf &= LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; - if (buf == LAN88XX_EXT_MODE_CTRL_AUTO_MDIX_) { - cmd->base.eth_tp_mdix = ETH_TP_MDI_AUTO; - cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO; - } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI_) { - cmd->base.eth_tp_mdix = ETH_TP_MDI; - cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI; - } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI_X_) { - cmd->base.eth_tp_mdix = ETH_TP_MDI_X; - cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_X; - } - usb_autopm_put_interface(dev->intf); return ret; @@ -1565,9 +1501,6 @@ static int lan78xx_set_link_ksettings(struct net_device *net, if (ret < 0) return ret; - if (dev->mdix_ctrl != cmd->base.eth_tp_mdix_ctrl) - lan78xx_set_mdix_status(net, cmd->base.eth_tp_mdix_ctrl); - /* change speed & duplex */ ret = phy_ethtool_ksettings_set(phydev, cmd); @@ -2019,6 +1952,9 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) phydev->irq = 0; netdev_dbg(dev->net, "phydev->irq = %d\n", phydev->irq); + /* set to AUTOMDIX */ + phydev->mdix = ETH_TP_MDI_AUTO; + ret = phy_connect_direct(dev->net, phydev, lan78xx_link_status_change, PHY_INTERFACE_MODE_GMII); @@ -2028,9 +1964,6 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) return -EIO; } - /* set to AUTOMDIX */ - lan78xx_set_mdix_status(dev->net, ETH_TP_MDI_AUTO); - /* MAC doesn't support 1000T Half */ phydev->supported &= ~SUPPORTED_1000baseT_Half; |