realtek: dsa: allow to drop phy-handle on switch ports

When Realtek SerDes is completely handled by PCS, it is not treated as
a regular PHY anymore. Thus, we should be able to drop the currently
used pseudo-PHYs and phy-handles for ports which just use the SerDes as
PCS but have no PHY attached.

Allow to drop the phy-handle from switch port definitions if there is a
pcs-handle defined by relaxing several checks in the DSA driver.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/20577
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Jonas Jelonek 2025-10-11 21:36:25 +00:00 committed by Robert Marko
parent c447ba0a83
commit ed240e3cc2
4 changed files with 16 additions and 10 deletions

View file

@ -336,9 +336,8 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
pcs_node = of_parse_phandle(dn, "pcs-handle", 0);
phy_node = of_parse_phandle(dn, "phy-handle", 0);
if (!phy_node) {
if (pn != priv->cpu_port)
dev_err(priv->dev, "Port node %d misses phy-handle\n", pn);
if (pn != priv->cpu_port && !phy_node && !pcs_node) {
dev_err(priv->dev, "Port node %d has neither pcs-handle nor phy-handle\n", pn);
continue;
}
@ -385,6 +384,13 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
}
}
if (!phy_node) {
if (priv->pcs[pn])
priv->ports[pn].phy_is_integrated = true;
continue;
}
/* Check for the integrated SerDes of the RTL8380M first */
if (of_property_read_bool(phy_node, "phy-is-integrated")
&& priv->id == 0x8380 && pn >= 24) {

View file

@ -51,7 +51,7 @@ static void rtl83xx_enable_phy_polling(struct rtl838x_switch_priv *priv)
msleep(1000);
/* Enable all ports with a PHY, including the SFP-ports */
for (int i = 0; i < priv->cpu_port; i++) {
if (priv->ports[i].phy)
if (priv->ports[i].phy || priv->pcs[i])
v |= BIT_ULL(i);
}
@ -436,7 +436,7 @@ static int rtl83xx_setup(struct dsa_switch *ds)
* they will work in isolated mode (only traffic between port and CPU).
*/
for (int i = 0; i < priv->cpu_port; i++) {
if (priv->ports[i].phy) {
if (priv->ports[i].phy || priv->pcs[i]) {
priv->ports[i].pm = BIT_ULL(priv->cpu_port);
priv->r->traffic_set(i, BIT_ULL(i));
}
@ -512,7 +512,7 @@ static int rtl93xx_setup(struct dsa_switch *ds)
* they will work in isolated mode (only traffic between port and CPU).
*/
for (int i = 0; i < priv->cpu_port; i++) {
if (priv->ports[i].phy) {
if (priv->ports[i].phy || priv->pcs[i]) {
priv->ports[i].pm = BIT_ULL(priv->cpu_port);
priv->r->traffic_set(i, BIT_ULL(i));
}
@ -1045,7 +1045,7 @@ static void rtldsa_poll_counters(struct work_struct *work)
struct rtldsa_counter_state *counters;
for (int i = 0; i < priv->cpu_port; i++) {
if (!priv->ports[i].phy)
if (!priv->ports[i].phy && !priv->pcs[i])
continue;
counters = &priv->ports[i].counters;
@ -1064,7 +1064,7 @@ static void rtldsa_init_counters(struct rtl838x_switch_priv *priv)
struct rtldsa_counter_state *counters;
for (int i = 0; i < priv->cpu_port; i++) {
if (!priv->ports[i].phy)
if (!priv->ports[i].phy && !priv->pcs[i])
continue;
counters = &priv->ports[i].counters;

View file

@ -2419,7 +2419,7 @@ static void rtl930x_led_init(struct rtl838x_switch_priv *priv)
sw_w32_mask(0x3 << pos, 0, RTL930X_LED_PORT_FIB_SET_SEL_CTRL(i));
sw_w32_mask(0x3 << pos, 0, RTL930X_LED_PORT_COPR_SET_SEL_CTRL(i));
if (!priv->ports[i].phy && !(forced_leds_per_port[i]))
if (!priv->ports[i].phy && !priv->pcs[i] && !(forced_leds_per_port[i]))
continue;
if (forced_leds_per_port[i] > 0)

View file

@ -1547,7 +1547,7 @@ static void rtldsa_931x_led_init(struct rtl838x_switch_priv *priv)
sw_w32_mask(0x3 << pos, 0, RTL931X_LED_PORT_COPR_SET_SEL_CTRL(i));
/* Skip port if not present (auto-detect) or not in forced mask */
if (!priv->ports[i].phy && !(forced_leds_per_port[i]))
if (!priv->ports[i].phy && !priv->pcs[i] && !(forced_leds_per_port[i]))
continue;
if (forced_leds_per_port[i] > 0)