net: phy: at803x: support qca8081 1G chip type
authorLuo Jie <quic_luoj@quicinc.com>
Sun, 16 Jul 2023 08:49:22 +0000 (16:49 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Jul 2023 09:15:13 +0000 (10:15 +0100)
The qca8081 1G chip version does not support 2.5 capability, which
is distinguished from qca8081 2.5G chip according to the bit0 of
register mmd7.0x901d, the 1G version chip also has the same PHY ID
as the normal qca8081 2.5G chip.

Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/at803x.c

index 6cdc1b8..cb4c45c 100644 (file)
 #define QCA808X_CDT_STATUS_STAT_OPEN           2
 #define QCA808X_CDT_STATUS_STAT_SHORT          3
 
+/* QCA808X 1G chip type */
+#define QCA808X_PHY_MMD7_CHIP_TYPE             0x901d
+#define QCA808X_PHY_CHIP_TYPE_1G               BIT(0)
+
 MODULE_DESCRIPTION("Qualcomm Atheros AR803x and QCA808X PHY driver");
 MODULE_AUTHOR("Matus Ujhelyi");
 MODULE_LICENSE("GPL");
@@ -2000,6 +2004,17 @@ static int qca808x_get_features(struct phy_device *phydev)
         */
        linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported);
 
+       /* As for the qca8081 1G version chip, the 2500baseT ability is also
+        * existed in the bit0 of MMD1.21, we need to remove it manually if
+        * it is the qca8081 1G chip according to the bit0 of MMD7.0x901d.
+        */
+       ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE);
+       if (ret < 0)
+               return ret;
+
+       if (QCA808X_PHY_CHIP_TYPE_1G & ret)
+               linkmode_clear_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported);
+
        return 0;
 }