1 From 0e37ad71b2ff772009595002da2860999e98e14e Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Wed, 18 May 2022 15:55:12 +0100
4 Subject: [PATCH 09/12] net: mtk_eth_soc: move MAC_MCR setting to mac_finish()
6 Move the setting of the MTK_MAC_MCR register from the end of mac_config
7 into the phylink mac_finish() method, to keep it as the very last write
8 that is done during configuration.
10 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
11 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
13 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 33 ++++++++++++++-------
14 1 file changed, 22 insertions(+), 11 deletions(-)
16 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 @@ -316,8 +316,8 @@ static void mtk_mac_config(struct phylin
19 struct mtk_mac *mac = container_of(config, struct mtk_mac,
21 struct mtk_eth *eth = mac->hw;
22 - u32 mcr_cur, mcr_new, sid, i;
23 int val, ge_mode, err = 0;
26 /* MT76x8 has no hardware settings between for the MAC */
27 if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
28 @@ -455,16 +455,6 @@ static void mtk_mac_config(struct phylin
33 - mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
35 - mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE |
36 - MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK;
38 - /* Only update control register when needed! */
39 - if (mcr_new != mcr_cur)
40 - mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
45 @@ -477,6 +467,26 @@ init_err:
46 mac->id, phy_modes(state->interface), err);
49 +static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
50 + phy_interface_t interface)
52 + struct mtk_mac *mac = container_of(config, struct mtk_mac,
54 + u32 mcr_cur, mcr_new;
57 + mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
59 + mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE |
60 + MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK;
62 + /* Only update control register when needed! */
63 + if (mcr_new != mcr_cur)
64 + mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
69 static void mtk_mac_pcs_get_state(struct phylink_config *config,
70 struct phylink_link_state *state)
72 @@ -581,6 +591,7 @@ static const struct phylink_mac_ops mtk_
73 .mac_pcs_get_state = mtk_mac_pcs_get_state,
74 .mac_an_restart = mtk_mac_an_restart,
75 .mac_config = mtk_mac_config,
76 + .mac_finish = mtk_mac_finish,
77 .mac_link_down = mtk_mac_link_down,
78 .mac_link_up = mtk_mac_link_up,