Commit 26f4dbab authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: mscc: ocelot: refactor adjust_link into a netdev-independent function

This will be called from the Felix DSA frontend, which will work in
PHYLIB compatibility mode initially.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2b120dde
...@@ -410,15 +410,13 @@ static u16 ocelot_wm_enc(u16 value) ...@@ -410,15 +410,13 @@ static u16 ocelot_wm_enc(u16 value)
return value; return value;
} }
static void ocelot_port_adjust_link(struct net_device *dev) static void ocelot_adjust_link(struct ocelot *ocelot, int port,
struct phy_device *phydev)
{ {
struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot_port *ocelot_port = ocelot->ports[port];
struct ocelot_port *ocelot_port = &priv->port;
struct ocelot *ocelot = ocelot_port->ocelot;
int speed, atop_wm, mode = 0; int speed, atop_wm, mode = 0;
u8 port = priv->chip_port;
switch (dev->phydev->speed) { switch (phydev->speed) {
case SPEED_10: case SPEED_10:
speed = OCELOT_SPEED_10; speed = OCELOT_SPEED_10;
break; break;
...@@ -434,14 +432,14 @@ static void ocelot_port_adjust_link(struct net_device *dev) ...@@ -434,14 +432,14 @@ static void ocelot_port_adjust_link(struct net_device *dev)
mode = DEV_MAC_MODE_CFG_GIGA_MODE_ENA; mode = DEV_MAC_MODE_CFG_GIGA_MODE_ENA;
break; break;
default: default:
netdev_err(dev, "Unsupported PHY speed: %d\n", dev_err(ocelot->dev, "Unsupported PHY speed on port %d: %d\n",
dev->phydev->speed); port, phydev->speed);
return; return;
} }
phy_print_status(dev->phydev); phy_print_status(phydev);
if (!dev->phydev->link) if (!phydev->link)
return; return;
/* Only full duplex supported for now */ /* Only full duplex supported for now */
...@@ -536,6 +534,15 @@ static void ocelot_port_adjust_link(struct net_device *dev) ...@@ -536,6 +534,15 @@ static void ocelot_port_adjust_link(struct net_device *dev)
ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG); ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
} }
static void ocelot_port_adjust_link(struct net_device *dev)
{
struct ocelot_port_private *priv = netdev_priv(dev);
struct ocelot *ocelot = priv->port.ocelot;
int port = priv->chip_port;
ocelot_adjust_link(ocelot, port, dev->phydev);
}
static void ocelot_port_enable(struct ocelot *ocelot, int port, static void ocelot_port_enable(struct ocelot *ocelot, int port,
struct phy_device *phy) struct phy_device *phy)
{ {
......
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