Skip to content

Commit abf7e53

Browse files
ffainellidavem330
authored andcommitted
net: ethoc: Account for duplex changes
ethoc_mdio_poll() which is our PHYLIB adjust_link callback does nothing, we should at least react to duplex changes and change MODER accordingly. Speed changes is not a problem, since the OpenCores Ethernet core seems to be reacting okay without us telling it. Signed-off-by: Florian Fainelli <[email protected]> Reviewed-by: Tobias Klauser <[email protected]> Acked-by: Thierry Reding <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1c0d32f commit abf7e53

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/net/ethernet/ethoc.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ struct ethoc {
221221
struct mii_bus *mdio;
222222
struct clk *clk;
223223
s8 phy_id;
224+
225+
int old_link;
226+
int old_duplex;
224227
};
225228

226229
/**
@@ -667,6 +670,32 @@ static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
667670

668671
static void ethoc_mdio_poll(struct net_device *dev)
669672
{
673+
struct ethoc *priv = netdev_priv(dev);
674+
struct phy_device *phydev = dev->phydev;
675+
bool changed = false;
676+
u32 mode;
677+
678+
if (priv->old_link != phydev->link) {
679+
changed = true;
680+
priv->old_link = phydev->link;
681+
}
682+
683+
if (priv->old_duplex != phydev->duplex) {
684+
changed = true;
685+
priv->old_duplex = phydev->duplex;
686+
}
687+
688+
if (!changed)
689+
return;
690+
691+
mode = ethoc_read(priv, MODER);
692+
if (phydev->duplex == DUPLEX_FULL)
693+
mode |= MODER_FULLD;
694+
else
695+
mode &= ~MODER_FULLD;
696+
ethoc_write(priv, MODER, mode);
697+
698+
phy_print_status(phydev);
670699
}
671700

672701
static int ethoc_mdio_probe(struct net_device *dev)
@@ -685,6 +714,9 @@ static int ethoc_mdio_probe(struct net_device *dev)
685714
return -ENXIO;
686715
}
687716

717+
priv->old_duplex = -1;
718+
priv->old_link = -1;
719+
688720
err = phy_connect_direct(dev, phy, ethoc_mdio_poll,
689721
PHY_INTERFACE_MODE_GMII);
690722
if (err) {
@@ -721,6 +753,9 @@ static int ethoc_open(struct net_device *dev)
721753
netif_start_queue(dev);
722754
}
723755

756+
priv->old_link = -1;
757+
priv->old_duplex = -1;
758+
724759
phy_start(dev->phydev);
725760
napi_enable(&priv->napi);
726761

0 commit comments

Comments
 (0)