🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8094

[PATCH v3 5/7] net: dsa: mediatek: support MDIO switch downstream of MMIO switch

#8094
From: Caleb James DeLisle
Date: Wed, 28 Oct 2026 01:13
119 lines
12371 bytes
The MT7530 / MT7531 can connect via either MDIO or MMIO. In MMIO mode
the switch provides its own MDIO bus which connects to its integrated
PHYs, but also can be connected to other things, such as another
switch.

If the MDIO bus contains another switch, then the upstream switch
will register but it will not setup the DSA tree because the
downstream switch is missing. Without the complete DSA tree,
mt753x_setup() will not be called on the switch and therefore
mt7530_setup_mdio() is never called so the downstream switch never
registers.

Update mt7530_setup_mdio() so that it can be called multiple times,
export the symbol, and call it again after dsa_register_switch()
from mt7988_probe().

Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
---
 drivers/net/dsa/mt7530-mmio.c |  9 ++++++++-
 drivers/net/dsa/mt7530.c      | 13 +++++++++----
 drivers/net/dsa/mt7530.h      | 10 ++++++++++
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/mt7530-mmio.c b/drivers/net/dsa/mt7530-mmio.c
index cf3bdb23a2d5..f387190a9539 100644
--- a/drivers/net/dsa/mt7530-mmio.c
+++ b/drivers/net/dsa/mt7530-mmio.c
@@ -61,7 +61,14 @@ mt7988_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->regmap))
 		return PTR_ERR(priv->regmap);
 
-	return dsa_register_switch(priv->ds);
+	ret = dsa_register_switch(priv->ds);
+
+	if (ret)
+		return ret;
+
+	mt7530_setup_mdio(priv);
+
+	return 0;
 }
 
 static void mt7988_remove(struct platform_device *pdev)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index d09ff207e2df..dbe3887097db 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2447,7 +2447,7 @@ mt7530_free_mdio_irq(struct mt7530_priv *priv)
 	}
 }
 
