[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230704065916.132486-4-michael.haener@siemens.com>
Date: Tue, 4 Jul 2023 08:59:06 +0200
From: "M. Haener" <michael.haener@...mens.com>
To: netdev@...r.kernel.org
Cc: Michael Haener <michael.haener@...mens.com>,
linux-kernel@...r.kernel.org, Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Russell King <linux@...linux.org.uk>,
Alexander Sverdlin <alexander.sverdlin@...mens.com>
Subject: [PATCH v2 3/3] net: dsa: mv88e632x: Add SERDES ops
From: Michael Haener <michael.haener@...mens.com>
The 88e632x family has several SERDES 100/1000 blocks. By adding these
operations, these functionalities can be used.
Signed-off-by: Michael Haener <michael.haener@...mens.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 18 ++++++++++++++
drivers/net/dsa/mv88e6xxx/serdes.c | 39 ++++++++++++++++++++++++++++++
drivers/net/dsa/mv88e6xxx/serdes.h | 9 +++++++
3 files changed, 66 insertions(+)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 11b98546b938..9802a3608dc6 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -4905,10 +4905,19 @@ static const struct mv88e6xxx_ops mv88e6320_ops = {
.reset = mv88e6352_g1_reset,
.vtu_getnext = mv88e6185_g1_vtu_getnext,
.vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
+ .serdes_get_lane = mv88e6320_serdes_get_lane,
+ .serdes_read = mv88e6320_serdes_read,
+ .serdes_write = mv88e6320_serdes_write,
+ .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
.gpio_ops = &mv88e6352_gpio_ops,
.avb_ops = &mv88e6352_avb_ops,
.ptp_ops = &mv88e6352_ptp_ops,
.phylink_get_caps = mv88e6185_phylink_get_caps,
+ .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
+ .serdes_get_strings = mv88e6352_serdes_get_strings,
+ .serdes_get_stats = mv88e6352_serdes_get_stats,
+ .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
+ .serdes_get_regs = mv88e6352_serdes_get_regs,
};
static const struct mv88e6xxx_ops mv88e6321_ops = {
@@ -4951,10 +4960,19 @@ static const struct mv88e6xxx_ops mv88e6321_ops = {
.reset = mv88e6352_g1_reset,
.vtu_getnext = mv88e6185_g1_vtu_getnext,
.vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
+ .serdes_get_lane = mv88e6320_serdes_get_lane,
+ .serdes_read = mv88e6320_serdes_read,
+ .serdes_write = mv88e6320_serdes_write,
+ .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
.gpio_ops = &mv88e6352_gpio_ops,
.avb_ops = &mv88e6352_avb_ops,
.ptp_ops = &mv88e6352_ptp_ops,
.phylink_get_caps = mv88e6185_phylink_get_caps,
+ .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
+ .serdes_get_strings = mv88e6352_serdes_get_strings,
+ .serdes_get_stats = mv88e6352_serdes_get_stats,
+ .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
+ .serdes_get_regs = mv88e6352_serdes_get_regs,
};
static const struct mv88e6xxx_ops mv88e6341_ops = {
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c
index b988d47ecbdd..411fe9ac421a 100644
--- a/drivers/net/dsa/mv88e6xxx/serdes.c
+++ b/drivers/net/dsa/mv88e6xxx/serdes.c
@@ -17,6 +17,45 @@
#include "port.h"
#include "serdes.h"
+int mv88e6320_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
+ int reg, u16 *val)
+{
+ return mv88e6xxx_phy_page_read(chip, lane,
+ MV88E6320_SERDES_PAGE_FIBER,
+ reg, val);
+}
+
+int mv88e6320_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg,
+ u16 val)
+{
+ return mv88e6xxx_phy_page_write(chip, lane,
+ MV88E6320_SERDES_PAGE_FIBER,
+ reg, val);
+}
+
+int mv88e6320_serdes_get_lane(struct mv88e6xxx_chip *chip, int port)
+{
+ u8 cmode = chip->ports[port].cmode;
+ int lane = -ENODEV;
+
+ switch (port) {
+ case 0:
+ if (cmode == MV88E6XXX_PORT_STS_CMODE_100BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_SGMII)
+ lane = MV88E6320_PORT0_LANE;
+ break;
+ case 1:
+ if (cmode == MV88E6XXX_PORT_STS_CMODE_100BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_SGMII)
+ lane = MV88E6320_PORT1_LANE;
+ break;
+ }
+
+ return lane;
+}
+
int mv88e6352_serdes_read(struct mv88e6xxx_chip *chip, int lane,
int device, int reg, u16 *val)
{
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.h b/drivers/net/dsa/mv88e6xxx/serdes.h
index d3e83c674ef7..9dcc9e581c05 100644
--- a/drivers/net/dsa/mv88e6xxx/serdes.h
+++ b/drivers/net/dsa/mv88e6xxx/serdes.h
@@ -14,6 +14,10 @@
struct phylink_link_state;
+#define MV88E6320_PORT0_LANE 0x0c
+#define MV88E6320_PORT1_LANE 0x0d
+#define MV88E6320_SERDES_PAGE_FIBER 0x01
+
#define MV88E6352_ADDR_SERDES 0x0f
#define MV88E6352_SERDES_PAGE_FIBER 0x01
#define MV88E6352_SERDES_IRQ 0x0b
@@ -116,14 +120,19 @@ struct phylink_link_state;
int mv88e6xxx_pcs_decode_state(struct device *dev, u16 bmsr, u16 lpa,
u16 status, struct phylink_link_state *state);
+int mv88e6320_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6393x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
+int mv88e6320_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
+ int reg, u16 *val);
int mv88e6352_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
int reg, u16 *val);
int mv88e6390_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
int reg, u16 *val);
+int mv88e6320_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg,
+ u16 val);
int mv88e6352_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg,
u16 val);
unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip,
--
2.41.0
Powered by blists - more mailing lists