Skip to contentSkip to conversation

net: dsa: lantiq_gswip: prepare for supporting MaxLinear GSW1xx

PATCH Superseded Daniel Golle 2 participants 10 messages Aug 29, 2025

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover net: dsa: lantiq_gswip: prepare for supporting MaxLinear GSW1xx

Continue to prepare for supporting the newer standalone MaxLinear GSW1xx switch family by extending the existing lantiq_gswip driver to allow it to support MII interfaces and MDIO bus of the GSW1xx.

This series has been preceded by an RFC series which covers everything needed to support the MaxLinear GSW1xx family of switches. Andrew Lunn had suggested to split it into a couple of smaller series and start with the changes which don't yet make actual functional changes or support new features.

Everything has been compile and runtime tested on AVM Fritz!Box 7490 (GSWIP version 2.1, VR9 v1.2)

v3: explicitly initialize mii_port_reg_offset to 0
v2: move lantiq_gswip driver to its own folder

Daniel Golle (6):
net: dsa: lantiq_gswip: move to dedicated folder
net: dsa: lantiq_gswip: support model-specific mac_select_pcs()
net: dsa: lantiq_gswip: ignore SerDes modes in phylink_mac_config()
net: dsa: lantiq_gswip: support offset of MII registers
net: dsa: lantiq_gswip: support standard MDIO node name
net: dsa: lantiq_gswip: move MDIO bus registration to .setup()

 MAINTAINERS                                 |  3 +-
 drivers/net/dsa/Kconfig                     |  8 +--
 drivers/net/dsa/Makefile                    |  2 +-
 drivers/net/dsa/lantiq/Kconfig              |  7 +++
 drivers/net/dsa/lantiq/Makefile             |  1 +
 drivers/net/dsa/{ => lantiq}/lantiq_gswip.c | 54 ++++++++++++++++-----
 drivers/net/dsa/{ => lantiq}/lantiq_gswip.h |  4 ++
 drivers/net/dsa/{ => lantiq}/lantiq_pce.h   |  0
 8 files changed, 57 insertions(+), 22 deletions(-)
 create mode 100644 drivers/net/dsa/lantiq/Kconfig
 create mode 100644 drivers/net/dsa/lantiq/Makefile
 rename drivers/net/dsa/{ => lantiq}/lantiq_gswip.c (98%)
 rename drivers/net/dsa/{ => lantiq}/lantiq_gswip.h (98%)
 rename drivers/net/dsa/{ => lantiq}/lantiq_pce.h (100%)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v3 1/6 net: dsa: lantiq_gswip: move to dedicated folder

Move the lantiq_gswip driver to its own folder and update MAINTAINERS file accordingly.
This is done ahead of extending the driver to support the MaxLinear GSW1xx series of standalone switch ICs, which includes adding a bunch of files.

---
v3: no changes
v2: move driver to its own folder

 MAINTAINERS                                 | 3 +--
 drivers/net/dsa/Kconfig                     | 8 +-------
 drivers/net/dsa/Makefile                    | 2 +-
 drivers/net/dsa/lantiq/Kconfig              | 7 +++++++
 drivers/net/dsa/lantiq/Makefile             | 1 +
 drivers/net/dsa/{ => lantiq}/lantiq_gswip.c | 0
 drivers/net/dsa/{ => lantiq}/lantiq_gswip.h | 0
 drivers/net/dsa/{ => lantiq}/lantiq_pce.h   | 0
 8 files changed, 11 insertions(+), 10 deletions(-)
 create mode 100644 drivers/net/dsa/lantiq/Kconfig
 create mode 100644 drivers/net/dsa/lantiq/Makefile
 rename drivers/net/dsa/{ => lantiq}/lantiq_gswip.c (100%)
 rename drivers/net/dsa/{ => lantiq}/lantiq_gswip.h (100%)
 rename drivers/net/dsa/{ => lantiq}/lantiq_pce.h (100%)
