generic: 5.15: replace ramips AR8033 fiber patch with 5.18 patches
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 704-10-v5.19-net-mtk_eth_soc-correct-802.3z-speed-setting.patch
1 From 7da3f901f8ecb425105fad39a0f5de73306abe52 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Wed, 18 May 2022 15:54:47 +0100
4 Subject: [PATCH 04/12] net: mtk_eth_soc: correct 802.3z speed setting
5
6 Phylink does not guarantee that state->speed will be set correctly in
7 the mac_config() call, so it's a bug that the driver makes use of it.
8 Moreover, it is making use of it in a function that is only ever called
9 for 1000BASE-X and 2500BASE-X which operate at a fixed speed which
10 happens to be the same setting irrespective of the interface mode. We
11 can simply remove the switch statement and just set the SGMII interface
12 speed.
13
14 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16 ---
17 drivers/net/ethernet/mediatek/mtk_sgmii.c | 18 +++++-------------
18 1 file changed, 5 insertions(+), 13 deletions(-)
19
20 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c
21 +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c
22 @@ -34,6 +34,7 @@ int mtk_sgmii_init(struct mtk_sgmii *ss,
23 return 0;
24 }
25
26 +/* For SGMII interface mode */
27 int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id)
28 {
29 unsigned int val;
30 @@ -60,6 +61,9 @@ int mtk_sgmii_setup_mode_an(struct mtk_s
31 return 0;
32 }
33
34 +/* For 1000BASE-X and 2500BASE-X interface modes, which operate at a
35 + * fixed speed.
36 + */
37 int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id,
38 const struct phylink_link_state *state)
39 {
40 @@ -82,19 +86,7 @@ int mtk_sgmii_setup_mode_force(struct mt
41 /* SGMII force mode setting */
42 regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val);
43 val &= ~SGMII_IF_MODE_MASK;
44 -
45 - switch (state->speed) {
46 - case SPEED_10:
47 - val |= SGMII_SPEED_10;
48 - break;
49 - case SPEED_100:
50 - val |= SGMII_SPEED_100;
51 - break;
52 - case SPEED_2500:
53 - case SPEED_1000:
54 - val |= SGMII_SPEED_1000;
55 - break;
56 - }
57 + val |= SGMII_SPEED_1000;
58
59 if (state->duplex == DUPLEX_FULL)
60 val |= SGMII_DUPLEX_FULL;