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 <namiltd@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/23933
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Mieczyslaw Nalewaj
2026-06-29 14:54:58 +02:00
committed by Robert Marko
parent 3c0a73b4d2
commit 0a64c7a7b6
@@ -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,18 +1034,26 @@ 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);
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);
}
}
map = mt7530_find_mapping(dev->of_node);
if (map)
mt7530_apply_mapping(mt7530, map);
mt7530_apply_config(swdev);
/* magic vodoo */
if (bus && mt7530_r32(mt7530, REG_HWTRAP) != 0x1117edf) {
dev_info(dev, "fixing up MHWTRAP register - bootloader probably played with it\n");