netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v4 1/1] net: phy: marvell: make use of fiber autoneg bypass mode
@ 2024-10-04 21:27 Qingtao Cao
  2024-10-04 21:54 ` Russell King (Oracle)
  0 siblings, 1 reply; 3+ messages in thread
From: Qingtao Cao @ 2024-10-04 21:27 UTC (permalink / raw)
  Cc: Qingtao Cao, Andrew Lunn, Heiner Kallweit, Russell King,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, linux-kernel

88E151x supports the SGMII autoneg bypass mode and it defaults to be
enabled. When it is activated, the device assumes a link-up status so
avoid bringing down fibre link in this case

Test case:
1. Two 88E151x are connected with SFP
2. One enables autoneg while the other is 1000BASE-X
3. On the one with autoneg, the link can still be up with this change
   otherwise not

Signed-off-by: Qingtao Cao <qingtao.cao@digi.com>
---
 drivers/net/phy/marvell.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 9964bf3dea2f..6d48add9dc0a 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -195,6 +195,9 @@
 
 #define MII_88E1510_MSCR_2		0x15
 
+#define MII_88E151X_FSCR2		0x1a
+#define MII_88E151X_FSCR2_BYPASS_STATUS	BIT(5)
+
 #define MII_VCT5_TX_RX_MDI0_COUPLING	0x10
 #define MII_VCT5_TX_RX_MDI1_COUPLING	0x11
 #define MII_VCT5_TX_RX_MDI2_COUPLING	0x12
@@ -1623,12 +1626,24 @@ static void fiber_lpa_mod_linkmode_lpa_t(unsigned long *advertising, u32 lpa)
 static int marvell_read_status_page_an(struct phy_device *phydev,
 				       int fiber, int status)
 {
+	int fscr2;
 	int lpa;
 	int err;
 
 	if (!(status & MII_M1011_PHY_STATUS_RESOLVED)) {
 		phydev->link = 0;
-		return 0;
+		if (!fiber)
+			return 0;
+
+		/* Already on page 1 for fibre */
+		fscr2 = phy_read(phydev, MII_88E151X_FSCR2);
+		if (fscr2 < 0)
+			return fscr2;
+
+		if (!(fscr2 & MII_88E151X_FSCR2_BYPASS_STATUS))
+			return 0;
+
+		phydev->link = 1;
 	}
 
 	if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
-- 
2.34.1


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

end of thread, other threads:[~2024-10-05 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-04 21:27 [PATCH net-next v4 1/1] net: phy: marvell: make use of fiber autoneg bypass mode Qingtao Cao
2024-10-04 21:54 ` Russell King (Oracle)
2024-10-05 16:43   ` Andrew Lunn

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