Skip to content

Commit 5a4ec12

Browse files
rohangt07gregkh
authored andcommitted
net: stmmac: xgmac: Correct supported speed modes
[ Upstream commit 42ef11b ] Correct supported speed modes as per the XGMAC databook. Commit 9cb54af ("net: stmmac: Fix IP-cores specific MAC capabilities") removes support for 10M, 100M and 1000HD. 1000HD is not supported by XGMAC IP, but it does support 10M and 100M FD mode for XGMAC version >= 2_20, and it also supports 10M and 100M HD mode if the HDSEL bit is set in the MAC_HW_FEATURE0 reg. This commit enables support for 10M and 100M speed modes for XGMAC IP based on XGMAC version and MAC capabilities. Fixes: 9cb54af ("net: stmmac: Fix IP-cores specific MAC capabilities") Signed-off-by: Rohan G Thomas <rohan.g.thomas@altera.com> Reviewed-by: Matthew Gerlach <matthew.gerlach@altera.com> Link: https://patch.msgid.link/20250825-xgmac-minor-fixes-v3-2-c225fe4444c0@altera.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f71b60e commit 5a4ec12

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,
4949
writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);
5050
}
5151

52+
static void dwxgmac2_update_caps(struct stmmac_priv *priv)
53+
{
54+
if (!priv->dma_cap.mbps_10_100)
55+
priv->hw->link.caps &= ~(MAC_10 | MAC_100);
56+
else if (!priv->dma_cap.half_duplex)
57+
priv->hw->link.caps &= ~(MAC_10HD | MAC_100HD);
58+
}
59+
5260
static void dwxgmac2_set_mac(void __iomem *ioaddr, bool enable)
5361
{
5462
u32 tx = readl(ioaddr + XGMAC_TX_CONFIG);
@@ -1424,6 +1432,7 @@ static void dwxgmac2_set_arp_offload(struct mac_device_info *hw, bool en,
14241432

14251433
const struct stmmac_ops dwxgmac210_ops = {
14261434
.core_init = dwxgmac2_core_init,
1435+
.update_caps = dwxgmac2_update_caps,
14271436
.set_mac = dwxgmac2_set_mac,
14281437
.rx_ipc = dwxgmac2_rx_ipc,
14291438
.rx_queue_enable = dwxgmac2_rx_queue_enable,
@@ -1532,8 +1541,8 @@ int dwxgmac2_setup(struct stmmac_priv *priv)
15321541
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
15331542

15341543
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1535-
MAC_1000FD | MAC_2500FD | MAC_5000FD |
1536-
MAC_10000FD;
1544+
MAC_10 | MAC_100 | MAC_1000FD |
1545+
MAC_2500FD | MAC_5000FD | MAC_10000FD;
15371546
mac->link.duplex = 0;
15381547
mac->link.speed10 = XGMAC_CONFIG_SS_10_MII;
15391548
mac->link.speed100 = XGMAC_CONFIG_SS_100_MII;

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,11 @@ static int dwxgmac2_dma_interrupt(struct stmmac_priv *priv,
382382
static int dwxgmac2_get_hw_feature(void __iomem *ioaddr,
383383
struct dma_features *dma_cap)
384384
{
385+
struct stmmac_priv *priv;
385386
u32 hw_cap;
386387

388+
priv = container_of(dma_cap, struct stmmac_priv, dma_cap);
389+
387390
/* MAC HW feature 0 */
388391
hw_cap = readl(ioaddr + XGMAC_HW_FEATURE0);
389392
dma_cap->edma = (hw_cap & XGMAC_HWFEAT_EDMA) >> 31;
@@ -406,6 +409,8 @@ static int dwxgmac2_get_hw_feature(void __iomem *ioaddr,
406409
dma_cap->vlhash = (hw_cap & XGMAC_HWFEAT_VLHASH) >> 4;
407410
dma_cap->half_duplex = (hw_cap & XGMAC_HWFEAT_HDSEL) >> 3;
408411
dma_cap->mbps_1000 = (hw_cap & XGMAC_HWFEAT_GMIISEL) >> 1;
412+
if (dma_cap->mbps_1000 && priv->synopsys_id >= DWXGMAC_CORE_2_20)
413+
dma_cap->mbps_10_100 = 1;
409414

410415
/* MAC HW feature 1 */
411416
hw_cap = readl(ioaddr + XGMAC_HW_FEATURE1);

0 commit comments

Comments
 (0)