1 From 2b1b8c4c215af7988136401c902338d091d408a1 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 2/2] net: phy: realtek: disable SGMII in-band AN for 2.5G PHYs
6 MAC drivers don't use SGMII in-band autonegotiation unless told to do so
7 in device tree using 'managed = "in-band-status"'. When using MDIO to
8 access a PHY, in-band-status is unneeded as we have link-status via
9 MDIO. Switch off SGMII in-band autonegotiation using magic values.
11 Reported-by: Chen Minqiang <ptpt52@gmail.com>
12 Reported-by: Chukun Pan <amadeus@jmu.edu.cn>
13 Reported-by: Yevhen Kolomeiko <jarvis2709@gmail.com>
14 Tested-by: Yevhen Kolomeiko <jarvis2709@gmail.com>
15 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
17 drivers/net/phy/realtek.c | 8 ++++++++
18 1 file changed, 8 insertions(+)
20 --- a/drivers/net/phy/realtek.c
21 +++ b/drivers/net/phy/realtek.c
22 @@ -883,6 +883,7 @@ static irqreturn_t rtl9000a_handle_inter
23 static int rtl8221b_config_init(struct phy_device *phydev)
28 switch (phydev->interface) {
29 case PHY_INTERFACE_MODE_2500BASEX:
30 @@ -919,6 +920,13 @@ static int rtl8221b_config_init(struct p
34 + /* Disable SGMII AN */
35 + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7588, 0x2);
36 + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7589, 0x71d0);
37 + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, 0x3);
38 + phy_read_mmd_poll_timeout(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587,
39 + val, !(val & BIT(0)), 500, 100000, false);