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@xxxxxxxxxxxxxx> --- 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