mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v1 2/2] net: sja1105: add function to configure CPU port
Date: Wed, 29 May 2024 11:41:24 +0200	[thread overview]
Message-ID: <20240529094124.513880-2-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20240529094124.513880-1-o.rempel@pengutronix.de>

Introduce sja1105_cpu_port_enable() to configure the CPU port.
Typically, dedicated Ethernet devices attach to a PHY with an adjust
link function for the networking framework to handle link adjustments.
However, for the CPU port, we face a unique scenario where the device
tree defines two Ethernet devices each with a fixed link: CPU == fixed
link and fixed link == Switch.

This function reflects the model where fixed link driver extracts all
needed information from the device tree, but we do not create an
Ethernet device for the fixed link == Switch bundle, only for the
CPU == fixed link part. Thus, instead of adding adjust link support for
non-dedicated Ethernet devices or making them official Ethernet devices,
we opt to use a port_enable call in the DSA framework.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/sja1105.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/sja1105.c b/drivers/net/sja1105.c
index c759c40b36..4ef30b8c81 100644
--- a/drivers/net/sja1105.c
+++ b/drivers/net/sja1105.c
@@ -2840,8 +2840,35 @@ static int sja1105_rcv(struct dsa_switch *ds, int *port, void *packet,
 	return 0;
 }
 
+static int sja1105_cpu_port_enable(struct dsa_port *dp, int port,
+				   struct phy_device *phy)
+{
+	struct device *dev = dp->ds->dev;
+	struct sja1105_private *priv = dev_get_priv(dev);
+	phy_interface_t phy_mode = phy->interface;
+	struct dsa_switch *ds = &priv->ds;
+	int cpu = ds->cpu_port;
+	int ret;
+
+	if (port != cpu)
+		return 0;
+
+	sja1105_set_speed(dp, port, phy->speed);
+
+	ret = sja1105_port_set_mode(dp, port, phy_mode);
+	if (ret)
+		return ret;
+
+	ret = sja1105_set_rgmii_delay(priv, port, phy_mode);
+	if (ret)
+		return ret;
+
+	return sja1105_static_config_reload(priv);
+}
+
 static const struct dsa_switch_ops sja1105_dsa_ops = {
 	.port_pre_enable	= sja1105_port_pre_enable,
+	.port_enable		= sja1105_cpu_port_enable,
 	.adjust_link		= sja1105_adjust_link,
 	.xmit			= sja1105_xmit,
 	.rcv			= sja1105_rcv,
-- 
2.39.2




  reply	other threads:[~2024-05-29  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29  9:41 [PATCH v1 1/2] net: sja1105: split adjust_link into reusable functions Oleksij Rempel
2024-05-29  9:41 ` Oleksij Rempel [this message]
2024-05-30 13:25 ` Sascha Hauer

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=20240529094124.513880-2-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.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