MAINTAINERS +1 -2
index bce96dd254b8..e86bdad15919 100644
@@ -13801,8 +13801,7 @@ M:	Hauke Mehrtens <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/net/dsa/lantiq,gswip.yaml
-F:	drivers/net/dsa/lantiq_gswip.c
-F:	drivers/net/dsa/lantiq_pce.h
+F:	drivers/net/dsa/lantiq/*
 F:	drivers/net/ethernet/lantiq_xrx200.c
 F:	net/dsa/tag_gswip.c
 
drivers/net/dsa/Kconfig +1 -7
index 202a35d8d061..4d9af691b989 100644
@@ -26,13 +26,7 @@ config NET_DSA_LOOP
 
 source "drivers/net/dsa/hirschmann/Kconfig"
 
-config NET_DSA_LANTIQ_GSWIP
-	tristate "Lantiq / Intel GSWIP"
-	depends on HAS_IOMEM
-	select NET_DSA_TAG_GSWIP
-	help
-	  This enables support for the Lantiq / Intel GSWIP 2.1 found in
-	  the xrx200 / VR9 SoC.
+source "drivers/net/dsa/lantiq/Kconfig"
 
 config NET_DSA_MT7530
 	tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
drivers/net/dsa/Makefile +1 -1
index 23dbdf1a36a8..c0a534fe6eaf 100644
@@ -6,7 +6,6 @@ ifdef CONFIG_NET_DSA_LOOP
 obj-$(CONFIG_FIXED_PHY)		+= dsa_loop_bdinfo.o
 endif
 obj-$(CONFIG_NET_DSA_KS8995) 	+= ks8995.o
-obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
 obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530.o
 obj-$(CONFIG_NET_DSA_MT7530_MDIO) += mt7530-mdio.o
 obj-$(CONFIG_NET_DSA_MT7530_MMIO) += mt7530-mmio.o
@@ -20,6 +19,7 @@ obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o
 obj-y				+= b53/
 obj-y				+= hirschmann/
+obj-y				+= lantiq/
 obj-y				+= microchip/
 obj-y				+= mv88e6xxx/
 obj-y				+= ocelot/
drivers/net/dsa/lantiq/Kconfig new file +7 -0
new file mode 100644
index 000000000000..1cb053c823f7
@@ -0,0 +1,7 @@
+config NET_DSA_LANTIQ_GSWIP
+	tristate "Lantiq / Intel GSWIP"
+	depends on HAS_IOMEM
+	select NET_DSA_TAG_GSWIP
+	help
+	  This enables support for the Lantiq / Intel GSWIP 2.1 found in
+	  the xrx200 / VR9 SoC.
drivers/net/dsa/lantiq/Makefile new file +1 -0
new file mode 100644
index 000000000000..849f85ebebd6
@@ -0,0 +1 @@
+obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
drivers/net/dsa/lantiq/lantiq_gswip.c renamed from drivers/net/dsa/lantiq_gswip.c +0 -0
similarity index 100%
rename from drivers/net/dsa/lantiq_gswip.c
rename to drivers/net/dsa/lantiq/lantiq_gswip.c
drivers/net/dsa/lantiq/lantiq_gswip.h renamed from drivers/net/dsa/lantiq_gswip.h +0 -0
similarity index 100%
rename from drivers/net/dsa/lantiq_gswip.h
rename to drivers/net/dsa/lantiq/lantiq_gswip.h
drivers/net/dsa/lantiq/lantiq_pce.h renamed from drivers/net/dsa/lantiq_pce.h +0 -0
similarity index 100%
rename from drivers/net/dsa/lantiq_pce.h
rename to drivers/net/dsa/lantiq/lantiq_pce.h
Signature · 1 line
2.51.0
#2 lore raw

PATCH v3 2/6 net: dsa: lantiq_gswip: support model-specific mac_select_pcs()

In reply to Daniel Golle

Call mac_select_pcs() function if provided in struct gswip_hwinfo. The MaxLinear GSW1xx series got one port wired to a SerDes PCS and PHY which can do 1000Base-X, 2500Base-X and SGMII. Support for the SerDes port will be provided using phylink_pcs, so provide a convenient way for mac_select_pcs() to differ based on the hardware model.

---
v3: no changes
v2: fix accidental change from 'static const struct' to 'const struct'
reported by the kbuild bot

 drivers/net/dsa/lantiq/lantiq_gswip.c | 19 ++++++++++++++++---
 drivers/net/dsa/lantiq/lantiq_gswip.h |  3 +++
 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/net/dsa/lantiq/lantiq_gswip.c +16 -3
index 67919c3935e4..acb6996356e9 100644
@@ -1592,10 +1592,23 @@ static int gswip_get_sset_count(struct dsa_switch *ds, int port, int sset)
 	return ARRAY_SIZE(gswip_rmon_cnt);
 }
 
+static struct phylink_pcs *gswip_phylink_mac_select_pcs(struct phylink_config *config,
+							phy_interface_t interface)
+{
+	struct dsa_port *dp = dsa_phylink_to_port(config);
+	struct gswip_priv *priv = dp->ds->priv;
+
+	if (priv->hw_info->mac_select_pcs)
+		return priv->hw_info->mac_select_pcs(config, interface);
+
+	return NULL;
+}
+
 static const struct phylink_mac_ops gswip_phylink_mac_ops = {
-	.mac_config	= gswip_phylink_mac_config,
-	.mac_link_down	= gswip_phylink_mac_link_down,
-	.mac_link_up	= gswip_phylink_mac_link_up,
+	.mac_config		= gswip_phylink_mac_config,
+	.mac_link_down		= gswip_phylink_mac_link_down,
+	.mac_link_up		= gswip_phylink_mac_link_up,
+	.mac_select_pcs		= gswip_phylink_mac_select_pcs,
 };
 
 static const struct dsa_switch_ops gswip_switch_ops = {
drivers/net/dsa/lantiq/lantiq_gswip.h +3 -0
index 620c2d560cbe..19bbe6fddf04 100644
@@ -4,6 +4,7 @@
 
 #include <linux/clk.h>
 #include <linux/mutex.h>
+#include <linux/phylink.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
@@ -237,6 +238,8 @@ struct gswip_hw_info {
 	enum dsa_tag_protocol tag_protocol;
 	void (*phylink_get_caps)(struct dsa_switch *ds, int port,
 				 struct phylink_config *config);
+	struct phylink_pcs *(*mac_select_pcs)(struct phylink_config *config,
+					      phy_interface_t interface);
 };
 
 struct gswip_gphy_fw {
Signature · 1 line
2.51.0
#3 lore raw

PATCH v3 3/6 net: dsa: lantiq_gswip: ignore SerDes modes in phylink_mac_config()

In reply to Daniel Golle

We can safely ignore SerDes interface modes 1000Base-X, 2500Base-X and SGMII in phylink_mac_config() as they are being taken care of by the PCS and the SGMII port anyway doesn't have MII_CFG and MII_PCDU registers and hence gswip_phylink_mac_config() is already a no-op apart from outputing a misleading error message.

Return early in case of SerDes interface modes to avoid printing that error message.

---
v3: improve commit message
v2: no changes

 drivers/net/dsa/lantiq/lantiq_gswip.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/dsa/lantiq/lantiq_gswip.c +4 -0
index acb6996356e9..3e2a54569828 100644
@@ -1444,6 +1444,10 @@ static void gswip_phylink_mac_config(struct phylink_config *config,
 	miicfg |= GSWIP_MII_CFG_LDCLKDIS;
 
 	switch (state->interface) {
+	case PHY_INTERFACE_MODE_SGMII:
+	case PHY_INTERFACE_MODE_1000BASEX:
+	case PHY_INTERFACE_MODE_2500BASEX:
+		return;
 	case PHY_INTERFACE_MODE_MII:
 	case PHY_INTERFACE_MODE_INTERNAL:
 		miicfg |= GSWIP_MII_CFG_MODE_MIIM;
Signature · 1 line
2.51.0
#4 lore raw

PATCH v3 4/6 net: dsa: lantiq_gswip: support offset of MII registers

In reply to Daniel Golle

The MaxLinear GSW1xx family got a single (R)(G)MII port at index 5 but the registers MII_PCDU and MII_CFG are those of port 0. Allow applying an offset for the port index to access those registers.

---
v3: no changes
v2: no changes

 drivers/net/dsa/lantiq/lantiq_gswip.c | 14 ++++++++++++--
 drivers/net/dsa/lantiq/lantiq_gswip.h |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/dsa/lantiq/lantiq_gswip.c +12 -2
index 3e2a54569828..57441afa12e4 100644
@@ -183,21 +183,29 @@ static void gswip_mii_mask(struct gswip_priv *priv, u32 clear, u32 set,
 static void gswip_mii_mask_cfg(struct gswip_priv *priv, u32 clear, u32 set,
 			       int port)
 {
+	int reg_port;
+
 	/* MII_CFG register only exists for MII ports */
 	if (!(priv->hw_info->mii_ports & BIT(port)))
 		return;
 
