1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Fri, 20 May 2022 20:11:39 +0200
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: introduce support for mt7986
6 Add support for mt7986-eth driver available on mt7986 soc.
8 Tested-by: Sam Shih <sam.shih@mediatek.com>
9 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
13 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
14 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 @@ -87,6 +87,43 @@ static const struct mtk_reg_map mt7628_r
19 +static const struct mtk_reg_map mt7986_reg_map = {
20 + .tx_irq_mask = 0x461c,
21 + .tx_irq_status = 0x4618,
24 + .rx_cnt_cfg = 0x6104,
28 + .delay_irq = 0x620c,
29 + .irq_status = 0x6220,
36 + .rx_cnt_cfg = 0x4504,
40 + .delay_irq = 0x460c,
56 /* strings used by ethtool */
57 static const struct mtk_ethtool_stats {
58 char str[ETH_GSTRING_LEN];
59 @@ -110,7 +147,7 @@ static const char * const mtk_clks_sourc
60 "ethif", "sgmiitop", "esw", "gp0", "gp1", "gp2", "fe", "trgpll",
61 "sgmii_tx250m", "sgmii_rx250m", "sgmii_cdr_ref", "sgmii_cdr_fb",
62 "sgmii2_tx250m", "sgmii2_rx250m", "sgmii2_cdr_ref", "sgmii2_cdr_fb",
63 - "sgmii_ck", "eth2pll",
64 + "sgmii_ck", "eth2pll", "wocpu0", "wocpu1", "netsys0", "netsys1"
67 void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg)
68 @@ -3708,6 +3745,21 @@ static const struct mtk_soc_data mt7629_
72 +static const struct mtk_soc_data mt7986_data = {
73 + .reg_map = &mt7986_reg_map,
75 + .caps = MT7986_CAPS,
76 + .required_clks = MT7986_CLKS_BITMAP,
77 + .required_pctl = false,
79 + .txd_size = sizeof(struct mtk_tx_dma_v2),
80 + .rxd_size = sizeof(struct mtk_rx_dma_v2),
81 + .rx_irq_done_mask = MTK_RX_DONE_INT_V2,
82 + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
83 + .dma_len_offset = 8,
87 static const struct mtk_soc_data rt5350_data = {
88 .reg_map = &mt7628_reg_map,
90 @@ -3730,6 +3782,7 @@ const struct of_device_id of_mtk_match[]
91 { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data},
92 { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data},
93 { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data},
94 + { .compatible = "mediatek,mt7986-eth", .data = &mt7986_data},
95 { .compatible = "ralink,rt5350-eth", .data = &rt5350_data},
98 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
99 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
100 @@ -624,6 +624,10 @@ enum mtk_clks_map {
101 MTK_CLK_SGMII2_CDR_FB,
111 @@ -654,6 +658,16 @@ enum mtk_clks_map {
112 BIT(MTK_CLK_SGMII2_CDR_FB) | \
113 BIT(MTK_CLK_SGMII_CK) | \
114 BIT(MTK_CLK_ETH2PLL) | BIT(MTK_CLK_SGMIITOP))
115 +#define MT7986_CLKS_BITMAP (BIT(MTK_CLK_FE) | BIT(MTK_CLK_GP2) | BIT(MTK_CLK_GP1) | \
116 + BIT(MTK_CLK_WOCPU1) | BIT(MTK_CLK_WOCPU0) | \
117 + BIT(MTK_CLK_SGMII_TX_250M) | \
118 + BIT(MTK_CLK_SGMII_RX_250M) | \
119 + BIT(MTK_CLK_SGMII_CDR_REF) | \
120 + BIT(MTK_CLK_SGMII_CDR_FB) | \
121 + BIT(MTK_CLK_SGMII2_TX_250M) | \
122 + BIT(MTK_CLK_SGMII2_RX_250M) | \
123 + BIT(MTK_CLK_SGMII2_CDR_REF) | \
124 + BIT(MTK_CLK_SGMII2_CDR_FB))
128 @@ -852,6 +866,10 @@ enum mkt_eth_capabilities {
129 MTK_MUX_U3_GMAC2_TO_QPHY | \
130 MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA)
132 +#define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \
133 + MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
134 + MTK_NETSYS_V2 | MTK_RSTCTRL_PPE1)
136 struct mtk_tx_dma_desc_info {