ba76ca40ffaaa873604710f4963e59c1f0fa632a
[openwrt/staging/thess.git] /
1 From 12198c3a410fe69843e335c1bbf6d4c2a4d48e4e Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Thu, 27 Oct 2022 14:11:03 +0100
4 Subject: [PATCH 05/10] net: mtk_eth_soc: add out of band forcing of speed and
5 duplex in pcs_link_up
6
7 Add support for forcing the link speed and duplex setting in the
8 pcs_link_up() method for out of band modes, which will be useful when
9 we finish converting the pcs_config() method. Until then, we still have
10 to force duplex for 802.3z modes to work correctly.
11
12 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
13 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
14 ---
15 drivers/net/ethernet/mediatek/mtk_sgmii.c | 28 ++++++++++++++---------
16 1 file changed, 17 insertions(+), 11 deletions(-)
17
18 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c
20 @@ -108,17 +108,23 @@ static void mtk_pcs_link_up(struct phyli
21 struct mtk_pcs *mpcs = pcs_to_mtk_pcs(pcs);
22 unsigned int sgm_mode;
23
24 - if (!phy_interface_mode_is_8023z(interface))
25 - return;
26 + if (!phylink_autoneg_inband(mode) ||
27 + phy_interface_mode_is_8023z(interface)) {
28 + /* Force the speed and duplex setting */
29 + if (speed == SPEED_10)
30 + sgm_mode = SGMII_SPEED_10;
31 + else if (speed == SPEED_100)
32 + sgm_mode = SGMII_SPEED_100;
33 + else
34 + sgm_mode = SGMII_SPEED_1000;
35
36 - /* SGMII force duplex setting */
37 - if (duplex == DUPLEX_FULL)
38 - sgm_mode = SGMII_DUPLEX_FULL;
39 - else
40 - sgm_mode = 0;
41 + if (duplex == DUPLEX_FULL)
42 + sgm_mode |= SGMII_DUPLEX_FULL;
43
44 - regmap_update_bits(mpcs->regmap, SGMSYS_SGMII_MODE,
45 - SGMII_DUPLEX_FULL, sgm_mode);
46 + regmap_update_bits(mpcs->regmap, SGMSYS_SGMII_MODE,
47 + SGMII_DUPLEX_FULL | SGMII_SPEED_MASK,
48 + sgm_mode);
49 + }
50 }
51
52 static const struct phylink_pcs_ops mtk_pcs_ops = {