[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241009053946.3198805-6-vineeth.karumanchi@amd.com>
Date: Wed, 9 Oct 2024 11:09:46 +0530
From: Vineeth Karumanchi <vineeth.karumanchi@....com>
To: <nicolas.ferre@...rochip.com>, <claudiu.beznea@...on.dev>,
<davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <robh@...nel.org>, <krzk+dt@...nel.org>,
<conor+dt@...nel.org>, <linux@...linux.org.uk>, <andrew@...n.ch>
CC: <vineeth.karumanchi@....com>, <netdev@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>, <git@....com>
Subject: [RFC PATCH net-next 5/5] net: macb: Get speed and link status runtime.
- Update speed value by reading HS_SPEED_MAC register.
- Update link status by reading NSR_LINK bit of NSR register
for slower speeds (1G and 2.5G) and USX_BLOCK_LOCK bit
of USX_STATUS register for higher speeds.
Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@....com>
---
drivers/net/ethernet/cadence/macb_main.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 7beb775a0bd7..48ba19a76418 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -624,14 +624,21 @@ static void macb_usx_pcs_get_state(struct phylink_pcs *pcs,
struct phylink_link_state *state)
{
struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs);
+ u32 hs_mac_map[] = {SPEED_UNKNOWN, SPEED_1000, SPEED_2500,
+ SPEED_5000, SPEED_10000};
u32 val;
- state->speed = SPEED_10000;
state->duplex = 1;
state->an_complete = 1;
- val = gem_readl(bp, USX_STATUS);
- state->link = !!(val & GEM_BIT(USX_BLOCK_LOCK));
+ val = gem_readl(bp, HS_MAC_CONFIG);
+ val = GEM_BFEXT(HS_MAC_SPEED, val);
+ state->speed = hs_mac_map[val];
+
+ state->link = (state->speed < SPEED_5000) ?
+ !!(macb_readl(bp, NSR) & MACB_BIT(NSR_LINK)) :
+ !!(gem_readl(bp, USX_STATUS) & GEM_BIT(USX_BLOCK_LOCK));
+
val = gem_readl(bp, NCFGR);
if (val & GEM_BIT(PAE))
state->pause = MLO_PAUSE_RX;
--
2.34.1
Powered by blists - more mailing lists