-	gswip_mii_mask(priv, clear, set, GSWIP_MII_CFGp(port));
+	reg_port = port + priv->hw_info->mii_port_reg_offset;
+
+	gswip_mii_mask(priv, clear, set, GSWIP_MII_CFGp(reg_port));
 }
 
 static void gswip_mii_mask_pcdu(struct gswip_priv *priv, u32 clear, u32 set,
 				int port)
 {
+	int reg_port;
+
 	/* MII_PCDU register only exists for MII ports */
 	if (!(priv->hw_info->mii_ports & BIT(port)))
 		return;
 
-	switch (port) {
+	reg_port = port + priv->hw_info->mii_port_reg_offset;
+
+	switch (reg_port) {
 	case 0:
 		gswip_mii_mask(priv, clear, set, GSWIP_MII_PCDU0);
 		break;
@@ -2027,6 +2035,7 @@ static const struct gswip_hw_info gswip_xrx200 = {
 	.max_ports = 7,
 	.allowed_cpu_ports = BIT(6),
 	.mii_ports = BIT(0) | BIT(1) | BIT(5),
+	.mii_port_reg_offset = 0;
 	.phylink_get_caps = gswip_xrx200_phylink_get_caps,
 	.pce_microcode = &gswip_pce_microcode,
 	.pce_microcode_size = ARRAY_SIZE(gswip_pce_microcode),
@@ -2037,6 +2046,7 @@ static const struct gswip_hw_info gswip_xrx300 = {
 	.max_ports = 7,
 	.allowed_cpu_ports = BIT(6),
 	.mii_ports = BIT(0) | BIT(5),
+	.mii_port_reg_offset = 0;
 	.phylink_get_caps = gswip_xrx300_phylink_get_caps,
 	.pce_microcode = &gswip_pce_microcode,
 	.pce_microcode_size = ARRAY_SIZE(gswip_pce_microcode),
drivers/net/dsa/lantiq/lantiq_gswip.h +1 -0
index 19bbe6fddf04..2df9c8e8cfd0 100644
@@ -233,6 +233,7 @@ struct gswip_hw_info {
 	int max_ports;
 	unsigned int allowed_cpu_ports;
 	unsigned int mii_ports;
+	int mii_port_reg_offset;
 	const struct gswip_pce_microcode (*pce_microcode)[];
 	size_t pce_microcode_size;
 	enum dsa_tag_protocol tag_protocol;
Signature · 1 line
2.51.0
#5 lore raw

Re: [PATCH v3 4/6] net: dsa: lantiq_gswip: support offset of MII registers

Quoted 9 lines · Daniel Golle

The MaxLinear GSW1xx family got a single (R)(G)MII port at index 5 but the registers MII_PCDU and MII_CFG are those of port 0. Allow applying an offset for the port index to access those registers.

---
v3: no changes
v2: no changes

I forgot to include the change I made upon Hauke's request, and it's even wrong. Sorry for the noise. I will send v4 tomorrow...

Quoted 9 lines
drivers/net/dsa/lantiq/lantiq_gswip.c +1 -0
@@ -2027,6 +2035,7 @@ static const struct gswip_hw_info gswip_xrx200 = {
 	.max_ports = 7,
 	.allowed_cpu_ports = BIT(6),
 	.mii_ports = BIT(0) | BIT(1) | BIT(5),
+	.mii_port_reg_offset = 0;
 	.phylink_get_caps = gswip_xrx200_phylink_get_caps,
 	.pce_microcode = &gswip_pce_microcode,
 	.pce_microcode_size = ARRAY_SIZE(gswip_pce_microcode),

drivers/net/dsa/lantiq/lantiq_gswip.c static const struct gswip_hw_info gswip_xrx300 = { · line 2052

Quoted 7 lines
drivers/net/dsa/lantiq/lantiq_gswip.c +1 -0
@@ -2037,6 +2046,7 @@ static const struct gswip_hw_info gswip_xrx300 = {
 	.max_ports = 7,
 	.allowed_cpu_ports = BIT(6),
 	.mii_ports = BIT(0) | BIT(5),
+	.mii_port_reg_offset = 0;
 	.phylink_get_caps = gswip_xrx300_phylink_get_caps,
 	.pce_microcode = &gswip_pce_microcode,
 	.pce_microcode_size = ARRAY_SIZE(gswip_pce_microcode),

Both above will triger compiler error, should be ',' instead ';'.

#6 lore raw

PATCH v3 5/6 net: dsa: lantiq_gswip: support standard MDIO node name

In reply to Daniel Golle

Instead of matching against the child node's compatible string also support locating the node of the device tree node of the MDIO bus in the standard way by referencing the node name ("mdio").

---
v3: no changes
v2: no changes

 drivers/net/dsa/lantiq/lantiq_gswip.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/dsa/lantiq/lantiq_gswip.c +3 -0
index 57441afa12e4..2124ee061d05 100644
@@ -286,6 +286,9 @@ static int gswip_mdio(struct gswip_priv *priv)
 	int err = 0;
 
 	mdio_np = of_get_compatible_child(switch_np, "lantiq,xrx200-mdio");
+	if (!mdio_np)
+		mdio_np = of_get_child_by_name(switch_np, "mdio");
+
 	if (!of_device_is_available(mdio_np))
 		goto out_put_node;
 
Signature · 1 line
2.51.0
#7 lore raw

PATCH v3 6/6 net: dsa: lantiq_gswip: move MDIO bus registration to .setup()

In reply to Daniel Golle

Instead of registering the switch MDIO bus in the probe() function, move the call to gswip_mdio() into the .setup() DSA switch op, so it can be reused independently of the probe() function.

---
v3: no changes
v2: no changes

 drivers/net/dsa/lantiq/lantiq_gswip.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/dsa/lantiq/lantiq_gswip.c +7 -7
index 2124ee061d05..1d9b9689ef9f 100644
@@ -627,6 +627,13 @@ static int gswip_setup(struct dsa_switch *ds)
 	/* Configure the MDIO Clock 2.5 MHz */
 	gswip_mdio_mask(priv, 0xff, 0x09, GSWIP_MDIO_MDC_CFG1);
 
+	/* bring up the mdio bus */
+	err = gswip_mdio(priv);
+	if (err) {
+		dev_err(priv->dev, "mdio bus setup failed\n");
+		return err;
+	}
+
 	/* Disable the xMII interface and clear it's isolation bit */
 	for (i = 0; i < priv->hw_info->max_ports; i++)
 		gswip_mii_mask_cfg(priv,
@@ -1973,13 +1980,6 @@ static int gswip_probe(struct platform_device *pdev)
 					     "gphy fw probe failed\n");
 	}
 
-	/* bring up the mdio bus */
-	err = gswip_mdio(priv);
-	if (err) {
-		dev_err_probe(dev, err, "mdio probe failed\n");
-		goto gphy_fw_remove;
-	}
-
 	err = dsa_register_switch(priv->ds);
 	if (err) {
 		dev_err_probe(dev, err, "dsa switch registration failed\n");
Signature · 1 line
2.51.0
#8 lore raw
In reply to Daniel Golle
Quoted 18 lines · Daniel Golle

Continue to prepare for supporting the newer standalone MaxLinear GSW1xx switch family by extending the existing lantiq_gswip driver to allow it to support MII interfaces and MDIO bus of the GSW1xx.

This series has been preceded by an RFC series which covers everything needed to support the MaxLinear GSW1xx family of switches. Andrew Lunn had suggested to split it into a couple of smaller series and start with the changes which don't yet make actual functional changes or support new features.

Everything has been compile and runtime tested on AVM Fritz!Box 7490 (GSWIP version 2.1, VR9 v1.2)

v3: explicitly initialize mii_port_reg_offset to 0
v2: move lantiq_gswip driver to its own folder

Quoted 7 lines

Daniel Golle (6):
net: dsa: lantiq_gswip: move to dedicated folder
net: dsa: lantiq_gswip: support model-specific mac_select_pcs()
net: dsa: lantiq_gswip: ignore SerDes modes in phylink_mac_config()
net: dsa: lantiq_gswip: support offset of MII registers
net: dsa: lantiq_gswip: support standard MDIO node name
net: dsa: lantiq_gswip: move MDIO bus registration to .setup()

The whole series is intended for net-next, I messed up putting that into the subject line. Let me know if I should resend another time for that or if it is fine to go into net-next like that.

maintainer
#9 lore raw
Quoted 3 lines · On Fri, 29 Aug 2025 14:03:44 +0100 Daniel Golle wrote:

The whole series is intended for net-next, I messed up putting that into the subject line. Let me know if I should resend another time for that or if it is fine to go into net-next like that.

It's alright, FWIW. If all the changes are under drivers/net/ the CI will default to net-next.