Skip to contentSkip to conversation

net: dsa: add support for MT7988

PATCH In review Daniel Golle 4 participants 39 messages Mar 30, 2023 – Apr 3, 2023

Subsystems (6)
lore
Share & tools
lore

Daniel Golle

author maintainer
#0 lore raw

cover net: dsa: add support for MT7988

The MediaTek MT7988 SoC comes with a built-in switch very similar to previous MT7530 and MT7531. However, the switch address space is mapped into the SoCs memory space rather than being connected via MDIO. Using MMIO simplifies register access and also removes the need for a bus lock, and for that reason also makes interrupt handling more light-weight.

Note that this is different from previous SoCs like MT7621 and MT7623N which also came with an integrated MT7530-like switch which yet had to be accessed via MDIO.

Split-off the part of the driver registering an MDIO driver, then add another module acting as MMIO/platform driver.

The whole series has been tested on various MediaTek boards:
* MT7623A + MT7530 (BPi-R2)
* MT7986A + MT7531 (BPi-R3)
* MT7988A reference board

Changes since RFC v3:
* WARN_ON_ONCE if register read fails
* move probing of the reset GPIO and reset controller link out of common probe function, as they are not actually common

Changes since RFC v2:
* split into many small commits to ease review
* introduce helper functions to reduce code duplication
* use helpers for locking to make lock-skipping easier and less ugly to implement.
* add dt-bindings for mediatek,mt7988-switch

Changes since initial RFC:
* use regmap for register access and move register access to bus- specific driver
* move initialization of MT7531 SGMII PCS to MDIO driver

Daniel Golle (15):
net: dsa: mt7530: make some noise if register read fails
net: dsa: mt7530: refactor SGMII PCS creation
net: dsa: mt7530: use unlocked regmap accessors
net: dsa: mt7530: use regmap to access switch register space
net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function
net: dsa: mt7530: introduce mutex helpers
net: dsa: mt7530: move p5_intf_modes() function to mt7530.c
net: dsa: mt7530: introduce mt7530_probe_common helper function
net: dsa: mt7530: introduce mt7530_remove_common helper function
net: dsa: mt7530: split-off common parts from mt7531_setup
net: dsa: mt7530: introduce separate MDIO driver
net: dsa: mt7530: skip locking if MDIO bus isn't present
net: dsa: mt7530: add support for 10G link modes for CPU port
net: dsa: mt7530: introduce driver for MT7988 built-in switch
dt-bindings: net: dsa: mediatek,mt7530: add mediatek,mt7988-switch

 .../bindings/net/dsa/mediatek,mt7530.yaml     |  26 +-
 MAINTAINERS                                   |   3 +
 drivers/net/dsa/Kconfig                       |  28 +-
 drivers/net/dsa/Makefile                      |   4 +-
 drivers/net/dsa/mt7530-mdio.c                 | 271 ++++++++++
 drivers/net/dsa/mt7530-mmio.c                 | 101 ++++
 drivers/net/dsa/mt7530.c                      | 511 ++++++++----------
 drivers/net/dsa/mt7530.h                      |  38 +-
 8 files changed, 668 insertions(+), 314 deletions(-)
 create mode 100644 drivers/net/dsa/mt7530-mdio.c
 create mode 100644 drivers/net/dsa/mt7530-mmio.c

base-commit: 4ddd6375c3ef6756d492ea5466408cace097121b

Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH 1/15 net: dsa: mt7530: make some noise if register read fails

Simply returning the negative error value instead of the read value doesn't seem like a good idea. Return 0 instead and add WARN_ON_ONCE(1) so this kind of error will not go unnoticed.

---
 drivers/net/dsa/mt7530.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +2 -1
index a0d99af897ace..18d4aa6bb9968 100644
@@ -224,9 +224,10 @@ mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
 	/* MT7530 uses 31 as the pseudo port */
 	ret = bus->write(bus, 0x1f, 0x1f, page);
 	if (ret < 0) {
+		WARN_ON_ONCE(1);
 		dev_err(&bus->dev,
 			"failed to read mt7530 register\n");
-		return ret;
+		return 0;
 	}
 
 	lo = bus->read(bus, 0x1f, r);
Signature · 1 line
2.39.2
author maintainer
#3 lore raw

PATCH 2/15 net: dsa: mt7530: refactor SGMII PCS creation

In reply to Daniel Golle

Instead of macro templates use a dedidated function and allocated regmap_config when creating the regmaps for the pcs-mtk-lynxi instances.
This is in preparation to switching to use unlocked regmap accessors and have regmap's locking API handle locking for us.

---
 drivers/net/dsa/mt7530.c | 74 +++++++++++++++++++++++++++-------------
 1 file changed, 50 insertions(+), 24 deletions(-)
drivers/net/dsa/mt7530.c +50 -24
index 18d4aa6bb9968..5685c71bc9173 100644
@@ -2927,26 +2927,56 @@ static const struct regmap_bus mt7531_regmap_bus = {
 	.reg_update_bits = mt7530_regmap_update_bits,
 };
 
-#define MT7531_PCS_REGMAP_CONFIG(_name, _reg_base) \
-	{				\
-		.name = _name,		\
-		.reg_bits = 16,		\
-		.val_bits = 32,		\
-		.reg_stride = 4,	\
-		.reg_base = _reg_base,	\
-		.max_register = 0x17c,	\
-	}
-
-static const struct regmap_config mt7531_pcs_config[] = {
-	MT7531_PCS_REGMAP_CONFIG("port5", MT7531_SGMII_REG_BASE(5)),
-	MT7531_PCS_REGMAP_CONFIG("port6", MT7531_SGMII_REG_BASE(6)),
-};
+static int
+mt7531_create_sgmii(struct mt7530_priv *priv)
+{
+	struct regmap_config *mt7531_pcs_config[2];
+	struct phylink_pcs *pcs;
+	struct regmap *regmap;
+	int i, ret = 0;
+
+	for (i = 0; i < 2; i++) {
+		mt7531_pcs_config[i] = devm_kzalloc(priv->dev,
+						    sizeof(struct regmap_config),
+						    GFP_KERNEL);
+		if (!mt7531_pcs_config[i]) {
+			ret = -ENOMEM;
+			break;
+		}
+
+		mt7531_pcs_config[i]->name = i ? "port6" : "port5";
+		mt7531_pcs_config[i]->reg_bits = 16;
+		mt7531_pcs_config[i]->val_bits = 32;
+		mt7531_pcs_config[i]->reg_stride = 4;
+		mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
+		mt7531_pcs_config[i]->max_register = 0x17c;
+
+		regmap = devm_regmap_init(priv->dev,
+					  &mt7531_regmap_bus, priv,
+					  mt7531_pcs_config[i]);
+		if (IS_ERR(regmap)) {
+			ret = PTR_ERR(regmap);
+			break;
+		}
+		pcs = mtk_pcs_lynxi_create(priv->dev, regmap,
+					   MT7531_PHYA_CTRL_SIGNAL3, 0);
+		if (!pcs) {
+			ret = -ENXIO;
+			break;
+		}
+		priv->ports[5 + i].sgmii_pcs = pcs;
+	}
+
+	if (ret && i)
+		mtk_pcs_lynxi_destroy(priv->ports[5].sgmii_pcs);
+
+	return ret;
+}
 
 static int
 mt753x_setup(struct dsa_switch *ds)
 {
 	struct mt7530_priv *priv = ds->priv;
-	struct regmap *regmap;
 	int i, ret;
 
 	/* Initialise the PCS devices */
@@ -2968,15 +2998,11 @@ mt753x_setup(struct dsa_switch *ds)
 	if (ret && priv->irq)
 		mt7530_free_irq_common(priv);
 
-	if (priv->id == ID_MT7531)
-		for (i = 0; i < 2; i++) {
-			regmap = devm_regmap_init(ds->dev,
-						  &mt7531_regmap_bus, priv,
-						  &mt7531_pcs_config[i]);
-			priv->ports[5 + i].sgmii_pcs =
-				mtk_pcs_lynxi_create(ds->dev, regmap,
-						     MT7531_PHYA_CTRL_SIGNAL3, 0);
-		}
+	if (priv->id == ID_MT7531) {
+		ret = mt7531_create_sgmii(priv);
+		if (ret && priv->irq)
+			mt7530_free_irq_common(priv);
+	}
 
 	return ret;
 }
Signature · 1 line
2.39.2
author maintainer
#5 lore raw

PATCH 3/15 net: dsa: mt7530: use unlocked regmap accessors

In reply to Daniel Golle

Instead of wrapping the locked register accessor functions, use the unlocked variants and add locking wrapper functions to let regmap handle the locking.

This is a preparation towards being able to always use regmap to access switch registers instead of open-coded accessor functions.

---
 drivers/net/dsa/mt7530.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/net/dsa/mt7530.c +14 -9
index 5685c71bc9173..d8b041d79f2b7 100644
@@ -2900,7 +2900,7 @@ static int mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val
 {
 	struct mt7530_priv *priv = context;
 
-	*val = mt7530_read(priv, reg);
+	*val = mt7530_mii_read(priv, reg);
 	return 0;
 };
 
@@ -2908,23 +2908,25 @@ static int mt7530_regmap_write(void *context, unsigned int reg, unsigned int val
 {
 	struct mt7530_priv *priv = context;
 
-	mt7530_write(priv, reg, val);
+	mt7530_mii_write(priv, reg, val);
 	return 0;
 };
 
-static int mt7530_regmap_update_bits(void *context, unsigned int reg,
-				     unsigned int mask, unsigned int val)
+static void
+mt7530_mdio_regmap_lock(void *mdio_lock)
 {
-	struct mt7530_priv *priv = context;
+	mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED);
+}
 
-	mt7530_rmw(priv, reg, mask, val);
-	return 0;
-};
+static void
+mt7530_mdio_regmap_unlock(void *mdio_lock)
+{
+	mutex_unlock(mdio_lock);
+}
 
 static const struct regmap_bus mt7531_regmap_bus = {
 	.reg_write = mt7530_regmap_write,
 	.reg_read = mt7530_regmap_read,
-	.reg_update_bits = mt7530_regmap_update_bits,
 };
 
 static int
@@ -2950,6 +2952,9 @@ mt7531_create_sgmii(struct mt7530_priv *priv)
 		mt7531_pcs_config[i]->reg_stride = 4;
 		mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
 		mt7531_pcs_config[i]->max_register = 0x17c;
+		mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock;
+		mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
+		mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
 
 		regmap = devm_regmap_init(priv->dev,
 					  &mt7531_regmap_bus, priv,
Signature · 1 line
2.39.2
author maintainer
#7 lore raw

PATCH 4/15 net: dsa: mt7530: use regmap to access switch register space

In reply to Daniel Golle

Use regmap API to access the switch register space.

---
 drivers/net/dsa/mt7530.c | 91 +++++++++++++++++++++++++---------------
 drivers/net/dsa/mt7530.h |  2 +
 2 files changed, 60 insertions(+), 33 deletions(-)
drivers/net/dsa/mt7530.c +58 -33
index d8b041d79f2b7..e27a0e551cec0 100644
@@ -183,9 +183,9 @@ core_clear(struct mt7530_priv *priv, u32 reg, u32 val)
 }
 
 static int
-mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
+mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
 {
-	struct mii_bus *bus = priv->bus;
+	struct mii_bus *bus = context;
 	u16 page, r, lo, hi;
 	int ret;
 
@@ -197,24 +197,34 @@ mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
 	/* MT7530 uses 31 as the pseudo port */
 	ret = bus->write(bus, 0x1f, 0x1f, page);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	ret = bus->write(bus, 0x1f, r,  lo);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	ret = bus->write(bus, 0x1f, 0x10, hi);
-err:
+	return ret;
+}
+
+static int
+mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
+{
+	int ret;
+
+	ret = regmap_write(priv->regmap, reg, val);
+
 	if (ret < 0)
-		dev_err(&bus->dev,
+		dev_err(priv->dev,
 			"failed to write mt7530 register\n");
+
 	return ret;
 }
 
-static u32
-mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
+static int
+mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
 {
-	struct mii_bus *bus = priv->bus;
+	struct mii_bus *bus = context;
 	u16 page, r, lo, hi;
 	int ret;
 
@@ -223,17 +233,32 @@ mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
 
 	/* MT7530 uses 31 as the pseudo port */
 	ret = bus->write(bus, 0x1f, 0x1f, page);
-	if (ret < 0) {
+	if (ret < 0)
+		return ret;
+
+	lo = bus->read(bus, 0x1f, r);
+	hi = bus->read(bus, 0x1f, 0x10);
+
+	*val = (hi << 16) | (lo & 0xffff);
+
+	return 0;
+}
+
+static u32
+mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
+{
+	int ret;
+	u32 val;
+
+	ret = regmap_read(priv->regmap, reg, &val);
+	if (ret) {
 		WARN_ON_ONCE(1);
-		dev_err(&bus->dev,
+		dev_err(priv->dev,
 			"failed to read mt7530 register\n");
 		return 0;
 	}
 
-	lo = bus->read(bus, 0x1f, r);
-	hi = bus->read(bus, 0x1f, 0x10);
-
-	return (hi << 16) | (lo & 0xffff);
+	return val;
 }
 
 static void
@@ -2896,22 +2921,6 @@ static const struct phylink_pcs_ops mt7530_pcs_ops = {
 	.pcs_an_restart = mt7530_pcs_an_restart,
 };
 
-static int mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
-{
-	struct mt7530_priv *priv = context;
-
-	*val = mt7530_mii_read(priv, reg);
-	return 0;
-};
-
-static int mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
-{
-	struct mt7530_priv *priv = context;
-
-	mt7530_mii_write(priv, reg, val);
-	return 0;
-};
-
 static void
 mt7530_mdio_regmap_lock(void *mdio_lock)
 {
@@ -2924,7 +2933,7 @@ mt7530_mdio_regmap_unlock(void *mdio_lock)
 	mutex_unlock(mdio_lock);
 }
 
-static const struct regmap_bus mt7531_regmap_bus = {
+static const struct regmap_bus mt7530_regmap_bus = {
 	.reg_write = mt7530_regmap_write,
 	.reg_read = mt7530_regmap_read,
 };
@@ -2957,7 +2966,7 @@ mt7531_create_sgmii(struct mt7530_priv *priv)
 		mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
 
 		regmap = devm_regmap_init(priv->dev,
-					  &mt7531_regmap_bus, priv,
+					  &mt7530_regmap_bus, priv->bus,
 					  mt7531_pcs_config[i]);
 		if (IS_ERR(regmap)) {
 			ret = PTR_ERR(regmap);
@@ -3128,6 +3137,7 @@ MODULE_DEVICE_TABLE(of, mt7530_of_match);
 static int
 mt7530_probe(struct mdio_device *mdiodev)
 {
+	static struct regmap_config *regmap_config;
 	struct mt7530_priv *priv;
 	struct device_node *dn;
 
@@ -3207,6 +3217,21 @@ mt7530_probe(struct mdio_device *mdiodev)
 	mutex_init(&priv->reg_mutex);
 	dev_set_drvdata(&mdiodev->dev, priv);
 
+	regmap_config = devm_kzalloc(&mdiodev->dev, sizeof(*regmap_config),
+				     GFP_KERNEL);
+	if (!regmap_config)
+		return -ENOMEM;
+
+	regmap_config->reg_bits = 16;
+	regmap_config->val_bits = 32;
+	regmap_config->reg_stride = 4;
+	regmap_config->max_register = MT7530_CREV;
+	regmap_config->disable_locking = true;
+	priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus,
+					priv->bus, regmap_config);
+	if (IS_ERR(priv->regmap))
+		return PTR_ERR(priv->regmap);
+
 	return dsa_register_switch(priv->ds);
 }
 
drivers/net/dsa/mt7530.h +2 -0
index c5d29f3fc1d80..39aaca50961bd 100644
@@ -754,6 +754,7 @@ struct mt753x_info {
  * @dev:		The device pointer
  * @ds:			The pointer to the dsa core structure
  * @bus:		The bus used for the device and built-in PHY
+ * @regmap:		The regmap instance representing all switch registers
  * @rstc:		The pointer to reset control used by MCM
  * @core_pwr:		The power supplied into the core
  * @io_pwr:		The power supplied into the I/O
@@ -774,6 +775,7 @@ struct mt7530_priv {
 	struct device		*dev;
 	struct dsa_switch	*ds;
 	struct mii_bus		*bus;
+	struct regmap		*regmap;
 	struct reset_control	*rstc;
 	struct regulator	*core_pwr;
 	struct regulator	*io_pwr;
Signature · 1 line
2.39.2
author maintainer
#10 lore raw

PATCH 5/15 net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function

In reply to Daniel Golle

Move creating the SGMII PCS from mt753x_setup() to the more appropriate mt7530_probe() function.
This is done also in preparation of moving all functions related to MDIO-connected MT753x switches to a separate module.

---
 drivers/net/dsa/mt7530.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/dsa/mt7530.c +7 -6
index e27a0e551cec0..803809b430c85 100644
@@ -3012,12 +3012,6 @@ mt753x_setup(struct dsa_switch *ds)
 	if (ret && priv->irq)
 		mt7530_free_irq_common(priv);
 
-	if (priv->id == ID_MT7531) {
-		ret = mt7531_create_sgmii(priv);
-		if (ret && priv->irq)
-			mt7530_free_irq_common(priv);
-	}
-
 	return ret;
 }
 
@@ -3140,6 +3134,7 @@ mt7530_probe(struct mdio_device *mdiodev)
 	static struct regmap_config *regmap_config;
 	struct mt7530_priv *priv;
 	struct device_node *dn;
+	int ret;
 
 	dn = mdiodev->dev.of_node;
 
@@ -3232,6 +3227,12 @@ mt7530_probe(struct mdio_device *mdiodev)
 	if (IS_ERR(priv->regmap))
 		return PTR_ERR(priv->regmap);
 
+	if (priv->id == ID_MT7531) {
+		ret = mt7531_create_sgmii(priv);
+		if (ret)
+			return ret;
+	}
+
 	return dsa_register_switch(priv->ds);
 }
 
Signature · 1 line
2.39.2
author maintainer
#12 lore raw

PATCH 6/15 net: dsa: mt7530: introduce mutex helpers

In reply to Daniel Golle

As the MDIO bus lock only needs to be involved if actually operating on an MDIO-connected switch we will need to skip locking for built-in switches which are accessed via MMIO.
Create helper functions which simplify that upcoming change.

---
 drivers/net/dsa/mt7530.c | 72 ++++++++++++++++++++--------------------
 1 file changed, 36 insertions(+), 36 deletions(-)
drivers/net/dsa/mt7530.c +36 -36
index 803809b430c85..4fed18303673e 100644
@@ -143,31 +143,40 @@ core_write_mmd_indirect(struct mt7530_priv *priv, int prtad,
 }
 
 static void
-core_write(struct mt7530_priv *priv, u32 reg, u32 val)
+mt7530_mutex_lock(struct mt7530_priv *priv)
 {
-	struct mii_bus *bus = priv->bus;
+	mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
+}
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+static void
+mt7530_mutex_unlock(struct mt7530_priv *priv)
+{
+	mutex_unlock(&priv->bus->mdio_lock);
+}
+
+static void
+core_write(struct mt7530_priv *priv, u32 reg, u32 val)
+{
+	mt7530_mutex_lock(priv);
 
 	core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
 
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 }
 
 static void
 core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
 {
-	struct mii_bus *bus = priv->bus;
 	u32 val;
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	val = core_read_mmd_indirect(priv, reg, MDIO_MMD_VEND2);
 	val &= ~mask;
 	val |= set;
 	core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
 
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 }
 
 static void
@@ -264,13 +273,11 @@ mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
 static void
 mt7530_write(struct mt7530_priv *priv, u32 reg, u32 val)
 {
-	struct mii_bus *bus = priv->bus;
-
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	mt7530_mii_write(priv, reg, val);
 
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 }
 
 static u32
@@ -282,14 +289,13 @@ _mt7530_unlocked_read(struct mt7530_dummy_poll *p)
 static u32
 _mt7530_read(struct mt7530_dummy_poll *p)
 {
-	struct mii_bus		*bus = p->priv->bus;
 	u32 val;
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(p->priv);
 
 	val = mt7530_mii_read(p->priv, p->reg);
 
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(p->priv);
 
 	return val;
 }
@@ -307,17 +313,16 @@ static void
 mt7530_rmw(struct mt7530_priv *priv, u32 reg,
 	   u32 mask, u32 set)
 {
-	struct mii_bus *bus = priv->bus;
 	u32 val;
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	val = mt7530_mii_read(priv, reg);
 	val &= ~mask;
 	val |= set;
 	mt7530_mii_write(priv, reg, val);
 
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 }
 
 static void
@@ -661,14 +666,13 @@ static int
 mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad,
 			int regnum)
 {
-	struct mii_bus *bus = priv->bus;
 	struct mt7530_dummy_poll p;
 	u32 reg, val;
 	int ret;
 
 	INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
 				 !(val & MT7531_PHY_ACS_ST), 20, 100000);
@@ -701,7 +705,7 @@ mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad,
 
 	ret = val & MT7531_MDIO_RW_DATA_MASK;
 out:
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 
 	return ret;
 }
@@ -710,14 +714,13 @@ static int
 mt7531_ind_c45_phy_write(struct mt7530_priv *priv, int port, int devad,
 			 int regnum, u16 data)
 {
-	struct mii_bus *bus = priv->bus;
 	struct mt7530_dummy_poll p;
 	u32 val, reg;
 	int ret;
 
 	INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
 				 !(val & MT7531_PHY_ACS_ST), 20, 100000);
@@ -749,7 +752,7 @@ mt7531_ind_c45_phy_write(struct mt7530_priv *priv, int port, int devad,
 	}
 
 out:
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 
 	return ret;
 }
@@ -757,14 +760,13 @@ mt7531_ind_c45_phy_write(struct mt7530_priv *priv, int port, int devad,
 static int
 mt7531_ind_c22_phy_read(struct mt7530_priv *priv, int port, int regnum)
 {
-	struct mii_bus *bus = priv->bus;
 	struct mt7530_dummy_poll p;
 	int ret;
 	u32 val;
 
 	INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
 				 !(val & MT7531_PHY_ACS_ST), 20, 100000);
@@ -787,7 +789,7 @@ mt7531_ind_c22_phy_read(struct mt7530_priv *priv, int port, int regnum)
 
 	ret = val & MT7531_MDIO_RW_DATA_MASK;
 out:
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 
 	return ret;
 }
@@ -796,14 +798,13 @@ static int
 mt7531_ind_c22_phy_write(struct mt7530_priv *priv, int port, int regnum,
 			 u16 data)
 {
-	struct mii_bus *bus = priv->bus;
 	struct mt7530_dummy_poll p;
 	int ret;
 	u32 reg;
 
 	INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	ret = readx_poll_timeout(_mt7530_unlocked_read, &p, reg,
 				 !(reg & MT7531_PHY_ACS_ST), 20, 100000);
@@ -825,7 +826,7 @@ mt7531_ind_c22_phy_write(struct mt7530_priv *priv, int port, int regnum,
 	}
 
 out:
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 
 	return ret;
 }
@@ -1106,7 +1107,6 @@ static int
 mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 {
 	struct mt7530_priv *priv = ds->priv;
-	struct mii_bus *bus = priv->bus;
 	int length;
 	u32 val;
 
@@ -1117,7 +1117,7 @@ mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 	if (!dsa_is_cpu_port(ds, port))
 		return 0;
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 
 	val = mt7530_mii_read(priv, MT7530_GMACCR);
 	val &= ~MAX_RX_PKT_LEN_MASK;
@@ -1138,7 +1138,7 @@ mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 
 	mt7530_mii_write(priv, MT7530_GMACCR, val);
 
-	mutex_unlock(&bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 
 	return 0;
 }
@@ -1939,10 +1939,10 @@ mt7530_irq_thread_fn(int irq, void *dev_id)
 	u32 val;
 	int p;
 
-	mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 	val = mt7530_mii_read(priv, MT7530_SYS_INT_STS);
 	mt7530_mii_write(priv, MT7530_SYS_INT_STS, val);
-	mutex_unlock(&priv->bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 
 	for (p = 0; p < MT7530_NUM_PHYS; p++) {
 		if (BIT(p) & val) {
@@ -1978,7 +1978,7 @@ mt7530_irq_bus_lock(struct irq_data *d)
 {
 	struct mt7530_priv *priv = irq_data_get_irq_chip_data(d);
 
-	mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
+	mt7530_mutex_lock(priv);
 }
 
 static void
@@ -1987,7 +1987,7 @@ mt7530_irq_bus_sync_unlock(struct irq_data *d)
 	struct mt7530_priv *priv = irq_data_get_irq_chip_data(d);
 
 	mt7530_mii_write(priv, MT7530_SYS_INT_EN, priv->irq_enable);
-	mutex_unlock(&priv->bus->mdio_lock);
+	mt7530_mutex_unlock(priv);
 }
 
 static struct irq_chip mt7530_irq_chip = {
Signature · 1 line
2.39.2
author maintainer
#13 lore raw

PATCH 7/15 net: dsa: mt7530: move p5_intf_modes() function to mt7530.c

In reply to Daniel Golle

In preparation of splitting mt7530.c into a driver for MDIO-connected as well as MDIO-accessed built-in switches on one hand and MMIO-accessed built-in switches move the p5_inft_modes() function from mt7530.h to mt7530.c. The function is only needed there and will trigger a compiler warning about a defined but unused function otherwise when including mt7530.h in the to-be-introduced bus-specific drivers.

---
 drivers/net/dsa/mt7530.c | 18 ++++++++++++++++++
 drivers/net/dsa/mt7530.h | 18 ------------------
 2 files changed, 18 insertions(+), 18 deletions(-)
drivers/net/dsa/mt7530.c +18 -0
index 4fed18303673e..4993e36c2f507 100644
@@ -948,6 +948,24 @@ mt7530_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
 	return 0;
 }
 
+static const char *p5_intf_modes(unsigned int p5_interface)
+{
+	switch (p5_interface) {
+	case P5_DISABLED:
+		return "DISABLED";
+	case P5_INTF_SEL_PHY_P0:
+		return "PHY P0";
+	case P5_INTF_SEL_PHY_P4:
+		return "PHY P4";
+	case P5_INTF_SEL_GMAC5:
+		return "GMAC5";
+	case P5_INTF_SEL_GMAC5_SGMII:
+		return "GMAC5_SGMII";
+	default:
+		return "unknown";
+	}
+}
+
 static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
 {
 	struct mt7530_priv *priv = ds->priv;
drivers/net/dsa/mt7530.h +0 -18
index 39aaca50961bd..2a611173a7d08 100644
@@ -682,24 +682,6 @@ enum p5_interface_select {
 	P5_INTF_SEL_GMAC5_SGMII,
 };
 
-static const char *p5_intf_modes(unsigned int p5_interface)
-{
-	switch (p5_interface) {
-	case P5_DISABLED:
-		return "DISABLED";
-	case P5_INTF_SEL_PHY_P0:
-		return "PHY P0";
-	case P5_INTF_SEL_PHY_P4:
-		return "PHY P4";
-	case P5_INTF_SEL_GMAC5:
-		return "GMAC5";
-	case P5_INTF_SEL_GMAC5_SGMII:
-		return "GMAC5_SGMII";
-	default:
-		return "unknown";
-	}
-}
-
 struct mt7530_priv;
 
 struct mt753x_pcs {
Signature · 1 line
2.39.2
author maintainer
#14 lore raw

PATCH 8/15 net: dsa: mt7530: introduce mt7530_probe_common helper function

In reply to Daniel Golle

Move commonly used parts from mt7530_probe into new mt7530_probe_common helper function which will be used by both, mt7530_probe and the to-be-introduced mt7988_probe.

---
 drivers/net/dsa/mt7530.c | 98 ++++++++++++++++++++++------------------
 1 file changed, 54 insertions(+), 44 deletions(-)
drivers/net/dsa/mt7530.c +54 -44
index 4993e36c2f507..b3a9eb40e45a9 100644
@@ -3147,44 +3147,21 @@ static const struct of_device_id mt7530_of_match[] = {
 MODULE_DEVICE_TABLE(of, mt7530_of_match);
 
 static int
-mt7530_probe(struct mdio_device *mdiodev)
+mt7530_probe_common(struct mt7530_priv *priv)
 {
-	static struct regmap_config *regmap_config;
-	struct mt7530_priv *priv;
-	struct device_node *dn;
-	int ret;
-
-	dn = mdiodev->dev.of_node;
-
-	priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
+	struct device *dev = priv->dev;
 
-	priv->ds = devm_kzalloc(&mdiodev->dev, sizeof(*priv->ds), GFP_KERNEL);
+	priv->ds = devm_kzalloc(dev, sizeof(*priv->ds), GFP_KERNEL);
 	if (!priv->ds)
 		return -ENOMEM;
 
-	priv->ds->dev = &mdiodev->dev;
+	priv->ds->dev = dev;
 	priv->ds->num_ports = MT7530_NUM_PORTS;
 
-	/* Use medatek,mcm property to distinguish hardware type that would
-	 * casues a little bit differences on power-on sequence.
-	 */
-	priv->mcm = of_property_read_bool(dn, "mediatek,mcm");
-	if (priv->mcm) {
-		dev_info(&mdiodev->dev, "MT7530 adapts as multi-chip module\n");
-
-		priv->rstc = devm_reset_control_get(&mdiodev->dev, "mcm");
-		if (IS_ERR(priv->rstc)) {
-			dev_err(&mdiodev->dev, "Couldn't get our reset line\n");
-			return PTR_ERR(priv->rstc);
-		}
-	}
-
 	/* Get the hardware identifier from the devicetree node.
 	 * We will need it for some of the clock and regulator setup.
 	 */
-	priv->info = of_device_get_match_data(&mdiodev->dev);
+	priv->info = of_device_get_match_data(dev);
 	if (!priv->info)
 		return -EINVAL;
 
@@ -3198,23 +3175,53 @@ mt7530_probe(struct mdio_device *mdiodev)
 		return -EINVAL;
 
 	priv->id = priv->info->id;
+	priv->dev = dev;
+	priv->ds->priv = priv;
+	priv->ds->ops = &mt7530_switch_ops;
+	mutex_init(&priv->reg_mutex);
+	dev_set_drvdata(dev, priv);
 
-	if (priv->id == ID_MT7530) {
-		priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
-		if (IS_ERR(priv->core_pwr))
-			return PTR_ERR(priv->core_pwr);
+	return 0;
+}
 
-		priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
-		if (IS_ERR(priv->io_pwr))
-			return PTR_ERR(priv->io_pwr);
-	}
+static int
+mt7530_probe(struct mdio_device *mdiodev)
+{
+	static struct regmap_config *regmap_config;
+	struct mt7530_priv *priv;
+	struct device_node *dn;
+	int ret;
+
+	dn = mdiodev->dev.of_node;
 
-	/* Not MCM that indicates switch works as the remote standalone
+	priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->bus = mdiodev->bus;
+	priv->dev = &mdiodev->dev;
+
+	ret = mt7530_probe_common(priv);
+	if (ret)
+		return ret;
+
+	/* Use medatek,mcm property to distinguish hardware type that would
+	 * cause a little bit differences on power-on sequence.
+	 * Not MCM that indicates switch works as the remote standalone
 	 * integrated circuit so the GPIO pin would be used to complete
 	 * the reset, otherwise memory-mapped register accessing used
 	 * through syscon provides in the case of MCM.
 	 */
-	if (!priv->mcm) {
+	priv->mcm = of_property_read_bool(dn, "mediatek,mcm");
+	if (priv->mcm) {
+		dev_info(&mdiodev->dev, "MT7530 adapts as multi-chip module\n");
+
+		priv->rstc = devm_reset_control_get(&mdiodev->dev, "mcm");
+		if (IS_ERR(priv->rstc)) {
+			dev_err(&mdiodev->dev, "Couldn't get our reset line\n");
+			return PTR_ERR(priv->rstc);
+		}
+	} else {
 		priv->reset = devm_gpiod_get_optional(&mdiodev->dev, "reset",
 						      GPIOD_OUT_LOW);
 		if (IS_ERR(priv->reset)) {
@@ -3223,12 +3230,15 @@ mt7530_probe(struct mdio_device *mdiodev)
 		}
 	}
 
-	priv->bus = mdiodev->bus;
-	priv->dev = &mdiodev->dev;
-	priv->ds->priv = priv;
-	priv->ds->ops = &mt7530_switch_ops;
-	mutex_init(&priv->reg_mutex);
-	dev_set_drvdata(&mdiodev->dev, priv);
+	if (priv->id == ID_MT7530) {
+		priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
+		if (IS_ERR(priv->core_pwr))
+			return PTR_ERR(priv->core_pwr);
+
+		priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
+		if (IS_ERR(priv->io_pwr))
+			return PTR_ERR(priv->io_pwr);
+	}
 
 	regmap_config = devm_kzalloc(&mdiodev->dev, sizeof(*regmap_config),
 				     GFP_KERNEL);
Signature · 1 line
2.39.2
author maintainer
#15 lore raw

PATCH 9/15 net: dsa: mt7530: introduce mt7530_remove_common helper function

In reply to Daniel Golle

Move commonly used parts from mt7530_remove into new mt7530_remove_common helper function which will be used by both, mt7530_remove and the to-be-introduced mt7988_remove.

---
 drivers/net/dsa/mt7530.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/dsa/mt7530.c +12 -6
index b3a9eb40e45a9..de2fa5df9332c 100644
@@ -3264,6 +3264,17 @@ mt7530_probe(struct mdio_device *mdiodev)
 	return dsa_register_switch(priv->ds);
 }
 
+static void
+mt7530_remove_common(struct mt7530_priv *priv)
+{
+	if (priv->irq)
+		mt7530_free_irq(priv);
+
+	dsa_unregister_switch(priv->ds);
+
+	mutex_destroy(&priv->reg_mutex);
+}
+
 static void
 mt7530_remove(struct mdio_device *mdiodev)
 {
@@ -3283,15 +3294,10 @@ mt7530_remove(struct mdio_device *mdiodev)
 		dev_err(priv->dev, "Failed to disable io pwr: %d\n",
 			ret);
 
-	if (priv->irq)
-		mt7530_free_irq(priv);
-
-	dsa_unregister_switch(priv->ds);
+	mt7530_remove_common(priv);
 
 	for (i = 0; i < 2; ++i)
 		mtk_pcs_lynxi_destroy(priv->ports[5 + i].sgmii_pcs);
-
-	mutex_destroy(&priv->reg_mutex);
 }
 
 static void mt7530_shutdown(struct mdio_device *mdiodev)
Signature · 1 line
2.39.2
author maintainer
#16 lore raw

PATCH 10/15 net: dsa: mt7530: split-off common parts from mt7531_setup

In reply to Daniel Golle

MT7988 shares a significant part of the setup function with MT7531. Split-off those parts into a shared function which is going to be used also by mt7988_setup.

---
 drivers/net/dsa/mt7530.c | 99 ++++++++++++++++++++++------------------
 1 file changed, 55 insertions(+), 44 deletions(-)
drivers/net/dsa/mt7530.c +55 -44
index de2fa5df9332c..26657c93d750b 100644
@@ -2352,12 +2352,65 @@ mt7530_setup(struct dsa_switch *ds)
 	return 0;
 }
 
+static int
+mt7531_setup_common(struct dsa_switch *ds)
+{
+	struct mt7530_priv *priv = ds->priv;
+	struct dsa_port *cpu_dp;
+	int ret, i;
+
+	/* BPDU to CPU port */
+	dsa_switch_for_each_cpu_port(cpu_dp, ds) {
+		mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK,
+			   BIT(cpu_dp->index));
+		break;
+	}
+	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
+		   MT753X_BPDU_CPU_ONLY);
+
+	/* Enable and reset MIB counters */
+	mt7530_mib_reset(ds);
+
+	for (i = 0; i < MT7530_NUM_PORTS; i++) {
+		/* Disable forwarding by default on all ports */
+		mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
+			   PCR_MATRIX_CLR);
+
+		/* Disable learning by default on all ports */
+		mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
+
+		mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR);
+
+		if (dsa_is_cpu_port(ds, i)) {
+			ret = mt753x_cpu_port_enable(ds, i);
+			if (ret)
+				return ret;
+		} else {
+			mt7530_port_disable(ds, i);
+
+			/* Set default PVID to 0 on all user ports */
+			mt7530_rmw(priv, MT7530_PPBV1_P(i), G0_PORT_VID_MASK,
+				   G0_PORT_VID_DEF);
+		}
+
+		/* Enable consistent egress tag */
+		mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK,
+			   PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
+	}
+
+	/* Flush the FDB table */
+	ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
 static int
 mt7531_setup(struct dsa_switch *ds)
 {
 	struct mt7530_priv *priv = ds->priv;
 	struct mt7530_dummy_poll p;
-	struct dsa_port *cpu_dp;
 	u32 val, id;
 	int ret, i;
 
@@ -2435,44 +2488,7 @@ mt7531_setup(struct dsa_switch *ds)
 	mt7531_ind_c45_phy_write(priv, MT753X_CTRL_PHY_ADDR, MDIO_MMD_VEND2,
 				 CORE_PLL_GROUP4, val);
 
-	/* BPDU to CPU port */
-	dsa_switch_for_each_cpu_port(cpu_dp, ds) {
-		mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK,
-			   BIT(cpu_dp->index));
-		break;
-	}
-	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
-		   MT753X_BPDU_CPU_ONLY);
-
-	/* Enable and reset MIB counters */
-	mt7530_mib_reset(ds);
-
-	for (i = 0; i < MT7530_NUM_PORTS; i++) {
-		/* Disable forwarding by default on all ports */
-		mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
-			   PCR_MATRIX_CLR);
-
-		/* Disable learning by default on all ports */
-		mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
-
-		mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR);
-
-		if (dsa_is_cpu_port(ds, i)) {
-			ret = mt753x_cpu_port_enable(ds, i);
-			if (ret)
-				return ret;
-		} else {
-			mt7530_port_disable(ds, i);
-
-			/* Set default PVID to 0 on all user ports */
-			mt7530_rmw(priv, MT7530_PPBV1_P(i), G0_PORT_VID_MASK,
-				   G0_PORT_VID_DEF);
-		}
-
-		/* Enable consistent egress tag */
-		mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK,
-			   PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
-	}
+	mt7531_setup_common(ds);
 
 	/* Setup VLAN ID 0 for VLAN-unaware bridges */
 	ret = mt7530_setup_vlan0(priv);
@@ -2482,11 +2498,6 @@ mt7531_setup(struct dsa_switch *ds)
 	ds->assisted_learning_on_cpu_port = true;
 	ds->mtu_enforcement_ingress = true;
 
-	/* Flush the FDB table */
-	ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
-	if (ret < 0)
-		return ret;
-
 	return 0;
 }
 
