Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ho Jie Feng <hjf3108@gmail.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Russell King <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	Gleb Pesin <dormancygrace@gmail.com>,
	Ho Jie Feng <hjf3108@gmail.com>
Subject: [PATCH net-next 13/13] net: ethernet: mtk_eth_soc: add RT305x support
Date: Sun,  6 Dec 2026 01:21:52 +0800	[thread overview]
Message-ID: <20261205172152.3142989-14-hjf3108@gmail.com> (raw)
In-Reply-To: <20261205172152.3142989-1-hjf3108@gmail.com>

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 <hjf3108@gmail.com>
---
 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



  parent reply	other threads:[~2026-12-05 17:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 01/13] net: ethernet: mtk_eth_soc: reset PDMA TX completion index on ring setup Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 02/13] net: ethernet: mtk_eth_soc: move PDMA TX ring registers to the register map Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 03/13] net: ethernet: mtk_eth_soc: add a per-SoC TX done interrupt mask Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 04/13] net: ethernet: mtk_eth_soc: complete PDMA TX on the right MAC Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 05/13] dt-bindings: net: mediatek,net: fix the ralink,rt5350-eth constraints Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 06/13] dt-bindings: net: mediatek,net: add ralink,rt3883-eth Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 07/13] net: ethernet: mtk_eth_soc: use BIT_ULL() for the required clocks Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 08/13] net: ethernet: mtk_eth_soc: add RT3883 support Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 09/13] net: ethernet: mtk_eth_soc: allow building for RT5350 Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 10/13] dt-bindings: net: mediatek,net: add ralink,rt2880-eth Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 11/13] net: ethernet: mtk_eth_soc: add RT2880 support Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 12/13] dt-bindings: net: mediatek,net: add ralink,rt3050-eth Ho Jie Feng
2026-12-05 17:21 ` Ho Jie Feng [this message]
2026-12-05 17:28 ` [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs netdev-bot+sinfo
2026-12-05 17:49   ` Jie Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261205172152.3142989-14-hjf3108@gmail.com \
    --to=hjf3108@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dormancygrace@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox