[openwrt/openwrt] ramips: mt7620: fix ethernet driver GMAC port init

LEDE Commits lede-commits at lists.infradead.org
Tue Apr 19 05:55:58 PDT 2022


ynezz pushed a commit to openwrt/openwrt.git, branch openwrt-21.02:
https://git.openwrt.org/01bbed74445f82a0da8c414b132762fe2aed1344

commit 01bbed74445f82a0da8c414b132762fe2aed1344
Author: Michael Pratt <mcpratt at pm.me>
AuthorDate: Tue Jun 1 23:01:26 2021 -0400

    ramips: mt7620: fix ethernet driver GMAC port init
    
    A workaround was added to the switch driver
    to set SOC port 4 as an RGMII GMAC interface
    based on the DTS property mediatek,port4-gmac.
    (previously mediatek,port4)
    
    However, the ethernet driver already does this,
    but is being blocked by a return statement
    whenever the phy-handle and fixed-link properties
    are both missing from nodes that define the port properties.
    
    Revert the workaround, so that both the switch driver
    and ethernet driver are not doing the same thing
    and move the phy-handle related lines down
    so nothing is ending the function prematurely.
    
    While at it, clean up kernel messages
    and delete useless return statements.
    
    Fixes: f6d81e2fa1f1 ("mt7620: gsw: make IntPHY and ExtPHY share mdio addr 4 possible")
    Signed-off-by: Michael Pratt <mcpratt at pm.me>
    (cherry picked from commit afd60d650e769e9578eac5bb3647807f683aaf7c)
---
 .../files/drivers/net/ethernet/ralink/gsw_mt7620.c     |  6 ------
 .../files/drivers/net/ethernet/ralink/soc_mt7620.c     | 18 +++++++++---------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c
index 798dc919bc..2a34e9417d 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c
+++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c
@@ -211,12 +211,6 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode)
 		_mt7620_mii_write(gsw, gsw->ephy_base + 4, 4, 0x05e1);
 		_mt7620_mii_write(gsw, gsw->ephy_base + 4, 16, 0x1313);
 		pr_info("gsw: setting port4 to ephy mode\n");
-	} else if (!mdio_mode) {
-		u32 val = rt_sysc_r32(SYSC_REG_CFG1);
-
-		val &= ~(3 << 14);
-		rt_sysc_w32(val, SYSC_REG_CFG1);
-		pr_info("gsw: setting port4 to gmac mode\n");
 	}
 }
 
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c
index 0b332ae9d6..49aa4da507 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c
+++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c
@@ -158,7 +158,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np)
 	    (size != (4 * sizeof(*priv->phy->phy_fixed[id])))) {
 		pr_err("%s: invalid fixed link property\n", np->name);
 		priv->phy->phy_fixed[id] = NULL;
-		return;
 	}
 
 	phy_mode = of_get_phy_mode(np);
@@ -196,10 +195,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np)
 		return;
 	}
 
-	priv->phy->phy_node[id] = of_parse_phandle(np, "phy-handle", 0);
-	if (!priv->phy->phy_node[id] && !priv->phy->phy_fixed[id])
-		return;
-
 	val = rt_sysc_r32(SYSC_REG_CFG1);
 	val &= ~(3 << shift);
 	val |= mask << shift;
@@ -240,8 +235,8 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np)
 			val = 2;
 			break;
 		default:
-			dev_err(priv->dev, "invalid link speed: %d\n",
-				priv->phy->speed[id]);
+			dev_err(priv->dev, "port %d - invalid link speed: %d\n",
+				id, priv->phy->speed[id]);
 			priv->phy->phy_fixed[id] = 0;
 			return;
 		}
@@ -255,7 +250,13 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np)
 		if (priv->phy->duplex[id])
 			val |= PMCR_DUPLEX;
 		mtk_switch_w32(gsw, val, GSW_REG_PORT_PMCR(id));
-		dev_info(priv->dev, "using fixed link parameters\n");
+		dev_info(priv->dev, "port %d - using fixed link parameters\n", id);
+		return;
+	}
+
+	priv->phy->phy_node[id] = of_parse_phandle(np, "phy-handle", 0);
+	if (!priv->phy->phy_node[id]) {
+		dev_err(priv->dev, "port %d - missing phy handle\n", id);
 		return;
 	}
 
@@ -268,7 +269,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np)
 		fe_connect_phy_node(priv, priv->phy->phy_node[id], id);
 		gsw->autopoll |= BIT(be32_to_cpup(phy_addr));
 		mt7620_auto_poll(gsw,id);
-		return;
 	}
 }
 




More information about the lede-commits mailing list