Signature · 1 line
2.39.2
author maintainer
#17 lore raw

PATCH 11/15 net: dsa: mt7530: introduce separate MDIO driver

In reply to Daniel Golle

Split MT7530 switch driver into a common part and a part specific for MDIO connected switches and multi-chip modules.
Move MDIO-specific functions to newly introduced mt7530-mdio.c while keeping the common parts in mt7530.c.
In order to maintain compatibility with existing kernel configurations keep CONFIG_NET_DSA_MT7530 as symbol to select the MDIO-specific driver while the newly introduced hidden symbol CONFIG_NET_DSA_MT7530_COMMON is selected by CONFIG_NET_DSA_MT7530.

---
 MAINTAINERS                   |   1 +
 drivers/net/dsa/Kconfig       |  16 +-
 drivers/net/dsa/Makefile      |   3 +-
 drivers/net/dsa/mt7530-mdio.c | 271 ++++++++++++++++++++++++++++++++++
 drivers/net/dsa/mt7530.c      | 263 +--------------------------------
 drivers/net/dsa/mt7530.h      |   6 +
 6 files changed, 300 insertions(+), 260 deletions(-)
 create mode 100644 drivers/net/dsa/mt7530-mdio.c
MAINTAINERS +1 -0
index 91201c2b81908..14924aed15ca7 100644
@@ -13176,6 +13176,7 @@ M:	Landen Chao <[email protected]>
 M:	DENG Qingfang <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	drivers/net/dsa/mt7530-mdio.c
 F:	drivers/net/dsa/mt7530.*
 F:	net/dsa/tag_mtk.c
 
drivers/net/dsa/Kconfig +12 -4
index 6b45fa8b69078..c2551b13324c2 100644
@@ -34,15 +34,23 @@ config NET_DSA_LANTIQ_GSWIP
 	  This enables support for the Lantiq / Intel GSWIP 2.1 found in
 	  the xrx200 / VR9 SoC.
 
-config NET_DSA_MT7530
-	tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
+config NET_DSA_MT7530_COMMON
+	tristate
 	select NET_DSA_TAG_MTK
 	select MEDIATEK_GE_PHY
+	help
+	  This enables support for the common parts of MediaTek Ethernet
+	  switch chips.
+
+config NET_DSA_MT7530
+	tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
+	select NET_DSA_MT7530_COMMON
 	select PCS_MTK_LYNXI
 	help
 	  This enables support for the MediaTek MT7530 and MT7531 Ethernet
-	  switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT,
-	  MT7621ST and MT7623AI SoCs is supported.
+	  switch chips which are connected via MDIO.
+	  Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and
+	  MT7623AI SoCs is supported as well.
 
 config NET_DSA_MV88E6060
 	tristate "Marvell 88E6060 ethernet switch chip support"
drivers/net/dsa/Makefile +2 -1
index 16eb879e0cb4d..71250d7dd41af 100644
@@ -6,7 +6,8 @@ ifdef CONFIG_NET_DSA_LOOP
 obj-$(CONFIG_FIXED_PHY)		+= dsa_loop_bdinfo.o
 endif
 obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
-obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530.o
+obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o
+obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530-mdio.o
 obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
 obj-$(CONFIG_NET_DSA_RZN1_A5PSW) += rzn1_a5psw.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
drivers/net/dsa/mt7530-mdio.c new file +271 -0

271 lines not on this page · raw message

drivers/net/dsa/mt7530.c +8 -255

314 lines not on this page · raw message

drivers/net/dsa/mt7530.h +6 -0
index 2a611173a7d08..ce02aa592a7a8 100644
@@ -814,4 +814,10 @@ static inline void INIT_MT7530_DUMMY_POLL(struct mt7530_dummy_poll *p,
 	p->reg = reg;
 }
 
+int mt7530_probe_common(struct mt7530_priv *priv);
+void mt7530_remove_common(struct mt7530_priv *priv);
+
+extern const struct dsa_switch_ops mt7530_switch_ops;
+extern const struct mt753x_info mt753x_table[];
+
 #endif /* __MT7530_H */
