]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: phy: air_en8811h: deprecate "airoha,pnswap-rx" and "airoha,pnswap-tx"
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 19 Jan 2026 09:12:17 +0000 (11:12 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 22 Jan 2026 03:46:58 +0000 (19:46 -0800)
Prefer the new "rx-polarity" and "tx-polarity" properties, and use the
vendor specific ones as fallback if the standard description doesn't
exist.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260119091220.1493761-3-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/Kconfig
drivers/net/phy/air_en8811h.c

index a7ade7b95a2eeb76e0b732e41cac9f22cc4c5822..7b73332a13d9520582fb45780528de4e17496f5e 100644 (file)
@@ -98,6 +98,7 @@ config AS21XXX_PHY
 
 config AIR_EN8811H_PHY
        tristate "Airoha EN8811H 2.5 Gigabit PHY"
+       select PHY_COMMON_PROPS
        help
          Currently supports the Airoha EN8811H PHY.
 
index badd65f0ccee2edc7be6803dbdaea56f67e954b6..e890bb2c0aa8bf557891d7f74c0089f580ddd4a9 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/phy.h>
+#include <linux/phy/phy-common-props.h>
 #include <linux/firmware.h>
 #include <linux/property.h>
 #include <linux/wordpart.h>
@@ -966,11 +967,45 @@ static int en8811h_probe(struct phy_device *phydev)
        return 0;
 }
 
+static int en8811h_config_serdes_polarity(struct phy_device *phydev)
+{
+       struct device *dev = &phydev->mdio.dev;
+       unsigned int pol, default_pol;
+       u32 pbus_value = 0;
+       int ret;
+
+       default_pol = PHY_POL_NORMAL;
+       if (device_property_read_bool(dev, "airoha,pnswap-rx"))
+               default_pol = PHY_POL_INVERT;
+
+       ret = phy_get_rx_polarity(dev_fwnode(dev), phy_modes(phydev->interface),
+                                 BIT(PHY_POL_NORMAL) | BIT(PHY_POL_INVERT),
+                                 default_pol, &pol);
+       if (ret)
+               return ret;
+       if (pol == PHY_POL_INVERT)
+               pbus_value |= EN8811H_POLARITY_RX_REVERSE;
+
+       default_pol = PHY_POL_NORMAL;
+       if (device_property_read_bool(dev, "airoha,pnswap-tx"))
+               default_pol = PHY_POL_INVERT;
+
+       ret = phy_get_tx_polarity(dev_fwnode(dev), phy_modes(phydev->interface),
+                                 BIT(PHY_POL_NORMAL) | BIT(PHY_POL_INVERT),
+                                 default_pol, &pol);
+       if (ret)
+               return ret;
+       if (pol == PHY_POL_NORMAL)
+               pbus_value |= EN8811H_POLARITY_TX_NORMAL;
+
+       return air_buckpbus_reg_modify(phydev, EN8811H_POLARITY,
+                                      EN8811H_POLARITY_RX_REVERSE |
+                                      EN8811H_POLARITY_TX_NORMAL, pbus_value);
+}
+
 static int en8811h_config_init(struct phy_device *phydev)
 {
        struct en8811h_priv *priv = phydev->priv;
-       struct device *dev = &phydev->mdio.dev;
-       u32 pbus_value;
        int ret;
 
        /* If restart happened in .probe(), no need to restart now */
@@ -1003,19 +1038,7 @@ static int en8811h_config_init(struct phy_device *phydev)
        if (ret < 0)
                return ret;
 
-       /* Serdes polarity */
-       pbus_value = 0;
-       if (device_property_read_bool(dev, "airoha,pnswap-rx"))
-               pbus_value |=  EN8811H_POLARITY_RX_REVERSE;
-       else
-               pbus_value &= ~EN8811H_POLARITY_RX_REVERSE;
-       if (device_property_read_bool(dev, "airoha,pnswap-tx"))
-               pbus_value &= ~EN8811H_POLARITY_TX_NORMAL;
-       else
-               pbus_value |=  EN8811H_POLARITY_TX_NORMAL;
-       ret = air_buckpbus_reg_modify(phydev, EN8811H_POLARITY,
-                                     EN8811H_POLARITY_RX_REVERSE |
-                                     EN8811H_POLARITY_TX_NORMAL, pbus_value);
+       ret = en8811h_config_serdes_polarity(phydev);
        if (ret < 0)
                return ret;