mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/staging/wigyori.git] / target / linux / generic / pending-5.4 / 751-net-phylink-make-Broadcom-BCM84881-based-SFPs-work.patch
1 From 7adb5b2126bc013f0964ddaefad6ad1b132e86c3 Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Wed, 11 Dec 2019 10:56:50 +0000
4 Subject: [PATCH] net: phylink: make Broadcom BCM84881 based SFPs work
5
6 The Broadcom BCM84881 does not appear to send the SGMII control word
7 when operating in SGMII mode, which causes network adapters to fail
8 to link with the PHY, or decide to operate at fixed 1G speed, even if
9 the PHY negotiated 100M.
10
11 Work around this by detecting the Broadcom BCM84881 and switch to phy
12 mode rather than inband mode.
13
14 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
15 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/phy/phylink.c | 18 ++++++++++++++++--
19 1 file changed, 16 insertions(+), 2 deletions(-)
20
21 --- a/drivers/net/phy/phylink.c
22 +++ b/drivers/net/phy/phylink.c
23 @@ -1842,10 +1842,20 @@ static void phylink_sfp_link_up(void *up
24 phylink_run_resolve(pl);
25 }
26
27 +/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII
28 + * or 802.3z control word, so inband will not work.
29 + */
30 +static bool phylink_phy_no_inband(struct phy_device *phy)
31 +{
32 + return phy->is_c45 &&
33 + (phy->c45_ids.device_ids[1] & 0xfffffff0) == 0xae025150;
34 +}
35 +
36 static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)
37 {
38 struct phylink *pl = upstream;
39 phy_interface_t interface;
40 + u8 mode;
41 int ret;
42
43 /*
44 @@ -1857,9 +1867,13 @@ static int phylink_sfp_connect_phy(void
45 */
46 phy_support_asym_pause(phy);
47
48 + if (phylink_phy_no_inband(phy))
49 + mode = MLO_AN_PHY;
50 + else
51 + mode = MLO_AN_INBAND;
52 +
53 /* Do the initial configuration */
54 - ret = phylink_sfp_config(pl, MLO_AN_INBAND, phy->supported,
55 - phy->advertising);
56 + ret = phylink_sfp_config(pl, mode, phy->supported, phy->advertising);
57 if (ret < 0)
58 return ret;
59