netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: mt7530: setup core clock even in TRGMII mode
@ 2021-03-11  1:21 Ilya Lipnitskiy
  2021-03-11  3:21 ` Florian Fainelli
  2021-03-12  8:07 ` [PATCH net,v2] " Ilya Lipnitskiy
  0 siblings, 2 replies; 5+ messages in thread
From: Ilya Lipnitskiy @ 2021-03-11  1:21 UTC (permalink / raw)
  To: Sean Wang, Landen Chao, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller,
	Jakub Kicinski, Matthias Brugger, Philipp Zabel, Russell King,
	netdev, linux-arm-kernel, linux-mediatek, linux-kernel
  Cc: Ilya Lipnitskiy

A recent change to MIPS ralink reset logic made it so mt7530 actually
resets the switch on platforms such as mt7621 (where bit 2 is the reset
line for the switch). That exposed an issue where the switch would not
function properly in TRGMII mode after a reset.

Reconfigure core clock in TRGMII mode to fix the issue.

Tested on Ubiquiti ER-X (MT7621) with TRGMII mode enabled.

Fixes: 3f9ef7785a9c ("MIPS: ralink: manage low reset lines")
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
 drivers/net/dsa/mt7530.c | 52 +++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index f06f5fa2f898..9871d7cff93a 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -436,34 +436,32 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
 			     TD_DM_DRVP(8) | TD_DM_DRVN(8));
 
 	/* Setup core clock for MT7530 */
-	if (!trgint) {
-		/* Disable MT7530 core clock */
-		core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
-
-		/* Disable PLL, since phy_device has not yet been created
-		 * provided for phy_[read,write]_mmd_indirect is called, we
-		 * provide our own core_write_mmd_indirect to complete this
-		 * function.
-		 */
-		core_write_mmd_indirect(priv,
-					CORE_GSWPLL_GRP1,
-					MDIO_MMD_VEND2,
-					0);
-
-		/* Set core clock into 500Mhz */
-		core_write(priv, CORE_GSWPLL_GRP2,
-			   RG_GSWPLL_POSDIV_500M(1) |
-			   RG_GSWPLL_FBKDIV_500M(25));
+	/* Disable MT7530 core clock */
+	core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
 
-		/* Enable PLL */
-		core_write(priv, CORE_GSWPLL_GRP1,
-			   RG_GSWPLL_EN_PRE |
-			   RG_GSWPLL_POSDIV_200M(2) |
-			   RG_GSWPLL_FBKDIV_200M(32));
-
-		/* Enable MT7530 core clock */
-		core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
-	}
+	/* Disable PLL, since phy_device has not yet been created
+	 * provided for phy_[read,write]_mmd_indirect is called, we
+	 * provide our own core_write_mmd_indirect to complete this
+	 * function.
+	 */
+	core_write_mmd_indirect(priv,
+				CORE_GSWPLL_GRP1,
+				MDIO_MMD_VEND2,
+				0);
+
+	/* Set core clock into 500Mhz */
+	core_write(priv, CORE_GSWPLL_GRP2,
+		   RG_GSWPLL_POSDIV_500M(1) |
+		   RG_GSWPLL_FBKDIV_500M(25));
+
+	/* Enable PLL */
+	core_write(priv, CORE_GSWPLL_GRP1,
+		   RG_GSWPLL_EN_PRE |
+		   RG_GSWPLL_POSDIV_200M(2) |
+		   RG_GSWPLL_FBKDIV_200M(32));
+
+	/* Enable MT7530 core clock */
+	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
 
 	/* Setup the MT7530 TRGMII Tx Clock */
 	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net: dsa: mt7530: setup core clock even in TRGMII mode
  2021-03-11  1:21 [PATCH net] net: dsa: mt7530: setup core clock even in TRGMII mode Ilya Lipnitskiy
@ 2021-03-11  3:21 ` Florian Fainelli
  2021-03-12  8:07 ` [PATCH net,v2] " Ilya Lipnitskiy
  1 sibling, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2021-03-11  3:21 UTC (permalink / raw)
  To: Ilya Lipnitskiy, Sean Wang, Landen Chao, Andrew Lunn,
	Vivien Didelot, Vladimir Oltean, David S. Miller, Jakub Kicinski,
	Matthias Brugger, Philipp Zabel, Russell King, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel



