704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 0e37ad71b2ff772009595002da2860999e98e14e Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  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. Move the setting of the MTK_MAC_MCR register from the end of mac_config
  6. into the phylink mac_finish() method, to keep it as the very last write
  7. that is done during configuration.
  8. Signed-off-by: Russell King (Oracle) <[email protected]>
  9. Signed-off-by: Jakub Kicinski <[email protected]>
  10. ---
  11. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 33 ++++++++++++++-------
  12. 1 file changed, 22 insertions(+), 11 deletions(-)
  13. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  14. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  15. @@ -316,8 +316,8 @@ static void mtk_mac_config(struct phylin
  16. struct mtk_mac *mac = container_of(config, struct mtk_mac,
  17. phylink_config);
  18. struct mtk_eth *eth = mac->hw;
  19. - u32 mcr_cur, mcr_new, sid, i;
  20. int val, ge_mode, err = 0;
  21. + u32 sid, i;
  22. /* MT76x8 has no hardware settings between for the MAC */
  23. if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
  24. @@ -455,6 +455,25 @@ static void mtk_mac_config(struct phylin
  25. return;
  26. }
  27. + return;
  28. +
  29. +err_phy:
  30. + dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
  31. + mac->id, phy_modes(state->interface));
  32. + return;
  33. +
  34. +init_err:
  35. + dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
  36. + mac->id, phy_modes(state->interface), err);
  37. +}
  38. +
  39. +static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
  40. + phy_interface_t interface)
  41. +{
  42. + struct mtk_mac *mac = container_of(config, struct mtk_mac,
  43. + phylink_config);
  44. + u32 mcr_cur, mcr_new;
  45. +
  46. /* Setup gmac */
  47. mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
  48. mcr_new = mcr_cur;
  49. @@ -466,16 +485,7 @@ static void mtk_mac_config(struct phylin
  50. if (mcr_new != mcr_cur)
  51. mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
  52. - return;
  53. -
  54. -err_phy:
  55. - dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
  56. - mac->id, phy_modes(state->interface));
  57. - return;
  58. -
  59. -init_err:
  60. - dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
  61. - mac->id, phy_modes(state->interface), err);
  62. + return 0;
  63. }
  64. static void mtk_mac_pcs_get_state(struct phylink_config *config,
  65. @@ -582,6 +592,7 @@ static const struct phylink_mac_ops mtk_
  66. .mac_pcs_get_state = mtk_mac_pcs_get_state,
  67. .mac_an_restart = mtk_mac_an_restart,
  68. .mac_config = mtk_mac_config,
  69. + .mac_finish = mtk_mac_finish,
  70. .mac_link_down = mtk_mac_link_down,
  71. .mac_link_up = mtk_mac_link_up,
  72. };