From: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
To: <nicolas.ferre@microchip.com>, <claudiu.beznea@tuxon.dev>,
<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <robh@kernel.org>, <krzk+dt@kernel.org>,
<conor+dt@kernel.org>, <linux@armlinux.org.uk>, <andrew@lunn.ch>
Cc: <vineeth.karumanchi@amd.com>, <netdev@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<git@amd.com>
Subject: [RFC PATCH net-next 4/5] net: macb: Configure High Speed Mac for given speed.
Date: Wed, 9 Oct 2024 11:09:45 +0530 [thread overview]
Message-ID: <20241009053946.3198805-5-vineeth.karumanchi@amd.com> (raw)
In-Reply-To: <20241009053946.3198805-1-vineeth.karumanchi@amd.com>
HS Mac configuration steps:
- Configure speed and serdes rate bits of USX_CONTROL register from
user specified speed in the device-tree.
- Enable HS Mac for 5G and 10G speeds.
- Reset RX receive path to achieve USX block lock for the
configured serdes rate.
- Wait for USX block lock synchronization.
Move the initialization instances to macb_usx_pcs_link_up().
Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
---
drivers/net/ethernet/cadence/macb.h | 1 +
drivers/net/ethernet/cadence/macb_main.c | 57 ++++++++++++++++++++----
2 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 47e80fa72865..ed4edeac3a59 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -825,6 +825,7 @@
})
#define MACB_READ_NSR(bp) macb_readl(bp, NSR)
+#define MACB_READ_USX_STATUS(bp) gem_readl(bp, USX_STATUS)
/* struct macb_dma_desc - Hardware DMA descriptor
* @addr: DMA address of data buffer
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 3f9dc0b037c0..7beb775a0bd7 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -94,6 +94,7 @@ struct sifive_fu540_macb_mgmt {
#define MACB_PM_TIMEOUT 100 /* ms */
#define MACB_MDIO_TIMEOUT 1000000 /* in usecs */
+#define GEM_SYNC_TIMEOUT 2500000 /* in usecs */
/* DMA buffer descriptor might be different size
* depends on hardware configuration:
@@ -564,14 +565,59 @@ static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
int duplex)
{
struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs);
- u32 config;
+ u32 speed_val, serdes_rate, config;
+ bool hs_mac = false;
+
+ switch (speed) {
+ case SPEED_1000:
+ speed_val = HS_SPEED_1000M;
+ serdes_rate = MACB_SERDES_RATE_1G;
+ break;
+ case SPEED_2500:
+ speed_val = HS_SPEED_2500M;
+ serdes_rate = MACB_SERDES_RATE_2_5G;
+ break;
+ case SPEED_5000:
+ speed_val = HS_SPEED_5000M;
+ serdes_rate = MACB_SERDES_RATE_5G;
+ hs_mac = true;
+ break;
+ case SPEED_10000:
+ speed_val = HS_SPEED_10000M;
+ serdes_rate = MACB_SERDES_RATE_10G;
+ hs_mac = true;
+ break;
+ default:
+ netdev_err(bp->dev, "Specified speed not supported\n");
+ return;
+ }
+
+ /* Enable HS MAC for high speeds */
+ if (hs_mac) {
+ config = macb_or_gem_readl(bp, NCR);
+ config |= GEM_BIT(ENABLE_HS_MAC);
+ macb_or_gem_writel(bp, NCR, config);
+ }
+
+ /* Configure HS MAC for specified speed */
+ config = gem_readl(bp, HS_MAC_CONFIG);
+ config = GEM_BFINS(HS_MAC_SPEED, speed_val, config);
+ gem_writel(bp, HS_MAC_CONFIG, config);
config = gem_readl(bp, USX_CONTROL);
- config = GEM_BFINS(SERDES_RATE, MACB_SERDES_RATE_10G, config);
- config = GEM_BFINS(USX_CTRL_SPEED, HS_SPEED_10000M, config);
+ config = GEM_BFINS(SERDES_RATE, serdes_rate, config);
+ config = GEM_BFINS(USX_CTRL_SPEED, speed_val, config);
config &= ~(GEM_BIT(TX_SCR_BYPASS) | GEM_BIT(RX_SCR_BYPASS));
+ config |= GEM_BIT(RX_SYNC_RESET);
+ gem_writel(bp, USX_CONTROL, config);
+ mdelay(250);
+ config &= ~GEM_BIT(RX_SYNC_RESET);
config |= GEM_BIT(TX_EN);
gem_writel(bp, USX_CONTROL, config);
+
+ if (readx_poll_timeout(MACB_READ_USX_STATUS, bp, config, config & GEM_BIT(USX_BLOCK_LOCK),
+ 1, GEM_SYNC_TIMEOUT))
+ netdev_err(bp->dev, "USX PCS block lock not achieved\n");
}
static void macb_usx_pcs_get_state(struct phylink_pcs *pcs,
@@ -662,7 +708,6 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,
ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL);
} else if (state->interface == PHY_INTERFACE_MODE_10GBASER) {
ctrl |= GEM_BIT(PCSSEL);
- ncr |= GEM_BIT(ENABLE_HS_MAC);
} else if (bp->caps & MACB_CAPS_MIIONRGMII &&
bp->phy_interface == PHY_INTERFACE_MODE_MII) {
ncr |= MACB_BIT(MIIONRGMII);
@@ -766,10 +811,6 @@ static void macb_mac_link_up(struct phylink_config *config,
macb_or_gem_writel(bp, NCFGR, ctrl);
- if (bp->phy_interface == PHY_INTERFACE_MODE_10GBASER)
- gem_writel(bp, HS_MAC_CONFIG, GEM_BFINS(HS_MAC_SPEED, HS_SPEED_10000M,
- gem_readl(bp, HS_MAC_CONFIG)));
-
spin_unlock_irqrestore(&bp->lock, flags);
if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC))
--
2.34.1
next prev parent reply other threads:[~2024-10-09 5:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 5:39 [RFC PATCH net-next 0/5] net: macb: Add versal2 10GBE device support Vineeth Karumanchi
2024-10-09 5:39 ` [RFC PATCH net-next 1/5] dt-bindings: net: macb: Add support for versal2 10gbe device Vineeth Karumanchi
2024-10-09 6:43 ` Krzysztof Kozlowski
2024-10-09 5:39 ` [RFC PATCH net-next 2/5] net: macb: Add versal2 10GBE device support Vineeth Karumanchi
2024-10-09 5:39 ` [RFC PATCH net-next 3/5] net: macb: Update USX_CONTROL reg's bitfields and constants Vineeth Karumanchi
2024-10-09 9:04 ` Russell King (Oracle)
2024-10-09 5:39 ` Vineeth Karumanchi [this message]
2024-10-09 6:36 ` [RFC PATCH net-next 4/5] net: macb: Configure High Speed Mac for given speed Maxime Chevallier
2024-10-10 13:53 ` Karumanchi, Vineeth
2024-10-09 9:19 ` Russell King (Oracle)
2024-10-10 14:09 ` Karumanchi, Vineeth
2024-10-10 14:17 ` Russell King (Oracle)
2024-10-09 5:39 ` [RFC PATCH net-next 5/5] net: macb: Get speed and link status runtime Vineeth Karumanchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241009053946.3198805-5-vineeth.karumanchi@amd.com \
--to=vineeth.karumanchi@amd.com \
--cc=andrew@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=git@amd.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®