On 3/10/2021 5:21 PM, Ilya Lipnitskiy wrote:
> A recent change to MIPS ralink reset logic made it so mt7530 actually
> resets the switch on platforms such as mt7621 (where bit 2 is the reset
> line for the switch). That exposed an issue where the switch would not
> function properly in TRGMII mode after a reset.
> 
> Reconfigure core clock in TRGMII mode to fix the issue.
> 
> Tested on Ubiquiti ER-X (MT7621) with TRGMII mode enabled.
> 
> Fixes: 3f9ef7785a9c ("MIPS: ralink: manage low reset lines")
> Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net,v2] net: dsa: mt7530: setup core clock even in TRGMII mode
  2021-03-11  1:21 [PATCH net] net: dsa: mt7530: setup core clock even in TRGMII mode Ilya Lipnitskiy
  2021-03-11  3:21 ` Florian Fainelli
@ 2021-03-12  8:07 ` Ilya Lipnitskiy
  2021-03-19 10:25   ` René van Dorst
  1 sibling, 1 reply; 5+ messages in thread
From: Ilya Lipnitskiy @ 2021-03-12  8:07 UTC (permalink / raw)
  To: Sean Wang, Landen Chao, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller,
	Jakub Kicinski, Matthias Brugger, Philipp Zabel, Russell King,
	netdev, linux-arm-kernel, linux-mediatek, linux-kernel, sander,
	tsbogend, john
  Cc: Ilya Lipnitskiy

A recent change to MIPS ralink reset logic made it so mt7530 actually
resets the switch on platforms such as mt7621 (where bit 2 is the reset
line for the switch). That exposed an issue where the switch would not
function properly in TRGMII mode after a reset.

Reconfigure core clock in TRGMII mode to fix the issue.

Tested on Ubiquiti ER-X (MT7621) with TRGMII mode enabled.

Fixes: 3f9ef7785a9c ("MIPS: ralink: manage low reset lines")
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
 drivers/net/dsa/mt7530.c | 52 +++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index f06f5fa2f898..9871d7cff93a 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -436,34 +436,32 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
 			     TD_DM_DRVP(8) | TD_DM_DRVN(8));
 
 	/* Setup core clock for MT7530 */
-	if (!trgint) {
-		/* Disable MT7530 core clock */
-		core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
-
-		/* Disable PLL, since phy_device has not yet been created
-		 * provided for phy_[read,write]_mmd_indirect is called, we
-		 * provide our own core_write_mmd_indirect to complete this
-		 * function.
-		 */
-		core_write_mmd_indirect(priv,
-					CORE_GSWPLL_GRP1,
-					MDIO_MMD_VEND2,
-					0);
-
-		/* Set core clock into 500Mhz */
-		core_write(priv, CORE_GSWPLL_GRP2,
-			   RG_GSWPLL_POSDIV_500M(1) |
-			   RG_GSWPLL_FBKDIV_500M(25));
+	/* Disable MT7530 core clock */
+	core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
 
-		/* Enable PLL */
-		core_write(priv, CORE_GSWPLL_GRP1,
-			   RG_GSWPLL_EN_PRE |
-			   RG_GSWPLL_POSDIV_200M(2) |
-			   RG_GSWPLL_FBKDIV_200M(32));
-
-		/* Enable MT7530 core clock */
-		core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
-	}
+	/* Disable PLL, since phy_device has not yet been created
+	 * provided for phy_[read,write]_mmd_indirect is called, we
+	 * provide our own core_write_mmd_indirect to complete this
+	 * function.
+	 */
+	core_write_mmd_indirect(priv,
+				CORE_GSWPLL_GRP1,
+				MDIO_MMD_VEND2,
+				0);
+
+	/* Set core clock into 500Mhz */
+	core_write(priv, CORE_GSWPLL_GRP2,
+		   RG_GSWPLL_POSDIV_500M(1) |
+		   RG_GSWPLL_FBKDIV_500M(25));
+
+	/* Enable PLL */
+	core_write(priv, CORE_GSWPLL_GRP1,
+		   RG_GSWPLL_EN_PRE |
+		   RG_GSWPLL_POSDIV_200M(2) |
+		   RG_GSWPLL_FBKDIV_200M(32));
+
+	/* Enable MT7530 core clock */
+	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
 
 	/* Setup the MT7530 TRGMII Tx Clock */
 	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net,v2] net: dsa: mt7530: setup core clock even in TRGMII mode
  2021-03-12  8:07 ` [PATCH net,v2] " Ilya Lipnitskiy
@ 2021-03-19 10:25   ` René van Dorst
  2021-03-19 12:47     ` Aw: " Frank Wunderlich
  0 siblings, 1 reply; 5+ messages in thread
From: René van Dorst @ 2021-03-19 10:25 UTC (permalink / raw)
  To: Ilya Lipnitskiy
  Cc: Sean Wang, Landen Chao, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller,
	Jakub Kicinski, Matthias Brugger, Philipp Zabel, Russell King,
	netdev, linux-arm-kernel, linux-mediatek, linux-kernel, sander,
	tsbogend, john, Frank Wunderlich

Quoting Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>:

> A recent change to MIPS ralink reset logic made it so mt7530 actually
> resets the switch on platforms such as mt7621 (where bit 2 is the reset
> line for the switch). That exposed an issue where the switch would not
> function properly in TRGMII mode after a reset.
>
> Reconfigure core clock in TRGMII mode to fix the issue.
>
> Tested on Ubiquiti ER-X (MT7621) with TRGMII mode enabled.
>
> Fixes: 3f9ef7785a9c ("MIPS: ralink: manage low reset lines")
> Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
> ---
>  drivers/net/dsa/mt7530.c | 52 +++++++++++++++++++---------------------
>  1 file changed, 25 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index f06f5fa2f898..9871d7cff93a 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -436,34 +436,32 @@ mt7530_pad_clk_setup(struct dsa_switch *ds,  
> phy_interface_t interface)
>  			     TD_DM_DRVP(8) | TD_DM_DRVN(8));
>
>  	/* Setup core clock for MT7530 */
> -	if (!trgint) {
> -		/* Disable MT7530 core clock */
> -		core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
> -
> -		/* Disable PLL, since phy_device has not yet been created
> -		 * provided for phy_[read,write]_mmd_indirect is called, we
> -		 * provide our own core_write_mmd_indirect to complete this
> -		 * function.
> -		 */
> -		core_write_mmd_indirect(priv,
> -					CORE_GSWPLL_GRP1,
> -					MDIO_MMD_VEND2,
> -					0);
> -
> -		/* Set core clock into 500Mhz */
> -		core_write(priv, CORE_GSWPLL_GRP2,
> -			   RG_GSWPLL_POSDIV_500M(1) |
> -			   RG_GSWPLL_FBKDIV_500M(25));
> +	/* Disable MT7530 core clock */
> +	core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
>
> -		/* Enable PLL */
> -		core_write(priv, CORE_GSWPLL_GRP1,
> -			   RG_GSWPLL_EN_PRE |
> -			   RG_GSWPLL_POSDIV_200M(2) |
> -			   RG_GSWPLL_FBKDIV_200M(32));
> -
> -		/* Enable MT7530 core clock */
> -		core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
> -	}
> +	/* Disable PLL, since phy_device has not yet been created
> +	 * provided for phy_[read,write]_mmd_indirect is called, we
> +	 * provide our own core_write_mmd_indirect to complete this
> +	 * function.
> +	 */
> +	core_write_mmd_indirect(priv,
> +				CORE_GSWPLL_GRP1,
> +				MDIO_MMD_VEND2,
> +				0);
> +
> +	/* Set core clock into 500Mhz */
> +	core_write(priv, CORE_GSWPLL_GRP2,
> +		   RG_GSWPLL_POSDIV_500M(1) |
> +		   RG_GSWPLL_FBKDIV_500M(25));
> +
> +	/* Enable PLL */
> +	core_write(priv, CORE_GSWPLL_GRP1,
> +		   RG_GSWPLL_EN_PRE |
> +		   RG_GSWPLL_POSDIV_200M(2) |
> +		   RG_GSWPLL_FBKDIV_200M(32));
> +
> +	/* Enable MT7530 core clock */
> +	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
>
>  	/* Setup the MT7530 TRGMII Tx Clock */
>  	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
> --
> 2.30.2

Hi Ilya,

Thanks for fixing this issue.

I remember that Frank also had an issue with TRGMII on his MT7623 ARM board.
I never found why it did not work but this may be also fix his issue  
on the MT7623 devices.

Added Frank to CC.

Tested on Ubiquiti ER-X-SFP (MT7621) with and without TRGMII mode enabled.

Tested-by: René van Dorst <opensource@vdorst.com>

Greats,

René


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Aw: Re: [PATCH net,v2] net: dsa: mt7530: setup core clock even in TRGMII mode
  2021-03-19 10:25   ` René van Dorst
@ 2021-03-19 12:47     ` Frank Wunderlich
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Wunderlich @ 2021-03-19 12:47 UTC (permalink / raw)
  To: René van Dorst, Ilya Lipnitskiy
  Cc: Sean Wang, Landen Chao, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller,
	Jakub Kicinski, Matthias Brugger, Philipp Zabel, Russell King,
	netdev, linux-arm-kernel, linux-mediatek, linux-kernel, sander,
	tsbogend, john

Hi René,Ilya

> Gesendet: Freitag, 19. März 2021 um 11:25 Uhr
> Von: "René van Dorst" <opensource@vdorst.com>
> Hi Ilya,
> 
> Thanks for fixing this issue.
> 
> I remember that Frank also had an issue with TRGMII on his MT7623 ARM board.
> I never found why it did not work but this may be also fix his issue  
> on the MT7623 devices.
> 
> Added Frank to CC.

thanks for pointing me here. my issue was after getting trgmii working with phylink-patches (5.3) that i only got only 940Mbit over the switch/gmac0 (using multiple clients to one iperf3-server), trgmii afair supports ~2.1 Gbit/s, so nearly twice bandwidth possible in theory. this maybe can clock-related

I'm not sure if it is the same issue ilya fixes here, but i try to test this on my bananapi-r2

regards Frank

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-19 12:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11  1:21 [PATCH net] net: dsa: mt7530: setup core clock even in TRGMII mode Ilya Lipnitskiy
2021-03-11  3:21 ` Florian Fainelli
2021-03-12  8:07 ` [PATCH net,v2] " Ilya Lipnitskiy
2021-03-19 10:25   ` René van Dorst
2021-03-19 12:47     ` Aw: " Frank Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).