From f1f0572d1fda32426cad6f520622568b1de56b2a Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Mon, 30 Mar 2026 18:13:02 +0200 Subject: [PATCH] realtek: dsa: remove redundant integrated phy attribute The dsa driver currently has different attributes to denote what hardware is around a port: - phy_is_integrated: true if phy is not driven by a serdes - phy: the type of the attached phy (e.g. 0=NONE, 2=RTL8218B, ....) - pcs: link to a serdes pcs instance This is somehow redundant and especially the phy type should be only part of the phy driver and is not needed by the dsa driver at all. Remove the redundancy by simply keeping a boolean attribute "phy" that flags a phy driven port and can be used similar to the pcs (pointer) attribute. With that the driver can check phy/pcs as follows: - if (ports[i].pcs) -> port has a dedicated serdes - if (ports[i].phy) -> port has a dedicated phy That implemented, the "phy-is-integrated" attribute of a phy can be removed from the dts. This will be a separate commit. As a side effect the following (annoying) boot message for kernel 6.18 gets fixed. OF: /switchcore@1b000000/mdio-controller/mdio-bus@0/ethernet-phy@24: Read of boolean property 'sfp' with a value. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/22698 Signed-off-by: Robert Marko --- .../drivers/net/dsa/rtl83xx/common.c | 25 +------------------ .../files-6.18/drivers/net/dsa/rtl83xx/dsa.c | 2 +- .../drivers/net/dsa/rtl83xx/rtl838x.h | 12 +-------- .../drivers/net/dsa/rtl83xx/rtl931x.c | 6 ++--- 4 files changed, 6 insertions(+), 39 deletions(-) diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c index 0c5e9f3f384..0414be41f28 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c @@ -327,30 +327,7 @@ static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) } } - if (!phy_node) { - if (priv->ports[pn].pcs) - priv->ports[pn].phy_is_integrated = true; - - continue; - } - - if (of_property_read_bool(phy_node, "phy-is-integrated") && - !of_property_read_bool(phy_node, "sfp")) { - priv->ports[pn].phy = PHY_RTL8218B_INT; - continue; - } - - if (!of_property_read_bool(phy_node, "phy-is-integrated") && - of_property_read_bool(phy_node, "sfp")) { - priv->ports[pn].phy = PHY_RTL8214FC; - continue; - } - - if (!of_property_read_bool(phy_node, "phy-is-integrated") && - !of_property_read_bool(phy_node, "sfp")) { - priv->ports[pn].phy = PHY_RTL8218B_EXT; - continue; - } + priv->ports[pn].phy = !!phy_node; } /* Disable MAC polling the PHY so that we can start configuration */ diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c index 86a8fc52be9..cc519422598 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c @@ -526,7 +526,7 @@ static void rtldsa_93xx_phylink_mac_link_up(struct phylink_config *config, mcr |= RTL930X_RX_PAUSE_EN; if (duplex == DUPLEX_FULL || priv->lagmembers & BIT_ULL(port)) mcr |= RTL930X_DUPLEX_MODE; - if (dsa_port_is_cpu(dp) || !priv->ports[port].phy_is_integrated) + if (dsa_port_is_cpu(dp) || priv->ports[port].phy) mcr |= RTL930X_FORCE_EN; } diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h index acdc40f0488..5efcdc3c567 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.h @@ -896,15 +896,6 @@ typedef enum { */ #define RTLDSA_COUNTERS_FAST_POLL_INTERVAL (3 * HZ) -enum phy_type { - PHY_NONE = 0, - PHY_RTL838X_SDS = 1, - PHY_RTL8218B_INT = 2, - PHY_RTL8218B_EXT = 3, - PHY_RTL8214FC = 4, - PHY_RTL839X_SDS = 5, -}; - enum pbvlan_type { PBVLAN_TYPE_INNER = 0, PBVLAN_TYPE_OUTER, @@ -1003,14 +994,13 @@ struct rtldsa_93xx_lag_entry { struct rtldsa_port { bool enable:1; - bool phy_is_integrated:1; + bool phy:1; bool isolated:1; bool rate_police_egress:1; bool rate_police_ingress:1; u64 pm; u16 pvid; bool eee_enabled; - enum phy_type phy; struct phylink_pcs *pcs; int led_set; int leds_on_this_port; diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl931x.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl931x.c index 2e31c10cdc1..ea5a2391211 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl931x.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl931x.c @@ -1688,10 +1688,10 @@ static void rtldsa_931x_led_init(struct rtl838x_switch_priv *priv) sw_w32_mask(0x3 << pos, (priv->ports[i].leds_on_this_port - 1) << pos, RTL931X_LED_PORT_NUM_CTRL(i)); - if (priv->ports[i].phy_is_integrated) - pm_fiber |= BIT_ULL(i); - else + if (priv->ports[i].phy) pm_copper |= BIT_ULL(i); + else + pm_fiber |= BIT_ULL(i); set = priv->ports[i].led_set; sw_w32_mask(0, set << pos, RTL931X_LED_PORT_COPR_SET_SEL_CTRL(i)); -- 2.47.3