Commit fc548b99 authored by Russell King's avatar Russell King Committed by David S. Miller

net: mvneta: prepare to convert to phylink

Prepare to convert mvneta to phylink by splitting the adjust_link
function into its consituent parts.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3b8bc674
...@@ -3251,37 +3251,73 @@ static int mvneta_set_mac_addr(struct net_device *dev, void *addr) ...@@ -3251,37 +3251,73 @@ static int mvneta_set_mac_addr(struct net_device *dev, void *addr)
return 0; return 0;
} }
static void mvneta_adjust_link(struct net_device *ndev) static void mvneta_mac_config(struct net_device *ndev)
{ {
struct mvneta_port *pp = netdev_priv(ndev); struct mvneta_port *pp = netdev_priv(ndev);
struct phy_device *phydev = ndev->phydev; struct phy_device *phydev = ndev->phydev;
int status_change = 0; u32 val;
if (phydev->link) { if ((pp->speed != phydev->speed) ||
if ((pp->speed != phydev->speed) || (pp->duplex != phydev->duplex)) {
(pp->duplex != phydev->duplex)) { val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
u32 val; val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
MVNETA_GMAC_CONFIG_GMII_SPEED |
MVNETA_GMAC_CONFIG_FULL_DUPLEX);
val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG); if (phydev->duplex)
val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED | val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
MVNETA_GMAC_CONFIG_GMII_SPEED |
MVNETA_GMAC_CONFIG_FULL_DUPLEX);
if (phydev->duplex) if (phydev->speed == SPEED_1000)
val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX; val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
else if (phydev->speed == SPEED_100)
val |= MVNETA_GMAC_CONFIG_MII_SPEED;
if (phydev->speed == SPEED_1000) mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
else if (phydev->speed == SPEED_100)
val |= MVNETA_GMAC_CONFIG_MII_SPEED;
mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val); pp->duplex = phydev->duplex;
pp->speed = phydev->speed;
}
}
pp->duplex = phydev->duplex; static void mvneta_mac_link_down(struct net_device *ndev, bool autoneg)
pp->speed = phydev->speed; {
} struct mvneta_port *pp = netdev_priv(ndev);
u32 val;
if (!autoneg) {
val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
val &= ~MVNETA_GMAC_FORCE_LINK_PASS;
val |= MVNETA_GMAC_FORCE_LINK_DOWN;
mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
} }
mvneta_port_down(pp);
}
static void mvneta_mac_link_up(struct net_device *ndev, bool autoneg)
{
struct mvneta_port *pp = netdev_priv(ndev);
u32 val;
if (!autoneg) {
val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
val &= ~MVNETA_GMAC_FORCE_LINK_DOWN;
val |= MVNETA_GMAC_FORCE_LINK_PASS;
mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
}
mvneta_port_up(pp);
}
static void mvneta_adjust_link(struct net_device *ndev)
{
struct mvneta_port *pp = netdev_priv(ndev);
struct phy_device *phydev = ndev->phydev;
int status_change = 0;
if (phydev->link)
mvneta_mac_config(ndev);
if (phydev->link != pp->link) { if (phydev->link != pp->link) {
if (!phydev->link) { if (!phydev->link) {
pp->duplex = -1; pp->duplex = -1;
...@@ -3293,27 +3329,10 @@ static void mvneta_adjust_link(struct net_device *ndev) ...@@ -3293,27 +3329,10 @@ static void mvneta_adjust_link(struct net_device *ndev)
} }
if (status_change) { if (status_change) {
if (phydev->link) { if (phydev->link)
if (!pp->use_inband_status) { mvneta_mac_link_down(ndev, pp->use_inband_status);
u32 val = mvreg_read(pp, else
MVNETA_GMAC_AUTONEG_CONFIG); mvneta_mac_link_up(ndev, pp->use_inband_status);
val &= ~MVNETA_GMAC_FORCE_LINK_DOWN;
val |= MVNETA_GMAC_FORCE_LINK_PASS;
mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG,
val);
}
mvneta_port_up(pp);
} else {
if (!pp->use_inband_status) {
u32 val = mvreg_read(pp,
MVNETA_GMAC_AUTONEG_CONFIG);
val &= ~MVNETA_GMAC_FORCE_LINK_PASS;
val |= MVNETA_GMAC_FORCE_LINK_DOWN;
mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG,
val);
}
mvneta_port_down(pp);
}
phy_print_status(phydev); phy_print_status(phydev);
} }
} }
......
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