From 0a64c7a7b6d9ca5805a9a5ff2067b6694dbc5010 Mon Sep 17 00:00:00 2001 From: Mieczyslaw Nalewaj Date: Wed, 3 Jun 2026 16:51:29 +0200 Subject: [PATCH] ramips: ethernet: ralink: add mediatek,no-swconfig property Skip swconfig registration and disable MAC learning when the "mediatek,no-swconfig" property is set. This is needed for MT7620 devices using the internal switch as a transparent bridge to an external RGMII switch, where ports 0-4 are unused. The no-swconfig property itself is valid for both DSA and non-DSA setups. However, disabling MAC learning is only required for DSA, where multiple CPU-facing interfaces would otherwise cause an incorrect ARL table to be built. Non-DSA setups work correctly without disabling MAC learning. Signed-off-by: Mieczyslaw Nalewaj Link: https://github.com/openwrt/openwrt/pull/23933 Signed-off-by: Robert Marko --- .../drivers/net/ethernet/ralink/mt7530.c | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c index 07f092a2f8c..277a98cbe7d 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c @@ -84,9 +84,12 @@ enum { }; #define REG_ESW_PORT_PCR(x) (0x2004 | ((x) << 8)) +#define REG_ESW_PORT_PSC(x) (0x200C | ((x) << 8)) #define REG_ESW_PORT_PVC(x) (0x2010 | ((x) << 8)) #define REG_ESW_PORT_PPBV1(x) (0x2014 | ((x) << 8)) +#define REG_ESW_PORT_PSC_SA_DIS BIT(4) + #define REG_ESW_PORT_PCR_MIRROR_SRC_RX_BIT BIT(8) #define REG_ESW_PORT_PCR_MIRROR_SRC_TX_BIT BIT(9) #define REG_ESW_PORT_PCR_MIRROR_SRC_RX_MASK 0x0100 @@ -1008,6 +1011,7 @@ mt7530_probe(struct device *dev, void __iomem *base, struct mii_bus *bus, int vl struct mt7530_priv *mt7530; struct mt7530_mapping *map; int ret; + int i; mt7530 = devm_kzalloc(dev, sizeof(struct mt7530_priv), GFP_KERNEL); if (!mt7530) @@ -1030,17 +1034,25 @@ mt7530_probe(struct device *dev, void __iomem *base, struct mii_bus *bus, int vl swdev->vlans = MT7530_NUM_VLANS; swdev->ops = &mt7530_ops; - ret = register_switch(swdev, NULL); - if (ret) { - dev_err(dev, "failed to register mt7530\n"); - return ret; - } + if (!of_property_present(dev->of_node, "mediatek,no-swconfig")) { + ret = register_switch(swdev, NULL); + if (ret) { + dev_err(dev, "failed to register %s\n", swdev->name); + return ret; + } + map = mt7530_find_mapping(dev->of_node); + if (map) + mt7530_apply_mapping(mt7530, map); + mt7530_apply_config(swdev); + } else { + pr_info("%s: swconfig disabled, MAC learning disabled on all ports\n", swdev->name); - map = mt7530_find_mapping(dev->of_node); - if (map) - mt7530_apply_mapping(mt7530, map); - mt7530_apply_config(swdev); + for (i = 0; i < MT7530_NUM_PORTS; i++) { + mt7530_w32(mt7530, REG_ESW_PORT_PSC(i), + mt7530_r32(mt7530, REG_ESW_PORT_PSC(i)) | REG_ESW_PORT_PSC_SA_DIS); + } + } /* magic vodoo */ if (bus && mt7530_r32(mt7530, REG_HWTRAP) != 0x1117edf) { -- 2.47.3