Signature · 1 line
2.39.2
author maintainer
#18 lore raw

PATCH 12/15 net: dsa: mt7530: skip locking if MDIO bus isn't present

In reply to Daniel Golle

As MT7530 and MT7531 internally use 32-bit wide registers, each access to any register of the switch requires several operations on the MDIO bus. Hence if there is congruent access, e.g. due to PCS or PHY polling, this can mess up and interfere with another ongoing register access sequence.

However, the MDIO bus mutex is only relevant for MDIO-connected switches. Prepare switches which have there registers directly mapped into the SoCs register space via MMIO which do not require such locking. There we can simply use regmap's default locking mechanism.

Hence guard mutex operations to only be performed in case of MDIO connected switches.

---
 drivers/net/dsa/mt7530.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/dsa/mt7530.c +4 -2
index ea8d8e669aacc..3a4682e71e746 100644
@@ -145,13 +145,15 @@ core_write_mmd_indirect(struct mt7530_priv *priv, int prtad,
 static void
 mt7530_mutex_lock(struct mt7530_priv *priv)
 {
-	mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
+	if (priv->bus)
+		mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
 }
 
 static void
 mt7530_mutex_unlock(struct mt7530_priv *priv)
 {
-	mutex_unlock(&priv->bus->mdio_lock);
+	if (priv->bus)
+		mutex_unlock(&priv->bus->mdio_lock);
 }
 
 static void
Signature · 1 line
2.39.2
author maintainer
#19 lore raw

PATCH 13/15 net: dsa: mt7530: add support for 10G link modes for CPU port

In reply to Daniel Golle

The built-in switch of the MT7988 SoC is internally connected using a stateless 10G link. Add support for 10G interface modes to silence a warning otherwise occurring when the switch driver is setup.

---
 drivers/net/dsa/mt7530.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +6 -1
index 3a4682e71e746..ac666da2d10dc 100644
@@ -2618,6 +2618,9 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
 	case PHY_INTERFACE_MODE_1000BASEX:
 	case PHY_INTERFACE_MODE_2500BASEX:
 		/* handled in SGMII PCS driver */
+	case PHY_INTERFACE_MODE_USXGMII:
+	case PHY_INTERFACE_MODE_10GKR:
+		/* internal stateless 10G link */
 		return 0;
 	default:
 		return -EINVAL;
@@ -2741,7 +2744,9 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
 	 * variants.
 	 */
 	if (interface == PHY_INTERFACE_MODE_TRGMII ||
-	    (phy_interface_mode_is_8023z(interface))) {
+	    interface == PHY_INTERFACE_MODE_USXGMII ||
+	    interface == PHY_INTERFACE_MODE_10GKR ||
+	    phy_interface_mode_is_8023z(interface)) {
 		speed = SPEED_1000;
 		duplex = DUPLEX_FULL;
 	}
Signature · 1 line
2.39.2
author maintainer
#22 lore raw

PATCH 14/15 net: dsa: mt7530: introduce driver for MT7988 built-in switch

In reply to Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
 MAINTAINERS                   |   2 +
 drivers/net/dsa/Kconfig       |  12 ++++
 drivers/net/dsa/Makefile      |   1 +
 drivers/net/dsa/mt7530-mmio.c | 101 ++++++++++++++++++++++++++++++++++
 drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++-
 drivers/net/dsa/mt7530.h      |  12 ++--
 6 files changed, 206 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/dsa/mt7530-mmio.c
MAINTAINERS +2 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER
 M:	Sean Wang <[email protected]>
 M:	Landen Chao <[email protected]>
 M:	DENG Qingfang <[email protected]>
+M:	Daniel Golle <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	drivers/net/dsa/mt7530-mdio.c
+F:	drivers/net/dsa/mt7530-mmio.c
 F:	drivers/net/dsa/mt7530.*
 F:	net/dsa/tag_mtk.c
 
drivers/net/dsa/Kconfig +12 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530
 	  Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and
 	  MT7623AI SoCs is supported as well.
 
+config NET_DSA_MT7988
+	tristate "MediaTek MT7988 built-in Ethernet switch support"
+	select NET_DSA_MT7530_COMMON
+	depends on HAS_IOMEM
+	help
+	  This enables support for the built-in Ethernet switch found
+	  in the MediaTek MT7988 SoC.
+	  The switch is a similar design as MT7531, however, unlike
+	  other MT7530 and MT7531 the switch registers are directly
+	  mapped into the SoCs register space rather than being accessible
+	  via MDIO.
+
 config NET_DSA_MV88E6060
 	tristate "Marvell 88E6060 ethernet switch chip support"
 	select NET_DSA_TAG_TRAILER
drivers/net/dsa/Makefile +1 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
 obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
 obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o
 obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530-mdio.o
+obj-$(CONFIG_NET_DSA_MT7988)	+= mt7530-mmio.o
 obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
 obj-$(CONFIG_NET_DSA_RZN1_A5PSW) += rzn1_a5psw.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
drivers/net/dsa/mt7530-mmio.c new file +101 -0

101 lines not on this page · raw message

drivers/net/dsa/mt7530.c +84 -2

110 lines not on this page · raw message

drivers/net/dsa/mt7530.h +6 -6
index ce02aa592a7a8..01db5c9724fa8 100644
@@ -18,6 +18,7 @@ enum mt753x_id {
 	ID_MT7530 = 0,
 	ID_MT7621 = 1,
 	ID_MT7531 = 2,
+	ID_MT7988 = 3,
 };
 
 #define	NUM_TRGMII_CTRL			5
@@ -54,11 +55,11 @@ enum mt753x_id {
 #define  MT7531_MIRROR_PORT_SET(x)	(((x) & MIRROR_MASK) << 16)
 #define  MT7531_CPU_PMAP_MASK		GENMASK(7, 0)
 
-#define MT753X_MIRROR_REG(id)		(((id) == ID_MT7531) ? \
+#define MT753X_MIRROR_REG(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
 					 MT7531_CFC : MT7530_MFC)
-#define MT753X_MIRROR_EN(id)		(((id) == ID_MT7531) ? \
+#define MT753X_MIRROR_EN(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
 					 MT7531_MIRROR_EN : MIRROR_EN)
-#define MT753X_MIRROR_MASK(id)		(((id) == ID_MT7531) ? \
+#define MT753X_MIRROR_MASK(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
 					 MT7531_MIRROR_MASK : MIRROR_MASK)
 
 /* Registers for BPDU and PAE frame control*/
@@ -295,9 +296,8 @@ enum mt7530_vlan_port_acc_frm {
 					 MT7531_FORCE_DPX | \
 					 MT7531_FORCE_RX_FC | \
 					 MT7531_FORCE_TX_FC)
-#define  PMCR_FORCE_MODE_ID(id)		(((id) == ID_MT7531) ? \
-					 MT7531_FORCE_MODE : \
-					 PMCR_FORCE_MODE)
+#define  PMCR_FORCE_MODE_ID(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
+					 MT7531_FORCE_MODE : PMCR_FORCE_MODE)
 #define  PMCR_LINK_SETTINGS_MASK	(PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
 					 PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
 					 PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
Signature · 1 line
2.39.2
author maintainer
#35 lore raw

PATCH 15/15 dt-bindings: net: dsa: mediatek,mt7530: add mediatek,mt7988-switch

In reply to Daniel Golle

Add documentation for the built-in switch which can be found in the MediaTek MT7988 SoC.

---
 .../bindings/net/dsa/mediatek,mt7530.yaml     | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +24 -2
index 5ae9cd8f99a24..15953f0e9d1a6 100644
@@ -11,16 +11,23 @@ maintainers:
   - Landen Chao <[email protected]>
   - DENG Qingfang <[email protected]>
   - Sean Wang <[email protected]>
+  - Daniel Golle <[email protected]>
 
 description: |
-  There are two versions of MT7530, standalone and in a multi-chip module.
+  There are three versions of MT7530, standalone, in a multi-chip module and
+  built-into a SoC.
 
   MT7530 is a part of the multi-chip module in MT7620AN, MT7620DA, MT7620DAN,
   MT7620NN, MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs.
 
+  The MT7988 SoC comes a built-in switch similar to MT7531 as well as 4 Gigabit
+  Ethernet PHYs and the switch registers are directly mapped into SoC's memory
+  map rather than using MDIO. It comes with an internally connected 10G CPU port
+  and 4 user ports connected to the built-in Gigabit Ethernet PHYs.
+
   MT7530 in MT7620AN, MT7620DA, MT7620DAN and MT7620NN SoCs has got 10/100 PHYs
   and the switch registers are directly mapped into SoC's memory map rather than
-  using MDIO. The DSA driver currently doesn't support this.
+  using MDIO. The DSA driver currently doesn't support MT7620 variants.
 
   There is only the standalone version of MT7531.
 
@@ -81,6 +88,10 @@ properties:
           Multi-chip module MT7530 in MT7621AT, MT7621DAT and MT7621ST SoCs
         const: mediatek,mt7621
 
+      - description:
+          Built-in switch of the MT7988 SoC
+        const: mediatek,mt7988-switch
+
   reg:
     maxItems: 1
 
@@ -268,6 +279,17 @@ allOf:
       required:
         - mediatek,mcm
 
+  - if:
+      properties:
+        compatible:
+          const: mediatek,mt7988-switch
+    then:
+      $ref: "#/$defs/mt7530-dsa-port"
+      properties:
+        gpio-controller: false
+        mediatek,mcm: false
+        reset-names: false
+
 unevaluatedProperties: false
 
 examples:
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 1/15
#2 lore raw

Re: [PATCH net-next 01/15] net: dsa: mt7530: make some noise if register read fails

In reply to Daniel Golle
Quoted 6 lines · Daniel Golle

Simply returning the negative error value instead of the read value doesn't seem like a good idea. Return 0 instead and add WARN_ON_ONCE(1) so this kind of error will not go unnoticed.

Andrew

maintainer Reviewed-by on v1 2/15
#4 lore raw

Re: [PATCH net-next 02/15] net: dsa: mt7530: refactor SGMII PCS creation

In reply to Daniel Golle
Quoted 7 lines · Daniel Golle

Instead of macro templates use a dedidated function and allocated regmap_config when creating the regmaps for the pcs-mtk-lynxi instances.
This is in preparation to switching to use unlocked regmap accessors and have regmap's locking API handle locking for us.

Andrew

maintainer Reviewed-by on v1 3/15
#6 lore raw

Re: [PATCH net-next 03/15] net: dsa: mt7530: use unlocked regmap accessors

In reply to Daniel Golle
Quoted 8 lines · Daniel Golle

Instead of wrapping the locked register accessor functions, use the unlocked variants and add locking wrapper functions to let regmap handle the locking.

This is a preparation towards being able to always use regmap to access switch registers instead of open-coded accessor functions.

Andrew

maintainer Reviewed-by on v1 5/15
#11 lore raw

Re: [PATCH net-next 05/15] net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function

In reply to Daniel Golle
Quoted 6 lines · Daniel Golle

Move creating the SGMII PCS from mt753x_setup() to the more appropriate mt7530_probe() function.
This is done also in preparation of moving all functions related to MDIO-connected MT753x switches to a separate module.

Andrew

maintainer Reviewed-by on v1 14/15
#23 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

In reply to Daniel Golle
Quoted 10 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

Andrew

author maintainer
#9 lore raw

Re: [PATCH net-next 04/15] net: dsa: mt7530: use regmap to access switch register space

In reply to Daniel Golle
Quoted 1 line · Daniel Golle

Use regmap API to access the switch register space.

I missed to make use of regmap_update_bits in mt7530_rmw which is also used in mt7530_set and mt7530_clear.

I've now made that change and re-tested, it works just as fine and prevents some unneccesary locking overhead.
I'll post an updated patch in v2 after giving it a bit more time for other reviewers to also take a look.

Quoted 199 lines
---
 drivers/net/dsa/mt7530.c | 91 +++++++++++++++++++++++++---------------
 drivers/net/dsa/mt7530.h |  2 +
 2 files changed, 60 insertions(+), 33 deletions(-)
drivers/net/dsa/mt7530.c +58 -33
index d8b041d79f2b7..e27a0e551cec0 100644
@@ -183,9 +183,9 @@ core_clear(struct mt7530_priv *priv, u32 reg, u32 val)
 }
 
 static int
-mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
+mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
 {
-	struct mii_bus *bus = priv->bus;
+	struct mii_bus *bus = context;
 	u16 page, r, lo, hi;
 	int ret;
 
@@ -197,24 +197,34 @@ mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
 	/* MT7530 uses 31 as the pseudo port */
 	ret = bus->write(bus, 0x1f, 0x1f, page);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	ret = bus->write(bus, 0x1f, r,  lo);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	ret = bus->write(bus, 0x1f, 0x10, hi);
-err:
+	return ret;
+}
+
+static int
+mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
+{
+	int ret;
+
+	ret = regmap_write(priv->regmap, reg, val);
+
 	if (ret < 0)
-		dev_err(&bus->dev,
+		dev_err(priv->dev,
 			"failed to write mt7530 register\n");
+
 	return ret;
 }
 
-static u32
-mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
+static int
+mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
 {
-	struct mii_bus *bus = priv->bus;
+	struct mii_bus *bus = context;
 	u16 page, r, lo, hi;
 	int ret;
 
@@ -223,17 +233,32 @@ mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
 
 	/* MT7530 uses 31 as the pseudo port */
 	ret = bus->write(bus, 0x1f, 0x1f, page);
-	if (ret < 0) {
+	if (ret < 0)
+		return ret;
+
+	lo = bus->read(bus, 0x1f, r);
+	hi = bus->read(bus, 0x1f, 0x10);
+
+	*val = (hi << 16) | (lo & 0xffff);
+
+	return 0;
+}
+
+static u32
+mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
+{
+	int ret;
+	u32 val;
+
+	ret = regmap_read(priv->regmap, reg, &val);
+	if (ret) {
 		WARN_ON_ONCE(1);
-		dev_err(&bus->dev,
+		dev_err(priv->dev,
 			"failed to read mt7530 register\n");
 		return 0;
 	}
 
-	lo = bus->read(bus, 0x1f, r);
-	hi = bus->read(bus, 0x1f, 0x10);
-
-	return (hi << 16) | (lo & 0xffff);
+	return val;
 }
 
 static void
@@ -2896,22 +2921,6 @@ static const struct phylink_pcs_ops mt7530_pcs_ops = {
 	.pcs_an_restart = mt7530_pcs_an_restart,
 };
 
-static int mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
-{
-	struct mt7530_priv *priv = context;
-
-	*val = mt7530_mii_read(priv, reg);
-	return 0;
-};
-
-static int mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
-{
-	struct mt7530_priv *priv = context;
-
-	mt7530_mii_write(priv, reg, val);
-	return 0;
-};
-
 static void
 mt7530_mdio_regmap_lock(void *mdio_lock)
 {
@@ -2924,7 +2933,7 @@ mt7530_mdio_regmap_unlock(void *mdio_lock)
 	mutex_unlock(mdio_lock);
 }
 
-static const struct regmap_bus mt7531_regmap_bus = {
+static const struct regmap_bus mt7530_regmap_bus = {
 	.reg_write = mt7530_regmap_write,
 	.reg_read = mt7530_regmap_read,
 };
@@ -2957,7 +2966,7 @@ mt7531_create_sgmii(struct mt7530_priv *priv)
 		mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
 
 		regmap = devm_regmap_init(priv->dev,
-					  &mt7531_regmap_bus, priv,
+					  &mt7530_regmap_bus, priv->bus,
 					  mt7531_pcs_config[i]);
 		if (IS_ERR(regmap)) {
 			ret = PTR_ERR(regmap);
@@ -3128,6 +3137,7 @@ MODULE_DEVICE_TABLE(of, mt7530_of_match);
 static int
 mt7530_probe(struct mdio_device *mdiodev)
 {
+	static struct regmap_config *regmap_config;
 	struct mt7530_priv *priv;
 	struct device_node *dn;
 
@@ -3207,6 +3217,21 @@ mt7530_probe(struct mdio_device *mdiodev)
 	mutex_init(&priv->reg_mutex);
 	dev_set_drvdata(&mdiodev->dev, priv);
 
+	regmap_config = devm_kzalloc(&mdiodev->dev, sizeof(*regmap_config),
+				     GFP_KERNEL);
+	if (!regmap_config)
+		return -ENOMEM;
+
+	regmap_config->reg_bits = 16;
+	regmap_config->val_bits = 32;
+	regmap_config->reg_stride = 4;
+	regmap_config->max_register = MT7530_CREV;
+	regmap_config->disable_locking = true;
+	priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus,
+					priv->bus, regmap_config);
+	if (IS_ERR(priv->regmap))
+		return PTR_ERR(priv->regmap);
+
 	return dsa_register_switch(priv->ds);
 }
 
drivers/net/dsa/mt7530.h +2 -0
index c5d29f3fc1d80..39aaca50961bd 100644
@@ -754,6 +754,7 @@ struct mt753x_info {
  * @dev:		The device pointer
  * @ds:			The pointer to the dsa core structure
  * @bus:		The bus used for the device and built-in PHY
+ * @regmap:		The regmap instance representing all switch registers
  * @rstc:		The pointer to reset control used by MCM
  * @core_pwr:		The power supplied into the core
  * @io_pwr:		The power supplied into the I/O
@@ -774,6 +775,7 @@ struct mt7530_priv {
 	struct device		*dev;
 	struct dsa_switch	*ds;
 	struct mii_bus		*bus;
+	struct regmap		*regmap;
 	struct reset_control	*rstc;
 	struct regulator	*core_pwr;
 	struct regulator	*io_pwr;
Signature · 1 line
2.39.2
#36 lore raw

Re: [PATCH 15/15] dt-bindings: net: dsa: mediatek,mt7530: add mediatek,mt7988-switch

In reply to Daniel Golle
Quoted 13 lines · Daniel Golle

Add documentation for the built-in switch which can be found in the MediaTek MT7988 SoC.

---
  .../bindings/net/dsa/mediatek,mt7530.yaml     | 26 +++++++++++++++++--
  1 file changed, 24 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -0
index 5ae9cd8f99a24..15953f0e9d1a6 100644

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 14

Quoted 4 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +1 -0
@@ -11,16 +11,23 @@ maintainers:
    - Landen Chao <[email protected]>
    - DENG Qingfang <[email protected]>
    - Sean Wang <[email protected]>
+  - Daniel Golle <[email protected]>

Please put it in alphabetical order by the first name.

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 18

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +2 -1
  description: |
-  There are two versions of MT7530, standalone and in a multi-chip module.
+  There are three versions of MT7530, standalone, in a multi-chip module and
+  built-into a SoC.

I assume you put this to point out the situation with MT7988?

This brings to light an underlying problem with the description as the MT7620 SoCs described below have the MT7530 switch built into the SoC, instead of being part of the MCM.

The switch IP on MT7988 is for sure not MT7530 so either fix this and the text below as a separate patch or let me handle it.

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 23

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +1 -0
    MT7530 is a part of the multi-chip module in MT7620AN, MT7620DA, MT7620DAN,
    MT7620NN, MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs.
 
+  The MT7988 SoC comes a built-in switch similar to MT7531 as well as 4 Gigabit

s/comes a/comes with a

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 26

Quoted 3 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +3 -0
+  Ethernet PHYs and the switch registers are directly mapped into SoC's memory
+  map rather than using MDIO. It comes with an internally connected 10G CPU port
+  and 4 user ports connected to the built-in Gigabit Ethernet PHYs.

Are you sure this is not the MT7531 IP built into the SoC, like MT7530 on the MT7620 SoCs? Maybe DENG Qingfang would like to clarify as they did for MT7530.

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 32

Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +2 -1
+
    MT7530 in MT7620AN, MT7620DA, MT7620DAN and MT7620NN SoCs has got 10/100 PHYs
    and the switch registers are directly mapped into SoC's memory map rather than
-  using MDIO. The DSA driver currently doesn't support this.
+  using MDIO. The DSA driver currently doesn't support MT7620 variants.
 
    There is only the standalone version of MT7531.

Can you put the MT7988 information below here instead.

Quoted 13 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +4 -0
@@ -81,6 +88,10 @@ properties:
            Multi-chip module MT7530 in MT7621AT, MT7621DAT and MT7621ST SoCs
          const: mediatek,mt7621
 
+      - description:
+          Built-in switch of the MT7988 SoC
+        const: mediatek,mt7988-switch
+
    reg:
      maxItems: 1
 

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml allOf: · line 287

Quoted 9 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +6 -0
@@ -268,6 +279,17 @@ allOf:
        required:
          - mediatek,mcm
 
+  - if:
+      properties:
+        compatible:
+          const: mediatek,mt7988-switch
+    then:
+      $ref: "#/$defs/mt7530-dsa-port"

The CPU ports bindings for MT7530 don't match the characteristics of the switch on the MT7988 SoC you described above. We need new definitions for the CPU ports on the switch on the MT7988 SoC.

What's the CPU port number? Does it accept rgmii or only the 10G phy-mode?

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml allOf: · line 291

Quoted 4 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +4 -0
+      properties:
+        gpio-controller: false
+        mediatek,mcm: false
+        reset-names: false

I'd rather not add reset-names here and do:

- if:
required:
- mediatek,mcm
then:
properties:
reset-gpios: false

required:
- resets
- reset-names
else:
properties:
resets: false
reset-names: false

I can handle this if you'd like.

Arınç

#38 lore raw
In reply to Daniel Golle
Quoted 9 lines · Daniel Golle

The MediaTek MT7988 SoC comes with a built-in switch very similar to previous MT7530 and MT7531. However, the switch address space is mapped into the SoCs memory space rather than being connected via MDIO. Using MMIO simplifies register access and also removes the need for a bus lock, and for that reason also makes interrupt handling more light-weight.

Note that this is different from previous SoCs like MT7621 and MT7623N which also came with an integrated MT7530-like switch which yet had to be accessed via MDIO.

MT7623NI does not come with the MT7530 switch. MT7623AI does.

It's not an MT7530-like switch, it's the MT7530 switch, which is part of the multi-chip module, in a chip-stack package.

To be more specific, it's only the MT7621AT, MT7621DAT, and MT7621ST SoCs. MT7621NT SoC don't have it.

Quoted 6 lines

Split-off the part of the driver registering an MDIO driver, then add another module acting as MMIO/platform driver.

The whole series has been tested on various MediaTek boards:
* MT7623A + MT7530 (BPi-R2)

BPI-R2 has MT7623NI SoC, not MT7623AI. The MT7530 switch in this device is standalone.

Arınç

#24 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

In reply to Daniel Golle
Quoted 64 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
  MAINTAINERS                   |   2 +
  drivers/net/dsa/Kconfig       |  12 ++++
  drivers/net/dsa/Makefile      |   1 +
  drivers/net/dsa/mt7530-mmio.c | 101 ++++++++++++++++++++++++++++++++++
  drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++-
  drivers/net/dsa/mt7530.h      |  12 ++--
  6 files changed, 206 insertions(+), 8 deletions(-)

create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +2 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER
  M:	Sean Wang <[email protected]>
  M:	Landen Chao <[email protected]>
  M:	DENG Qingfang <[email protected]>
+M:	Daniel Golle <[email protected]>
  L:	[email protected]
  S:	Maintained
  F:	drivers/net/dsa/mt7530-mdio.c
+F:	drivers/net/dsa/mt7530-mmio.c
  F:	drivers/net/dsa/mt7530.*
  F:	net/dsa/tag_mtk.c
 
drivers/net/dsa/Kconfig +12 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530
  	  Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and
  	  MT7623AI SoCs is supported as well.
 
+config NET_DSA_MT7988
+	tristate "MediaTek MT7988 built-in Ethernet switch support"
+	select NET_DSA_MT7530_COMMON
+	depends on HAS_IOMEM
+	help
+	  This enables support for the built-in Ethernet switch found
+	  in the MediaTek MT7988 SoC.
+	  The switch is a similar design as MT7531, however, unlike
+	  other MT7530 and MT7531 the switch registers are directly
+	  mapped into the SoCs register space rather than being accessible
+	  via MDIO.
+
  config NET_DSA_MV88E6060
  	tristate "Marvell 88E6060 ethernet switch chip support"
  	select NET_DSA_TAG_TRAILER
drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644

drivers/net/dsa/Makefile endif · line 11

Quoted 4 lines
drivers/net/dsa/Makefile +1 -0
@@ -8,6 +8,7 @@ endif
  obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
  obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o
  obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530-mdio.o
+obj-$(CONFIG_NET_DSA_MT7988)	+= mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

The mmio driver could be useful in the future for the MT7530 on the MT7620 SoCs or generally new hardware that would use MMIO to be controlled.

Luiz did this for the Realtek switches that use MDIO and SMI to be controlled.

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/realtek/Kconfig

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/realtek/Makefile

Arınç

author maintainer
#25 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

Quoted 63 lines · Arınç ÜNAL
Quoted 62 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
  MAINTAINERS                   |   2 +
  drivers/net/dsa/Kconfig       |  12 ++++
  drivers/net/dsa/Makefile      |   1 +
  drivers/net/dsa/mt7530-mmio.c | 101 ++++++++++++++++++++++++++++++++++
  drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++-
  drivers/net/dsa/mt7530.h      |  12 ++--
  6 files changed, 206 insertions(+), 8 deletions(-)

create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +2 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER
  M:	Sean Wang <[email protected]>
  M:	Landen Chao <[email protected]>
  M:	DENG Qingfang <[email protected]>
+M:	Daniel Golle <[email protected]>
  L:	[email protected]
  S:	Maintained
  F:	drivers/net/dsa/mt7530-mdio.c
+F:	drivers/net/dsa/mt7530-mmio.c
  F:	drivers/net/dsa/mt7530.*
  F:	net/dsa/tag_mtk.c
drivers/net/dsa/Kconfig +12 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530
  	  Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and
  	  MT7623AI SoCs is supported as well.
+config NET_DSA_MT7988
+	tristate "MediaTek MT7988 built-in Ethernet switch support"
+	select NET_DSA_MT7530_COMMON
+	depends on HAS_IOMEM
+	help
+	  This enables support for the built-in Ethernet switch found
+	  in the MediaTek MT7988 SoC.
+	  The switch is a similar design as MT7531, however, unlike
+	  other MT7530 and MT7531 the switch registers are directly
+	  mapped into the SoCs register space rather than being accessible
+	  via MDIO.
+
  config NET_DSA_MV88E6060
  	tristate "Marvell 88E6060 ethernet switch chip support"
  	select NET_DSA_TAG_TRAILER
drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
Quoted 8 lines

drivers/net/dsa/Makefile endif · line 11

Quoted 4 lines
drivers/net/dsa/Makefile +1 -0
  obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
  obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o
  obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530-mdio.o
+obj-$(CONFIG_NET_DSA_MT7988)	+= mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
* mt7530.c is the shared/common switch hardware driver
* mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for MT7530, MT7531, MT7621, MT7623, ...
* mt7530-mmio.c contains the platform device driver for in-SoC switches which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to select the MDIO driver, I decided it would be better to hide the symbol of the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like it was before.

Hence I decided to go with
CONFIG_NET_DSA_MT7530 selects the MDIO driver, just like before CONFIG_NET_DSA_MT7988 selects the new MMIO driver CONFIG_NET_DSA_MT7530_COMMON is hidden, selected by both of the above

Quoted 4 lines

The mmio driver could be useful in the future for the MT7530 on the MT7620 SoCs or generally new hardware that would use MMIO to be controlled.

Sure, it would be a bit confusing once we add support for MT7620A/N (if that ever happens...), then CONFIG_NET_DSA_MT7988 would need to be selected to support this ancient MIPS SoC...

If you are planning to work on support for MT7620A/N feel free to suggest a better way to name the Kconfig symbols.

Quoted 6 lines

Luiz did this for the Realtek switches that use MDIO and SMI to be controlled.

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/realtek/Kconfig

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/realtek/Makefile

Are you suggesting to split-off a device-specific driver which would then select the access-method driver (MDIO vs. MMIO) and the common/shared driver? To me this looks like overkill for MT7530, given that the designs of all MT7530 are pretty similar, ie. same tag format and also otherwise very similar.

Thank you for reviewing!

Daniel

#26 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

Quoted 73 lines · Daniel Golle
Quoted 63 lines · Arınç ÜNAL
Quoted 62 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
   MAINTAINERS                   |   2 +
   drivers/net/dsa/Kconfig       |  12 ++++
   drivers/net/dsa/Makefile      |   1 +
   drivers/net/dsa/mt7530-mmio.c | 101 ++++++++++++++++++++++++++++++++++
   drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++-
   drivers/net/dsa/mt7530.h      |  12 ++--
   6 files changed, 206 insertions(+), 8 deletions(-)

create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +2 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER
   M:	Sean Wang <[email protected]>
   M:	Landen Chao <[email protected]>
   M:	DENG Qingfang <[email protected]>
+M:	Daniel Golle <[email protected]>
   L:	[email protected]
   S:	Maintained
   F:	drivers/net/dsa/mt7530-mdio.c
+F:	drivers/net/dsa/mt7530-mmio.c
   F:	drivers/net/dsa/mt7530.*
   F:	net/dsa/tag_mtk.c
drivers/net/dsa/Kconfig +12 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530
   	  Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and
   	  MT7623AI SoCs is supported as well.
+config NET_DSA_MT7988
+	tristate "MediaTek MT7988 built-in Ethernet switch support"
+	select NET_DSA_MT7530_COMMON
+	depends on HAS_IOMEM
+	help
+	  This enables support for the built-in Ethernet switch found
+	  in the MediaTek MT7988 SoC.
+	  The switch is a similar design as MT7531, however, unlike
+	  other MT7530 and MT7531 the switch registers are directly
+	  mapped into the SoCs register space rather than being accessible
+	  via MDIO.
+
   config NET_DSA_MV88E6060
   	tristate "Marvell 88E6060 ethernet switch chip support"
   	select NET_DSA_TAG_TRAILER
drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
Quoted 8 lines

drivers/net/dsa/Makefile endif · line 11

Quoted 4 lines
drivers/net/dsa/Makefile +1 -0
   obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
   obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o
   obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530-mdio.o
+obj-$(CONFIG_NET_DSA_MT7988)	+= mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

Quoted 8 lines

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
* mt7530.c is the shared/common switch hardware driver
* mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for

    MT7530, MT7531, MT7621, MT7623, ...

* mt7530-mmio.c contains the platform device driver for in-SoC switches which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

Ok great.

Quoted 10 lines

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to select the MDIO driver, I decided it would be better to hide the symbol of the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like it was before.

You can "imply NET_DSA_MT7530_MDIO" from NET_DSA_MT7530 so the MDIO driver is also enabled when NET_DSA_MT7530 is selected. For example, on Realtek, both MDIO and SMI drivers are enabled by default when either of the main drivers are selected.

config NET_DSA_MT7530

	tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
	select NET_DSA_TAG_MTK
	select MEDIATEK_GE_PHY
	select PCS_MTK_LYNXI
	imply NET_DSA_MT7530_MDIO
	imply NET_DSA_MT7530_MMIO
Quoted 11 lines

Hence I decided to go with
CONFIG_NET_DSA_MT7530 selects the MDIO driver, just like before CONFIG_NET_DSA_MT7988 selects the new MMIO driver CONFIG_NET_DSA_MT7530_COMMON is hidden, selected by both of the above

Quoted 4 lines

The mmio driver could be useful in the future for the MT7530 on the MT7620 SoCs or generally new hardware that would use MMIO to be controlled.

Quoted 6 lines

Sure, it would be a bit confusing once we add support for MT7620A/N (if that ever happens...), then CONFIG_NET_DSA_MT7988 would need to be selected to support this ancient MIPS SoC...

If you are planning to work on support for MT7620A/N feel free to suggest a better way to name the Kconfig symbols.

I don't plan to but Luiz may. Onto my suggestions.

Firstly, all of the functions on the mt7530-mmio driver should be changed from mt7988_* to mt7530_mmio_*. Same goes for the mt7530-mdio driver too as some of the functions don't start with mt7530_mdio_*. The MDIO and MMIO drivers are supposed to be used for the switches the MT7530 DSA driver supports. The mt7530_ prefix is derived from that. The mmio_ or mdio_ prefix is derived from, well, the driver itself.

You're calling the .name of the MMIO driver, mt7988-switch; the MDIO driver mt7530. That doesn't make sense. They should be mt7530-mmio and mt7530-mdio (or mediatek-mmio and mediatek-mdio).

What I'm going to say next depends on how generic the MMIO and MDIO drivers are so that they can be used on all MediaTek architecture switches. Let's say, a new MediaTek switch is introduced. It seems likely that either the MMIO or MDIO driver will be used to control the switch. Maybe the driver for this new switch won't be under mt7530.c, like on Realtek, but that doesn't change the outcome.

You know the MMIO and MDIO drivers better than I do, so if this makes sense to you, I'd rather call the MDIO and MMIO drivers MediaTek MDIO and MediaTek MMIO, and change the code accordingly. E.g. mt7988_* to mediatek_mmio_*, the filename from mt7530-mmio.c to mediatek-mmio.c, kernel config option from NET_DSA_MT7530_MMIO to NET_DSA_MEDIATEK_MMIO. This is currently the case with the Realtek MDIO and SMI drivers.

If not, call it MediaTek MT7530 MMIO and MediaTek MT7530 MDIO.

Quoted 6 lines
Quoted 6 lines

Luiz did this for the Realtek switches that use MDIO and SMI to be controlled.

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/realtek/Kconfig

Quoted 7 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/realtek/Makefile

Are you suggesting to split-off a device-specific driver which would then select the access-method driver (MDIO vs. MMIO) and the common/shared driver? To me this looks like overkill for MT7530, given that the designs of all MT7530 are pretty similar, ie. same tag format and also otherwise very similar.

No, and agreed. I just wanted to show the Realtek MDIO and SMI drivers' kconfig as an example.

Quoted 3 lines

Thank you for reviewing!

Great work so far!

Arınç

maintainer
#27 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

Quoted 6 lines

Firstly, all of the functions on the mt7530-mmio driver should be changed from mt7988_* to mt7530_mmio_*. Same goes for the mt7530-mdio driver too as some of the functions don't start with mt7530_mdio_*. The MDIO and MMIO drivers are supposed to be used for the switches the MT7530 DSA driver supports. The mt7530_ prefix is derived from that. The mmio_ or mdio_ prefix is derived from, well, the driver itself.

There are examples of similar naming schemes in other DSA drivers. For the marvell mv88e6xxx driver, all generic functions use the mv88e6xxx_ prefix. For functions which are specific to a family of marvell switches, we use a prefix for when the feature was introduced. So for example we have mv88e6352_g1_reset(), where that method of resetting the devices was introduced in the mv88e6352. This also gives us some namespace space, so we can also have mv88e6185_g1_reset() which is used for a different family.

So i personally don't have a problem using different prefixes within one driver, if it helps with understanding and name space issues.

Quoted 6 lines

What I'm going to say next depends on how generic the MMIO and MDIO drivers are so that they can be used on all MediaTek architecture switches. Let's say, a new MediaTek switch is introduced. It seems likely that either the MMIO or MDIO driver will be used to control the switch. Maybe the driver for this new switch won't be under mt7530.c, like on Realtek, but that doesn't change the outcome.

My experience with silicon vendors is that they like to change the hardware in none backwards compatible ways. So i would actually avoid generic names, it makes it harder to deal with different variants.

Andrew

#28 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

In reply to Arınç ÜNAL
Quoted 99 lines · Arınç ÜNAL
Quoted 74 lines · Daniel Golle
Quoted 64 lines · Arınç ÜNAL
Quoted 63 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
   MAINTAINERS                   |   2 + drivers/net/dsa/Kconfig       |  12 ++++ drivers/net/dsa/Makefile      |   1 + drivers/net/dsa/mt7530-mmio.c | 101
++++++++++++++++++++++++++++++++++
   drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++- drivers/net/dsa/mt7530.h      |  12 ++--

   6 files changed, 206 insertions(+), 8 deletions(-)

   create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +0 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER

   M:    Sean Wang <[email protected]>
   M:    Landen Chao <[email protected]>
   M:    DENG Qingfang <[email protected]>
+M:    Daniel Golle <[email protected]>
   L:    [email protected]
   S:    Maintained
   F:    drivers/net/dsa/mt7530-mdio.c
+F:    drivers/net/dsa/mt7530-mmio.c
   F:    drivers/net/dsa/mt7530.*
   F:    net/dsa/tag_mtk.c

drivers/net/dsa/Kconfig +0 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530

         Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs is supported as well.

drivers/net/dsa/Kconfig +12 -0
+config NET_DSA_MT7988
+    tristate "MediaTek MT7988 built-in Ethernet switch support"
+    select NET_DSA_MT7530_COMMON
+    depends on HAS_IOMEM
+    help
+      This enables support for the built-in Ethernet switch found
+      in the MediaTek MT7988 SoC.
+      The switch is a similar design as MT7531, however, unlike
+      other MT7530 and MT7531 the switch registers are directly
+      mapped into the SoCs register space rather than being accessible
+      via MDIO.
+

   config NET_DSA_MV88E6060
       tristate "Marvell 88E6060 ethernet switch chip support" select NET_DSA_TAG_TRAILER

drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
Quoted 8 lines
Quoted 4 lines

   obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o obj-$(CONFIG_NET_DSA_MT7530)    += mt7530-mdio.o +obj-$(CONFIG_NET_DSA_MT7988)    += mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

Quoted 8 lines

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
  * mt7530.c is the shared/common switch hardware driver
  * mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for MT7530, MT7531, MT7621, MT7623, ...
  * mt7530-mmio.c contains the platform device driver for in-SoC switches which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

Ok great.

Quoted 10 lines

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to select the MDIO driver, I decided it would be better to hide the symbol of the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like it was before.

You can "imply NET_DSA_MT7530_MDIO" from NET_DSA_MT7530 so the MDIO driver is also enabled when NET_DSA_MT7530 is selected. For example, on Realtek, both MDIO and SMI drivers are enabled by default when either of the main drivers are selected.

Quoted 7 lines

config NET_DSA_MT7530
    tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
    select MEDIATEK_GE_PHY
    select PCS_MTK_LYNXI
    imply NET_DSA_MT7530_MDIO
    imply NET_DSA_MT7530_MMIO

The final kconfig should look like this:

config NET_DSA_MT7530

	tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
	select NET_DSA_TAG_MTK
	select MEDIATEK_GE_PHY
	select PCS_MTK_LYNXI
	imply NET_DSA_MT7530_MDIO
	imply NET_DSA_MT7530_MMIO
	help
	  This enables support for the MediaTek MT7530 and MT7531 Ethernet
	  switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT,
	  MT7621ST and MT7623AI SoCs, and built-in switch in MT7688 SoC is
	  supported.

config NET_DSA_MT7530_MDIO
tristate "MediaTek MT7530 MDIO interface driver"
default NET_DSA_MT7530
depends on NET_DSA_MT7530
help
This enables support for the MediaTek MT7530 switch chips which are connected via MDIO.

config NET_DSA_MT7530_MMIO
tristate "MediaTek MT7530 MMIO interface driver"
depends on HAS_IOMEM
depends on NET_DSA_MT7530
help
This enables support for the MediaTek MT7530 switch chips which are connected via MMIO.

You should also change MODULE_DESCRIPTION for both drivers to something like "Driver for MediaTek MT7530 ethernet switches connected via MMIO interface".

Arınç

#29 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

Quoted 124 lines · Arınç ÜNAL
Quoted 100 lines · Arınç ÜNAL
Quoted 75 lines · Daniel Golle
Quoted 65 lines · Arınç ÜNAL
Quoted 64 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
   MAINTAINERS                   |   2 + drivers/net/dsa/Kconfig       |  12 ++++ drivers/net/dsa/Makefile      |   1 + drivers/net/dsa/mt7530-mmio.c | 101
++++++++++++++++++++++++++++++++++
   drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++- drivers/net/dsa/mt7530.h      |  12 ++--

   6 files changed, 206 insertions(+), 8 deletions(-)

   create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +0 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER

   M:    Sean Wang <[email protected]>
   M:    Landen Chao <[email protected]>
   M:    DENG Qingfang <[email protected]>
+M:    Daniel Golle <[email protected]>
   L:    [email protected]
   S:    Maintained
   F:    drivers/net/dsa/mt7530-mdio.c
+F:    drivers/net/dsa/mt7530-mmio.c
   F:    drivers/net/dsa/mt7530.*
   F:    net/dsa/tag_mtk.c

drivers/net/dsa/Kconfig +0 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530

         Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs is supported as well.
+config NET_DSA_MT7988
+    tristate "MediaTek MT7988 built-in Ethernet switch support" +    select NET_DSA_MT7530_COMMON
+    depends on HAS_IOMEM
+    help
+      This enables support for the built-in Ethernet switch found +      in the MediaTek MT7988 SoC.
+      The switch is a similar design as MT7531, however, unlike +      other MT7530 and MT7531 the switch registers are directly +      mapped into the SoCs register space rather than being accessible
+      via MDIO.
+
   config NET_DSA_MV88E6060
       tristate "Marvell 88E6060 ethernet switch chip support" select NET_DSA_TAG_TRAILER

drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
Quoted 8 lines
Quoted 4 lines

   obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o obj-$(CONFIG_NET_DSA_MT7530)    += mt7530-mdio.o +obj-$(CONFIG_NET_DSA_MT7988)    += mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

Quoted 8 lines

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
  * mt7530.c is the shared/common switch hardware driver
  * mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for MT7530, MT7531, MT7621, MT7623, ...
  * mt7530-mmio.c contains the platform device driver for in-SoC switches which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

Ok great.

Quoted 10 lines

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to select the MDIO driver, I decided it would be better to hide the symbol of the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like it was before.

You can "imply NET_DSA_MT7530_MDIO" from NET_DSA_MT7530 so the MDIO driver is also enabled when NET_DSA_MT7530 is selected. For example, on Realtek, both MDIO and SMI drivers are enabled by default when either of the main drivers are selected.

Quoted 7 lines

config NET_DSA_MT7530
     tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
     select MEDIATEK_GE_PHY
     select PCS_MTK_LYNXI
     imply NET_DSA_MT7530_MDIO
     imply NET_DSA_MT7530_MMIO

The final kconfig should look like this:

config NET_DSA_MT7530
    tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
    select MEDIATEK_GE_PHY
    select PCS_MTK_LYNXI
    imply NET_DSA_MT7530_MDIO
    imply NET_DSA_MT7530_MMIO
    help
      This enables support for the MediaTek MT7530 and MT7531 Ethernet switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs, and built-in switch in MT7688 SoC is supported.

Quoted 3 lines

config NET_DSA_MT7530_MDIO
    tristate "MediaTek MT7530 MDIO interface driver" default NET_DSA_MT7530

This is unnecessary.

Arınç

author maintainer
#30 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

In reply to Arınç ÜNAL
Quoted 117 lines · Arınç ÜNAL
Quoted 105 lines · Arınç ÜNAL
Quoted 74 lines · Daniel Golle
Quoted 64 lines · Arınç ÜNAL
Quoted 63 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
   MAINTAINERS                   |   2 + drivers/net/dsa/Kconfig       |  12 ++++ drivers/net/dsa/Makefile      |   1 + drivers/net/dsa/mt7530-mmio.c | 101
++++++++++++++++++++++++++++++++++
   drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++- drivers/net/dsa/mt7530.h      |  12 ++--

   6 files changed, 206 insertions(+), 8 deletions(-)

   create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +0 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER

   M:    Sean Wang <[email protected]>
   M:    Landen Chao <[email protected]>
   M:    DENG Qingfang <[email protected]>
+M:    Daniel Golle <[email protected]>
   L:    [email protected]
   S:    Maintained
   F:    drivers/net/dsa/mt7530-mdio.c
+F:    drivers/net/dsa/mt7530-mmio.c
   F:    drivers/net/dsa/mt7530.*
   F:    net/dsa/tag_mtk.c

drivers/net/dsa/Kconfig +0 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530

         Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs is supported as well.

drivers/net/dsa/Kconfig +12 -0
+config NET_DSA_MT7988
+    tristate "MediaTek MT7988 built-in Ethernet switch support"
+    select NET_DSA_MT7530_COMMON
+    depends on HAS_IOMEM
+    help
+      This enables support for the built-in Ethernet switch found
+      in the MediaTek MT7988 SoC.
+      The switch is a similar design as MT7531, however, unlike
+      other MT7530 and MT7531 the switch registers are directly
+      mapped into the SoCs register space rather than being accessible
+      via MDIO.
+

   config NET_DSA_MV88E6060
       tristate "Marvell 88E6060 ethernet switch chip support" select NET_DSA_TAG_TRAILER

drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
Quoted 8 lines
Quoted 4 lines

   obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o obj-$(CONFIG_NET_DSA_MT7530)    += mt7530-mdio.o +obj-$(CONFIG_NET_DSA_MT7988)    += mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

Quoted 8 lines

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
  * mt7530.c is the shared/common switch hardware driver
  * mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for MT7530, MT7531, MT7621, MT7623, ...
  * mt7530-mmio.c contains the platform device driver for in-SoC switches which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

Ok great.

Quoted 6 lines

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

Quoted 7 lines

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to
select the MDIO driver, I decided it would be better to hide the symbol of
the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like
it was before.

You can "imply NET_DSA_MT7530_MDIO" from NET_DSA_MT7530 so the MDIO driver is also enabled when NET_DSA_MT7530 is selected. For example, on Realtek, both MDIO and SMI drivers are enabled by default when either of the main drivers are selected.

Quoted 7 lines

config NET_DSA_MT7530
    tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
    select MEDIATEK_GE_PHY
    select PCS_MTK_LYNXI
    imply NET_DSA_MT7530_MDIO
    imply NET_DSA_MT7530_MMIO

The final kconfig should look like this:

config NET_DSA_MT7530

Quoted 10 lines
	tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
	select NET_DSA_TAG_MTK
	select MEDIATEK_GE_PHY
	select PCS_MTK_LYNXI
	imply NET_DSA_MT7530_MDIO
	imply NET_DSA_MT7530_MMIO
	help
	  This enables support for the MediaTek MT7530 and MT7531 Ethernet
	  switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT,
	  MT7621ST and MT7623AI SoCs, and built-in switch in MT7688 SoC is
                                                             ^^^^^^

You probably meant MT7988.

The built-in Fast Ethernet switch of older Ralink SoCs as well as MT7628 and MT7688 is a whole different story:
https://github.com/stroese/linux/blob/gardena-v5.5/drivers/net/dsa/mt7628-esw.c

Quoted 18 lines

supported.

config NET_DSA_MT7530_MDIO
tristate "MediaTek MT7530 MDIO interface driver"
default NET_DSA_MT7530
depends on NET_DSA_MT7530
help
This enables support for the MediaTek MT7530 switch chips which are connected via MDIO.

config NET_DSA_MT7530_MMIO
tristate "MediaTek MT7530 MMIO interface driver"
depends on HAS_IOMEM
depends on NET_DSA_MT7530
help
This enables support for the MediaTek MT7530 switch chips which are connected via MMIO.

Quoted 3 lines

You should also change MODULE_DESCRIPTION for both drivers to something like "Driver for MediaTek MT7530 ethernet switches connected via MMIO interface".

Ack. Will do.

#31 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

Quoted 128 lines · Daniel Golle
Quoted 117 lines · Arınç ÜNAL
Quoted 105 lines · Arınç ÜNAL
Quoted 74 lines · Daniel Golle
Quoted 64 lines · Arınç ÜNAL
Quoted 63 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
    MAINTAINERS                   |   2 +
    drivers/net/dsa/Kconfig       |  12 ++++
    drivers/net/dsa/Makefile      |   1 +
    drivers/net/dsa/mt7530-mmio.c | 101
++++++++++++++++++++++++++++++++++
    drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++-
    drivers/net/dsa/mt7530.h      |  12 ++--
    6 files changed, 206 insertions(+), 8 deletions(-)

   create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +2 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER
    M:    Sean Wang <[email protected]>
    M:    Landen Chao <[email protected]>
    M:    DENG Qingfang <[email protected]>
+M:    Daniel Golle <[email protected]>
    L:    [email protected]
    S:    Maintained
    F:    drivers/net/dsa/mt7530-mdio.c
+F:    drivers/net/dsa/mt7530-mmio.c
    F:    drivers/net/dsa/mt7530.*
    F:    net/dsa/tag_mtk.c
drivers/net/dsa/Kconfig +12 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530
          Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and
          MT7623AI SoCs is supported as well.
+config NET_DSA_MT7988
+    tristate "MediaTek MT7988 built-in Ethernet switch support"
+    select NET_DSA_MT7530_COMMON
+    depends on HAS_IOMEM
+    help
+      This enables support for the built-in Ethernet switch found
+      in the MediaTek MT7988 SoC.
+      The switch is a similar design as MT7531, however, unlike
+      other MT7530 and MT7531 the switch registers are directly
+      mapped into the SoCs register space rather than being accessible
+      via MDIO.
+
    config NET_DSA_MV88E6060
        tristate "Marvell 88E6060 ethernet switch chip support"
        select NET_DSA_TAG_TRAILER
drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
Quoted 8 lines

drivers/net/dsa/Makefile endif · line 11

Quoted 4 lines
drivers/net/dsa/Makefile +1 -0
    obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
    obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o
    obj-$(CONFIG_NET_DSA_MT7530)    += mt7530-mdio.o
+obj-$(CONFIG_NET_DSA_MT7988)    += mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

Quoted 8 lines

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
  * mt7530.c is the shared/common switch hardware driver
  * mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for MT7530, MT7531, MT7621, MT7623, ...
  * mt7530-mmio.c contains the platform device driver for in-SoC switches which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

Ok great.

Quoted 6 lines

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

Quoted 7 lines

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to
select the MDIO driver, I decided it would be better to hide the symbol of
the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like
it was before.

You can "imply NET_DSA_MT7530_MDIO" from NET_DSA_MT7530 so the MDIO driver is also enabled when NET_DSA_MT7530 is selected. For example, on Realtek, both MDIO and SMI drivers are enabled by default when either of the main drivers are selected.

Quoted 7 lines

config NET_DSA_MT7530
    tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
    select MEDIATEK_GE_PHY
    select PCS_MTK_LYNXI
    imply NET_DSA_MT7530_MDIO
    imply NET_DSA_MT7530_MMIO

The final kconfig should look like this:

config NET_DSA_MT7530

Quoted 10 lines
	tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
	select NET_DSA_TAG_MTK
	select MEDIATEK_GE_PHY
	select PCS_MTK_LYNXI
	imply NET_DSA_MT7530_MDIO
	imply NET_DSA_MT7530_MMIO
	help
	  This enables support for the MediaTek MT7530 and MT7531 Ethernet
	  switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT,
	  MT7621ST and MT7623AI SoCs, and built-in switch in MT7688 SoC is
Quoted 6 lines
                                                              ^^^^^^

You probably meant MT7988.

The built-in Fast Ethernet switch of older Ralink SoCs as well as MT7628 and MT7688 is a whole different story:
https://github.com/stroese/linux/blob/gardena-v5.5/drivers/net/dsa/mt7628-esw.c

Yup, typo. "is" at the end should also be "are".

Arınç

#32 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

In reply to Arınç ÜNAL
Quoted 109 lines · Arınç ÜNAL
Quoted 100 lines · Arınç ÜNAL
Quoted 75 lines · Daniel Golle
Quoted 65 lines · Arınç ÜNAL
Quoted 64 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
   MAINTAINERS                   |   2 + drivers/net/dsa/Kconfig       |  12 ++++ drivers/net/dsa/Makefile      |   1 + drivers/net/dsa/mt7530-mmio.c | 101
++++++++++++++++++++++++++++++++++
   drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++- drivers/net/dsa/mt7530.h      |  12 ++--

   6 files changed, 206 insertions(+), 8 deletions(-)

   create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +0 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER

   M:    Sean Wang <[email protected]>
   M:    Landen Chao <[email protected]>
   M:    DENG Qingfang <[email protected]>
+M:    Daniel Golle <[email protected]>
   L:    [email protected]
   S:    Maintained
   F:    drivers/net/dsa/mt7530-mdio.c
+F:    drivers/net/dsa/mt7530-mmio.c
   F:    drivers/net/dsa/mt7530.*
   F:    net/dsa/tag_mtk.c

drivers/net/dsa/Kconfig +0 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530

         Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs is supported as well.
+config NET_DSA_MT7988
+    tristate "MediaTek MT7988 built-in Ethernet switch support" +    select NET_DSA_MT7530_COMMON
+    depends on HAS_IOMEM
+    help
+      This enables support for the built-in Ethernet switch found +      in the MediaTek MT7988 SoC.
+      The switch is a similar design as MT7531, however, unlike +      other MT7530 and MT7531 the switch registers are directly +      mapped into the SoCs register space rather than being accessible
+      via MDIO.
+
   config NET_DSA_MV88E6060
       tristate "Marvell 88E6060 ethernet switch chip support" select NET_DSA_TAG_TRAILER

drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif
Quoted 8 lines
Quoted 4 lines

   obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o obj-$(CONFIG_NET_DSA_MT7530)    += mt7530-mdio.o +obj-$(CONFIG_NET_DSA_MT7988)    += mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and mmio drivers to separate modules and kept switch hardware support on mt7530.c?

Quoted 8 lines

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
  * mt7530.c is the shared/common switch hardware driver
  * mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for MT7530, MT7531, MT7621, MT7623, ...
  * mt7530-mmio.c contains the platform device driver for in-SoC switches which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

Ok great.

Quoted 10 lines

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to select the MDIO driver, I decided it would be better to hide the symbol of the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like it was before.

You can "imply NET_DSA_MT7530_MDIO" from NET_DSA_MT7530 so the MDIO driver is also enabled when NET_DSA_MT7530 is selected. For example, on Realtek, both MDIO and SMI drivers are enabled by default when either of the main drivers are selected.

Quoted 7 lines

config NET_DSA_MT7530
     tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
     select MEDIATEK_GE_PHY
     select PCS_MTK_LYNXI
     imply NET_DSA_MT7530_MDIO
     imply NET_DSA_MT7530_MMIO

Quoted 7 lines

The final kconfig should look like this:

config NET_DSA_MT7530
    tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
    select MEDIATEK_GE_PHY
    select PCS_MTK_LYNXI

Looks like PCS_MTK_LYNXI is used on NET_DSA_MT7530_MDIO instead now. I also see '#include <linux/pcs/pcs-mtk-lynxi.h>' on mt7530.c but don't see any functions called on it. Leftover?

Quoted 10 lines

    imply NET_DSA_MT7530_MDIO
    imply NET_DSA_MT7530_MMIO
    help
      This enables support for the MediaTek MT7530 and MT7531 Ethernet switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs, and built-in switch in MT7688 SoC is supported.

config NET_DSA_MT7530_MDIO
    tristate "MediaTek MT7530 MDIO interface driver"

Should go here:

select PCS_MTK_LYNXI

Arınç

author maintainer
#33 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

Quoted 127 lines · Arınç ÜNAL
Quoted 118 lines · Arınç ÜNAL
Quoted 109 lines · Arınç ÜNAL
Quoted 76 lines · Daniel Golle
Quoted 66 lines · Arınç ÜNAL
Quoted 65 lines · Daniel Golle

Add driver for the built-in Gigabit Ethernet switch which can be found in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has it's registers mapped into the SoCs register space rather than being connected externally or internally via MDIO.

Introduce a new platform driver to support that.

---
   MAINTAINERS                   |   2 + drivers/net/dsa/Kconfig       |  12 ++++ drivers/net/dsa/Makefile      |   1 + drivers/net/dsa/mt7530-mmio.c | 101
++++++++++++++++++++++++++++++++++
   drivers/net/dsa/mt7530.c      |  86 ++++++++++++++++++++++++++++- drivers/net/dsa/mt7530.h      |  12 ++--

   6 files changed, 206 insertions(+), 8 deletions(-)

   create mode 100644 drivers/net/dsa/mt7530-mmio.c

MAINTAINERS +0 -0
index 14924aed15ca7..674673dbdfd8b 100644
@@ -13174,9 +13174,11 @@ MEDIATEK SWITCH DRIVER

   M:    Sean Wang <[email protected]>
   M:    Landen Chao <[email protected]>
   M:    DENG Qingfang <[email protected]>
+M:    Daniel Golle <[email protected]>
   L:    [email protected]
   S:    Maintained
   F:    drivers/net/dsa/mt7530-mdio.c
+F:    drivers/net/dsa/mt7530-mmio.c
   F:    drivers/net/dsa/mt7530.*
   F:    net/dsa/tag_mtk.c

drivers/net/dsa/Kconfig +0 -0
index c2551b13324c2..de4d86e37973f 100644
@@ -52,6 +52,18 @@ config NET_DSA_MT7530

         Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs is supported as well.
+config NET_DSA_MT7988
+    tristate "MediaTek MT7988 built-in Ethernet switch support" +    select NET_DSA_MT7530_COMMON
+    depends on HAS_IOMEM
+    help
+      This enables support for the built-in Ethernet switch found +      in the MediaTek MT7988 SoC.
+      The switch is a similar design as MT7531, however, unlike +      other MT7530 and MT7531 the switch registers are directly +      mapped into the SoCs register space rather than being accessible
+      via MDIO.
+
   config NET_DSA_MV88E6060
       tristate "Marvell 88E6060 ethernet switch chip support" select NET_DSA_TAG_TRAILER

drivers/net/dsa/Makefile +0 -0
index 71250d7dd41af..103a33e20de4b 100644
@@ -8,6 +8,7 @@ endif

   obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o

Quoted 8 lines
Quoted 3 lines

   obj-$(CONFIG_NET_DSA_MT7530_COMMON) += mt7530.o obj-$(CONFIG_NET_DSA_MT7530)    += mt7530-mdio.o +obj-$(CONFIG_NET_DSA_MT7988)    += mt7530-mmio.o

I'm not fond of this way. Wouldn't it be better if we split the mdio and
mmio drivers to separate modules and kept switch hardware support on mt7530.c?

Quoted 10 lines

You mean this in terms of Kconfig symbols?
Because the way you describe is basically what I'm doing here:
  * mt7530.c is the shared/common switch hardware driver
  * mt7530-mdio.c contains the MDIO accessors and MDIO device drivers for
    MT7530, MT7531, MT7621, MT7623, ...
  * mt7530-mmio.c contains the platform device driver for in-SoC switches
    which are accessed via MMIO, ie. MT7988 (and yes, this could be extended to also support MT7620A/N).

Ok great.

Quoted 6 lines

In early drafts I also named the Kconfig symbols CONFIG_NET_DSA_MT7530 for mt7530.c (ie. the common part) CONFIG_NET_DSA_MT7530_MDIO for the MDIO driver CONFIG_NET_DSA_MT7530_MMIO for the MMIO driver

Quoted 7 lines

However, as existing kernel configurations expect CONFIG_NET_DSA_MT7530 to
select the MDIO driver, I decided it would be better to hide the symbol of
the common part and have CONFIG_NET_DSA_MT7530 select the MDIO driver like
it was before.

You can "imply NET_DSA_MT7530_MDIO" from NET_DSA_MT7530 so the MDIO driver is also enabled when NET_DSA_MT7530 is selected. For example, on Realtek, both MDIO and SMI drivers are enabled by default when either of the main drivers are selected.

Quoted 7 lines

config NET_DSA_MT7530
     tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
     select MEDIATEK_GE_PHY
     select PCS_MTK_LYNXI
     imply NET_DSA_MT7530_MDIO
     imply NET_DSA_MT7530_MMIO

Quoted 7 lines

The final kconfig should look like this:

config NET_DSA_MT7530
    tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK
    select MEDIATEK_GE_PHY
    select PCS_MTK_LYNXI

Quoted 3 lines

Looks like PCS_MTK_LYNXI is used on NET_DSA_MT7530_MDIO instead now. I also see '#include <linux/pcs/pcs-mtk-lynxi.h>' on mt7530.c but don't see any functions called on it. Leftover?

Yes, you are right, it's only used in mt7530-mdio.c and the #include in mt7530.c is a left-over which I shall remove.

Quoted 9 lines
Quoted 9 lines

    imply NET_DSA_MT7530_MDIO
    imply NET_DSA_MT7530_MMIO
    help
      This enables support for the MediaTek MT7530 and MT7531 Ethernet switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs, and built-in switch in MT7688 SoC is supported.

Quoted 6 lines
Quoted 2 lines

config NET_DSA_MT7530_MDIO
    tristate "MediaTek MT7530 MDIO interface driver"

Should go here:

select PCS_MTK_LYNXI

Yeah, in Kconfig I had taken care of this already, but forgot to remove the include in mt7530.c...

Thank you for spotting this. I'll soon post v2 which includes these fixes.

#34 lore raw

Re: [PATCH net-next 14/15] net: dsa: mt7530: introduce driver for MT7988 built-in switch

In reply to Arınç ÜNAL
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

The mmio driver could be useful in the future for the MT7530 on the MT7620 SoCs or generally new hardware that would use MMIO to be controlled.

Quoted 8 lines
Quoted 6 lines

Sure, it would be a bit confusing once we add support for MT7620A/N (if that ever happens...), then CONFIG_NET_DSA_MT7988 would need to be selected to support this ancient MIPS SoC...

If you are planning to work on support for MT7620A/N feel free to suggest a better way to name the Kconfig symbols.

I don't plan to but Luiz may. Onto my suggestions.

I did start a branch to bring mt7620 ethernet+dsa upstream, but since I burned my test device's serial port, my mt7620 and rtl8367s dev days are over. After me, I wouldn't bet someone else will invest the required amount of time that mt7620 needs just to support an outdated SoC. Its internal MT7530 still only supports FastEthernet, so to have GbE, you need to add a second switch connected to its single Gigabit RGMII port. If you need GbE, you can just use an mt7621.

Regards,

Luiz

#20 lore raw

Re: [PATCH net-next 13/15] net: dsa: mt7530: add support for 10G link modes for CPU port

In reply to Daniel Golle
Quoted 15 lines · Daniel Golle

The built-in switch of the MT7988 SoC is internally connected using a stateless 10G link. Add support for 10G interface modes to silence a warning otherwise occurring when the switch driver is setup.

---
  drivers/net/dsa/mt7530.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +0 -0
index 3a4682e71e746..ac666da2d10dc 100644

drivers/net/dsa/mt7530.c mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, · line 2626

Quoted 9 lines
drivers/net/dsa/mt7530.c +3 -0
@@ -2618,6 +2618,9 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
  	case PHY_INTERFACE_MODE_1000BASEX:
  	case PHY_INTERFACE_MODE_2500BASEX:
  		/* handled in SGMII PCS driver */
+	case PHY_INTERFACE_MODE_USXGMII:
+	case PHY_INTERFACE_MODE_10GKR:
+		/* internal stateless 10G link */
  		return 0;
  	default:
  		return -EINVAL;

I think it'd be better to make this explicitly for the switch in the MT7988 SoC.

drivers/net/dsa/mt7530.c +5 -2
index e5347dd2521b..f7542c7f60e4 100644
@@ -2666,10 +2665,13 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
 	case PHY_INTERFACE_MODE_1000BASEX:
 	case PHY_INTERFACE_MODE_2500BASEX:
 		/* handled in SGMII PCS driver */
+		return 0;
 	case PHY_INTERFACE_MODE_USXGMII:
 	case PHY_INTERFACE_MODE_10GKR:
-		/* internal stateless 10G link */
-		return 0;
+		if (priv->id == ID_MT7988)
+			/* internal stateless 10G link */
+			return 0;
+
 	default:
 		return -EINVAL;
 	}

Arınç

author maintainer
#21 lore raw

Re: [PATCH net-next 13/15] net: dsa: mt7530: add support for 10G link modes for CPU port

Quoted 20 lines · Arınç ÜNAL
Quoted 19 lines · Daniel Golle

The built-in switch of the MT7988 SoC is internally connected using a stateless 10G link. Add support for 10G interface modes to silence a warning otherwise occurring when the switch driver is setup.

---
  drivers/net/dsa/mt7530.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +1 -0
index 3a4682e71e746..ac666da2d10dc 100644
@@ -2618,6 +2618,9 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
  	case PHY_INTERFACE_MODE_1000BASEX:
  	case PHY_INTERFACE_MODE_2500BASEX:
  		/* handled in SGMII PCS driver */
+	case PHY_INTERFACE_MODE_USXGMII:
Quoted 8 lines

drivers/net/dsa/mt7530.c mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, · line 2676

Quoted 5 lines
drivers/net/dsa/mt7530.c +2 -0
+	case PHY_INTERFACE_MODE_10GKR:
+		/* internal stateless 10G link */
  		return 0;
  	default:
  		return -EINVAL;

I think it'd be better to make this explicitly for the switch in the MT7988 SoC.

I decided to rather introduce mt7988_mac_config (a noop returning either 0 or -EINVAL), mt7988_mac_port_get_caps (allowing only USXGMII and 10000FD) and mt7988_cpu_port_config (setting CPU port bit in registers but not caring about interface mode and speed other than USXGMII/10000FD).

The updated commit adding MT7988 is here:
https://github.com/dangowrt/linux/commit/595c940cbee90b5dbdc8173974a007fefe641550

So then I dropped
"net: dsa: mt7530: add support for 10G link modes for CPU port" because it is no longer needed if all this is done explicitely for MT7988.

Quoted 23 lines
drivers/net/dsa/mt7530.c +5 -2
index e5347dd2521b..f7542c7f60e4 100644
@@ -2666,10 +2665,13 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
 	case PHY_INTERFACE_MODE_1000BASEX:
 	case PHY_INTERFACE_MODE_2500BASEX:
 		/* handled in SGMII PCS driver */
+		return 0;
 	case PHY_INTERFACE_MODE_USXGMII:
 	case PHY_INTERFACE_MODE_10GKR:
-		/* internal stateless 10G link */
-		return 0;
+		if (priv->id == ID_MT7988)
+			/* internal stateless 10G link */
+			return 0;
+
 	default:
 		return -EINVAL;
 	}

Arınç

author maintainer
#37 lore raw

Re: [PATCH 15/15] dt-bindings: net: dsa: mediatek,mt7530: add mediatek,mt7988-switch

In reply to Arınç ÜNAL

Hi!

Now that I see the email, see my reply below.

Quoted 26 lines · Arınç ÜNAL
Quoted 13 lines · Daniel Golle

Add documentation for the built-in switch which can be found in the MediaTek MT7988 SoC.

---
  .../bindings/net/dsa/mediatek,mt7530.yaml     | 26 +++++++++++++++++--
  1 file changed, 24 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -0
index 5ae9cd8f99a24..15953f0e9d1a6 100644

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 14

Quoted 4 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +1 -0
@@ -11,16 +11,23 @@ maintainers:
    - Landen Chao <[email protected]>
    - DENG Qingfang <[email protected]>
    - Sean Wang <[email protected]>
+  - Daniel Golle <[email protected]>

Please put it in alphabetical order by the first name.

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 18

Quoted 4 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +2 -1
  description: |
-  There are two versions of MT7530, standalone and in a multi-chip module.
+  There are three versions of MT7530, standalone, in a multi-chip module and
+  built-into a SoC.
Quoted 5 lines

I assume you put this to point out the situation with MT7988?

This brings to light an underlying problem with the description as the MT7620 SoCs described below have the MT7530 switch built into the SoC, instead of being part of the MCM.

That's true, also MT7620A/N are not MCM but rather a single die which includes the MT7530 switch afaik.

Quoted 10 lines

The switch IP on MT7988 is for sure not MT7530 so either fix this and the text below as a separate patch or let me handle it.

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 23

Quoted 3 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +1 -0
    MT7530 is a part of the multi-chip module in MT7620AN, MT7620DA, MT7620DAN,
    MT7620NN, MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs.
+  The MT7988 SoC comes a built-in switch similar to MT7531 as well as 4 Gigabit

s/comes a/comes with a

Quoted 7 lines

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 26

Quoted 3 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +3 -0
+  Ethernet PHYs and the switch registers are directly mapped into SoC's memory
+  map rather than using MDIO. It comes with an internally connected 10G CPU port
+  and 4 user ports connected to the built-in Gigabit Ethernet PHYs.

Are you sure this is not the MT7531 IP built into the SoC, like MT7530 on the MT7620 SoCs? Maybe DENG Qingfang would like to clarify as they did for MT7530.

It's basically MT7531 without port 5, without the SGMII units and with different built-in PHYs for port 0~3 (driver for those will follow in the next days, I'm still cleaning it).

Similar to other in-SoC switches also the reset routine works a bit differently, ie. instead of using a GPIO we use a bit of the reset controller, similar to how it works also for MCM.

Quoted 33 lines

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml maintainers: · line 32

Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +2 -1
+
    MT7530 in MT7620AN, MT7620DA, MT7620DAN and MT7620NN SoCs has got 10/100 PHYs
    and the switch registers are directly mapped into SoC's memory map rather than
-  using MDIO. The DSA driver currently doesn't support this.
+  using MDIO. The DSA driver currently doesn't support MT7620 variants.
    There is only the standalone version of MT7531.

Can you put the MT7988 information below here instead.

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +4 -0
@@ -81,6 +88,10 @@ properties:
            Multi-chip module MT7530 in MT7621AT, MT7621DAT and MT7621ST SoCs
          const: mediatek,mt7621
+      - description:
+          Built-in switch of the MT7988 SoC
+        const: mediatek,mt7988-switch
+
    reg:
      maxItems: 1

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml allOf: · line 286

Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +6 -0
@@ -268,6 +279,17 @@ allOf:
        required:
          - mediatek,mcm
+  - if:
+      properties:
+        compatible:
+          const: mediatek,mt7988-switch
+    then:
+      $ref: "#/$defs/mt7530-dsa-port"

The CPU ports bindings for MT7530 don't match the characteristics of the switch on the MT7988 SoC you described above. We need new definitions for the CPU ports on the switch on the MT7988 SoC.

Quoted 1 line

What's the CPU port number? Does it accept rgmii or only the 10G phy-mode?

CPU port is port 6. Port 5 is unused in MT7988 design.
It uses an internal 10G link, so I've decided to use 'internal' as phy mode which best describes that situation.

Quoted 23 lines

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml allOf: · line 291

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +4 -0
+      properties:
+        gpio-controller: false
+        mediatek,mcm: false
+        reset-names: false

I'd rather not add reset-names here and do:

- if:
required:
- mediatek,mcm
then:
properties:
reset-gpios: false

required:
- resets
- reset-names
else:
properties:
resets: false
reset-names: false

Quoted 1 line

I can handle this if you'd like.

Oh yes, that would be very nice. I'm definitely not an expert on dt-bindings and will probably need several attempts to correctly address all of that.

Thank you!

Daniel