ath79: add support for Huawei AP5030DN
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 706-v6.6-01-net-phy-at803x-support-qca8081-genphy_c45_pma_read_a.patch
1 From 8b8bc13d89a7d23d14b0e041c73f037c9db997b1 Mon Sep 17 00:00:00 2001
2 From: Luo Jie <quic_luoj@quicinc.com>
3 Date: Sun, 16 Jul 2023 16:49:19 +0800
4 Subject: [PATCH 1/6] net: phy: at803x: support qca8081
5 genphy_c45_pma_read_abilities
6
7 qca8081 PHY supports to use genphy_c45_pma_read_abilities for
8 getting the PHY features supported except for the autoneg ability
9
10 but autoneg ability exists in MDIO_STAT1 instead of MMD7.1, add it
11 manually after calling genphy_c45_pma_read_abilities.
12
13 Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
14 Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
16 ---
17 drivers/net/phy/at803x.c | 28 ++++++++++++++++++----------
18 1 file changed, 18 insertions(+), 10 deletions(-)
19
20 --- a/drivers/net/phy/at803x.c
21 +++ b/drivers/net/phy/at803x.c
22 @@ -902,15 +902,6 @@ static int at803x_get_features(struct ph
23 if (err)
24 return err;
25
26 - if (phydev->drv->phy_id == QCA8081_PHY_ID) {
27 - err = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE);
28 - if (err < 0)
29 - return err;
30 -
31 - linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported,
32 - err & MDIO_PMA_NG_EXTABLE_2_5GBT);
33 - }
34 -
35 if (phydev->drv->phy_id != ATH8031_PHY_ID)
36 return 0;
37
38 @@ -1996,6 +1987,23 @@ static int qca808x_cable_test_get_status
39 return 0;
40 }
41
42 +static int qca808x_get_features(struct phy_device *phydev)
43 +{
44 + int ret;
45 +
46 + ret = genphy_c45_pma_read_abilities(phydev);
47 + if (ret)
48 + return ret;
49 +
50 + /* The autoneg ability is not existed in bit3 of MMD7.1,
51 + * but it is supported by qca808x PHY, so we add it here
52 + * manually.
53 + */
54 + linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported);
55 +
56 + return 0;
57 +}
58 +
59 static struct phy_driver at803x_driver[] = {
60 {
61 /* Qualcomm Atheros AR8035 */
62 @@ -2163,7 +2171,7 @@ static struct phy_driver at803x_driver[]
63 .set_tunable = at803x_set_tunable,
64 .set_wol = at803x_set_wol,
65 .get_wol = at803x_get_wol,
66 - .get_features = at803x_get_features,
67 + .get_features = qca808x_get_features,
68 .config_aneg = at803x_config_aneg,
69 .suspend = genphy_suspend,
70 .resume = genphy_resume,