RT3050, RT3052, RT3350 and RT3352 have the RT3883 frame engine with a single GMAC, which is wired to port 6 of the embedded switch. It has no MDIO_CFG to force the link with, so use the MAC operations of MT7628. Add support for the RT305x SoCs. Build tested only, as no RT305x hardware was available. Signed-off-by: Ho Jie Feng --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 45 +++++++++++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 +++- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index d442c33ee8..e71607feed 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -997,7 +997,7 @@ static void rt5350_mac_link_up(struct phylink_config *config, { } -/* MT76x8 (rt5350-eth) does not expose any MAC control registers */ +/* RT305x and MT76x8 (rt5350-eth) do not expose any MAC control registers */ static const struct phylink_mac_ops rt5350_phylink_ops = { .mac_config = rt5350_mac_config, .mac_link_down = rt5350_mac_link_down, @@ -1050,7 +1050,7 @@ static void rt2880_mac_link_up(struct phylink_config *config, RT_MDIO_RX_SKEW | RT_MDIO_TX_SKEW, val, RT_MDIO_CFG(mac->id)); } -/* RT2880 family GMACs force the link through MDIO_CFG */ +/* RT2880 family RGMII GMACs force the link through MDIO_CFG */ static const struct phylink_mac_ops rt2880_phylink_ops = { .mac_config = rt5350_mac_config, .mac_link_down = rt2880_mac_link_down, @@ -3673,7 +3673,7 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config) val &= ~0xffff; /* take frames up to 2 KB, the RX buffer size */ - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) { + if (eth->soc->rt_jumbo) { val &= ~RT_GDMA_JMB_LEN; val |= RT_GDMA_JMB_EN | FIELD_PREP(RT_GDMA_JMB_LEN, 2); } @@ -4293,7 +4293,8 @@ static void rt2880_hw_init(struct mtk_eth *eth) FIELD_PREP(RT_US_CYC_CNT, clk_get_rate(clk) / HZ_PER_MHZ), RT_FE_GLO_CFG); - mtk_w32(eth, eth->soc->pse_fq_cfg, RT_PSE_FQ_CFG); + if (eth->soc->pse_fq_cfg) + mtk_w32(eth, eth->soc->pse_fq_cfg, RT_PSE_FQ_CFG); if (eth->soc->hw_features & NETIF_F_IP_CSUM) mtk_m32(eth, 0, RT_CSG_ICS_GEN_EN | RT_CSG_UCS_GEN_EN | @@ -5140,10 +5141,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->phylink_config.supported_interfaces); } - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) - mac_ops = &rt5350_phylink_ops; - else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880 | MTK_RGMII)) mac_ops = &rt2880_phylink_ops; + else if (mtk_is_ralink(eth)) + mac_ops = &rt5350_phylink_ops; if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) && id == MTK_GMAC2_ID) @@ -5191,6 +5192,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH - MTK_RX_ETH_HLEN; + else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880) && + !eth->soc->rt_jumbo) + eth->netdev[id]->max_mtu = ETH_DATA_LEN; else eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; @@ -5851,6 +5855,7 @@ static const struct mtk_soc_data rt2880_data = { .required_clks = RT3883_CLKS_BITMAP, .required_pctl = false, .pse_fq_cfg = RT2880_PSE_FQ_128Q, + .rt_jumbo = true, .version = 1, .tx = { .desc_size = sizeof(struct mtk_tx_dma), @@ -5869,6 +5874,30 @@ static const struct mtk_soc_data rt2880_data = { }, }; +static const struct mtk_soc_data rt3050_data = { + .reg_map = &rt2880_reg_map, + .caps = RT305X_CAPS, + .hw_features = MTK_HW_FEATURES_RT3883, + .required_clks = RT3883_CLKS_BITMAP, + .required_pctl = false, + .version = 1, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma), + .irq_done_mask = RT_INT_TX_DLY, + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = RT_INT_RX_DLY, + .dma_l4_valid = RX_DMA_L4_VALID_PDMA, + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + }, +}; + static const struct mtk_soc_data rt3883_data = { .reg_map = &rt2880_reg_map, .caps = RT3883_CAPS, @@ -5876,6 +5905,7 @@ static const struct mtk_soc_data rt3883_data = { .required_clks = RT3883_CLKS_BITMAP, .required_pctl = false, .pse_fq_cfg = RT3883_PSE_FQ_256Q, + .rt_jumbo = true, .version = 1, .tx = { .desc_size = sizeof(struct mtk_tx_dma), @@ -5928,6 +5958,7 @@ const struct of_device_id of_mtk_match[] = { { .compatible = "mediatek,mt7986-eth", .data = &mt7986_data }, { .compatible = "mediatek,mt7988-eth", .data = &mt7988_data }, { .compatible = "ralink,rt2880-eth", .data = &rt2880_data }, + { .compatible = "ralink,rt3050-eth", .data = &rt3050_data }, { .compatible = "ralink,rt3883-eth", .data = &rt3883_data }, { .compatible = "ralink,rt5350-eth", .data = &rt5350_data }, {}, diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index fbcdcbd849..716dac1536 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1180,6 +1180,8 @@ enum mkt_eth_capabilities { #define RT3883_CAPS (MTK_RGMII | MTK_SHARED_INT | MTK_SOC_RT2880) +#define RT305X_CAPS (MTK_SHARED_INT | MTK_SOC_RT2880) + struct mtk_tx_dma_desc_info { dma_addr_t addr; u32 size; @@ -1257,7 +1259,10 @@ struct mtk_reg_map { * @foe_entry_size Foe table entry size. * @has_accounting Bool indicating support for accounting of * offloaded flows. - * @pse_fq_cfg PSE free queue config of the RT2880 family. + * @pse_fq_cfg PSE free queue config of the RT2880 family, + * 0 keeps the reset value. + * @rt_jumbo Bool indicating that the RT2880 family GDMA + * has a jumbo frame limit. * @desc_size Tx/Rx DMA descriptor size. * @irq_done_mask Tx/Rx irq done register mask. * @dma_l4_valid Rx DMA valid register mask. @@ -1279,6 +1284,7 @@ struct mtk_soc_data { bool has_accounting; bool disable_pll_modes; u32 pse_fq_cfg; + bool rt_jumbo; struct { u32 desc_size; u32 irq_done_mask; -- 2.53.0