generic: 6.1: sync mt7530 DSA driver with upstream
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 790-29-v6.9-net-dsa-mt7530-do-not-run-mt7530_setup_port5-if-port.patch
diff --git a/target/linux/generic/backport-6.1/790-29-v6.9-net-dsa-mt7530-do-not-run-mt7530_setup_port5-if-port.patch b/target/linux/generic/backport-6.1/790-29-v6.9-net-dsa-mt7530-do-not-run-mt7530_setup_port5-if-port.patch
new file mode 100644 (file)
index 0000000..c121eb4
--- /dev/null
@@ -0,0 +1,62 @@
+From 3b423061eb3a62e59b57939ae1e1234756a0f6a1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
+Date: Mon, 22 Jan 2024 08:35:58 +0300
+Subject: [PATCH 29/48] net: dsa: mt7530: do not run mt7530_setup_port5() if
+ port 5 is disabled
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+There's no need to run all the code on mt7530_setup_port5() if port 5 is
+disabled. The only case for calling mt7530_setup_port5() from
+mt7530_setup() is when PHY muxing is enabled. That is because port 5 is not
+defined as a port on the devicetree, therefore, it cannot be controlled by
+phylink.
+
+Because of this, run mt7530_setup_port5() if priv->p5_intf_sel is
+P5_INTF_SEL_PHY_P0 or P5_INTF_SEL_PHY_P4. Remove the P5_DISABLED case from
+mt7530_setup_port5().
+
+Stop initialising the interface variable as the remaining cases will always
+call mt7530_setup_port5() with it initialised.
+
+Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
+Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
+Link: https://lore.kernel.org/r/20240122-for-netnext-mt7530-improvements-1-v3-7-042401f2b279@arinc9.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+---
+ drivers/net/dsa/mt7530.c | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+--- a/drivers/net/dsa/mt7530.c
++++ b/drivers/net/dsa/mt7530.c
+@@ -935,9 +935,6 @@ static void mt7530_setup_port5(struct ds
+               /* MT7530_P5_MODE_GMAC: P5 -> External phy or 2nd GMAC */
+               val &= ~MHWTRAP_P5_DIS;
+               break;
+-      case P5_DISABLED:
+-              interface = PHY_INTERFACE_MODE_NA;
+-              break;
+       default:
+               dev_err(ds->dev, "Unsupported p5_intf_sel %d\n",
+                       priv->p5_intf_sel);
+@@ -2358,8 +2355,6 @@ mt7530_setup(struct dsa_switch *ds)
+                * Set priv->p5_intf_sel to the appropriate value if PHY muxing
+                * is detected.
+                */
+-              interface = PHY_INTERFACE_MODE_NA;
+-
+               for_each_child_of_node(dn, mac_np) {
+                       if (!of_device_is_compatible(mac_np,
+                                                    "mediatek,eth-mac"))
+@@ -2391,7 +2386,9 @@ mt7530_setup(struct dsa_switch *ds)
+                       break;
+               }
+-              mt7530_setup_port5(ds, interface);
++              if (priv->p5_intf_sel == P5_INTF_SEL_PHY_P0 ||
++                  priv->p5_intf_sel == P5_INTF_SEL_PHY_P4)
++                      mt7530_setup_port5(ds, interface);
+       }
+ #ifdef CONFIG_GPIOLIB