netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers
@ 2023-09-25  7:51 Raju Lakkaraju
  2023-09-26 11:39 ` Serge Semin
  0 siblings, 1 reply; 8+ messages in thread
From: Raju Lakkaraju @ 2023-09-25  7:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jose.Abreu, linux, hkallweit1, UNGLinuxDriver

Add DW_2500BASEX case in xpcs_get_state( ) to update speed, duplex and pause
Update the port mode and autonegotiation

Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
---
 drivers/net/pcs/pcs-xpcs.c | 31 +++++++++++++++++++++++++++++++
 drivers/net/pcs/pcs-xpcs.h |  4 ++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 4dbc21f604f2..4f89dcedf0fc 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -1090,6 +1090,30 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
 	return 0;
 }
 
+static int xpcs_get_state_2500basex(struct dw_xpcs *xpcs,
+				    struct phylink_link_state *state)
+{
+	int sts, lpa;
+
+	sts = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_STS);
+	lpa = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_LP_BABL);
+	if (sts < 0 || lpa < 0) {
+		state->link = false;
+		return sts;
+	}
+
+	state->link = !!(sts & DW_VR_MII_MMD_STS_LINK_STS);
+	state->an_complete = !!(sts & DW_VR_MII_MMD_STS_AN_CMPL);
+	if (!state->link)
+		return 0;
+
+	state->speed = SPEED_2500;
+	state->pause |= MLO_PAUSE_TX | MLO_PAUSE_RX;
+	state->duplex = DUPLEX_FULL;
+
+	return 0;
+}
+
 static void xpcs_get_state(struct phylink_pcs *pcs,
 			   struct phylink_link_state *state)
 {
@@ -1127,6 +1151,13 @@ static void xpcs_get_state(struct phylink_pcs *pcs,
 			       ERR_PTR(ret));
 		}
 		break;
+	case DW_2500BASEX:
+		ret = xpcs_get_state_2500basex(xpcs, state);
+		if (ret) {
+			pr_err("xpcs_get_state_2500basex returned %pe\n",
+			       ERR_PTR(ret));
+		}
+		break;
 	default:
 		return;
 	}
diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h
index 39a90417e535..92c838f4b251 100644
--- a/drivers/net/pcs/pcs-xpcs.h
+++ b/drivers/net/pcs/pcs-xpcs.h
@@ -55,6 +55,10 @@
 /* Clause 37 Defines */
 /* VR MII MMD registers offsets */
 #define DW_VR_MII_MMD_CTRL		0x0000
+#define DW_VR_MII_MMD_STS		0x0001
+#define DW_VR_MII_MMD_STS_LINK_STS	BIT(2)
+#define DW_VR_MII_MMD_STS_AN_CMPL	BIT(5)
+#define DW_VR_MII_MMD_LP_BABL		0x0005
 #define DW_VR_MII_DIG_CTRL1		0x8000
 #define DW_VR_MII_AN_CTRL		0x8001
 #define DW_VR_MII_AN_INTR_STS		0x8002
-- 
2.34.1


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

end of thread, other threads:[~2023-09-26 19:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-25  7:51 [PATCH net-next] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers Raju Lakkaraju
2023-09-26 11:39 ` Serge Semin
2023-09-26 11:45   ` Russell King (Oracle)
2023-09-26 12:09     ` Serge Semin
2023-09-26 14:46       ` Russell King (Oracle)
2023-09-26 15:27         ` Serge Semin
2023-09-26 15:47           ` Russell King (Oracle)
2023-09-26 19:40             ` Serge Semin

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