c49bb19601a13b9aeb26e2e4dd479461c967b62f
[openwrt/openwrt.git] / target / linux / generic / pending-5.10 / 730-net-phy-at803x-fix-feature-detection.patch
1 From 97ca310aa18a93329ef5cd68c20de89761962f45 Mon Sep 17 00:00:00 2001
2 From: David Bauer <mail@david-bauer.net>
3 Date: Sun, 13 Jun 2021 12:19:36 +0200
4 Subject: [PATCH] net: phy: at803x: fix feature detection
5
6 AR8031/AR8033 have different status registers for copper
7 and fiber operation. However, the extended status register
8 is the same for both operation modes.
9
10 As a result of that, ESTATUS_1000_XFULL is set to 1 even when
11 operating in copper TP mode.
12
13 Remove this mode from the supported link modes, as this driver
14 currently only supports copper operation.
15
16 Signed-off-by: David Bauer <mail@david-bauer.net>
17 ---
18 drivers/net/phy/at803x.c | 30 +++++++++++++++++++++++++++++-
19 1 file changed, 29 insertions(+), 1 deletion(-)
20
21 --- a/drivers/net/phy/at803x.c
22 +++ b/drivers/net/phy/at803x.c
23 @@ -1032,6 +1032,34 @@ static int at803x_set_tunable(struct phy
24 }
25 }
26
27 +static int at803x_get_features(struct phy_device *phydev)
28 +{
29 + int err;
30 +
31 + err = genphy_read_abilities(phydev);
32 + if (err)
33 + return err;
34 +
35 + if (!at803x_match_phy_id(phydev, ATH8031_PHY_ID))
36 + return 0;
37 +
38 + /* AR8031/AR8033 have different status registers
39 + * for copper and fiber operation. However, the
40 + * extended status register is the same for both
41 + * operation modes.
42 + *
43 + * As a result of that, ESTATUS_1000_XFULL is set
44 + * to 1 even when operating in copper TP mode.
45 + *
46 + * Remove this mode from the supported link modes,
47 + * as this driver currently only supports copper
48 + * operation.
49 + */
50 + linkmode_clear_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
51 + phydev->supported);
52 + return 0;
53 +}
54 +
55 static int at803x_cable_test_result_trans(u16 status)
56 {
57 switch (FIELD_GET(AT803X_CDT_STATUS_STAT_MASK, status)) {
58 @@ -1364,7 +1392,7 @@ static struct phy_driver at803x_driver[]
59 .resume = at803x_resume,
60 .read_page = at803x_read_page,
61 .write_page = at803x_write_page,
62 - /* PHY_GBIT_FEATURES */
63 + .get_features = at803x_get_features,
64 .read_status = at803x_read_status,
65 .aneg_done = at803x_aneg_done,
66 .ack_interrupt = &at803x_ack_interrupt,