blob: f0b63937527f8614ef4ea25eda7f03af0b5db299 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From ac918399cae8b62f58f50b40bf8037d0fa9353eb Mon Sep 17 00:00:00 2001
2From: Vladimir Oltean <vladimir.oltean@nxp.com>
3Date: Sat, 9 Nov 2019 15:02:57 +0200
4Subject: [PATCH] net: mscc: ocelot: separate the common implementation of
5 ndo_open and ndo_stop
6
7Allow these functions to be called from the .port_enable and
8.port_disable callbacks of DSA.
9
10Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
11Signed-off-by: David S. Miller <davem@davemloft.net>
12---
13 drivers/net/ethernet/mscc/ocelot.c | 36 ++++++++++++++++++++++++++----------
14 1 file changed, 26 insertions(+), 10 deletions(-)
15
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);
20 }
21
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)
25 {
26- struct ocelot_port_private *priv = netdev_priv(dev);
27- struct ocelot *ocelot = priv->port.ocelot;
28- int port = priv->chip_port;
29- int err;
30-
31 /* Enable receiving frames on the port, and activate auto-learning of
32 * MAC addresses.
33 */
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);
38+}
39+
40+static int ocelot_port_open(struct net_device *dev)
41+{
42+ struct ocelot_port_private *priv = netdev_priv(dev);
43+ struct ocelot *ocelot = priv->port.ocelot;
44+ int port = priv->chip_port;
45+ int err;
46
47 if (priv->serdes) {
48 err = phy_set_mode_ext(priv->serdes, PHY_MODE_ETHERNET,
49@@ -571,21 +575,33 @@ static int ocelot_port_open(struct net_d
50
51 phy_attached_info(priv->phy);
52 phy_start(priv->phy);
53+
54+ ocelot_port_enable(ocelot, port, priv->phy);
55+
56 return 0;
57 }
58
59+static void ocelot_port_disable(struct ocelot *ocelot, int port)
60+{
61+ struct ocelot_port *ocelot_port = ocelot->ports[port];
62+
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);
66+}
67+
68 static int ocelot_port_stop(struct net_device *dev)
69 {
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;
74
75 phy_disconnect(priv->phy);
76
77 dev->phydev = NULL;
78
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);
83+
84 return 0;
85 }
86