mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-21 22:47:56 +00:00
generic: add support for MediaTek NETSYS v3
In order to support Ethernet on the MT7988 SoC add support for NETSYS v3
as well as new paths and USXGMII SerDes to the mtk_eth_soc driver.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
(cherry picked from commit 6983a215d9
)
This commit is contained in:
parent
d5dc84f44e
commit
5970f5d027
@ -0,0 +1,223 @@
|
||||
From 663fa1b7e0cb2c929008482014a70c6625caad75 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 7 Mar 2023 15:55:13 +0000
|
||||
Subject: [PATCH 1/7] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V1 capability
|
||||
bit
|
||||
|
||||
Introduce MTK_NETSYS_V1 bit in the device capabilities for
|
||||
MT7621/MT7622/MT7623/MT7628/MT7629 SoCs.
|
||||
Use !MTK_NETSYS_V1 instead of MTK_NETSYS_V2 in the driver codebase.
|
||||
This is a preliminary patch to introduce support for MT7988 SoC.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 30 +++++++-------
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 45 ++++++++++++---------
|
||||
2 files changed, 41 insertions(+), 34 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -597,7 +597,7 @@ static void mtk_set_queue_speed(struct m
|
||||
FIELD_PREP(MTK_QTX_SCH_MIN_RATE_MAN, 1) |
|
||||
FIELD_PREP(MTK_QTX_SCH_MIN_RATE_EXP, 4) |
|
||||
MTK_QTX_SCH_LEAKY_BUCKET_SIZE;
|
||||
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1))
|
||||
val |= MTK_QTX_SCH_LEAKY_BUCKET_EN;
|
||||
|
||||
if (IS_ENABLED(CONFIG_SOC_MT7621)) {
|
||||
@@ -974,7 +974,7 @@ static bool mtk_rx_get_desc(struct mtk_e
|
||||
rxd->rxd1 = READ_ONCE(dma_rxd->rxd1);
|
||||
rxd->rxd3 = READ_ONCE(dma_rxd->rxd3);
|
||||
rxd->rxd4 = READ_ONCE(dma_rxd->rxd4);
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1)) {
|
||||
rxd->rxd5 = READ_ONCE(dma_rxd->rxd5);
|
||||
rxd->rxd6 = READ_ONCE(dma_rxd->rxd6);
|
||||
}
|
||||
@@ -1032,7 +1032,7 @@ static int mtk_init_fq_dma(struct mtk_et
|
||||
|
||||
txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE);
|
||||
txd->txd4 = 0;
|
||||
- if (MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (!MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V1)) {
|
||||
txd->txd5 = 0;
|
||||
txd->txd6 = 0;
|
||||
txd->txd7 = 0;
|
||||
@@ -1221,7 +1221,7 @@ static void mtk_tx_set_dma_desc(struct n
|
||||
struct mtk_mac *mac = netdev_priv(dev);
|
||||
struct mtk_eth *eth = mac->hw;
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1))
|
||||
mtk_tx_set_dma_desc_v2(dev, txd, info);
|
||||
else
|
||||
mtk_tx_set_dma_desc_v1(dev, txd, info);
|
||||
@@ -1902,7 +1902,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
break;
|
||||
|
||||
/* find out which mac the packet come from. values start at 1 */
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1))
|
||||
mac = RX_DMA_GET_SPORT_V2(trxd.rxd5) - 1;
|
||||
else if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
|
||||
!(trxd.rxd4 & RX_DMA_SPECIAL_TAG))
|
||||
@@ -1998,7 +1998,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
skb->dev = netdev;
|
||||
bytes += skb->len;
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1)) {
|
||||
reason = FIELD_GET(MTK_RXD5_PPE_CPU_REASON, trxd.rxd5);
|
||||
hash = trxd.rxd5 & MTK_RXD5_FOE_ENTRY;
|
||||
if (hash != MTK_RXD5_FOE_ENTRY)
|
||||
@@ -2023,7 +2023,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
/* When using VLAN untagging in combination with DSA, the
|
||||
* hardware treats the MTK special tag as a VLAN and untags it.
|
||||
*/
|
||||
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) &&
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1) &&
|
||||
(trxd.rxd2 & RX_DMA_VTAG) && netdev_uses_dsa(netdev)) {
|
||||
unsigned int port = RX_DMA_VPID(trxd.rxd3) & GENMASK(2, 0);
|
||||
|
||||
@@ -2328,7 +2328,7 @@ static int mtk_tx_alloc(struct mtk_eth *
|
||||
txd->txd2 = next_ptr;
|
||||
txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
|
||||
txd->txd4 = 0;
|
||||
- if (MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (!MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V1)) {
|
||||
txd->txd5 = 0;
|
||||
txd->txd6 = 0;
|
||||
txd->txd7 = 0;
|
||||
@@ -2381,7 +2381,7 @@ static int mtk_tx_alloc(struct mtk_eth *
|
||||
FIELD_PREP(MTK_QTX_SCH_MIN_RATE_MAN, 1) |
|
||||
FIELD_PREP(MTK_QTX_SCH_MIN_RATE_EXP, 4) |
|
||||
MTK_QTX_SCH_LEAKY_BUCKET_SIZE;
|
||||
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1))
|
||||
val |= MTK_QTX_SCH_LEAKY_BUCKET_EN;
|
||||
mtk_w32(eth, val, soc->reg_map->qdma.qtx_sch + ofs);
|
||||
ofs += MTK_QTX_OFFSET;
|
||||
@@ -2515,7 +2515,7 @@ static int mtk_rx_alloc(struct mtk_eth *
|
||||
|
||||
rxd->rxd3 = 0;
|
||||
rxd->rxd4 = 0;
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1)) {
|
||||
rxd->rxd5 = 0;
|
||||
rxd->rxd6 = 0;
|
||||
rxd->rxd7 = 0;
|
||||
@@ -3063,7 +3063,7 @@ static int mtk_start_dma(struct mtk_eth
|
||||
MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO |
|
||||
MTK_RX_2B_OFFSET | MTK_TX_WB_DDONE;
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1))
|
||||
val |= MTK_MUTLI_CNT | MTK_RESV_BUF |
|
||||
MTK_WCOMP_EN | MTK_DMAD_WR_WDONE |
|
||||
MTK_CHK_DDONE_EN | MTK_LEAKY_BUCKET_EN;
|
||||
@@ -3475,7 +3475,7 @@ static void mtk_hw_reset(struct mtk_eth
|
||||
{
|
||||
u32 val;
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1)) {
|
||||
regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0);
|
||||
val = RSTCTRL_PPE0_V2;
|
||||
} else {
|
||||
@@ -3487,7 +3487,7 @@ static void mtk_hw_reset(struct mtk_eth
|
||||
|
||||
ethsys_reset(eth, RSTCTRL_ETH | RSTCTRL_FE | val);
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1))
|
||||
regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN,
|
||||
0x3ffffff);
|
||||
}
|
||||
@@ -3683,7 +3683,7 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
else
|
||||
mtk_hw_reset(eth);
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1)) {
|
||||
/* Set FE to PDMAv2 if necessary */
|
||||
val = mtk_r32(eth, MTK_FE_GLO_MISC);
|
||||
mtk_w32(eth, val | BIT(4), MTK_FE_GLO_MISC);
|
||||
@@ -3720,7 +3720,7 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
*/
|
||||
val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
|
||||
mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);
|
||||
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1)) {
|
||||
val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
|
||||
mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL);
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -816,6 +816,7 @@ enum mkt_eth_capabilities {
|
||||
MTK_SHARED_INT_BIT,
|
||||
MTK_TRGMII_MT7621_CLK_BIT,
|
||||
MTK_QDMA_BIT,
|
||||
+ MTK_NETSYS_V1_BIT,
|
||||
MTK_NETSYS_V2_BIT,
|
||||
MTK_SOC_MT7628_BIT,
|
||||
MTK_RSTCTRL_PPE1_BIT,
|
||||
@@ -851,6 +852,7 @@ enum mkt_eth_capabilities {
|
||||
#define MTK_SHARED_INT BIT(MTK_SHARED_INT_BIT)
|
||||
#define MTK_TRGMII_MT7621_CLK BIT(MTK_TRGMII_MT7621_CLK_BIT)
|
||||
#define MTK_QDMA BIT(MTK_QDMA_BIT)
|
||||
+#define MTK_NETSYS_V1 BIT(MTK_NETSYS_V1_BIT)
|
||||
#define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT)
|
||||
#define MTK_SOC_MT7628 BIT(MTK_SOC_MT7628_BIT)
|
||||
#define MTK_RSTCTRL_PPE1 BIT(MTK_RSTCTRL_PPE1_BIT)
|
||||
@@ -913,25 +915,30 @@ enum mkt_eth_capabilities {
|
||||
|
||||
#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x) & ~(MTK_CAP_MASK)) == (_x))
|
||||
|
||||
-#define MT7621_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | \
|
||||
- MTK_GMAC2_RGMII | MTK_SHARED_INT | \
|
||||
- MTK_TRGMII_MT7621_CLK | MTK_QDMA)
|
||||
-
|
||||
-#define MT7622_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_SGMII | MTK_GMAC2_RGMII | \
|
||||
- MTK_GMAC2_SGMII | MTK_GDM1_ESW | \
|
||||
- MTK_MUX_GDM1_TO_GMAC1_ESW | \
|
||||
- MTK_MUX_GMAC1_GMAC2_TO_SGMII_RGMII | MTK_QDMA)
|
||||
-
|
||||
-#define MT7623_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | MTK_GMAC2_RGMII | \
|
||||
- MTK_QDMA)
|
||||
-
|
||||
-#define MT7628_CAPS (MTK_SHARED_INT | MTK_SOC_MT7628)
|
||||
-
|
||||
-#define MT7629_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | MTK_GMAC2_GEPHY | \
|
||||
- MTK_GDM1_ESW | MTK_MUX_GDM1_TO_GMAC1_ESW | \
|
||||
- MTK_MUX_GMAC2_GMAC0_TO_GEPHY | \
|
||||
- MTK_MUX_U3_GMAC2_TO_QPHY | \
|
||||
- MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA)
|
||||
+#define MT7621_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | \
|
||||
+ MTK_GMAC2_RGMII | MTK_SHARED_INT | \
|
||||
+ MTK_TRGMII_MT7621_CLK | MTK_QDMA | \
|
||||
+ MTK_NETSYS_V1)
|
||||
+
|
||||
+#define MT7622_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_SGMII | \
|
||||
+ MTK_GMAC2_RGMII | MTK_GMAC2_SGMII | \
|
||||
+ MTK_GDM1_ESW | MTK_MUX_GDM1_TO_GMAC1_ESW |\
|
||||
+ MTK_MUX_GMAC1_GMAC2_TO_SGMII_RGMII | \
|
||||
+ MTK_QDMA | MTK_NETSYS_V1)
|
||||
+
|
||||
+#define MT7623_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | \
|
||||
+ MTK_GMAC2_RGMII | MTK_QDMA | \
|
||||
+ MTK_NETSYS_V1)
|
||||
+
|
||||
+#define MT7628_CAPS (MTK_SHARED_INT | MTK_SOC_MT7628 | \
|
||||
+ MTK_NETSYS_V1)
|
||||
+
|
||||
+#define MT7629_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \
|
||||
+ MTK_GMAC2_GEPHY | MTK_GDM1_ESW | \
|
||||
+ MTK_MUX_GMAC2_GMAC0_TO_GEPHY | MTK_QDMA | \
|
||||
+ MTK_MUX_U3_GMAC2_TO_QPHY | MTK_NETSYS_V1 |\
|
||||
+ MTK_MUX_GDM1_TO_GMAC1_ESW | \
|
||||
+ MTK_MUX_GMAC12_TO_GEPHY_SGMII)
|
||||
|
||||
#define MT7981_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | MTK_GMAC2_GEPHY | \
|
||||
MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
|
@ -0,0 +1,181 @@
|
||||
From 5af2b2dc4d6ba0ff7696e79f18e5b2bf862194eb Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 7 Mar 2023 15:55:24 +0000
|
||||
Subject: [PATCH 2/7] net: ethernet: mtk_eth_soc: move MAX_DEVS in mtk_soc_data
|
||||
|
||||
This is a preliminary patch to add MT7988 SoC support since it runs 3
|
||||
macs instead of 2.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 34 +++++++++++++++++++--
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 11 +++----
|
||||
2 files changed, 36 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -3989,7 +3989,10 @@ static void mtk_sgmii_destroy(struct mtk
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAX_DEVS; i++)
|
||||
+ if (!eth->sgmii_pcs)
|
||||
+ return;
|
||||
+
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++)
|
||||
mtk_pcs_lynxi_destroy(eth->sgmii_pcs[i]);
|
||||
}
|
||||
|
||||
@@ -4432,7 +4435,12 @@ static int mtk_sgmii_init(struct mtk_eth
|
||||
u32 flags;
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAX_DEVS; i++) {
|
||||
+ eth->sgmii_pcs = devm_kzalloc(eth->dev,
|
||||
+ sizeof(*eth->sgmii_pcs) *
|
||||
+ eth->soc->num_devs,
|
||||
+ GFP_KERNEL);
|
||||
+
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
np = of_parse_phandle(eth->dev->of_node, "mediatek,sgmiisys", i);
|
||||
if (!np)
|
||||
break;
|
||||
@@ -4477,6 +4485,18 @@ static int mtk_probe(struct platform_dev
|
||||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
|
||||
eth->ip_align = NET_IP_ALIGN;
|
||||
|
||||
+ eth->netdev = devm_kzalloc(eth->dev,
|
||||
+ sizeof(*eth->netdev) * eth->soc->num_devs,
|
||||
+ GFP_KERNEL);
|
||||
+ if (!eth->netdev)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ eth->mac = devm_kzalloc(eth->dev,
|
||||
+ sizeof(*eth->mac) * eth->soc->num_devs,
|
||||
+ GFP_KERNEL);
|
||||
+ if (!eth->mac)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
spin_lock_init(ð->page_lock);
|
||||
spin_lock_init(ð->tx_irq_lock);
|
||||
spin_lock_init(ð->rx_irq_lock);
|
||||
@@ -4662,7 +4682,7 @@ static int mtk_probe(struct platform_dev
|
||||
goto err_free_dev;
|
||||
}
|
||||
|
||||
- for (i = 0; i < MTK_MAX_DEVS; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!eth->netdev[i])
|
||||
continue;
|
||||
|
||||
@@ -4739,6 +4759,7 @@ static const struct mtk_soc_data mt2701_
|
||||
.hw_features = MTK_HW_FEATURES,
|
||||
.required_clks = MT7623_CLKS_BITMAP,
|
||||
.required_pctl = true,
|
||||
+ .num_devs = 2,
|
||||
.txrx = {
|
||||
.txd_size = sizeof(struct mtk_tx_dma),
|
||||
.rxd_size = sizeof(struct mtk_rx_dma),
|
||||
@@ -4757,6 +4778,7 @@ static const struct mtk_soc_data mt7621_
|
||||
.required_pctl = false,
|
||||
.offload_version = 1,
|
||||
.hash_offset = 2,
|
||||
+ .num_devs = 2,
|
||||
.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
|
||||
.txrx = {
|
||||
.txd_size = sizeof(struct mtk_tx_dma),
|
||||
@@ -4778,6 +4800,7 @@ static const struct mtk_soc_data mt7622_
|
||||
.offload_version = 2,
|
||||
.hash_offset = 2,
|
||||
.has_accounting = true,
|
||||
+ .num_devs = 2,
|
||||
.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
|
||||
.txrx = {
|
||||
.txd_size = sizeof(struct mtk_tx_dma),
|
||||
@@ -4797,6 +4820,7 @@ static const struct mtk_soc_data mt7623_
|
||||
.required_pctl = true,
|
||||
.offload_version = 1,
|
||||
.hash_offset = 2,
|
||||
+ .num_devs = 2,
|
||||
.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
|
||||
.txrx = {
|
||||
.txd_size = sizeof(struct mtk_tx_dma),
|
||||
@@ -4816,6 +4840,7 @@ static const struct mtk_soc_data mt7629_
|
||||
.required_clks = MT7629_CLKS_BITMAP,
|
||||
.required_pctl = false,
|
||||
.has_accounting = true,
|
||||
+ .num_devs = 2,
|
||||
.txrx = {
|
||||
.txd_size = sizeof(struct mtk_tx_dma),
|
||||
.rxd_size = sizeof(struct mtk_rx_dma),
|
||||
@@ -4837,6 +4862,7 @@ static const struct mtk_soc_data mt7981_
|
||||
.hash_offset = 4,
|
||||
.foe_entry_size = sizeof(struct mtk_foe_entry),
|
||||
.has_accounting = true,
|
||||
+ .num_devs = 2,
|
||||
.txrx = {
|
||||
.txd_size = sizeof(struct mtk_tx_dma_v2),
|
||||
.rxd_size = sizeof(struct mtk_rx_dma_v2),
|
||||
@@ -4856,6 +4882,7 @@ static const struct mtk_soc_data mt7986_
|
||||
.required_pctl = false,
|
||||
.offload_version = 2,
|
||||
.hash_offset = 4,
|
||||
+ .num_devs = 2,
|
||||
.foe_entry_size = sizeof(struct mtk_foe_entry),
|
||||
.has_accounting = true,
|
||||
.txrx = {
|
||||
@@ -4874,6 +4901,7 @@ static const struct mtk_soc_data rt5350_
|
||||
.hw_features = MTK_HW_FEATURES_MT7628,
|
||||
.required_clks = MT7628_CLKS_BITMAP,
|
||||
.required_pctl = false,
|
||||
+ .num_devs = 2,
|
||||
.txrx = {
|
||||
.txd_size = sizeof(struct mtk_tx_dma),
|
||||
.rxd_size = sizeof(struct mtk_rx_dma),
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -1018,6 +1018,7 @@ struct mtk_reg_map {
|
||||
* @required_pctl A bool value to show whether the SoC requires
|
||||
* the extra setup for those pins used by GMAC.
|
||||
* @hash_offset Flow table hash offset.
|
||||
+ * @num_devs SoC number of macs.
|
||||
* @foe_entry_size Foe table entry size.
|
||||
* @has_accounting Bool indicating support for accounting of
|
||||
* offloaded flows.
|
||||
@@ -1036,6 +1037,7 @@ struct mtk_soc_data {
|
||||
bool required_pctl;
|
||||
u8 offload_version;
|
||||
u8 hash_offset;
|
||||
+ u8 num_devs;
|
||||
u16 foe_entry_size;
|
||||
netdev_features_t hw_features;
|
||||
bool has_accounting;
|
||||
@@ -1051,9 +1053,6 @@ struct mtk_soc_data {
|
||||
|
||||
#define MTK_DMA_MONITOR_TIMEOUT msecs_to_jiffies(1000)
|
||||
|
||||
-/* currently no SoC has more than 2 macs */
|
||||
-#define MTK_MAX_DEVS 2
|
||||
-
|
||||
/* struct mtk_eth - This is the main datasructure for holding the state
|
||||
* of the driver
|
||||
* @dev: The device pointer
|
||||
@@ -1108,14 +1107,14 @@ struct mtk_eth {
|
||||
spinlock_t tx_irq_lock;
|
||||
spinlock_t rx_irq_lock;
|
||||
struct net_device dummy_dev;
|
||||
- struct net_device *netdev[MTK_MAX_DEVS];
|
||||
- struct mtk_mac *mac[MTK_MAX_DEVS];
|
||||
+ struct net_device **netdev;
|
||||
+ struct mtk_mac **mac;
|
||||
int irq[3];
|
||||
u32 msg_enable;
|
||||
unsigned long sysclk;
|
||||
struct regmap *ethsys;
|
||||
struct regmap *infra;
|
||||
- struct phylink_pcs *sgmii_pcs[MTK_MAX_DEVS];
|
||||
+ struct phylink_pcs **sgmii_pcs;
|
||||
struct regmap *pctl;
|
||||
bool hwlro;
|
||||
refcount_t dma_refcnt;
|
@ -0,0 +1,153 @@
|
||||
From 4e35e80750b33727e606be9e7ce447bde2e0deb7 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 7 Mar 2023 15:55:35 +0000
|
||||
Subject: [PATCH 3/7] net: ethernet: mtk_eth_soc: rely on num_devs and remove
|
||||
MTK_MAC_COUNT
|
||||
|
||||
Get rid of MTK_MAC_COUNT since it is a duplicated of eth->soc->num_devs.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 30 ++++++++++-----------
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 -
|
||||
2 files changed, 15 insertions(+), 16 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -900,7 +900,7 @@ static void mtk_stats_update(struct mtk_
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!eth->mac[i] || !eth->mac[i]->hw_stats)
|
||||
continue;
|
||||
if (spin_trylock(ð->mac[i]->hw_stats->stats_lock)) {
|
||||
@@ -1403,7 +1403,7 @@ static int mtk_queue_stopped(struct mtk_
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!eth->netdev[i])
|
||||
continue;
|
||||
if (netif_queue_stopped(eth->netdev[i]))
|
||||
@@ -1417,7 +1417,7 @@ static void mtk_wake_queue(struct mtk_et
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!eth->netdev[i])
|
||||
continue;
|
||||
netif_tx_wake_all_queues(eth->netdev[i]);
|
||||
@@ -1908,7 +1908,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
!(trxd.rxd4 & RX_DMA_SPECIAL_TAG))
|
||||
mac = RX_DMA_GET_SPORT(trxd.rxd4) - 1;
|
||||
|
||||
- if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
|
||||
+ if (unlikely(mac < 0 || mac >= eth->soc->num_devs ||
|
||||
!eth->netdev[mac]))
|
||||
goto release_desc;
|
||||
|
||||
@@ -2937,7 +2937,7 @@ static void mtk_dma_free(struct mtk_eth
|
||||
const struct mtk_soc_data *soc = eth->soc;
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++)
|
||||
+ for (i = 0; i < soc->num_devs; i++)
|
||||
if (eth->netdev[i])
|
||||
netdev_reset_queue(eth->netdev[i]);
|
||||
if (eth->scratch_ring) {
|
||||
@@ -3091,7 +3091,7 @@ static void mtk_gdm_config(struct mtk_et
|
||||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
|
||||
return;
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
|
||||
|
||||
/* default setup the forward port to send frame to PDMA */
|
||||
@@ -3704,7 +3704,7 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
* up with the more appropriate value when mtk_mac_config call is being
|
||||
* invoked.
|
||||
*/
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
struct net_device *dev = eth->netdev[i];
|
||||
|
||||
mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i));
|
||||
@@ -3909,7 +3909,7 @@ static void mtk_pending_work(struct work
|
||||
mtk_prepare_for_reset(eth);
|
||||
|
||||
/* stop all devices to make sure that dma is properly shut down */
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!eth->netdev[i] || !netif_running(eth->netdev[i]))
|
||||
continue;
|
||||
|
||||
@@ -3925,7 +3925,7 @@ static void mtk_pending_work(struct work
|
||||
mtk_hw_init(eth, true);
|
||||
|
||||
/* restart DMA and enable IRQs */
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!test_bit(i, &restart))
|
||||
continue;
|
||||
|
||||
@@ -3953,7 +3953,7 @@ static int mtk_free_dev(struct mtk_eth *
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!eth->netdev[i])
|
||||
continue;
|
||||
free_netdev(eth->netdev[i]);
|
||||
@@ -3972,7 +3972,7 @@ static int mtk_unreg_dev(struct mtk_eth
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
struct mtk_mac *mac;
|
||||
if (!eth->netdev[i])
|
||||
continue;
|
||||
@@ -4277,7 +4277,7 @@ static int mtk_add_mac(struct mtk_eth *e
|
||||
}
|
||||
|
||||
id = be32_to_cpup(_id);
|
||||
- if (id >= MTK_MAC_COUNT) {
|
||||
+ if (id >= eth->soc->num_devs) {
|
||||
dev_err(eth->dev, "%d is not a valid mac id\n", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -4407,7 +4407,7 @@ void mtk_eth_set_dma_device(struct mtk_e
|
||||
|
||||
rtnl_lock();
|
||||
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
dev = eth->netdev[i];
|
||||
|
||||
if (!dev || !(dev->flags & IFF_UP))
|
||||
@@ -4734,7 +4734,7 @@ static int mtk_remove(struct platform_de
|
||||
int i;
|
||||
|
||||
/* stop all devices to make sure that dma is properly shut down */
|
||||
- for (i = 0; i < MTK_MAC_COUNT; i++) {
|
||||
+ for (i = 0; i < eth->soc->num_devs; i++) {
|
||||
if (!eth->netdev[i])
|
||||
continue;
|
||||
mtk_stop(eth->netdev[i]);
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -33,7 +33,6 @@
|
||||
#define MTK_TX_DMA_BUF_LEN_V2 0xffff
|
||||
#define MTK_QDMA_RING_SIZE 2048
|
||||
#define MTK_DMA_SIZE 512
|
||||
-#define MTK_MAC_COUNT 2
|
||||
#define MTK_RX_ETH_HLEN (VLAN_ETH_HLEN + ETH_FCS_LEN)
|
||||
#define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN)
|
||||
#define MTK_DMA_DUMMY_DESC 0xffffffff
|
@ -0,0 +1,292 @@
|
||||
From ab817f559d505329d8a413c7d29250f6d87d77a0 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 7 Mar 2023 15:55:47 +0000
|
||||
Subject: [PATCH 4/7] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V3 capability
|
||||
bit
|
||||
|
||||
Introduce MTK_NETSYS_V3 bit in the device capabilities.
|
||||
This is a preliminary patch to introduce support for MT7988 SoC.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 115 ++++++++++++++++----
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 44 +++++++-
|
||||
2 files changed, 134 insertions(+), 25 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -880,17 +880,32 @@ void mtk_stats_update_mac(struct mtk_mac
|
||||
mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x20 + offs);
|
||||
hw_stats->rx_flow_control_packets +=
|
||||
mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x24 + offs);
|
||||
- hw_stats->tx_skip +=
|
||||
- mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x28 + offs);
|
||||
- hw_stats->tx_collisions +=
|
||||
- mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x2c + offs);
|
||||
- hw_stats->tx_bytes +=
|
||||
- mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x30 + offs);
|
||||
- stats = mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x34 + offs);
|
||||
- if (stats)
|
||||
- hw_stats->tx_bytes += (stats << 32);
|
||||
- hw_stats->tx_packets +=
|
||||
- mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x38 + offs);
|
||||
+
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) {
|
||||
+ hw_stats->tx_skip +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x50 + offs);
|
||||
+ hw_stats->tx_collisions +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x54 + offs);
|
||||
+ hw_stats->tx_bytes +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x40 + offs);
|
||||
+ stats = mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x44 + offs);
|
||||
+ if (stats)
|
||||
+ hw_stats->tx_bytes += (stats << 32);
|
||||
+ hw_stats->tx_packets +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x48 + offs);
|
||||
+ } else {
|
||||
+ hw_stats->tx_skip +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x28 + offs);
|
||||
+ hw_stats->tx_collisions +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x2c + offs);
|
||||
+ hw_stats->tx_bytes +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x30 + offs);
|
||||
+ stats = mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x34 + offs);
|
||||
+ if (stats)
|
||||
+ hw_stats->tx_bytes += (stats << 32);
|
||||
+ hw_stats->tx_packets +=
|
||||
+ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x38 + offs);
|
||||
+ }
|
||||
}
|
||||
|
||||
u64_stats_update_end(&hw_stats->syncp);
|
||||
@@ -1192,7 +1207,10 @@ static void mtk_tx_set_dma_desc_v2(struc
|
||||
data |= TX_DMA_LS0;
|
||||
WRITE_ONCE(desc->txd3, data);
|
||||
|
||||
- data = (mac->id + 1) << TX_DMA_FPORT_SHIFT_V2; /* forward port */
|
||||
+ if (mac->id == MTK_GMAC3_ID)
|
||||
+ data = PSE_GDM3_PORT;
|
||||
+ else
|
||||
+ data = (mac->id + 1) << TX_DMA_FPORT_SHIFT_V2; /* forward port */
|
||||
data |= TX_DMA_SWC_V2 | QID_BITS_V2(info->qid);
|
||||
WRITE_ONCE(desc->txd4, data);
|
||||
|
||||
@@ -1203,6 +1221,9 @@ static void mtk_tx_set_dma_desc_v2(struc
|
||||
/* tx checksum offload */
|
||||
if (info->csum)
|
||||
data |= TX_DMA_CHKSUM_V2;
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3) &&
|
||||
+ netdev_uses_dsa(dev))
|
||||
+ data |= TX_DMA_SPTAG_V3;
|
||||
}
|
||||
WRITE_ONCE(desc->txd5, data);
|
||||
|
||||
@@ -1268,8 +1289,13 @@ static int mtk_tx_map(struct sk_buff *sk
|
||||
mtk_tx_set_dma_desc(dev, itxd, &txd_info);
|
||||
|
||||
itx_buf->flags |= MTK_TX_FLAGS_SINGLE0;
|
||||
- itx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 :
|
||||
- MTK_TX_FLAGS_FPORT1;
|
||||
+ if (mac->id == MTK_GMAC1_ID)
|
||||
+ itx_buf->flags |= MTK_TX_FLAGS_FPORT0;
|
||||
+ else if (mac->id == MTK_GMAC2_ID)
|
||||
+ itx_buf->flags |= MTK_TX_FLAGS_FPORT1;
|
||||
+ else
|
||||
+ itx_buf->flags |= MTK_TX_FLAGS_FPORT2;
|
||||
+
|
||||
setup_tx_buf(eth, itx_buf, itxd_pdma, txd_info.addr, txd_info.size,
|
||||
k++);
|
||||
|
||||
@@ -1317,8 +1343,13 @@ static int mtk_tx_map(struct sk_buff *sk
|
||||
memset(tx_buf, 0, sizeof(*tx_buf));
|
||||
tx_buf->data = (void *)MTK_DMA_DUMMY_DESC;
|
||||
tx_buf->flags |= MTK_TX_FLAGS_PAGE0;
|
||||
- tx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 :
|
||||
- MTK_TX_FLAGS_FPORT1;
|
||||
+
|
||||
+ if (mac->id == MTK_GMAC1_ID)
|
||||
+ tx_buf->flags |= MTK_TX_FLAGS_FPORT0;
|
||||
+ else if (mac->id == MTK_GMAC2_ID)
|
||||
+ tx_buf->flags |= MTK_TX_FLAGS_FPORT1;
|
||||
+ else
|
||||
+ tx_buf->flags |= MTK_TX_FLAGS_FPORT2;
|
||||
|
||||
setup_tx_buf(eth, tx_buf, txd_pdma, txd_info.addr,
|
||||
txd_info.size, k++);
|
||||
@@ -1902,11 +1933,24 @@ static int mtk_poll_rx(struct napi_struc
|
||||
break;
|
||||
|
||||
/* find out which mac the packet come from. values start at 1 */
|
||||
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1))
|
||||
- mac = RX_DMA_GET_SPORT_V2(trxd.rxd5) - 1;
|
||||
- else if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
|
||||
- !(trxd.rxd4 & RX_DMA_SPECIAL_TAG))
|
||||
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V1)) {
|
||||
+ u32 val = RX_DMA_GET_SPORT_V2(trxd.rxd5);
|
||||
+
|
||||
+ switch (val) {
|
||||
+ case PSE_GDM1_PORT:
|
||||
+ case PSE_GDM2_PORT:
|
||||
+ mac = val - 1;
|
||||
+ break;
|
||||
+ case PSE_GDM3_PORT:
|
||||
+ mac = MTK_GMAC3_ID;
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ } else if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
|
||||
+ !(trxd.rxd4 & RX_DMA_SPECIAL_TAG)) {
|
||||
mac = RX_DMA_GET_SPORT(trxd.rxd4) - 1;
|
||||
+ }
|
||||
|
||||
if (unlikely(mac < 0 || mac >= eth->soc->num_devs ||
|
||||
!eth->netdev[mac]))
|
||||
@@ -2135,7 +2179,9 @@ static int mtk_poll_tx_qdma(struct mtk_e
|
||||
tx_buf = mtk_desc_to_tx_buf(ring, desc,
|
||||
eth->soc->txrx.txd_size);
|
||||
if (tx_buf->flags & MTK_TX_FLAGS_FPORT1)
|
||||
- mac = 1;
|
||||
+ mac = MTK_GMAC2_ID;
|
||||
+ else if (tx_buf->flags & MTK_TX_FLAGS_FPORT2)
|
||||
+ mac = MTK_GMAC3_ID;
|
||||
|
||||
if (!tx_buf->data)
|
||||
break;
|
||||
@@ -3742,7 +3788,26 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, reg_map->qdma.int_grp + 4);
|
||||
mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP);
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) {
|
||||
+ /* PSE should not drop port1, port8 and port9 packets */
|
||||
+ mtk_w32(eth, 0x00000302, PSE_DROP_CFG);
|
||||
+
|
||||
+ /* GDM and CDM Threshold */
|
||||
+ mtk_w32(eth, 0x00000707, MTK_CDMW0_THRES);
|
||||
+ mtk_w32(eth, 0x00000077, MTK_CDMW1_THRES);
|
||||
+
|
||||
+ /* Disable GDM1 RX CRC stripping */
|
||||
+ val = mtk_r32(eth, MTK_GDMA_FWD_CFG(0));
|
||||
+ val &= ~MTK_GDMA_STRP_CRC;
|
||||
+ mtk_w32(eth, val, MTK_GDMA_FWD_CFG(0));
|
||||
+
|
||||
+ /* PSE GDM3 MIB counter has incorrect hw default values,
|
||||
+ * so the driver ought to read clear the values beforehand
|
||||
+ * in case ethtool retrieve wrong mib values.
|
||||
+ */
|
||||
+ for (i = 0; i < 0x80; i += 0x4)
|
||||
+ mtk_r32(eth, reg_map->gdm1_cnt + 0x100 + i);
|
||||
+ } else if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
||||
/* PSE should not drop port8 and port9 packets from WDMA Tx */
|
||||
mtk_w32(eth, 0x00000300, PSE_DROP_CFG);
|
||||
|
||||
@@ -4314,7 +4379,11 @@ static int mtk_add_mac(struct mtk_eth *e
|
||||
}
|
||||
spin_lock_init(&mac->hw_stats->stats_lock);
|
||||
u64_stats_init(&mac->hw_stats->syncp);
|
||||
- mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET;
|
||||
+
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3))
|
||||
+ mac->hw_stats->reg_offset = id * 0x80;
|
||||
+ else
|
||||
+ mac->hw_stats->reg_offset = id * 0x40;
|
||||
|
||||
/* phylink create */
|
||||
err = of_get_phy_mode(np, &phy_mode);
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -121,6 +121,7 @@
|
||||
#define MTK_GDMA_ICS_EN BIT(22)
|
||||
#define MTK_GDMA_TCS_EN BIT(21)
|
||||
#define MTK_GDMA_UCS_EN BIT(20)
|
||||
+#define MTK_GDMA_STRP_CRC BIT(16)
|
||||
#define MTK_GDMA_TO_PDMA 0x0
|
||||
#define MTK_GDMA_DROP_ALL 0x7777
|
||||
|
||||
@@ -286,8 +287,6 @@
|
||||
/* QDMA Interrupt grouping registers */
|
||||
#define MTK_RLS_DONE_INT BIT(0)
|
||||
|
||||
-#define MTK_STAT_OFFSET 0x40
|
||||
-
|
||||
/* QDMA TX NUM */
|
||||
#define QID_BITS_V2(x) (((x) & 0x3f) << 16)
|
||||
#define MTK_QDMA_GMAC2_QID 8
|
||||
@@ -300,6 +299,8 @@
|
||||
#define TX_DMA_CHKSUM_V2 (0x7 << 28)
|
||||
#define TX_DMA_TSO_V2 BIT(31)
|
||||
|
||||
+#define TX_DMA_SPTAG_V3 BIT(27)
|
||||
+
|
||||
/* QDMA V2 descriptor txd4 */
|
||||
#define TX_DMA_FPORT_SHIFT_V2 8
|
||||
#define TX_DMA_FPORT_MASK_V2 0xf
|
||||
@@ -636,6 +637,7 @@ enum mtk_tx_flags {
|
||||
*/
|
||||
MTK_TX_FLAGS_FPORT0 = 0x04,
|
||||
MTK_TX_FLAGS_FPORT1 = 0x08,
|
||||
+ MTK_TX_FLAGS_FPORT2 = 0x10,
|
||||
};
|
||||
|
||||
/* This enum allows us to identify how the clock is defined on the array of the
|
||||
@@ -721,6 +723,42 @@ enum mtk_dev_state {
|
||||
MTK_RESETTING
|
||||
};
|
||||
|
||||
+/* PSE Port Definition */
|
||||
+enum mtk_pse_port {
|
||||
+ PSE_ADMA_PORT = 0,
|
||||
+ PSE_GDM1_PORT,
|
||||
+ PSE_GDM2_PORT,
|
||||
+ PSE_PPE0_PORT,
|
||||
+ PSE_PPE1_PORT,
|
||||
+ PSE_QDMA_TX_PORT,
|
||||
+ PSE_QDMA_RX_PORT,
|
||||
+ PSE_DROP_PORT,
|
||||
+ PSE_WDMA0_PORT,
|
||||
+ PSE_WDMA1_PORT,
|
||||
+ PSE_TDMA_PORT,
|
||||
+ PSE_NONE_PORT,
|
||||
+ PSE_PPE2_PORT,
|
||||
+ PSE_WDMA2_PORT,
|
||||
+ PSE_EIP197_PORT,
|
||||
+ PSE_GDM3_PORT,
|
||||
+ PSE_PORT_MAX
|
||||
+};
|
||||
+
|
||||
+/* GMAC Identifier */
|
||||
+enum mtk_gmac_id {
|
||||
+ MTK_GMAC1_ID = 0,
|
||||
+ MTK_GMAC2_ID,
|
||||
+ MTK_GMAC3_ID,
|
||||
+ MTK_GMAC_ID_MAX
|
||||
+};
|
||||
+
|
||||
+/* GDM Type */
|
||||
+enum mtk_gdm_type {
|
||||
+ MTK_GDM_TYPE = 0,
|
||||
+ MTK_XGDM_TYPE,
|
||||
+ MTK_GDM_TYPE_MAX
|
||||
+};
|
||||
+
|
||||
enum mtk_tx_buf_type {
|
||||
MTK_TYPE_SKB,
|
||||
MTK_TYPE_XDP_TX,
|
||||
@@ -817,6 +855,7 @@ enum mkt_eth_capabilities {
|
||||
MTK_QDMA_BIT,
|
||||
MTK_NETSYS_V1_BIT,
|
||||
MTK_NETSYS_V2_BIT,
|
||||
+ MTK_NETSYS_V3_BIT,
|
||||
MTK_SOC_MT7628_BIT,
|
||||
MTK_RSTCTRL_PPE1_BIT,
|
||||
MTK_U3_COPHY_V2_BIT,
|
||||
@@ -853,6 +892,7 @@ enum mkt_eth_capabilities {
|
||||
#define MTK_QDMA BIT(MTK_QDMA_BIT)
|
||||
#define MTK_NETSYS_V1 BIT(MTK_NETSYS_V1_BIT)
|
||||
#define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT)
|
||||
+#define MTK_NETSYS_V3 BIT(MTK_NETSYS_V3_BIT)
|
||||
#define MTK_SOC_MT7628 BIT(MTK_SOC_MT7628_BIT)
|
||||
#define MTK_RSTCTRL_PPE1 BIT(MTK_RSTCTRL_PPE1_BIT)
|
||||
#define MTK_U3_COPHY_V2 BIT(MTK_U3_COPHY_V2_BIT)
|
@ -0,0 +1,197 @@
|
||||
From 45b575fd9e6a455090820248bf1b98b1f2c7b6c8 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 7 Mar 2023 15:56:00 +0000
|
||||
Subject: [PATCH 5/7] net: ethernet: mtk_eth_soc: convert caps in mtk_soc_data
|
||||
struct to u64
|
||||
|
||||
This is a preliminary patch to introduce support for MT7988 SoC.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_path.c | 22 +++----
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 62 ++++++++++----------
|
||||
2 files changed, 42 insertions(+), 42 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_path.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_path.c
|
||||
@@ -15,10 +15,10 @@
|
||||
struct mtk_eth_muxc {
|
||||
const char *name;
|
||||
int cap_bit;
|
||||
- int (*set_path)(struct mtk_eth *eth, int path);
|
||||
+ int (*set_path)(struct mtk_eth *eth, u64 path);
|
||||
};
|
||||
|
||||
-static const char *mtk_eth_path_name(int path)
|
||||
+static const char *mtk_eth_path_name(u64 path)
|
||||
{
|
||||
switch (path) {
|
||||
case MTK_ETH_PATH_GMAC1_RGMII:
|
||||
@@ -40,7 +40,7 @@ static const char *mtk_eth_path_name(int
|
||||
}
|
||||
}
|
||||
|
||||
-static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, int path)
|
||||
+static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
bool updated = true;
|
||||
u32 val, mask, set;
|
||||
@@ -71,7 +71,7 @@ static int set_mux_gdm1_to_gmac1_esw(str
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, int path)
|
||||
+static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
bool updated = true;
|
||||
@@ -94,7 +94,7 @@ static int set_mux_gmac2_gmac0_to_gephy(
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, int path)
|
||||
+static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
unsigned int val = 0, mask = 0, reg = 0;
|
||||
bool updated = true;
|
||||
@@ -125,7 +125,7 @@ static int set_mux_u3_gmac2_to_qphy(stru
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, int path)
|
||||
+static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
bool updated = true;
|
||||
@@ -163,7 +163,7 @@ static int set_mux_gmac1_gmac2_to_sgmii_
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, int path)
|
||||
+static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
bool updated = true;
|
||||
@@ -218,7 +218,7 @@ static const struct mtk_eth_muxc mtk_eth
|
||||
},
|
||||
};
|
||||
|
||||
-static int mtk_eth_mux_setup(struct mtk_eth *eth, int path)
|
||||
+static int mtk_eth_mux_setup(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
int i, err = 0;
|
||||
|
||||
@@ -249,7 +249,7 @@ out:
|
||||
|
||||
int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
|
||||
{
|
||||
- int path;
|
||||
+ u64 path;
|
||||
|
||||
path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_SGMII :
|
||||
MTK_ETH_PATH_GMAC2_SGMII;
|
||||
@@ -260,7 +260,7 @@ int mtk_gmac_sgmii_path_setup(struct mtk
|
||||
|
||||
int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)
|
||||
{
|
||||
- int path = 0;
|
||||
+ u64 path = 0;
|
||||
|
||||
if (mac_id == 1)
|
||||
path = MTK_ETH_PATH_GMAC2_GEPHY;
|
||||
@@ -274,7 +274,7 @@ int mtk_gmac_gephy_path_setup(struct mtk
|
||||
|
||||
int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id)
|
||||
{
|
||||
- int path;
|
||||
+ u64 path;
|
||||
|
||||
path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_RGMII :
|
||||
MTK_ETH_PATH_GMAC2_RGMII;
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -878,44 +878,44 @@ enum mkt_eth_capabilities {
|
||||
};
|
||||
|
||||
/* Supported hardware group on SoCs */
|
||||
-#define MTK_RGMII BIT(MTK_RGMII_BIT)
|
||||
-#define MTK_TRGMII BIT(MTK_TRGMII_BIT)
|
||||
-#define MTK_SGMII BIT(MTK_SGMII_BIT)
|
||||
-#define MTK_ESW BIT(MTK_ESW_BIT)
|
||||
-#define MTK_GEPHY BIT(MTK_GEPHY_BIT)
|
||||
-#define MTK_MUX BIT(MTK_MUX_BIT)
|
||||
-#define MTK_INFRA BIT(MTK_INFRA_BIT)
|
||||
-#define MTK_SHARED_SGMII BIT(MTK_SHARED_SGMII_BIT)
|
||||
-#define MTK_HWLRO BIT(MTK_HWLRO_BIT)
|
||||
-#define MTK_SHARED_INT BIT(MTK_SHARED_INT_BIT)
|
||||
-#define MTK_TRGMII_MT7621_CLK BIT(MTK_TRGMII_MT7621_CLK_BIT)
|
||||
-#define MTK_QDMA BIT(MTK_QDMA_BIT)
|
||||
-#define MTK_NETSYS_V1 BIT(MTK_NETSYS_V1_BIT)
|
||||
-#define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT)
|
||||
-#define MTK_NETSYS_V3 BIT(MTK_NETSYS_V3_BIT)
|
||||
-#define MTK_SOC_MT7628 BIT(MTK_SOC_MT7628_BIT)
|
||||
-#define MTK_RSTCTRL_PPE1 BIT(MTK_RSTCTRL_PPE1_BIT)
|
||||
-#define MTK_U3_COPHY_V2 BIT(MTK_U3_COPHY_V2_BIT)
|
||||
+#define MTK_RGMII BIT_ULL(MTK_RGMII_BIT)
|
||||
+#define MTK_TRGMII BIT_ULL(MTK_TRGMII_BIT)
|
||||
+#define MTK_SGMII BIT_ULL(MTK_SGMII_BIT)
|
||||
+#define MTK_ESW BIT_ULL(MTK_ESW_BIT)
|
||||
+#define MTK_GEPHY BIT_ULL(MTK_GEPHY_BIT)
|
||||
+#define MTK_MUX BIT_ULL(MTK_MUX_BIT)
|
||||
+#define MTK_INFRA BIT_ULL(MTK_INFRA_BIT)
|
||||
+#define MTK_SHARED_SGMII BIT_ULL(MTK_SHARED_SGMII_BIT)
|
||||
+#define MTK_HWLRO BIT_ULL(MTK_HWLRO_BIT)
|
||||
+#define MTK_SHARED_INT BIT_ULL(MTK_SHARED_INT_BIT)
|
||||
+#define MTK_TRGMII_MT7621_CLK BIT_ULL(MTK_TRGMII_MT7621_CLK_BIT)
|
||||
+#define MTK_QDMA BIT_ULL(MTK_QDMA_BIT)
|
||||
+#define MTK_NETSYS_V1 BIT_ULL(MTK_NETSYS_V1_BIT)
|
||||
+#define MTK_NETSYS_V2 BIT_ULL(MTK_NETSYS_V2_BIT)
|
||||
+#define MTK_NETSYS_V3 BIT_ULL(MTK_NETSYS_V3_BIT)
|
||||
+#define MTK_SOC_MT7628 BIT_ULL(MTK_SOC_MT7628_BIT)
|
||||
+#define MTK_RSTCTRL_PPE1 BIT_ULL(MTK_RSTCTRL_PPE1_BIT)
|
||||
+#define MTK_U3_COPHY_V2 BIT_ULL(MTK_U3_COPHY_V2_BIT)
|
||||
|
||||
#define MTK_ETH_MUX_GDM1_TO_GMAC1_ESW \
|
||||
- BIT(MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT)
|
||||
+ BIT_ULL(MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT)
|
||||
#define MTK_ETH_MUX_GMAC2_GMAC0_TO_GEPHY \
|
||||
- BIT(MTK_ETH_MUX_GMAC2_GMAC0_TO_GEPHY_BIT)
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC2_GMAC0_TO_GEPHY_BIT)
|
||||
#define MTK_ETH_MUX_U3_GMAC2_TO_QPHY \
|
||||
- BIT(MTK_ETH_MUX_U3_GMAC2_TO_QPHY_BIT)
|
||||
+ BIT_ULL(MTK_ETH_MUX_U3_GMAC2_TO_QPHY_BIT)
|
||||
#define MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII \
|
||||
- BIT(MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT)
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT)
|
||||
#define MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII \
|
||||
- BIT(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT)
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT)
|
||||
|
||||
/* Supported path present on SoCs */
|
||||
-#define MTK_ETH_PATH_GMAC1_RGMII BIT(MTK_ETH_PATH_GMAC1_RGMII_BIT)
|
||||
-#define MTK_ETH_PATH_GMAC1_TRGMII BIT(MTK_ETH_PATH_GMAC1_TRGMII_BIT)
|
||||
-#define MTK_ETH_PATH_GMAC1_SGMII BIT(MTK_ETH_PATH_GMAC1_SGMII_BIT)
|
||||
-#define MTK_ETH_PATH_GMAC2_RGMII BIT(MTK_ETH_PATH_GMAC2_RGMII_BIT)
|
||||
-#define MTK_ETH_PATH_GMAC2_SGMII BIT(MTK_ETH_PATH_GMAC2_SGMII_BIT)
|
||||
-#define MTK_ETH_PATH_GMAC2_GEPHY BIT(MTK_ETH_PATH_GMAC2_GEPHY_BIT)
|
||||
-#define MTK_ETH_PATH_GDM1_ESW BIT(MTK_ETH_PATH_GDM1_ESW_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC1_RGMII BIT_ULL(MTK_ETH_PATH_GMAC1_RGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC1_TRGMII BIT_ULL(MTK_ETH_PATH_GMAC1_TRGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC1_SGMII BIT_ULL(MTK_ETH_PATH_GMAC1_SGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC2_RGMII BIT_ULL(MTK_ETH_PATH_GMAC2_RGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC2_SGMII BIT_ULL(MTK_ETH_PATH_GMAC2_SGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC2_GEPHY BIT_ULL(MTK_ETH_PATH_GMAC2_GEPHY_BIT)
|
||||
+#define MTK_ETH_PATH_GDM1_ESW BIT_ULL(MTK_ETH_PATH_GDM1_ESW_BIT)
|
||||
|
||||
#define MTK_GMAC1_RGMII (MTK_ETH_PATH_GMAC1_RGMII | MTK_RGMII)
|
||||
#define MTK_GMAC1_TRGMII (MTK_ETH_PATH_GMAC1_TRGMII | MTK_TRGMII)
|
||||
@@ -1071,7 +1071,7 @@ struct mtk_reg_map {
|
||||
struct mtk_soc_data {
|
||||
const struct mtk_reg_map *reg_map;
|
||||
u32 ana_rgc3;
|
||||
- u32 caps;
|
||||
+ u64 caps;
|
||||
u32 required_clks;
|
||||
bool required_pctl;
|
||||
u8 offload_version;
|
@ -0,0 +1,495 @@
|
||||
From 661bacf4363ca68939c15e20056b5f72fbd034e7 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sat, 25 Feb 2023 00:08:24 +0100
|
||||
Subject: [PATCH 6/7] net: ethernet: mtk_eth_soc: add support for MT7988 SoC
|
||||
|
||||
Introduce support for ethernet chip available in MT7988 SoC to
|
||||
mtk_eth_soc driver.
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 153 ++++++++++++++--
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 193 ++++++++++++++------
|
||||
2 files changed, 279 insertions(+), 67 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -152,6 +152,54 @@ static const struct mtk_reg_map mt7986_r
|
||||
.pse_oq_sta = 0x01a0,
|
||||
};
|
||||
|
||||
+static const struct mtk_reg_map mt7988_reg_map = {
|
||||
+ .tx_irq_mask = 0x461c,
|
||||
+ .tx_irq_status = 0x4618,
|
||||
+ .pdma = {
|
||||
+ .rx_ptr = 0x6900,
|
||||
+ .rx_cnt_cfg = 0x6904,
|
||||
+ .pcrx_ptr = 0x6908,
|
||||
+ .glo_cfg = 0x6a04,
|
||||
+ .rst_idx = 0x6a08,
|
||||
+ .delay_irq = 0x6a0c,
|
||||
+ .irq_status = 0x6a20,
|
||||
+ .irq_mask = 0x6a28,
|
||||
+ .adma_rx_dbg0 = 0x6a38,
|
||||
+ .int_grp = 0x6a50,
|
||||
+ },
|
||||
+ .qdma = {
|
||||
+ .qtx_cfg = 0x4400,
|
||||
+ .qtx_sch = 0x4404,
|
||||
+ .rx_ptr = 0x4500,
|
||||
+ .rx_cnt_cfg = 0x4504,
|
||||
+ .qcrx_ptr = 0x4508,
|
||||
+ .glo_cfg = 0x4604,
|
||||
+ .rst_idx = 0x4608,
|
||||
+ .delay_irq = 0x460c,
|
||||
+ .fc_th = 0x4610,
|
||||
+ .int_grp = 0x4620,
|
||||
+ .hred = 0x4644,
|
||||
+ .ctx_ptr = 0x4700,
|
||||
+ .dtx_ptr = 0x4704,
|
||||
+ .crx_ptr = 0x4710,
|
||||
+ .drx_ptr = 0x4714,
|
||||
+ .fq_head = 0x4720,
|
||||
+ .fq_tail = 0x4724,
|
||||
+ .fq_count = 0x4728,
|
||||
+ .fq_blen = 0x472c,
|
||||
+ .tx_sch_rate = 0x4798,
|
||||
+ },
|
||||
+ .gdm1_cnt = 0x1c00,
|
||||
+ .gdma_to_ppe0 = 0x3333,
|
||||
+ .ppe_base = 0x2200,
|
||||
+ .wdma_base = {
|
||||
+ [0] = 0x4800,
|
||||
+ [1] = 0x4c00,
|
||||
+ },
|
||||
+ .pse_iq_sta = 0x0180,
|
||||
+ .pse_oq_sta = 0x01a0,
|
||||
+};
|
||||
+
|
||||
/* strings used by ethtool */
|
||||
static const struct mtk_ethtool_stats {
|
||||
char str[ETH_GSTRING_LEN];
|
||||
@@ -179,10 +227,54 @@ static const struct mtk_ethtool_stats {
|
||||
};
|
||||
|
||||
static const char * const mtk_clks_source_name[] = {
|
||||
- "ethif", "sgmiitop", "esw", "gp0", "gp1", "gp2", "fe", "trgpll",
|
||||
- "sgmii_tx250m", "sgmii_rx250m", "sgmii_cdr_ref", "sgmii_cdr_fb",
|
||||
- "sgmii2_tx250m", "sgmii2_rx250m", "sgmii2_cdr_ref", "sgmii2_cdr_fb",
|
||||
- "sgmii_ck", "eth2pll", "wocpu0", "wocpu1", "netsys0", "netsys1"
|
||||
+ "ethif",
|
||||
+ "sgmiitop",
|
||||
+ "esw",
|
||||
+ "gp0",
|
||||
+ "gp1",
|
||||
+ "gp2",
|
||||
+ "gp3",
|
||||
+ "xgp1",
|
||||
+ "xgp2",
|
||||
+ "xgp3",
|
||||
+ "crypto",
|
||||
+ "fe",
|
||||
+ "trgpll",
|
||||
+ "sgmii_tx250m",
|
||||
+ "sgmii_rx250m",
|
||||
+ "sgmii_cdr_ref",
|
||||
+ "sgmii_cdr_fb",
|
||||
+ "sgmii2_tx250m",
|
||||
+ "sgmii2_rx250m",
|
||||
+ "sgmii2_cdr_ref",
|
||||
+ "sgmii2_cdr_fb",
|
||||
+ "sgmii_ck",
|
||||
+ "eth2pll",
|
||||
+ "wocpu0",
|
||||
+ "wocpu1",
|
||||
+ "netsys0",
|
||||
+ "netsys1",
|
||||
+ "ethwarp_wocpu2",
|
||||
+ "ethwarp_wocpu1",
|
||||
+ "ethwarp_wocpu0",
|
||||
+ "top_usxgmii0_sel",
|
||||
+ "top_usxgmii1_sel",
|
||||
+ "top_sgm0_sel",
|
||||
+ "top_sgm1_sel",
|
||||
+ "top_xfi_phy0_xtal_sel",
|
||||
+ "top_xfi_phy1_xtal_sel",
|
||||
+ "top_eth_gmii_sel",
|
||||
+ "top_eth_refck_50m_sel",
|
||||
+ "top_eth_sys_200m_sel",
|
||||
+ "top_eth_sys_sel",
|
||||
+ "top_eth_xgmii_sel",
|
||||
+ "top_eth_mii_sel",
|
||||
+ "top_netsys_sel",
|
||||
+ "top_netsys_500m_sel",
|
||||
+ "top_netsys_pao_2x_sel",
|
||||
+ "top_netsys_sync_250m_sel",
|
||||
+ "top_netsys_ppefb_250m_sel",
|
||||
+ "top_netsys_warp_sel",
|
||||
};
|
||||
|
||||
void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg)
|
||||
@@ -1207,10 +1299,19 @@ static void mtk_tx_set_dma_desc_v2(struc
|
||||
data |= TX_DMA_LS0;
|
||||
WRITE_ONCE(desc->txd3, data);
|
||||
|
||||
- if (mac->id == MTK_GMAC3_ID)
|
||||
- data = PSE_GDM3_PORT;
|
||||
- else
|
||||
- data = (mac->id + 1) << TX_DMA_FPORT_SHIFT_V2; /* forward port */
|
||||
+ /* set forward port */
|
||||
+ switch (mac->id) {
|
||||
+ case MTK_GMAC1_ID:
|
||||
+ data = PSE_GDM1_PORT << TX_DMA_FPORT_SHIFT_V2;
|
||||
+ break;
|
||||
+ case MTK_GMAC2_ID:
|
||||
+ data = PSE_GDM2_PORT << TX_DMA_FPORT_SHIFT_V2;
|
||||
+ break;
|
||||
+ case MTK_GMAC3_ID:
|
||||
+ data = PSE_GDM3_PORT << TX_DMA_FPORT_SHIFT_V2;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
data |= TX_DMA_SWC_V2 | QID_BITS_V2(info->qid);
|
||||
WRITE_ONCE(desc->txd4, data);
|
||||
|
||||
@@ -4964,6 +5065,25 @@ static const struct mtk_soc_data mt7986_
|
||||
},
|
||||
};
|
||||
|
||||
+static const struct mtk_soc_data mt7988_data = {
|
||||
+ .reg_map = &mt7988_reg_map,
|
||||
+ .ana_rgc3 = 0x128,
|
||||
+ .caps = MT7988_CAPS,
|
||||
+ .hw_features = MTK_HW_FEATURES,
|
||||
+ .required_clks = MT7988_CLKS_BITMAP,
|
||||
+ .required_pctl = false,
|
||||
+ .num_devs = 3,
|
||||
+ .txrx = {
|
||||
+ .txd_size = sizeof(struct mtk_tx_dma_v2),
|
||||
+ .rxd_size = sizeof(struct mtk_rx_dma_v2),
|
||||
+ .rx_irq_done_mask = MTK_RX_DONE_INT_V2,
|
||||
+ .rx_dma_l4_valid = RX_DMA_L4_VALID_V2,
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
|
||||
+ .dma_len_offset = 8,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+
|
||||
static const struct mtk_soc_data rt5350_data = {
|
||||
.reg_map = &mt7628_reg_map,
|
||||
.caps = MT7628_CAPS,
|
||||
@@ -4982,14 +5102,15 @@ static const struct mtk_soc_data rt5350_
|
||||
};
|
||||
|
||||
const struct of_device_id of_mtk_match[] = {
|
||||
- { .compatible = "mediatek,mt2701-eth", .data = &mt2701_data},
|
||||
- { .compatible = "mediatek,mt7621-eth", .data = &mt7621_data},
|
||||
- { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data},
|
||||
- { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data},
|
||||
- { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data},
|
||||
- { .compatible = "mediatek,mt7981-eth", .data = &mt7981_data},
|
||||
- { .compatible = "mediatek,mt7986-eth", .data = &mt7986_data},
|
||||
- { .compatible = "ralink,rt5350-eth", .data = &rt5350_data},
|
||||
+ { .compatible = "mediatek,mt2701-eth", .data = &mt2701_data },
|
||||
+ { .compatible = "mediatek,mt7621-eth", .data = &mt7621_data },
|
||||
+ { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data },
|
||||
+ { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data },
|
||||
+ { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data },
|
||||
+ { .compatible = "mediatek,mt7981-eth", .data = &mt7981_data },
|
||||
+ { .compatible = "mediatek,mt7986-eth", .data = &mt7986_data },
|
||||
+ { .compatible = "mediatek,mt7988-eth", .data = &mt7988_data },
|
||||
+ { .compatible = "ralink,rt5350-eth", .data = &rt5350_data },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, of_mtk_match);
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -116,7 +116,8 @@
|
||||
#define MTK_CDMP_EG_CTRL 0x404
|
||||
|
||||
/* GDM Exgress Control Register */
|
||||
-#define MTK_GDMA_FWD_CFG(x) (0x500 + (x * 0x1000))
|
||||
+#define MTK_GDMA_FWD_CFG(x) ((x == MTK_GMAC3_ID) ? \
|
||||
+ 0x540 : 0x500 + (x * 0x1000))
|
||||
#define MTK_GDMA_SPECIAL_TAG BIT(24)
|
||||
#define MTK_GDMA_ICS_EN BIT(22)
|
||||
#define MTK_GDMA_TCS_EN BIT(21)
|
||||
@@ -650,6 +651,11 @@ enum mtk_clks_map {
|
||||
MTK_CLK_GP0,
|
||||
MTK_CLK_GP1,
|
||||
MTK_CLK_GP2,
|
||||
+ MTK_CLK_GP3,
|
||||
+ MTK_CLK_XGP1,
|
||||
+ MTK_CLK_XGP2,
|
||||
+ MTK_CLK_XGP3,
|
||||
+ MTK_CLK_CRYPTO,
|
||||
MTK_CLK_FE,
|
||||
MTK_CLK_TRGPLL,
|
||||
MTK_CLK_SGMII_TX_250M,
|
||||
@@ -666,57 +672,108 @@ enum mtk_clks_map {
|
||||
MTK_CLK_WOCPU1,
|
||||
MTK_CLK_NETSYS0,
|
||||
MTK_CLK_NETSYS1,
|
||||
+ MTK_CLK_ETHWARP_WOCPU2,
|
||||
+ MTK_CLK_ETHWARP_WOCPU1,
|
||||
+ MTK_CLK_ETHWARP_WOCPU0,
|
||||
+ MTK_CLK_TOP_USXGMII_SBUS_0_SEL,
|
||||
+ MTK_CLK_TOP_USXGMII_SBUS_1_SEL,
|
||||
+ MTK_CLK_TOP_SGM_0_SEL,
|
||||
+ MTK_CLK_TOP_SGM_1_SEL,
|
||||
+ MTK_CLK_TOP_XFI_PHY_0_XTAL_SEL,
|
||||
+ MTK_CLK_TOP_XFI_PHY_1_XTAL_SEL,
|
||||
+ MTK_CLK_TOP_ETH_GMII_SEL,
|
||||
+ MTK_CLK_TOP_ETH_REFCK_50M_SEL,
|
||||
+ MTK_CLK_TOP_ETH_SYS_200M_SEL,
|
||||
+ MTK_CLK_TOP_ETH_SYS_SEL,
|
||||
+ MTK_CLK_TOP_ETH_XGMII_SEL,
|
||||
+ MTK_CLK_TOP_ETH_MII_SEL,
|
||||
+ MTK_CLK_TOP_NETSYS_SEL,
|
||||
+ MTK_CLK_TOP_NETSYS_500M_SEL,
|
||||
+ MTK_CLK_TOP_NETSYS_PAO_2X_SEL,
|
||||
+ MTK_CLK_TOP_NETSYS_SYNC_250M_SEL,
|
||||
+ MTK_CLK_TOP_NETSYS_PPEFB_250M_SEL,
|
||||
+ MTK_CLK_TOP_NETSYS_WARP_SEL,
|
||||
MTK_CLK_MAX
|
||||
};
|
||||
|
||||
-#define MT7623_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \
|
||||
- BIT(MTK_CLK_GP1) | BIT(MTK_CLK_GP2) | \
|
||||
- BIT(MTK_CLK_TRGPLL))
|
||||
-#define MT7622_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \
|
||||
- BIT(MTK_CLK_GP0) | BIT(MTK_CLK_GP1) | \
|
||||
- BIT(MTK_CLK_GP2) | \
|
||||
- BIT(MTK_CLK_SGMII_TX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_RX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_REF) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_FB) | \
|
||||
- BIT(MTK_CLK_SGMII_CK) | \
|
||||
- BIT(MTK_CLK_ETH2PLL))
|
||||
+#define MT7623_CLKS_BITMAP (BIT_ULL(MTK_CLK_ETHIF) | BIT_ULL(MTK_CLK_ESW) | \
|
||||
+ BIT_ULL(MTK_CLK_GP1) | BIT_ULL(MTK_CLK_GP2) | \
|
||||
+ BIT_ULL(MTK_CLK_TRGPLL))
|
||||
+#define MT7622_CLKS_BITMAP (BIT_ULL(MTK_CLK_ETHIF) | BIT_ULL(MTK_CLK_ESW) | \
|
||||
+ BIT_ULL(MTK_CLK_GP0) | BIT_ULL(MTK_CLK_GP1) | \
|
||||
+ BIT_ULL(MTK_CLK_GP2) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CK) | \
|
||||
+ BIT_ULL(MTK_CLK_ETH2PLL))
|
||||
#define MT7621_CLKS_BITMAP (0)
|
||||
#define MT7628_CLKS_BITMAP (0)
|
||||
-#define MT7629_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \
|
||||
- BIT(MTK_CLK_GP0) | BIT(MTK_CLK_GP1) | \
|
||||
- BIT(MTK_CLK_GP2) | BIT(MTK_CLK_FE) | \
|
||||
- BIT(MTK_CLK_SGMII_TX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_RX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_REF) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_FB) | \
|
||||
- BIT(MTK_CLK_SGMII2_TX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII2_RX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII2_CDR_REF) | \
|
||||
- BIT(MTK_CLK_SGMII2_CDR_FB) | \
|
||||
- BIT(MTK_CLK_SGMII_CK) | \
|
||||
- BIT(MTK_CLK_ETH2PLL) | BIT(MTK_CLK_SGMIITOP))
|
||||
-#define MT7981_CLKS_BITMAP (BIT(MTK_CLK_FE) | BIT(MTK_CLK_GP2) | BIT(MTK_CLK_GP1) | \
|
||||
- BIT(MTK_CLK_WOCPU0) | \
|
||||
- BIT(MTK_CLK_SGMII_TX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_RX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_REF) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_FB) | \
|
||||
- BIT(MTK_CLK_SGMII2_TX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII2_RX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII2_CDR_REF) | \
|
||||
- BIT(MTK_CLK_SGMII2_CDR_FB) | \
|
||||
- BIT(MTK_CLK_SGMII_CK))
|
||||
-#define MT7986_CLKS_BITMAP (BIT(MTK_CLK_FE) | BIT(MTK_CLK_GP2) | BIT(MTK_CLK_GP1) | \
|
||||
- BIT(MTK_CLK_WOCPU1) | BIT(MTK_CLK_WOCPU0) | \
|
||||
- BIT(MTK_CLK_SGMII_TX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_RX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_REF) | \
|
||||
- BIT(MTK_CLK_SGMII_CDR_FB) | \
|
||||
- BIT(MTK_CLK_SGMII2_TX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII2_RX_250M) | \
|
||||
- BIT(MTK_CLK_SGMII2_CDR_REF) | \
|
||||
- BIT(MTK_CLK_SGMII2_CDR_FB))
|
||||
+#define MT7629_CLKS_BITMAP (BIT_ULL(MTK_CLK_ETHIF) | BIT_ULL(MTK_CLK_ESW) | \
|
||||
+ BIT_ULL(MTK_CLK_GP0) | BIT_ULL(MTK_CLK_GP1) | \
|
||||
+ BIT_ULL(MTK_CLK_GP2) | BIT_ULL(MTK_CLK_FE) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_CDR_REF) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_CDR_FB) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CK) | \
|
||||
+ BIT_ULL(MTK_CLK_ETH2PLL) | BIT_ULL(MTK_CLK_SGMIITOP))
|
||||
+#define MT7981_CLKS_BITMAP (BIT_ULL(MTK_CLK_FE) | BIT_ULL(MTK_CLK_GP2) | BIT_ULL(MTK_CLK_GP1) | \
|
||||
+ BIT_ULL(MTK_CLK_WOCPU0) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_CDR_REF) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_CDR_FB) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CK))
|
||||
+#define MT7986_CLKS_BITMAP (BIT_ULL(MTK_CLK_FE) | BIT_ULL(MTK_CLK_GP2) | BIT_ULL(MTK_CLK_GP1) | \
|
||||
+ BIT_ULL(MTK_CLK_WOCPU1) | BIT_ULL(MTK_CLK_WOCPU0) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_CDR_REF) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_CDR_FB))
|
||||
+#define MT7988_CLKS_BITMAP (BIT_ULL(MTK_CLK_FE) | BIT_ULL(MTK_CLK_ESW) | \
|
||||
+ BIT_ULL(MTK_CLK_GP1) | BIT_ULL(MTK_CLK_GP2) | \
|
||||
+ BIT_ULL(MTK_CLK_GP3) | BIT_ULL(MTK_CLK_XGP1) | \
|
||||
+ BIT_ULL(MTK_CLK_XGP2) | BIT_ULL(MTK_CLK_XGP3) | \
|
||||
+ BIT_ULL(MTK_CLK_CRYPTO) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \
|
||||
+ BIT_ULL(MTK_CLK_ETHWARP_WOCPU2) | \
|
||||
+ BIT_ULL(MTK_CLK_ETHWARP_WOCPU1) | \
|
||||
+ BIT_ULL(MTK_CLK_ETHWARP_WOCPU0) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_USXGMII_SBUS_0_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_USXGMII_SBUS_1_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_SGM_0_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_SGM_1_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_XFI_PHY_0_XTAL_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_XFI_PHY_1_XTAL_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_ETH_GMII_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_ETH_REFCK_50M_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_ETH_SYS_200M_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_ETH_SYS_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_ETH_XGMII_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_ETH_MII_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_NETSYS_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_NETSYS_500M_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_NETSYS_PAO_2X_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_NETSYS_SYNC_250M_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_NETSYS_PPEFB_250M_SEL) | \
|
||||
+ BIT_ULL(MTK_CLK_TOP_NETSYS_WARP_SEL))
|
||||
|
||||
enum mtk_dev_state {
|
||||
MTK_HW_INIT,
|
||||
@@ -844,6 +901,7 @@ enum mkt_eth_capabilities {
|
||||
MTK_RGMII_BIT = 0,
|
||||
MTK_TRGMII_BIT,
|
||||
MTK_SGMII_BIT,
|
||||
+ MTK_USXGMII_BIT,
|
||||
MTK_ESW_BIT,
|
||||
MTK_GEPHY_BIT,
|
||||
MTK_MUX_BIT,
|
||||
@@ -866,6 +924,8 @@ enum mkt_eth_capabilities {
|
||||
MTK_ETH_MUX_U3_GMAC2_TO_QPHY_BIT,
|
||||
MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT,
|
||||
MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT,
|
||||
+ MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII_BIT,
|
||||
+ MTK_ETH_MUX_GMAC123_TO_USXGMII_BIT,
|
||||
|
||||
/* PATH BITS */
|
||||
MTK_ETH_PATH_GMAC1_RGMII_BIT,
|
||||
@@ -874,13 +934,18 @@ enum mkt_eth_capabilities {
|
||||
MTK_ETH_PATH_GMAC2_RGMII_BIT,
|
||||
MTK_ETH_PATH_GMAC2_SGMII_BIT,
|
||||
MTK_ETH_PATH_GMAC2_GEPHY_BIT,
|
||||
+ MTK_ETH_PATH_GMAC3_SGMII_BIT,
|
||||
MTK_ETH_PATH_GDM1_ESW_BIT,
|
||||
+ MTK_ETH_PATH_GMAC1_USXGMII_BIT,
|
||||
+ MTK_ETH_PATH_GMAC2_USXGMII_BIT,
|
||||
+ MTK_ETH_PATH_GMAC3_USXGMII_BIT,
|
||||
};
|
||||
|
||||
/* Supported hardware group on SoCs */
|
||||
#define MTK_RGMII BIT_ULL(MTK_RGMII_BIT)
|
||||
#define MTK_TRGMII BIT_ULL(MTK_TRGMII_BIT)
|
||||
#define MTK_SGMII BIT_ULL(MTK_SGMII_BIT)
|
||||
+#define MTK_USXGMII BIT_ULL(MTK_USXGMII_BIT)
|
||||
#define MTK_ESW BIT_ULL(MTK_ESW_BIT)
|
||||
#define MTK_GEPHY BIT_ULL(MTK_GEPHY_BIT)
|
||||
#define MTK_MUX BIT_ULL(MTK_MUX_BIT)
|
||||
@@ -907,6 +972,10 @@ enum mkt_eth_capabilities {
|
||||
BIT_ULL(MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT)
|
||||
#define MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII \
|
||||
BIT_ULL(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT)
|
||||
+#define MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII \
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII_BIT)
|
||||
+#define MTK_ETH_MUX_GMAC123_TO_USXGMII \
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC123_TO_USXGMII_BIT)
|
||||
|
||||
/* Supported path present on SoCs */
|
||||
#define MTK_ETH_PATH_GMAC1_RGMII BIT_ULL(MTK_ETH_PATH_GMAC1_RGMII_BIT)
|
||||
@@ -915,7 +984,11 @@ enum mkt_eth_capabilities {
|
||||
#define MTK_ETH_PATH_GMAC2_RGMII BIT_ULL(MTK_ETH_PATH_GMAC2_RGMII_BIT)
|
||||
#define MTK_ETH_PATH_GMAC2_SGMII BIT_ULL(MTK_ETH_PATH_GMAC2_SGMII_BIT)
|
||||
#define MTK_ETH_PATH_GMAC2_GEPHY BIT_ULL(MTK_ETH_PATH_GMAC2_GEPHY_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC3_SGMII BIT_ULL(MTK_ETH_PATH_GMAC3_SGMII_BIT)
|
||||
#define MTK_ETH_PATH_GDM1_ESW BIT_ULL(MTK_ETH_PATH_GDM1_ESW_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC1_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC1_USXGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC2_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC2_USXGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC3_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC3_USXGMII_BIT)
|
||||
|
||||
#define MTK_GMAC1_RGMII (MTK_ETH_PATH_GMAC1_RGMII | MTK_RGMII)
|
||||
#define MTK_GMAC1_TRGMII (MTK_ETH_PATH_GMAC1_TRGMII | MTK_TRGMII)
|
||||
@@ -923,7 +996,11 @@ enum mkt_eth_capabilities {
|
||||
#define MTK_GMAC2_RGMII (MTK_ETH_PATH_GMAC2_RGMII | MTK_RGMII)
|
||||
#define MTK_GMAC2_SGMII (MTK_ETH_PATH_GMAC2_SGMII | MTK_SGMII)
|
||||
#define MTK_GMAC2_GEPHY (MTK_ETH_PATH_GMAC2_GEPHY | MTK_GEPHY)
|
||||
+#define MTK_GMAC3_SGMII (MTK_ETH_PATH_GMAC3_SGMII | MTK_SGMII)
|
||||
#define MTK_GDM1_ESW (MTK_ETH_PATH_GDM1_ESW | MTK_ESW)
|
||||
+#define MTK_GMAC1_USXGMII (MTK_ETH_PATH_GMAC1_USXGMII | MTK_USXGMII)
|
||||
+#define MTK_GMAC2_USXGMII (MTK_ETH_PATH_GMAC2_USXGMII | MTK_USXGMII)
|
||||
+#define MTK_GMAC3_USXGMII (MTK_ETH_PATH_GMAC3_USXGMII | MTK_USXGMII)
|
||||
|
||||
/* MUXes present on SoCs */
|
||||
/* 0: GDM1 -> GMAC1, 1: GDM1 -> ESW */
|
||||
@@ -946,6 +1023,12 @@ enum mkt_eth_capabilities {
|
||||
#define MTK_MUX_GMAC12_TO_GEPHY_SGMII \
|
||||
(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII | MTK_MUX)
|
||||
|
||||
+#define MTK_MUX_GMAC123_TO_GEPHY_SGMII \
|
||||
+ (MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII | MTK_MUX)
|
||||
+
|
||||
+#define MTK_MUX_GMAC123_TO_USXGMII \
|
||||
+ (MTK_ETH_MUX_GMAC123_TO_USXGMII | MTK_MUX | MTK_INFRA)
|
||||
+
|
||||
#ifdef CONFIG_SOC_MT7621
|
||||
#define MTK_CAP_MASK MTK_NETSYS_V2
|
||||
#else
|
||||
@@ -984,9 +1067,17 @@ enum mkt_eth_capabilities {
|
||||
MTK_MUX_U3_GMAC2_TO_QPHY | MTK_U3_COPHY_V2 | \
|
||||
MTK_NETSYS_V2 | MTK_RSTCTRL_PPE1)
|
||||
|
||||
-#define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \
|
||||
- MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
|
||||
- MTK_NETSYS_V2 | MTK_RSTCTRL_PPE1)
|
||||
+#define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \
|
||||
+ MTK_MUX_GMAC12_TO_GEPHY_SGMII | \
|
||||
+ MTK_QDMA | MTK_NETSYS_V2 | \
|
||||
+ MTK_RSTCTRL_PPE1)
|
||||
+
|
||||
+#define MT7988_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \
|
||||
+ MTK_GMAC3_SGMII | MTK_QDMA | \
|
||||
+ MTK_MUX_GMAC123_TO_GEPHY_SGMII | \
|
||||
+ MTK_NETSYS_V3 | MTK_RSTCTRL_PPE1 | \
|
||||
+ MTK_GMAC1_USXGMII | MTK_GMAC2_USXGMII | \
|
||||
+ MTK_GMAC3_USXGMII | MTK_MUX_GMAC123_TO_USXGMII)
|
||||
|
||||
struct mtk_tx_dma_desc_info {
|
||||
dma_addr_t addr;
|
||||
@@ -1072,7 +1163,7 @@ struct mtk_soc_data {
|
||||
const struct mtk_reg_map *reg_map;
|
||||
u32 ana_rgc3;
|
||||
u64 caps;
|
||||
- u32 required_clks;
|
||||
+ u64 required_clks;
|
||||
bool required_pctl;
|
||||
u8 offload_version;
|
||||
u8 hash_offset;
|
File diff suppressed because it is too large
Load Diff
@ -253,6 +253,7 @@ CONFIG_NET_DSA_MT7530=y
|
||||
CONFIG_NET_DSA_TAG_MTK=y
|
||||
CONFIG_NET_FLOW_LIMIT=y
|
||||
CONFIG_NET_MEDIATEK_SOC=y
|
||||
CONFIG_NET_MEDIATEK_SOC_USXGMII=y
|
||||
CONFIG_NET_MEDIATEK_SOC_WED=y
|
||||
CONFIG_NET_SELFTESTS=y
|
||||
CONFIG_NET_SWITCHDEV=y
|
||||
|
@ -275,6 +275,7 @@ CONFIG_NET_DSA_MT7530=y
|
||||
CONFIG_NET_DSA_TAG_MTK=y
|
||||
CONFIG_NET_FLOW_LIMIT=y
|
||||
CONFIG_NET_MEDIATEK_SOC=y
|
||||
# CONFIG_NET_MEDIATEK_SOC_USXGMII is not set
|
||||
CONFIG_NET_MEDIATEK_SOC_WED=y
|
||||
CONFIG_NET_SELFTESTS=y
|
||||
CONFIG_NET_SWITCHDEV=y
|
||||
|
@ -20,7 +20,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -231,13 +231,35 @@ static int _mtk_mdio_write(struct mtk_et
|
||||
@@ -323,13 +323,35 @@ static int _mtk_mdio_write(struct mtk_et
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@ -63,7 +63,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
ret = mtk_mdio_busy_wait(eth);
|
||||
if (ret < 0)
|
||||
@@ -254,12 +276,33 @@ static int _mtk_mdio_read(struct mtk_eth
|
||||
@@ -346,12 +368,33 @@ static int _mtk_mdio_read(struct mtk_eth
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@ -103,7 +103,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
ret = mtk_mdio_busy_wait(eth);
|
||||
if (ret < 0)
|
||||
@@ -729,6 +772,7 @@ static int mtk_mdio_init(struct mtk_eth
|
||||
@@ -1018,6 +1061,7 @@ static int mtk_mdio_init(struct mtk_eth
|
||||
eth->mii_bus->name = "mdio";
|
||||
eth->mii_bus->read = mtk_mdio_read;
|
||||
eth->mii_bus->write = mtk_mdio_write;
|
||||
@ -113,7 +113,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -376,9 +376,12 @@
|
||||
@@ -382,9 +382,12 @@
|
||||
#define PHY_IAC_ADDR_MASK GENMASK(24, 20)
|
||||
#define PHY_IAC_ADDR(x) FIELD_PREP(PHY_IAC_ADDR_MASK, (x))
|
||||
#define PHY_IAC_CMD_MASK GENMASK(19, 18)
|
||||
|
@ -14,7 +14,7 @@ Signed-off-by: René van Dorst <opensource@vdorst.com>
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -4261,6 +4261,7 @@ static const struct net_device_ops mtk_n
|
||||
@@ -4638,6 +4638,7 @@ static const struct net_device_ops mtk_n
|
||||
|
||||
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
||||
{
|
||||
@ -22,7 +22,7 @@ Signed-off-by: René van Dorst <opensource@vdorst.com>
|
||||
const __be32 *_id = of_get_property(np, "reg", NULL);
|
||||
phy_interface_t phy_mode;
|
||||
struct phylink *phylink;
|
||||
@@ -4389,6 +4390,9 @@ static int mtk_add_mac(struct mtk_eth *e
|
||||
@@ -4796,6 +4797,9 @@ static int mtk_add_mac(struct mtk_eth *e
|
||||
register_netdevice_notifier(&mac->device_notifier);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user