7f80cd4a8826693b7579621a38fe950df0504bb4
[openwrt/openwrt.git] /
1 From f8c221dc7383a50defcc5b96595e092159dbe928 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Sat, 9 Nov 2019 15:02:59 +0200
4 Subject: [PATCH] net: mscc: ocelot: refactor adjust_link into a
5 netdev-independent function
6
7 This will be called from the Felix DSA frontend, which will work in
8 PHYLIB compatibility mode initially.
9
10 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13 drivers/net/ethernet/mscc/ocelot.c | 27 +++++++++++++++++----------
14 1 file changed, 17 insertions(+), 10 deletions(-)
15
16 --- a/drivers/net/ethernet/mscc/ocelot.c
17 +++ b/drivers/net/ethernet/mscc/ocelot.c
18 @@ -410,15 +410,13 @@ static u16 ocelot_wm_enc(u16 value)
19 return value;
20 }
21
22 -static void ocelot_port_adjust_link(struct net_device *dev)
23 +static void ocelot_adjust_link(struct ocelot *ocelot, int port,
24 + struct phy_device *phydev)
25 {
26 - struct ocelot_port_private *priv = netdev_priv(dev);
27 - struct ocelot_port *ocelot_port = &priv->port;
28 - struct ocelot *ocelot = ocelot_port->ocelot;
29 + struct ocelot_port *ocelot_port = ocelot->ports[port];
30 int speed, atop_wm, mode = 0;
31 - u8 port = priv->chip_port;
32
33 - switch (dev->phydev->speed) {
34 + switch (phydev->speed) {
35 case SPEED_10:
36 speed = OCELOT_SPEED_10;
37 break;
38 @@ -434,14 +432,14 @@ static void ocelot_port_adjust_link(stru
39 mode = DEV_MAC_MODE_CFG_GIGA_MODE_ENA;
40 break;
41 default:
42 - netdev_err(dev, "Unsupported PHY speed: %d\n",
43 - dev->phydev->speed);
44 + dev_err(ocelot->dev, "Unsupported PHY speed on port %d: %d\n",
45 + port, phydev->speed);
46 return;
47 }
48
49 - phy_print_status(dev->phydev);
50 + phy_print_status(phydev);
51
52 - if (!dev->phydev->link)
53 + if (!phydev->link)
54 return;
55
56 /* Only full duplex supported for now */
57 @@ -536,6 +534,15 @@ static void ocelot_port_adjust_link(stru
58 ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
59 }
60
61 +static void ocelot_port_adjust_link(struct net_device *dev)
62 +{
63 + struct ocelot_port_private *priv = netdev_priv(dev);
64 + struct ocelot *ocelot = priv->port.ocelot;
65 + int port = priv->chip_port;
66 +
67 + ocelot_adjust_link(ocelot, port, dev->phydev);
68 +}
69 +
70 static void ocelot_port_enable(struct ocelot *ocelot, int port,
71 struct phy_device *phy)
72 {