public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
@ 2026-02-26 15:45 Joris Vaisvila
  2026-02-26 16:06 ` Daniel Golle
  2026-02-28  2:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Joris Vaisvila @ 2026-02-26 15:45 UTC (permalink / raw)
  To: netdev
  Cc: nbd, sean.wang, lorenzo, andrew+netdev, davem, edumazet, kuba,
	pabeni, Joris Vaisvila

The MT7628 has a fixed-link PHY and does not expose MAC control
registers. Writes to these registers only corrupt the ESW VLAN
configuration.

This patch explicitly registers no-op phylink_mac_ops for MT7628, as
after removing the invalid register accesses, the existing
phylink_mac_ops effectively become no-ops.

This code was introduced by commit 296c9120752b
("net: ethernet: mediatek: Add MT7628/88 SoC support")

Signed-off-by: Joris Vaisvila <joey@tinyisr.com>
---
v4:
 - Remove unnecessary Fixes tag
 - Clarify commit message
 - Fix v3 nitpicks
v3: https://lore.kernel.org/netdev/20260122191822.1476732-1-joey@tinyisr.com/
 - Register separate mac_ops for MT7628 instead of using early return
   based on SoC for all phylink mac operations
 - Update commit message
v2: https://lore.kernel.org/netdev/20260106052845.1945352-1-joey@tinyisr.com/
 - Add missing fixes tag
v1: https://lore.kernel.org/netdev/20251230091151.129176-1-joey@tinyisr.com/

 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 34 ++++++++++++++++++---
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 35fef28ee2f9..1c3c6d94dbe8 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -562,9 +562,7 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
 	int val, ge_mode, err = 0;
 	u32 i;
 
-	/* MT76x8 has no hardware settings between for the MAC */
-	if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
-	    mac->interface != state->interface) {
+	if (mac->interface != state->interface) {
 		/* Setup soc pin functions */
 		switch (state->interface) {
 		case PHY_INTERFACE_MODE_TRGMII:
@@ -956,6 +954,30 @@ static const struct phylink_mac_ops mtk_phylink_ops = {
 	.mac_enable_tx_lpi = mtk_mac_enable_tx_lpi,
 };
 
+static void rt5350_mac_config(struct phylink_config *config, unsigned int mode,
+				const struct phylink_link_state *state)
+{
+}
+
+static void rt5350_mac_link_down(struct phylink_config *config, unsigned int mode,
+				phy_interface_t interface)
+{
+}
+
+static void rt5350_mac_link_up(struct phylink_config *config,
+			    struct phy_device *phy,
+			    unsigned int mode, phy_interface_t interface,
+			    int speed, int duplex, bool tx_pause, bool rx_pause)
+{
+}
+
+/* MT76x8 (rt5350-eth) does 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,
+	.mac_link_up = rt5350_mac_link_up,
+};
+
 static void mtk_mdio_config(struct mtk_eth *eth)
 {
 	u32 val;
@@ -4772,6 +4794,7 @@ static const struct net_device_ops mtk_netdev_ops = {
 
 static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
 {
+	const struct phylink_mac_ops *mac_ops = &mtk_phylink_ops;
 	const __be32 *_id = of_get_property(np, "reg", NULL);
 	phy_interface_t phy_mode;
 	struct phylink *phylink;
@@ -4906,9 +4929,12 @@ 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;
+
 	phylink = phylink_create(&mac->phylink_config,
 				 of_fwnode_handle(mac->of_node),
-				 phy_mode, &mtk_phylink_ops);
+				 phy_mode, mac_ops);
 	if (IS_ERR(phylink)) {
 		err = PTR_ERR(phylink);
 		goto free_netdev;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
  2026-02-26 15:45 [PATCH v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628 Joris Vaisvila
@ 2026-02-26 16:06 ` Daniel Golle
  2026-02-27  8:03   ` Stefan Roese
  2026-02-28  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Golle @ 2026-02-26 16:06 UTC (permalink / raw)
  To: Joris Vaisvila
  Cc: netdev, nbd, sean.wang, lorenzo, andrew+netdev, davem, edumazet,
	kuba, pabeni, Stefan Roese

On Thu, Feb 26, 2026 at 03:45:18PM +0000, Joris Vaisvila wrote:
> The MT7628 has a fixed-link PHY and does not expose MAC control
> registers. Writes to these registers only corrupt the ESW VLAN
> configuration.
> 
> This patch explicitly registers no-op phylink_mac_ops for MT7628, as
> after removing the invalid register accesses, the existing
> phylink_mac_ops effectively become no-ops.
> 
> This code was introduced by commit 296c9120752b
> ("net: ethernet: mediatek: Add MT7628/88 SoC support")
> 
> Signed-off-by: Joris Vaisvila <joey@tinyisr.com>

Reviewed-by: Daniel Golle <daniel@makrotpia.org>

Cc: Stefan Roese <sr@denx.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
  2026-02-26 16:06 ` Daniel Golle
@ 2026-02-27  8:03   ` Stefan Roese
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2026-02-27  8:03 UTC (permalink / raw)
  To: Daniel Golle, Joris Vaisvila
  Cc: netdev, nbd, sean.wang, lorenzo, andrew+netdev, davem, edumazet,
	kuba, pabeni

On 2/26/26 17:06, Daniel Golle wrote:
> On Thu, Feb 26, 2026 at 03:45:18PM +0000, Joris Vaisvila wrote:
>> The MT7628 has a fixed-link PHY and does not expose MAC control
>> registers. Writes to these registers only corrupt the ESW VLAN
>> configuration.
>>
>> This patch explicitly registers no-op phylink_mac_ops for MT7628, as
>> after removing the invalid register accesses, the existing
>> phylink_mac_ops effectively become no-ops.
>>
>> This code was introduced by commit 296c9120752b
>> ("net: ethernet: mediatek: Add MT7628/88 SoC support")
>>
>> Signed-off-by: Joris Vaisvila <joey@tinyisr.com>
> 
> Reviewed-by: Daniel Golle <daniel@makrotpia.org>
> 
> Cc: Stefan Roese <sr@denx.de>

Reviewed-by: Stefan Roese <stefan.roese@mailbox.org>

Thanks,
Stefan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
  2026-02-26 15:45 [PATCH v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628 Joris Vaisvila
  2026-02-26 16:06 ` Daniel Golle
@ 2026-02-28  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-28  2:50 UTC (permalink / raw)
  To: Joris Vaisvila
  Cc: netdev, nbd, sean.wang, lorenzo, andrew+netdev, davem, edumazet,
	kuba, pabeni

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 26 Feb 2026 15:45:18 +0000 you wrote:
> The MT7628 has a fixed-link PHY and does not expose MAC control
> registers. Writes to these registers only corrupt the ESW VLAN
> configuration.
> 
> This patch explicitly registers no-op phylink_mac_ops for MT7628, as
> after removing the invalid register accesses, the existing
> phylink_mac_ops effectively become no-ops.
> 
> [...]

Here is the summary with links:
  - [v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
    https://git.kernel.org/netdev/net-next/c/9a04d3b2f070

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-28  2:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 15:45 [PATCH v4] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628 Joris Vaisvila
2026-02-26 16:06 ` Daniel Golle
2026-02-27  8:03   ` Stefan Roese
2026-02-28  2:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox