0c729acb7fe79227c5b60dd7921c7c8ea77e3e5a
[openwrt/openwrt.git] /
1 From d54ef6aea00e7a6ace439baade6ad0aa38ee4b04 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 3 Apr 2023 01:21:57 +0300
4 Subject: [PATCH 287/326] net: phy: realtek: disable SGMII in-band AN for 2.5G
5 PHYs
6
7 MAC drivers don't use SGMII in-band autonegotiation unless told to do so
8 in device tree using 'managed = "in-band-status"'. When using MDIO to
9 access a PHY, in-band-status is unneeded as we have link-status via
10 MDIO. Switch off SGMII in-band autonegotiation using magic values.
11
12 Reported-by: Chen Minqiang <ptpt52@gmail.com>
13 Reported-by: Chukun Pan <amadeus@jmu.edu.cn>
14 Reported-by: Yevhen Kolomeiko <jarvis2709@gmail.com>
15 Tested-by: Yevhen Kolomeiko <jarvis2709@gmail.com>
16 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
17 ---
18 drivers/net/phy/realtek.c | 27 +++++++++++++++++++++++++--
19 1 file changed, 25 insertions(+), 2 deletions(-)
20
21 --- a/drivers/net/phy/realtek.c
22 +++ b/drivers/net/phy/realtek.c
23 @@ -786,8 +786,8 @@ static int rtl822x_write_mmd(struct phy_
24 static int rtl822xb_config_init(struct phy_device *phydev)
25 {
26 bool has_2500, has_sgmii;
27 + int ret, val;
28 u16 mode;
29 - int ret;
30
31 has_2500 = test_bit(PHY_INTERFACE_MODE_2500BASEX,
32 phydev->host_interfaces) ||
33 @@ -837,7 +837,29 @@ static int rtl822xb_config_init(struct p
34 if (ret < 0)
35 return ret;
36
37 - return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020);
38 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020);
39 + if (ret < 0)
40 + return ret;
41 +
42 + /* Disable SGMII AN */
43 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x7588, 0x2);
44 + if (ret < 0)
45 + return ret;
46 +
47 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x7589, 0x71d0);
48 + if (ret < 0)
49 + return ret;
50 +
51 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x7587, 0x3);
52 + if (ret < 0)
53 + return ret;
54 +
55 + ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, 0x7587,
56 + val, !(val & BIT(0)), 500, 100000, false);
57 + if (ret < 0)
58 + return ret;
59 +
60 + return 0;
61 }
62
63 static int rtl822xb_get_rate_matching(struct phy_device *phydev,