1 From 1737de8045838dcf3c7713c940eb1582810a319f Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Mon, 16 Dec 2019 15:07:20 +0200
4 Subject: [PATCH] net: mscc: ocelot: make phy_mode a member of the common
7 The Ocelot switchdev driver and the Felix DSA one need it for different
8 reasons. Felix (or at least the VSC9959 instantiation in NXP LS1028A) is
9 integrated with the traditional NXP Layerscape PCS design which does not
10 support runtime configuration of SerDes protocol. So it needs to
11 pre-validate the phy-mode from the device tree and prevent PHYLINK from
12 attempting to change it. For this, it needs to cache it in a private
15 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
17 drivers/net/ethernet/mscc/ocelot.c | 7 ++++---
18 drivers/net/ethernet/mscc/ocelot.h | 1 -
19 drivers/net/ethernet/mscc/ocelot_board.c | 4 ++--
20 include/soc/mscc/ocelot.h | 2 ++
21 4 files changed, 8 insertions(+), 6 deletions(-)
23 --- a/drivers/net/ethernet/mscc/ocelot.c
24 +++ b/drivers/net/ethernet/mscc/ocelot.c
25 @@ -500,13 +500,14 @@ EXPORT_SYMBOL(ocelot_port_enable);
26 static int ocelot_port_open(struct net_device *dev)
28 struct ocelot_port_private *priv = netdev_priv(dev);
29 - struct ocelot *ocelot = priv->port.ocelot;
30 + struct ocelot_port *ocelot_port = &priv->port;
31 + struct ocelot *ocelot = ocelot_port->ocelot;
32 int port = priv->chip_port;
36 err = phy_set_mode_ext(priv->serdes, PHY_MODE_ETHERNET,
38 + ocelot_port->phy_mode);
40 netdev_err(dev, "Could not set mode of SerDes\n");
42 @@ -514,7 +515,7 @@ static int ocelot_port_open(struct net_d
45 err = phy_connect_direct(dev, priv->phy, &ocelot_port_adjust_link,
47 + ocelot_port->phy_mode);
49 netdev_err(dev, "Could not attach to PHY\n");
51 --- a/drivers/net/ethernet/mscc/ocelot.h
52 +++ b/drivers/net/ethernet/mscc/ocelot.h
53 @@ -70,7 +70,6 @@ struct ocelot_port_private {
57 - phy_interface_t phy_mode;
60 struct ocelot_port_tc tc;
61 --- a/drivers/net/ethernet/mscc/ocelot_board.c
62 +++ b/drivers/net/ethernet/mscc/ocelot_board.c
63 @@ -412,9 +412,9 @@ static int mscc_ocelot_probe(struct plat
65 phy_mode = PHY_INTERFACE_MODE_NA;
67 - priv->phy_mode = phy_mode;
68 + ocelot_port->phy_mode = phy_mode;
70 - switch (priv->phy_mode) {
71 + switch (ocelot_port->phy_mode) {
72 case PHY_INTERFACE_MODE_NA:
74 case PHY_INTERFACE_MODE_SGMII:
75 --- a/include/soc/mscc/ocelot.h
76 +++ b/include/soc/mscc/ocelot.h
77 @@ -425,6 +425,8 @@ struct ocelot_port {
79 struct sk_buff_head tx_skbs;
82 + phy_interface_t phy_mode;