netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH net-next] net: dsa: mt7530: fix port specifications for MT7988
@ 2023-04-06 10:04 arinc9.unal
  2023-04-06 10:24 ` Arınç ÜNAL
  2023-04-06 11:07 ` Russell King (Oracle)
  0 siblings, 2 replies; 12+ messages in thread
From: arinc9.unal @ 2023-04-06 10:04 UTC (permalink / raw)
  To: Sean Wang, Landen Chao, DENG Qingfang, Daniel Golle, Andrew Lunn,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: Arınç ÜNAL, erkin.bozoglu, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

From: Arınç ÜNAL <arinc.unal@arinc9.com>

On the switch on the MT7988 SoC, there are only 4 PHYs. There's only port 6
as the CPU port, there's no port 5. Split the switch statement with a check
to enforce these for the switch on the MT7988 SoC. The internal phy-mode is
specific to MT7988 so put it for MT7988 only.

Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
---

Daniel, this is based on the information you provided me about the switch.
I will add this to my current patch series if it looks good to you.

Arınç

---
 drivers/net/dsa/mt7530.c | 67 ++++++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 24 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 6fbbdcb5987f..f167fa135ef1 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2548,7 +2548,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port,
 	phy_interface_zero(config->supported_interfaces);
 
 	switch (port) {
-	case 0 ... 4: /* Internal phy */
+	case 0 ... 3: /* Internal phy */
 		__set_bit(PHY_INTERFACE_MODE_INTERNAL,
 			  config->supported_interfaces);
 		break;
@@ -2710,37 +2710,56 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
 	struct mt7530_priv *priv = ds->priv;
 	u32 mcr_cur, mcr_new;
 
-	switch (port) {
-	case 0 ... 4: /* Internal phy */
-		if (state->interface != PHY_INTERFACE_MODE_GMII &&
-		    state->interface != PHY_INTERFACE_MODE_INTERNAL)
-			goto unsupported;
-		break;
-	case 5: /* Port 5, a CPU port. */
-		if (priv->p5_interface == state->interface)
+	if (priv->id == ID_MT7988) {
+		switch (port) {
+		case 0 ... 3: /* Internal phy */
+			if (state->interface != PHY_INTERFACE_MODE_INTERNAL)
+				goto unsupported;
 			break;
+		case 6: /* Port 6, a CPU port. */
+			if (priv->p6_interface == state->interface)
+				break;
 
-		if (mt753x_mac_config(ds, port, mode, state) < 0)
+			if (mt753x_mac_config(ds, port, mode, state) < 0)
+				goto unsupported;
+
+			priv->p6_interface = state->interface;
+			break;
+		default:
 			goto unsupported;
+		}
+	} else {
+		switch (port) {
+		case 0 ... 4: /* Internal phy */
+			if (state->interface != PHY_INTERFACE_MODE_GMII)
+				goto unsupported;
+			break;
+		case 5: /* Port 5, a CPU port. */
+			if (priv->p5_interface == state->interface)
+				break;
 
-		if (priv->p5_intf_sel == P5_INTF_SEL_GMAC5 ||
-		    priv->p5_intf_sel == P5_INTF_SEL_GMAC5_SGMII)
-			priv->p5_interface = state->interface;
-		break;
-	case 6: /* Port 6, a CPU port. */
-		if (priv->p6_interface == state->interface)
+			if (mt753x_mac_config(ds, port, mode, state) < 0)
+				goto unsupported;
+
+			if (priv->p5_intf_sel == P5_INTF_SEL_GMAC5 ||
+			priv->p5_intf_sel == P5_INTF_SEL_GMAC5_SGMII)
+				priv->p5_interface = state->interface;
 			break;
+		case 6: /* Port 6, a CPU port. */
+			if (priv->p6_interface == state->interface)
+				break;
 
-		if (mt753x_mac_config(ds, port, mode, state) < 0)
-			goto unsupported;
+			if (mt753x_mac_config(ds, port, mode, state) < 0)
+				goto unsupported;
 
-		priv->p6_interface = state->interface;
-		break;
-	default:
+			priv->p6_interface = state->interface;
+			break;
+		default:
 unsupported:
-		dev_err(ds->dev, "%s: unsupported %s port: %i\n",
-			__func__, phy_modes(state->interface), port);
-		return;
+			dev_err(ds->dev, "%s: unsupported %s port: %i\n",
+				__func__, phy_modes(state->interface), port);
+			return;
+		}
 	}
 
 	mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
-- 
2.37.2


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

end of thread, other threads:[~2023-04-07 11:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 10:04 [RFC PATCH net-next] net: dsa: mt7530: fix port specifications for MT7988 arinc9.unal
2023-04-06 10:24 ` Arınç ÜNAL
2023-04-06 11:07 ` Russell King (Oracle)
2023-04-06 13:13   ` Daniel Golle
2023-04-06 21:43   ` Arınç ÜNAL
2023-04-06 21:57     ` Daniel Golle
2023-04-07  8:56       ` Arınç ÜNAL
2023-04-07  9:28         ` Daniel Golle
2023-04-07 10:46           ` Arınç ÜNAL
2023-04-07 10:50             ` Arınç ÜNAL
2023-04-07 11:04               ` Daniel Golle
2023-04-07 11:03             ` Daniel Golle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).