5683f5
From cdd8b8a433c9c3c540d41591374fb0cbdc115878 Mon Sep 17 00:00:00 2001
5683f5
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
5683f5
Date: Wed, 24 Mar 2021 20:36:04 +0100
5683f5
Subject: [PATCH 10/17] net: dsa: lantiq_gswip: Let GSWIP automatically set the
5683f5
 xMII clock
5683f5
Git-commit: 3e6fdeb28f4c331acbd27bdb0effc4befd4ef8e8
5683f5
References: git-fixes
5683f5
Patch-mainline: v5.12-rc7
5683f5
5683f5
The xMII interface clock depends on the PHY interface (MII, RMII, RGMII)
5683f5
as well as the current link speed. Explicitly configure the GSWIP to
5683f5
automatically select the appropriate xMII interface clock.
5683f5
5683f5
This fixes an issue seen by some users where ports using an external
5683f5
RMII or RGMII PHY were deaf (no RX or TX traffic could be seen). Most
5683f5
likely this is due to an "invalid" xMII clock being selected either by
5683f5
the bootloader or hardware-defaults.
5683f5
5683f5
Fixes: 14fceff4771e51 ("net: dsa: Add Lantiq / Intel DSA driver for vrx200")
5683f5
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
5683f5
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
5683f5
Signed-off-by: David S. Miller <davem@davemloft.net>
5683f5
Signed-off-by: Denis Kirjanov <denis.kirjanov@suse.com>
5683f5
---
5683f5
 drivers/net/dsa/lantiq_gswip.c | 9 +++++++--
5683f5
 1 file changed, 7 insertions(+), 2 deletions(-)
5683f5
5683f5
diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
5683f5
index 69884a719b87..7bb7f3f4b880 100644
5683f5
--- a/drivers/net/dsa/lantiq_gswip.c
5683f5
+++ b/drivers/net/dsa/lantiq_gswip.c
5683f5
@@ -789,10 +789,15 @@ static int gswip_setup(struct dsa_switch *ds)
5683f5
 	/* Configure the MDIO Clock 2.5 MHz */
5683f5
 	gswip_mdio_mask(priv, 0xff, 0x09, GSWIP_MDIO_MDC_CFG1);
5683f5
 
5683f5
-	/* Disable the xMII link */
5683f5
-	for (i = 0; i < priv->hw_info->max_ports; i++)
5683f5
+	for (i = 0; i < priv->hw_info->max_ports; i++) {
5683f5
+		/* Disable the xMII link */
5683f5
 		gswip_mii_mask_cfg(priv, GSWIP_MII_CFG_EN, 0, i);
5683f5
 
5683f5
+		/* Automatically select the xMII interface clock */
5683f5
+		gswip_mii_mask_cfg(priv, GSWIP_MII_CFG_RATE_MASK,
5683f5
+				   GSWIP_MII_CFG_RATE_AUTO, i);
5683f5
+	}
5683f5
+
5683f5
 	/* enable special tag insertion on cpu port */
5683f5
 	gswip_switch_mask(priv, 0, GSWIP_FDMA_PCTRL_STEN,
5683f5
 			  GSWIP_FDMA_PCTRLp(cpu_port));
5683f5
-- 
5683f5
2.16.4
5683f5