a11e8049581e0c3713b558829228fa1248defdb5
[openwrt/staging/wigyori.git] /
1 From f058b2dd70b1a5503dff899010aeb53b436091e5 Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Wed, 28 Feb 2024 18:24:09 +0100
4 Subject: [PATCH 1/2] net: phy: qcom: qca808x: add helper for checking for 1G
5 only model
6
7 There are 2 versions of QCA808x, one 2.5G capable and one 1G capable.
8 Currently, this matter only in the .get_features call however, it will
9 be required for filling supported interface modes so lets add a helper
10 that can be reused.
11
12 Signed-off-by: Robert Marko <robimarko@gmail.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/phy/qcom/qca808x.c | 17 ++++++++++++-----
16 1 file changed, 12 insertions(+), 5 deletions(-)
17
18 --- a/drivers/net/phy/qcom/qca808x.c
19 +++ b/drivers/net/phy/qcom/qca808x.c
20 @@ -156,6 +156,17 @@ static bool qca808x_has_fast_retrain_or_
21 return linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported);
22 }
23
24 +static bool qca808x_is_1g_only(struct phy_device *phydev)
25 +{
26 + int ret;
27 +
28 + ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE);
29 + if (ret < 0)
30 + return true;
31 +
32 + return !!(QCA808X_PHY_CHIP_TYPE_1G & ret);
33 +}
34 +
35 static int qca808x_probe(struct phy_device *phydev)
36 {
37 struct device *dev = &phydev->mdio.dev;
38 @@ -350,11 +361,7 @@ static int qca808x_get_features(struct p
39 * existed in the bit0 of MMD1.21, we need to remove it manually if
40 * it is the qca8081 1G chip according to the bit0 of MMD7.0x901d.
41 */
42 - ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE);
43 - if (ret < 0)
44 - return ret;
45 -
46 - if (QCA808X_PHY_CHIP_TYPE_1G & ret)
47 + if (qca808x_is_1g_only(phydev))
48 linkmode_clear_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported);
49
50 return 0;