-static int
+int
 mt7530_setup_mdio(struct mt7530_priv *priv)
 {
 	struct device_node *mnp, *np = priv->dev->of_node;
@@ -2457,6 +2457,10 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
 	static int idx;
 	int ret = 0;
 
+	/* Already done */
+	if (priv->child_bus)
+		return 0;
+
 	mnp = of_get_child_by_name(np, "mdio");
 
 	if (mnp && !of_device_is_available(mnp))
@@ -2481,9 +2485,6 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
 	bus->parent = dev;
 	bus->phy_mask = ~ds->phys_mii_mask;
 
-	if (priv->irq_domain && !mnp)
-		mt7530_setup_mdio_irq(priv);
-
 	priv->child_bus = bus;
 
 	ret = devm_of_mdiobus_register(dev, bus, mnp);
@@ -2498,6 +2499,7 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
 	of_node_put(mnp);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(mt7530_setup_mdio);
 
 static int
 mt7530_setup(struct dsa_switch *ds)
@@ -3328,6 +3330,9 @@ mt753x_setup(struct dsa_switch *ds)
 	if (ret)
 		return ret;
 
+	if (priv->irq_domain && ds->user_mii_bus)
+		mt7530_setup_mdio_irq(priv);
+
 	/* Initialise the PCS devices */
 	for (i = 0; i < priv->ds->num_ports; i++) {
 		priv->pcs[i].pcs.ops = priv->info->pcs_ops;
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index 5b7394f6383c..c86bc4bca29b 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -969,6 +969,16 @@ struct mt7530_hw_stats {
 int mt7530_probe_common(struct mt7530_priv *priv);
 void mt7530_remove_common(struct mt7530_priv *priv);
 
+/*
+ * When an MMIO based switch has an MDIO bus which contains a downstream MDIO
+ * switch, the MDIO bus is not normally setup until mt753x_setup() has been
+ * called. But mt753x_setup() is not called until DSA sees that every switch in
+ * the tree has been probed. Calling mt7530_setup_mdio() after at the end of
+ * the MMIO probe function allows the downstream switch to register, completing
+ * the tree.
+ */
+int mt7530_setup_mdio(struct mt7530_priv *priv);
+
 extern const struct mt753x_info mt753x_table[];
 
 #endif /* __MT7530_H */
-- 
2.39.5
Technical Details
Message-ID: <20261028011317.1557238-6-cjd@cjdns.fr>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352692-linux-kernel-netdev=dewy.ru
References: <20261028011317.1557238-1-cjd@cjdns.fr>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352692-linux-kernel-netdev=dewy.ru
From: cjd@cjdns.fr (Caleb James DeLisle)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v3 5/7] net: dsa: mediatek: support MDIO switch downstream of MMIO switch
Date: Wed, 28 Oct 2026 01:13:15 +0000
Organization: Usenet Network
Message-ID: <20261028011317.1557238-6-cjd@cjdns.fr>
References: <20261028011317.1557238-1-cjd@cjdns.fr>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1674135"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+2DXoSCeUljrKHvexd950QS8bq8= sha256:zSYDu8ri2Dugno4Z/3ikFStop3YY7oVHpcUIdkfwPJA=
	sha1:JTv8rGjhQ84l9SRlaBc+prhYE/Y= sha256:RGB1jOCjfr526ujCqhph6lv506HMUZR7PBNA1W6FTQk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4B7AA125C25; Wed, 28 Oct 2026 04:15:20 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.05
X-Spam-Status: No, score=-2.05 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=cjdns.fr
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id lCtjZk-UDCpO;
	Wed, 28 Oct 2026 04:15:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-352692-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cjdns.fr
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 0F903125C1D; Wed, 28 Oct 2026 04:15:09 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id E7BBB603C44; Wed, 28 Oct 2026 01:14:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793150052;
	b=zOnpptwNWasKV2dQPC3zcDtTd8hqnI12/iv4jr8p4sjmMcv3XQSF7IOSMhWH15VkHs5k
	 97+oD6q62nqJxxiptLEvk7f17Px0/BGUwULjqHU8k1Uk0zOo/QJXQdbNDxH+YiF5WJQJG
	 CDeAmRbtZbQnGiTmV6VNM5iXgqoH18eAnqRwKTNJUrhsjSXPbTARrii00N9Un9bn6m3zB
	 YvTjHOlOm1HCI+m0mqJfDxek8m+lv+FHLGskV3bJTXZWYCH8Qb/BWlkJPZVzhoLHXMuy8
	 040z5bMF08AFqXfxVuGT6E2EAbGJCjyyh4eMHQIcedasY5gJ8Qh1b4mTZGtwLn0ZpHw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793150052;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To:
	 Cc:Subject:Date:Message-Id:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding:
	 X-Last-TLS-Session-Version;
	bh=13PPu/xOMjs99HJpioU697MQTba1QClKPHfCX/nPdYE=;
	b=D4H+976ntjkSayo1TdZGdxwiaAdYDItFJ/sLJifisX0yjKvAF4DAANDFPni7wU98J37G
	 2dqaX+tr2IyNXugtpEjobo2N2mzdUlAKL3XV11N+ojuq2KIvXp1gHQs0jX3OpunZBw4KO
	 PDledqnVOKhJWua8LpJcvjNpUdlas1+zoLMouSrmQTQIPM4Hkt6GCu2L+gP1T2ezM/BeZ
	 qx1D4iwY1Z81M1sRc82viBOsSTj/B440oLiENmVSEPjgXx6eiYq6CVn7CPD1HTgdiBHz4
	 RpybMtIzf6msq444rth68MnwkyE8Vbb6yyz1kZ/pjEbW/y4G1wuR29cjjncoMIQSnGQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cjdns.fr header.i=@cjdns.fr header.a=rsa-sha256 header.s=dkim header.b=LrEMZs09;
	dmarc=pass header.from=cjdns.fr;
	spf=pass smtp.mailfrom=cjdns.fr;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D55FE606A31F;
	Wed, 28 Oct 2026 01:14:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=cjdns.fr header.i=@cjdns.fr header.a=rsa-sha256 header.s=dkim header.b=LrEMZs09
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=5.135.140.105
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793150041;
	b=f1Tt0PnP8CdM0YaAEcqW3rSQY9KFRC7oEFmlmmZku7XmA2p4ghEaAH1tuhcSBAwdjBPw
	 CcsYHWoiu5stV/DlusmoaejPJx0pcMsumGOSmOfd88Wm5nzzPj8fXw6uBd+HWjmC0/oDC
	 ueGwHAG6MMcaK7I0vGo9H214IAcSncB8RGYCKIU/ENPUE5WXhWm5cgbFFjJwS/LlV9Ggk
	 kle7H9fX9vuWyT+9Eh94dvXje2emsnKjXY5/OWTZE8XwU3uzCITJc9tGn+yDJac1Ttx0a
	 Jwcv5j+c2cSahpUfrveGyI88Ji+TRmZ66Hoju0Gx2FYuHDmETeUOn9+xPn6Cc9Rvw5Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793150041;
	h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date:
	 Message-Id:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Last-TLS-Session-Version;
	bh=13PPu/xOMjs99HJpioU697MQTba1QClKPHfCX/nPdYE=;
	b=RbQ3Ii0YqzNHl6DjpH8PdqzmJxoIs8P+xKfCyAnbeVwykLBr8wt3CapldtZFGmFhUcBg
	 FOxeCKzRgXk/v/HO3PVxZ96TKuXRUDJOauXg1A1Hb6KSUpM0L+XVtLH+odYOLOQ7aza7E
	 4hcSb3E2yWzhkaYM+xB0Iu9Nyn4mJU/xOJ6DBDvqYh5s1YSv2FSV3Ki/vfUPVrZjsww8H
	 6HfbnCdw0TmNgezfPHE0huVlDITH5AYX6o0KHIlMehlAQXZUm+MYz4AJPV/VAt30wSz43
	 2aA0U3Nz8FDpdikrGCGg+aVEHh1J/7oTp37AKuGG/2k964Ib9DlLL5VSBT0g98IDK0g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cjdns.fr;
	spf=pass smtp.mailfrom=cjdns.fr;
	dkim=pass header.d=cjdns.fr header.i=@cjdns.fr header.a=rsa-sha256 header.s=dkim header.b=LrEMZs09;
	arc=none smtp.remote-ip=5.135.140.105
X-Received: from mail.cjdns.fr (mail.cjdns.fr [5.135.140.105])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 895F8606A325;
	Wed, 28 Oct 2026 01:14:00 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 895F8606A325
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cjdns.fr
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cjdns.fr
X-Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1E35F149B04;
	Wed, 28 Oct 2026 02:13:54 +0100 (CET)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cjdns.fr; s=dkim;
	t=1793150038; h=from:subject:date:message-id:to:cc:mime-version:
	 content-transfer-encoding:in-reply-to:references;
	bh=13PPu/xOMjs99HJpioU697MQTba1QClKPHfCX/nPdYE=;
	b=LrEMZs09lSDb0VLWSeHBf5VC1ErDpt/dyir2AdTyOQPY9SVdlsjVIwwklTsGTZJboIz+Ri
	A5u7FLV8IZ+Fc6HqnJedefSDuAbiPbrN35kmoDVsR9bgCVfyN2f33MQHzflaUKkZ2JwVMc
	NKUtOXvcuhbZ146ZEKzGFlC5+HzJ53uLeRnrrRS6fBoyzlULDZbFmcBzfHZSCUJ6j/kmD/
	rEca5KyWxj0kOK5/2hYwLxTdLPwJz4IJkPwdH86Iitxk17FKUT91U6Kmvb20DK1aSZD2U7
	Xd9fET7p6MXWkPHqquJXApLPOKdDLnMH79Azdun57XcViRqM6dfTWkutiYSShQ==
X-Cc: andrew@lunn.ch,
	olteanv@gmail.com,
	davem@davemloft.net,
	edumazet@google.com,
	kuba@kernel.org,
	pabeni@redhat.com,
	robh@kernel.org,
	krzk+dt@kernel.org,
	conor+dt@kernel.org,
	matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com,
	chester.a.unal@arinc9.com,
	daniel@makrotopia.org,
	linux@armlinux.org.uk,
	arinc.unal@arinc9.com,
	Landen.Chao@mediatek.com,
	dqfext@gmail.com,
	sean.wang@mediatek.com,
	devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	naseefkm@gmail.com,
	b.larsson@gmx.com,
	Caleb James DeLisle <cjd@cjdns.fr>
X-In-Reply-To: <20261028011317.1557238-1-cjd@cjdns.fr>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Last-TLS-Session-Version: TLSv1.3