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,6 +455,25 @@ static void mtk_mac_config(struct phylin
35 + dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
36 + mac->id, phy_modes(state->interface));
40 + dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
41 + mac->id, phy_modes(state->interface), err);
44 +static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
45 + phy_interface_t interface)
47 + struct mtk_mac *mac = container_of(config, struct mtk_mac,
49 + u32 mcr_cur, mcr_new;
52 mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
54 @@ -466,16 +485,7 @@ static void mtk_mac_config(struct phylin
55 if (mcr_new != mcr_cur)
56 mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
61 - dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
62 - mac->id, phy_modes(state->interface));
66 - dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
67 - mac->id, phy_modes(state->interface), err);
71 static void mtk_mac_pcs_get_state(struct phylink_config *config,
72 @@ -582,6 +592,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,