generic: 6.1, 6.6: move accepted patches to backport folders
[openwrt/staging/stintel.git] / target / linux / generic / backport-6.1 / 790-70-v6.10-796-net-dsa-mt7530-detect-PHY-muxing-when-PHY-is-defined.patch
1 From d8dcf5bd6d0eace9f7c1daa14b63b3925b09d033 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
3 Date: Tue, 30 Apr 2024 08:01:33 +0300
4 Subject: [PATCH] net: dsa: mt7530: detect PHY muxing when PHY is defined on
5 switch MDIO bus
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Currently, the MT7530 DSA subdriver configures the MT7530 switch to provide
11 direct access to switch PHYs, meaning, the switch PHYs listen on the MDIO
12 bus the switch listens on. The PHY muxing feature makes use of this.
13
14 This is problematic as the PHY may be attached before the switch is
15 initialised, in which case, the PHY will fail to be attached.
16
17 Since commit 91374ba537bd ("net: dsa: mt7530: support OF-based registration
18 of switch MDIO bus"), we can describe the switch PHYs on the MDIO bus of
19 the switch on the device tree. Extend the check to detect PHY muxing when
20 the PHY is defined on the MDIO bus of the switch on the device tree.
21
22 When the PHY is described this way, the switch will be initialised first,
23 then the switch MDIO bus will be registered. Only after these steps, the
24 PHY will be attached.
25
26 Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
27 Reviewed-by: Daniel Golle <daniel@makrotopia.org>
28 Link: https://lore.kernel.org/r/20240430-b4-for-netnext-mt7530-use-switch-mdio-bus-for-phy-muxing-v2-1-9104d886d0db@arinc9.com
29 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
30 ---
31 drivers/net/dsa/mt7530.c | 3 ++-
32 1 file changed, 2 insertions(+), 1 deletion(-)
33
34 --- a/drivers/net/dsa/mt7530.c
35 +++ b/drivers/net/dsa/mt7530.c
36 @@ -2489,7 +2489,8 @@ mt7530_setup(struct dsa_switch *ds)
37 if (!phy_node)
38 continue;
39
40 - if (phy_node->parent == priv->dev->of_node->parent) {
41 + if (phy_node->parent == priv->dev->of_node->parent ||
42 + phy_node->parent->parent == priv->dev->of_node) {
43 ret = of_get_phy_mode(mac_np, &interface);
44 if (ret && ret != -ENODEV) {
45 of_node_put(mac_np);