mediatek: copy patches-6.1 to patches-6.6
[openwrt/staging/981213.git] / target / linux / mediatek / patches-6.6 / 732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch
1 From a969b663c866129ed9eb217785a6574fbe826f1d Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Thu, 6 Apr 2023 23:36:50 +0100
4 Subject: [PATCH] net: phy: mxl-gpy: don't use SGMII AN if using phylink
5
6 MAC drivers using phylink expect SGMII in-band-status to be switched off
7 when attached to a PHY. Make sure this is the case also for mxl-gpy which
8 keeps SGMII in-band-status in case of SGMII interface mode is used.
9
10 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
11 ---
12 drivers/net/phy/mxl-gpy.c | 19 ++++++++++++++++---
13 1 file changed, 16 insertions(+), 3 deletions(-)
14
15 --- a/drivers/net/phy/mxl-gpy.c
16 +++ b/drivers/net/phy/mxl-gpy.c
17 @@ -371,8 +371,11 @@ static bool gpy_2500basex_chk(struct phy
18
19 phydev->speed = SPEED_2500;
20 phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
21 - phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL,
22 - VSPEC1_SGMII_CTRL_ANEN, 0);
23 +
24 + if (!phydev->phylink)
25 + phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL,
26 + VSPEC1_SGMII_CTRL_ANEN, 0);
27 +
28 return true;
29 }
30
31 @@ -396,6 +399,14 @@ static int gpy_config_aneg(struct phy_de
32 u32 adv;
33 int ret;
34
35 + /* Disable SGMII auto-negotiation if using phylink */
36 + if (phydev->phylink) {
37 + ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL,
38 + VSPEC1_SGMII_CTRL_ANEN, 0);
39 + if (ret < 0)
40 + return ret;
41 + }
42 +
43 if (phydev->autoneg == AUTONEG_DISABLE) {
44 /* Configure half duplex with genphy_setup_forced,
45 * because genphy_c45_pma_setup_forced does not support.
46 @@ -486,6 +497,8 @@ static void gpy_update_interface(struct
47 switch (phydev->speed) {
48 case SPEED_2500:
49 phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
50 + if (phydev->phylink)
51 + break;
52 ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL,
53 VSPEC1_SGMII_CTRL_ANEN, 0);
54 if (ret < 0)
55 @@ -497,7 +510,7 @@ static void gpy_update_interface(struct
56 case SPEED_100:
57 case SPEED_10:
58 phydev->interface = PHY_INTERFACE_MODE_SGMII;
59 - if (gpy_sgmii_aneg_en(phydev))
60 + if (phydev->phylink || gpy_sgmii_aneg_en(phydev))
61 break;
62 /* Enable and restart SGMII ANEG for 10/100/1000Mbps link speed
63 * if ANEG is disabled (in 2500-BaseX mode).