dt-bindings: net: mediatek: Add support for MediaTek MT7628/88 SoC
Subsystems (5)
PATCH v2 1/4 dt-bindings: net: mediatek: Add support for MediaTek MT7628/88 SoC
Add compatible for the ethernet IP core on MT7628/88 SoCs. Its compatible with the older Ralink Rt5350F SoC. And OpenWrt already uses this compatible string for the MT76x8.
---
v2:
- New patch - bindings description moved to separate patch
Documentation/devicetree/bindings/net/mediatek-net.txt | 1 +
1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/mediatek-net.txt +1 -0
@@ -12,6 +12,7 @@ Required properties: "mediatek,mt7623-eth", "mediatek,mt2701-eth": for MT7623 SoC "mediatek,mt7622-eth": for MT7622 SoC "mediatek,mt7629-eth": for MT7629 SoC + "ralink,rt5350-eth": for Ralink Rt5350F and MT7628/88 SoC - reg: Address and length of the register set for the device - interrupts: Should contain the three frame engines interrupts in numeric order. These are fe_int0, fe_int1 and fe_int2.
Signature · 1 line
2.22.1
PATCH v2 2/4 net: ethernet: mediatek: Rename MTK_QMTK_INT_STATUS to MTK_QDMA_INT_STATUS
Currently all QDMA registers are named "MTK_QDMA_foo" in this driver with one exception: MTK_QMTK_INT_STATUS. This patch renames MTK_QMTK_INT_STATUS to MTK_QDMA_INT_STATUS so that all macros follow this rule.
---
v2:
- New patch
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 ++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +4 -4
@@ -1122,11 +1122,11 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)int tx_done =0 ;mtk_handle_status_irq (eth); -mtk_w32 (eth,MTK_TX_DONE_INT ,MTK_QMTK_INT_STATUS ); +mtk_w32 (eth,MTK_TX_DONE_INT ,MTK_QDMA_INT_STATUS ); tx_done =mtk_poll_tx (eth, budget);if (unlikely (netif_msg_intr (eth))) { - status =mtk_r32 (eth,MTK_QMTK_INT_STATUS ); + status =mtk_r32 (eth,MTK_QDMA_INT_STATUS ); mask =mtk_r32 (eth,MTK_QDMA_INT_MASK ); dev_info(eth->dev, "done tx %d, intr 0x%08x/0x%x\n",
@@ -1136,7 +1136,7 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)if (tx_done == budget)return budget; - status =mtk_r32 (eth,MTK_QMTK_INT_STATUS ); + status =mtk_r32 (eth,MTK_QDMA_INT_STATUS );if (status &MTK_TX_DONE_INT )return budget;
@@ -1747,7 +1747,7 @@ static irqreturn_t mtk_handle_irq(int irq, void *_eth)mtk_handle_irq_rx (irq, _eth); }if (mtk_r32 (eth,MTK_QDMA_INT_MASK ) &MTK_TX_DONE_INT ) { -if (mtk_r32 (eth,MTK_QMTK_INT_STATUS ) &MTK_TX_DONE_INT ) +if (mtk_r32 (eth,MTK_QDMA_INT_STATUS ) &MTK_TX_DONE_INT )mtk_handle_irq_tx (irq, _eth); }
drivers/net/ethernet/mediatek/mtk_eth_soc.h +1 -1
@@ -212,7 +212,7 @@#define FC_THRES_MIN 0x4444/* QDMA Interrupt Status Register */ -#define MTK_QMTK_INT_STATUS 0x1A18 +#define MTK_QDMA_INT_STATUS 0x1A18#define MTK_RX_DONE_DLY BIT(30)#define MTK_RX_DONE_INT3 BIT(19)#define MTK_RX_DONE_INT2 BIT(18)
Signature · 1 line
2.22.1
PATCH v2 3/4 net: ethernet: mediatek: Rename NEXT_RX_DESP_IDX to NEXT_DESP_IDX
In reply to Stefan RoeseRename the NEXT_RX_DESP_IDX macro to NEXT_DESP_IDX, so that it better can be used for TX ops as well. This will be used in the upcoming MT7628/88 support (same functionality for RX and TX in this macro).
---
v2:
- New patch
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++-- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +2 -2
@@ -903,7 +903,7 @@ static struct mtk_rx_ring *mtk_get_rx_ring(struct mtk_eth *eth)for (i =0 ; i <MTK_MAX_RX_RING_NUM ; i++) { ring = ð->rx_ring[i]; - idx =NEXT_RX_DESP_IDX (ring->calc_idx, ring->dma_size); + idx =NEXT_DESP_IDX (ring->calc_idx, ring->dma_size);if (ring->dma[idx].rxd2 &RX_DMA_DONE ) { ring->calc_idx_update = true;return ring;
@@ -952,7 +952,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,if (unlikely (!ring)) goto rx_done; - idx =NEXT_RX_DESP_IDX (ring->calc_idx, ring->dma_size); + idx =NEXT_DESP_IDX (ring->calc_idx, ring->dma_size); rxd = &ring->dma[idx]; data = ring->data[idx];
drivers/net/ethernet/mediatek/mtk_eth_soc.h +1 -1
@@ -39,7 +39,7 @@ NETIF_F_SG | NETIF_F_TSO | \ NETIF_F_TSO6 | \ NETIF_F_IPV6_CSUM) -#define NEXT_RX_DESP_IDX (X ,Y ) (((X) + 1) & ((Y) - 1)) +#define NEXT_DESP_IDX (X ,Y ) (((X) + 1) & ((Y) - 1))#define MTK_MAX_RX_RING_NUM 4#define MTK_HW_LRO_DMA_SIZE 8
Signature · 1 line
2.22.1
PATCH v2 4/4 net: ethernet: mediatek: Add MT7628/88 SoC support
In reply to Stefan RoeseThis patch adds support for the MediaTek MT7628/88 SoCs to the common MediaTek ethernet driver. Some minor changes are needed for this and a bigger change, as the MT7628 does not support QDMA (only PDMA).
---
v2:
- Rebased on net-next (David)
- Used "ralink,rt5350-eth" compatible (Daniel)
- Fixed capability bit usage (Rene)
- Extracted DT bindings description to separate patch
- Introduced MTK_QDMA capability, which is used on all currently supported SoCs. Only the newly introcuded MT7628 uses PDMA and does not have this capability bit set
- Added tx_int_mask_reg/tx_int_status_reg variables to better abstract the QDMA vs PDMA usage
drivers/net/ethernet/mediatek/Kconfig | 2 +- drivers/net/ethernet/mediatek/mtk_eth_path.c | 4 + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 480 ++++++++++++++----- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 51 +- 4 files changed, 425 insertions(+), 112 deletions(-)
drivers/net/ethernet/mediatek/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config NET_VENDOR_MEDIATEK bool "MediaTek ethernet driver" - depends on ARCH_MEDIATEK || SOC_MT7621 + depends on ARCH_MEDIATEK || SOC_MT7621 || SOC_MT7620 ---help--- If you have a Mediatek SoC with ethernet, say Y.
drivers/net/ethernet/mediatek/mtk_eth_path.c +4 -0
@@ -315,6 +315,10 @@ int mtk_setup_hw_path(struct mtk_eth *eth, int mac_id, int phymode) {int err; +/* No mux'ing for MT7628/88 */ +if (MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 )) +return 0 ; +switch (phymode) {case PHY_INTERFACE_MODE_TRGMII :case PHY_INTERFACE_MODE_RGMII_TXID :
drivers/net/ethernet/mediatek/mtk_eth_soc.c +373 -107
804 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_eth_soc.h +47 -4
144 lines not on this page · raw message
Signature · 1 line
2.22.1
David Miller
maintainerRe: [PATCH net-next 4/4 v2] net: ethernet: mediatek: Add MT7628/88 SoC support
From: Stefan Roese <[email protected]>
Date: Wed, 14 Aug 2019 13:18:25 +0200
drivers/net/ethernet/mediatek/mtk_eth_soc.c static inline struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, · line 650
Quoted 4 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +4
-0+static int txd_to_idx (struct mtk_tx_ring *ring,struct mtk_tx_dma *dma) +{ +return ((u32 )dma - (u32 )ring->dma) /sizeof (*dma); +}
This will definitely warn on 64-bit, and you should avoid that even if this driver can not possibly be built on 64-bit platforms.
You cannot truncate a pointer to an integer which is potentially smaller in representation size than a pointer could potentially be.
Just can avoid all of these issues by using real pointer arithmetic and casting to (char *), or even better, (void *).