kernel: 5.15: update Aquantia PHY driver to v6.1 code
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch
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()
5
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.
9
10 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
11 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
12 ---
13 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 33 ++++++++++++++-------
14 1 file changed, 22 insertions(+), 11 deletions(-)
15
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,
20 phylink_config);
21 struct mtk_eth *eth = mac->hw;
22 - u32 mcr_cur, mcr_new, sid, i;
23 int val, ge_mode, err = 0;
24 + u32 sid, i;
25
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
29 return;
30 }
31
32 + return;
33 +
34 +err_phy:
35 + dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
36 + mac->id, phy_modes(state->interface));
37 + return;
38 +
39 +init_err:
40 + dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
41 + mac->id, phy_modes(state->interface), err);
42 +}
43 +
44 +static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
45 + phy_interface_t interface)
46 +{
47 + struct mtk_mac *mac = container_of(config, struct mtk_mac,
48 + phylink_config);
49 + u32 mcr_cur, mcr_new;
50 +
51 /* Setup gmac */
52 mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
53 mcr_new = mcr_cur;
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));
57
58 - return;
59 -
60 -err_phy:
61 - dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
62 - mac->id, phy_modes(state->interface));
63 - return;
64 -
65 -init_err:
66 - dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
67 - mac->id, phy_modes(state->interface), err);
68 + return 0;
69 }
70
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,
79 };