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
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.
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>
18 drivers/net/phy/realtek.c | 27 +++++++++++++++++++++++++--
19 1 file changed, 25 insertions(+), 2 deletions(-)
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)
26 bool has_2500, has_sgmii;
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
37 - return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020);
38 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020);
42 + /* Disable SGMII AN */
43 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x7588, 0x2);
47 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x7589, 0x71d0);
51 + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x7587, 0x3);
55 + ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, 0x7587,
56 + val, !(val & BIT(0)), 500, 100000, false);
63 static int rtl822xb_get_rate_matching(struct phy_device *phydev,