]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
ramips: ethernet: ralink: add mediatek,no-swconfig property 23933/head
authorMieczyslaw Nalewaj <namiltd@yahoo.com>
Wed, 3 Jun 2026 14:51:29 +0000 (16:51 +0200)
committerRobert Marko <robimarko@gmail.com>
Mon, 29 Jun 2026 12:54:58 +0000 (14:54 +0200)
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>
target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c

index 07f092a2f8caeef24e1e515c850b108f217eac7f..277a98cbe7d83448d6dae2be8c10780133774eaf 100644 (file)
@@ -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) {