netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mv643xx_eth: support MII/GMII/RGMII modes
@ 2022-09-30 19:49 David Yang
  2022-09-30 20:28 ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: David Yang @ 2022-09-30 19:49 UTC (permalink / raw)
  To: mmyangfl
  Cc: Sebastian Hesselbarth, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On device reset all ports are automatically set to RGMII mode. MII
mode must be explicitly enabled.

If SoC has two Ethernet controllers, by setting both of them into MII
mode, the first controller enters GMII mode, while the second
controller is effectively disabled. This requires configuring (and
maybe enabling) the second controller in the device tree, even though
it cannot be used.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/net/ethernet/marvell/mv643xx_eth.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index b6be0552a..e2216ce5e 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";
 #define TXQ_COMMAND			0x0048
 #define TXQ_FIX_PRIO_CONF		0x004c
 #define PORT_SERIAL_CONTROL1		0x004c
+#define  RGMII_EN			0x00000008
 #define  CLK125_BYPASS_EN		0x00000010
 #define TX_BW_RATE			0x0050
 #define TX_BW_MTU			0x0058
@@ -1245,6 +1246,21 @@ static void mv643xx_eth_adjust_link(struct net_device *dev)
 
 out_write:
 	wrlp(mp, PORT_SERIAL_CONTROL, pscr);
+
+	/* If two Ethernet controllers present in the SoC, MII modes follow the
+	 * following matrix:
+	 *
+	 * Port0 Mode	Port1 Mode	Port0 RGMII_EN	Port1 RGMII_EN
+	 * RGMII	RGMII		1		1
+	 * RGMII	MII/MMII	1		0
+	 * MII/MMII	RGMII		0		1
+	 * GMII		N/A		0		0
+	 *
+	 * To enable GMII on Port 0, Port 1 must also disable RGMII_EN too.
+	 */
+	if (!phy_interface_is_rgmii(dev->phydev))
+		wrlp(mp, PORT_SERIAL_CONTROL1,
+		     rdlp(mp, PORT_SERIAL_CONTROL1) & ~RGMII_EN);
 }
 
 /* statistics ***************************************************************/
-- 
2.35.1


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

end of thread, other threads:[~2022-10-04  8:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-30 19:49 [PATCH] net: mv643xx_eth: support MII/GMII/RGMII modes David Yang
2022-09-30 20:28 ` Andrew Lunn
2022-09-30 20:39   ` [PATCH v2] " David Yang
2022-10-04  8:52     ` Paolo Abeni
2022-09-30 20:47   ` [PATCH] " Yangfl
2022-09-30 21:05     ` Andrew Lunn
2022-09-30 21:35       ` [PATCH v3] net: mv643xx_eth: support MII/GMII/RGMII modes for Kirkwood David Yang
2022-09-30 22:25         ` [PATCH v4] " David Yang
2022-10-01  0:59           ` Jakub Kicinski
2022-10-01  8:42             ` [PATCH v5] " David Yang

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).