Commit 70f23a80 authored by David S. Miller's avatar David S. Miller

Merge branch 'ethoc-next'

Florian Fainelli says:

====================
net: ethoc: Misc improvements

This patch series fixes/improves a few things:

- implement a proper PHYLIB adjust_link callback to set the duplex mode
  accordingly
- do not open code the fetching of a MAC address in OF/DT environments
- demote an error message that occurs more frequently than expected in low
  CPU/memory/bandwidth environments

Tested on a Cirrus Logic EP93xx / TS7300 board.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1c0d32fd 38b4bc20
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_net.h>
#include <linux/module.h> #include <linux/module.h>
#include <net/ethoc.h> #include <net/ethoc.h>
...@@ -221,6 +222,9 @@ struct ethoc { ...@@ -221,6 +222,9 @@ struct ethoc {
struct mii_bus *mdio; struct mii_bus *mdio;
struct clk *clk; struct clk *clk;
s8 phy_id; s8 phy_id;
int old_link;
int old_duplex;
}; };
/** /**
...@@ -572,7 +576,7 @@ static irqreturn_t ethoc_interrupt(int irq, void *dev_id) ...@@ -572,7 +576,7 @@ static irqreturn_t ethoc_interrupt(int irq, void *dev_id)
/* We always handle the dropped packet interrupt */ /* We always handle the dropped packet interrupt */
if (pending & INT_MASK_BUSY) { if (pending & INT_MASK_BUSY) {
dev_err(&dev->dev, "packet dropped\n"); dev_dbg(&dev->dev, "packet dropped\n");
dev->stats.rx_dropped++; dev->stats.rx_dropped++;
} }
...@@ -667,6 +671,32 @@ static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val) ...@@ -667,6 +671,32 @@ static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
static void ethoc_mdio_poll(struct net_device *dev) static void ethoc_mdio_poll(struct net_device *dev)
{ {
struct ethoc *priv = netdev_priv(dev);
struct phy_device *phydev = dev->phydev;
bool changed = false;
u32 mode;
if (priv->old_link != phydev->link) {
changed = true;
priv->old_link = phydev->link;
}
if (priv->old_duplex != phydev->duplex) {
changed = true;
priv->old_duplex = phydev->duplex;
}
if (!changed)
return;
mode = ethoc_read(priv, MODER);
if (phydev->duplex == DUPLEX_FULL)
mode |= MODER_FULLD;
else
mode &= ~MODER_FULLD;
ethoc_write(priv, MODER, mode);
phy_print_status(phydev);
} }
static int ethoc_mdio_probe(struct net_device *dev) static int ethoc_mdio_probe(struct net_device *dev)
...@@ -685,6 +715,9 @@ static int ethoc_mdio_probe(struct net_device *dev) ...@@ -685,6 +715,9 @@ static int ethoc_mdio_probe(struct net_device *dev)
return -ENXIO; return -ENXIO;
} }
priv->old_duplex = -1;
priv->old_link = -1;
err = phy_connect_direct(dev, phy, ethoc_mdio_poll, err = phy_connect_direct(dev, phy, ethoc_mdio_poll,
PHY_INTERFACE_MODE_GMII); PHY_INTERFACE_MODE_GMII);
if (err) { if (err) {
...@@ -721,6 +754,9 @@ static int ethoc_open(struct net_device *dev) ...@@ -721,6 +754,9 @@ static int ethoc_open(struct net_device *dev)
netif_start_queue(dev); netif_start_queue(dev);
} }
priv->old_link = -1;
priv->old_duplex = -1;
phy_start(dev->phydev); phy_start(dev->phydev);
napi_enable(&priv->napi); napi_enable(&priv->napi);
...@@ -1123,11 +1159,9 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1123,11 +1159,9 @@ static int ethoc_probe(struct platform_device *pdev)
memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN); memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN);
priv->phy_id = pdata->phy_id; priv->phy_id = pdata->phy_id;
} else { } else {
const uint8_t *mac; const void *mac;
mac = of_get_property(pdev->dev.of_node, mac = of_get_mac_address(pdev->dev.of_node);
"local-mac-address",
NULL);
if (mac) if (mac)
memcpy(netdev->dev_addr, mac, IFHWADDRLEN); memcpy(netdev->dev_addr, mac, IFHWADDRLEN);
priv->phy_id = -1; priv->phy_id = -1;
......
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