[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230724101829.9431-1-ante.knezic@helmholz.de>
Date: Mon, 24 Jul 2023 12:18:29 +0200
From: Ante Knezic <ante.knezic@...mholz.de>
To: <netdev@...r.kernel.org>
CC: <andrew@...n.ch>, <f.fainelli@...il.com>, <olteanv@...il.com>,
<davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <linux-kernel@...r.kernel.org>,
Ante Knezic <ante.knezic@...mholz.de>
Subject: [PATCH net-next] net: dsa: mv88e6xxx: enable automedia on 6190x and 6390x devices
Marvell 6190x and 6390x devices support using unusued lanes of
ports 9 and 10 as automedia PHY/SERDES ports. In order to be
able to use them as automedia ports, serdes lanes must be
properly initialized so we allow setting the desired cmode to
be later used by the phylink_pcs infrastructure.
Signed-off-by: Ante Knezic <ante.knezic@...mholz.de>
---
drivers/net/dsa/mv88e6xxx/port.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
index 5394a8cf7bf1..060cbf8c703c 100644
--- a/drivers/net/dsa/mv88e6xxx/port.c
+++ b/drivers/net/dsa/mv88e6xxx/port.c
@@ -12,6 +12,7 @@
#include <linux/if_bridge.h>
#include <linux/phy.h>
#include <linux/phylink.h>
+#include <linux/of_net.h>
#include "chip.h"
#include "global2.h"
@@ -596,9 +597,42 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
return 0;
}
+static int mv88e6390x_port_automedia(struct mv88e6xxx_chip *chip, int port,
+ phy_interface_t mode)
+{
+ phy_interface_t of_mode;
+ struct dsa_port *dp;
+ int err;
+
+ if (mode == PHY_INTERFACE_MODE_NA) {
+ dp = dsa_to_port(chip->ds, port);
+ err = of_get_phy_mode(dp->dn, &of_mode);
+ if (err)
+ return -EOPNOTSUPP;
+
+ if (of_mode != PHY_INTERFACE_MODE_1000BASEX)
+ return -EOPNOTSUPP;
+
+ /* Physical cmode value is writable only for ports 9 and 10
+ * but we need the desired cmode in order to properly prepare
+ * phylink infrastructure. The physical cmode value will be
+ * updated by the switch itself once the automedia port is
+ * linked.
+ * Automedia ports support only 1000BASE-X cmode.
+ */
+ chip->ports[port].cmode = MV88E6XXX_PORT_STS_CMODE_1000BASEX;
+ return 0;
+ }
+
+ return -EOPNOTSUPP;
+}
+
int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
phy_interface_t mode)
{
+ if (port >= 2 && port <= 7)
+ return mv88e6390x_port_automedia(chip, port, mode);
+
if (port != 9 && port != 10)
return -EOPNOTSUPP;
--
2.11.0
Powered by blists - more mailing lists