From: Birger Koblitz Date: Sun, 16 Jan 2022 06:03:11 +0000 (+0100) Subject: realtek: Allow PHY-IDs to differ from Port numbers X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=60df655d5b17fd225b7c742a5780a09e397ae935;p=openwrt%2Fstaging%2Fansuel.git realtek: Allow PHY-IDs to differ from Port numbers We were using the PHY-ids (the reg entries in the PHY sections of the .dts) as the port numbers. Now scan the ports section in the .dts, and use the actual port numbers, following the phy-handle to the PHY properties. Signed-off-by: Birger Koblitz --- diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c index 6d2996f0af..5a90e53da2 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c @@ -257,7 +257,7 @@ int write_phy(u32 port, u32 page, u32 reg, u32 val) static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) { struct device *dev = priv->dev; - struct device_node *dn, *mii_np = dev->of_node; + struct device_node *dn, *phy_node, *mii_np = dev->of_node; struct mii_bus *bus; int ret; u32 pn; @@ -303,29 +303,54 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) return ret; } - dn = mii_np; - for_each_node_by_name(dn, "ethernet-phy") { + dn = of_find_compatible_node(NULL, NULL, "realtek,rtl83xx-switch"); + if (!dn) { + dev_err(priv->dev, "No RTL switch node in DTS\n"); + return -ENODEV; + } + + for_each_node_by_name(dn, "port") { if (of_property_read_u32(dn, "reg", &pn)) continue; + pr_info("%s found port %d\n", __func__, pn); + 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); + continue; + } + // Check for the integrated SerDes of the RTL8380M first - if (of_property_read_bool(dn, "phy-is-integrated") && priv->id == 0x8380 && pn >= 24) { + if (of_property_read_bool(phy_node, "phy-is-integrated") + && priv->id == 0x8380 && pn >= 24) { pr_debug("----> FÓUND A SERDES\n"); priv->ports[pn].phy = PHY_RTL838X_SDS; continue; } - if (of_property_read_bool(dn, "phy-is-integrated") && !of_property_read_bool(dn, "sfp")) { - priv->ports[pn].phy = PHY_RTL8218B_INT; - continue; + if (priv->id >= 0x9300) { + priv->ports[pn].phy_is_integrated = false; + if (of_property_read_bool(phy_node, "phy-is-integrated")) { + priv->ports[pn].phy_is_integrated = true; + priv->ports[pn].phy = PHY_RTL930X_SDS; + } + } else { + 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(dn, "phy-is-integrated") && of_property_read_bool(dn, "sfp")) { + 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(dn, "phy-is-integrated") && !of_property_read_bool(dn, "sfp")) { + 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; }