1 From ac918399cae8b62f58f50b40bf8037d0fa9353eb Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Sat, 9 Nov 2019 15:02:57 +0200
4 Subject: [PATCH] net: mscc: ocelot: separate the common implementation of
7 Allow these functions to be called from the .port_enable and
8 .port_disable callbacks of DSA.
10 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
13 drivers/net/ethernet/mscc/ocelot.c | 36 ++++++++++++++++++++++++++----------
14 1 file changed, 26 insertions(+), 10 deletions(-)
16 --- a/drivers/net/ethernet/mscc/ocelot.c
17 +++ b/drivers/net/ethernet/mscc/ocelot.c
18 @@ -536,13 +536,9 @@ static void ocelot_port_adjust_link(stru
19 ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
22 -static int ocelot_port_open(struct net_device *dev)
23 +static void ocelot_port_enable(struct ocelot *ocelot, int port,
24 + struct phy_device *phy)
26 - struct ocelot_port_private *priv = netdev_priv(dev);
27 - struct ocelot *ocelot = priv->port.ocelot;
28 - int port = priv->chip_port;
31 /* Enable receiving frames on the port, and activate auto-learning of
34 @@ -550,6 +546,14 @@ static int ocelot_port_open(struct net_d
35 ANA_PORT_PORT_CFG_RECV_ENA |
36 ANA_PORT_PORT_CFG_PORTID_VAL(port),
37 ANA_PORT_PORT_CFG, port);
40 +static int ocelot_port_open(struct net_device *dev)
42 + struct ocelot_port_private *priv = netdev_priv(dev);
43 + struct ocelot *ocelot = priv->port.ocelot;
44 + int port = priv->chip_port;
48 err = phy_set_mode_ext(priv->serdes, PHY_MODE_ETHERNET,
49 @@ -571,21 +575,33 @@ static int ocelot_port_open(struct net_d
51 phy_attached_info(priv->phy);
54 + ocelot_port_enable(ocelot, port, priv->phy);
59 +static void ocelot_port_disable(struct ocelot *ocelot, int port)
61 + struct ocelot_port *ocelot_port = ocelot->ports[port];
63 + ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
64 + ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
65 + QSYS_SWITCH_PORT_MODE, port);
68 static int ocelot_port_stop(struct net_device *dev)
70 struct ocelot_port_private *priv = netdev_priv(dev);
71 - struct ocelot_port *port = &priv->port;
72 + struct ocelot *ocelot = priv->port.ocelot;
73 + int port = priv->chip_port;
75 phy_disconnect(priv->phy);
79 - ocelot_port_writel(port, 0, DEV_MAC_ENA_CFG);
80 - ocelot_rmw_rix(port->ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
81 - QSYS_SWITCH_PORT_MODE, priv->chip_port);
82 + ocelot_port_disable(ocelot, port);