Skip to contentSkip to conversation

net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC

PATCH Superseded Daniel Golle 2 participants 2 messages Jun 11, 2023 – Jun 12, 2023

Subsystems (4)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 8/8 net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC

From: Lorenzo Bianconi <[email protected]>

Introduce support for ethernet chip available in MT7988 SoC to mtk_eth_soc driver. As a first step support only the first GMAC which is hard-wired to the internal DSA switch having 4 built-in gigabit Ethernet PHYs.

---
 drivers/net/ethernet/mediatek/mtk_eth_path.c |  11 +-
 drivers/net/ethernet/mediatek/mtk_eth_soc.c  | 205 +++++++++++++++++--
 drivers/net/ethernet/mediatek/mtk_eth_soc.h  |  85 +++++++-
 3 files changed, 279 insertions(+), 22 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_path.c +8 -3
index 34ac492e047cb..bc8e7e3121ac4 100644
@@ -42,8 +42,8 @@ static const char *mtk_eth_path_name(u64 path)
 
 static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path)
 {
+	u32 val, mask, set, reg;
 	bool updated = true;
-	u32 val, mask, set;
 
 	switch (path) {
 	case MTK_ETH_PATH_GMAC1_SGMII:
@@ -59,10 +59,15 @@ static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path)
 		break;
 	}
 
+	if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3))
+		reg = MTK_MAC_MISC_V3;
+	else
+		reg = MTK_MAC_MISC;
+
 	if (updated) {
-		val = mtk_r32(eth, MTK_MAC_MISC);
+		val = mtk_r32(eth, reg);
 		val = (val & mask) | set;
-		mtk_w32(eth, val, MTK_MAC_MISC);
+		mtk_w32(eth, val, reg);
 	}
 
 	dev_dbg(eth->dev, "path %s in %s updated = %d\n",
drivers/net/ethernet/mediatek/mtk_eth_soc.c +187 -18

267 lines not on this page · raw message

drivers/net/ethernet/mediatek/mtk_eth_soc.h +84 -1

128 lines not on this page · raw message

Signature · 1 line
2.41.0
#1 lore raw

drivers/net/ethernet/mediatek/mtk_eth_path.c static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path) · line 70

Quoted 6 lines · Daniel Golle
drivers/net/ethernet/mediatek/mtk_eth_path.c +2 -2
 	if (updated) {
-		val = mtk_r32(eth, MTK_MAC_MISC);
+		val = mtk_r32(eth, reg);
 		val = (val & mask) | set;
-		mtk_w32(eth, val, MTK_MAC_MISC);
+		mtk_w32(eth, val, reg);

mtk_m32() ?

drivers/net/ethernet/mediatek/mtk_eth_soc.c static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, · line 534

Quoted 11 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +11 -0
+	/* Force Port1 XGMAC Link Up */
+	val = mtk_r32(eth, MTK_XGMAC_STS(MTK_GMAC1_ID));
+	mtk_w32(eth, val | MTK_XGMAC_FORCE_LINK(MTK_GMAC1_ID),
+		MTK_XGMAC_STS(MTK_GMAC1_ID));
+
+	/* Adjust GSW bridge IPG to 11 */
+	val = mtk_r32(eth, MTK_GSW_CFG);
+	val &= ~(GSWTX_IPG_MASK | GSWRX_IPG_MASK);
+	val |= (GSW_IPG_11 << GSWTX_IPG_SHIFT) |
+	       (GSW_IPG_11 << GSWRX_IPG_SHIFT);
+	mtk_w32(eth, val, MTK_GSW_CFG);

mtk_m32() for both these?

drivers/net/ethernet/mediatek/mtk_eth_soc.c static void mtk_mac_config(struct phylink_config *config, unsigned int mode, · line 682

Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +7 -0
+	/* Setup gmac */
+	if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3) &&
+	    mac->interface == PHY_INTERFACE_MODE_INTERNAL) {
+		mtk_w32(mac->hw, MTK_GDMA_XGDM_SEL, MTK_GDMA_EG_CTRL(mac->id));
+		mtk_w32(mac->hw, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(mac->id));
+
+		mtk_setup_bridge_switch(eth);

I think this should be documented somewhere - that PHY_INTERFACE_MODE_INTERNAL means the MAC is connected to a switch. However, I'm not sure that's the best condition to use - don't we have a way for a MAC to test if it's connected to a DSA switch?

Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +6 -0
+	/* Configure MDC Turbo Mode */
+	if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) {
+		val = mtk_r32(eth, MTK_MAC_MISC_V3);
+		val |= MISC_MDC_TURBO;
+		mtk_w32(eth, val, MTK_MAC_MISC_V3);
+	}

drivers/net/ethernet/mediatek/mtk_eth_soc.c static int mtk_mdio_init(struct mtk_eth *eth) · line 944

Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +6 -1
 	val = mtk_r32(eth, MTK_PPSC);
+	if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1) ||
+	    MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
+		val |= PPSC_MDC_TURBO;
+
+	/* Configure MDC Divider */
 	val &= ~PPSC_MDC_CFG;
-	val |= FIELD_PREP(PPSC_MDC_CFG, divider) | PPSC_MDC_TURBO;
+	val |= FIELD_PREP(PPSC_MDC_CFG, divider);
 	mtk_w32(eth, val, MTK_PPSC);

More opportunities for mtk_m32().

drivers/net/ethernet/mediatek/mtk_eth_soc.c static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) · line 4623

Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +7 -0
+	if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_NETSYS_V3_BIT) &&
+	    MTK_HAS_CAPS(mac->hw->soc->caps, MTK_ESW_BIT) &&
+	    id == MTK_GMAC1_ID) {
+		mac->phylink_config.mac_capabilities = MAC_ASYM_PAUSE |
+						       MAC_SYM_PAUSE |
+						       MAC_10000FD;
+		phy_interface_zero(mac->phylink_config.supported_interfaces);

Were there bits set that you don't want?

Thanks!

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!