730-net-dsa-mt7530-setup-core-clock-even-in-TRGMII-mode.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From c3b8e07909dbe67b0d580416c1a5257643a73be7 Mon Sep 17 00:00:00 2001
  2. From: Ilya Lipnitskiy <[email protected]>
  3. Date: Fri, 12 Mar 2021 00:07:03 -0800
  4. Subject: [PATCH] net: dsa: mt7530: setup core clock even in TRGMII mode
  5. A recent change to MIPS ralink reset logic made it so mt7530 actually
  6. resets the switch on platforms such as mt7621 (where bit 2 is the reset
  7. line for the switch). That exposed an issue where the switch would not
  8. function properly in TRGMII mode after a reset.
  9. Reconfigure core clock in TRGMII mode to fix the issue.
  10. Tested on Ubiquiti ER-X (MT7621) with TRGMII mode enabled.
  11. Fixes: 3f9ef7785a9c ("MIPS: ralink: manage low reset lines")
  12. Signed-off-by: Ilya Lipnitskiy <[email protected]>
  13. Signed-off-by: David S. Miller <[email protected]>
  14. ---
  15. drivers/net/dsa/mt7530.c | 52 +++++++++++++++++++---------------------
  16. 1 file changed, 25 insertions(+), 27 deletions(-)
  17. --- a/drivers/net/dsa/mt7530.c
  18. +++ b/drivers/net/dsa/mt7530.c
  19. @@ -436,34 +436,32 @@ mt7530_pad_clk_setup(struct dsa_switch *
  20. TD_DM_DRVP(8) | TD_DM_DRVN(8));
  21. /* Setup core clock for MT7530 */
  22. - if (!trgint) {
  23. - /* Disable MT7530 core clock */
  24. - core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
  25. -
  26. - /* Disable PLL, since phy_device has not yet been created
  27. - * provided for phy_[read,write]_mmd_indirect is called, we
  28. - * provide our own core_write_mmd_indirect to complete this
  29. - * function.
  30. - */
  31. - core_write_mmd_indirect(priv,
  32. - CORE_GSWPLL_GRP1,
  33. - MDIO_MMD_VEND2,
  34. - 0);
  35. -
  36. - /* Set core clock into 500Mhz */
  37. - core_write(priv, CORE_GSWPLL_GRP2,
  38. - RG_GSWPLL_POSDIV_500M(1) |
  39. - RG_GSWPLL_FBKDIV_500M(25));
  40. -
  41. - /* Enable PLL */
  42. - core_write(priv, CORE_GSWPLL_GRP1,
  43. - RG_GSWPLL_EN_PRE |
  44. - RG_GSWPLL_POSDIV_200M(2) |
  45. - RG_GSWPLL_FBKDIV_200M(32));
  46. -
  47. - /* Enable MT7530 core clock */
  48. - core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
  49. - }
  50. + /* Disable MT7530 core clock */
  51. + core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
  52. +
  53. + /* Disable PLL, since phy_device has not yet been created
  54. + * provided for phy_[read,write]_mmd_indirect is called, we
  55. + * provide our own core_write_mmd_indirect to complete this
  56. + * function.
  57. + */
  58. + core_write_mmd_indirect(priv,
  59. + CORE_GSWPLL_GRP1,
  60. + MDIO_MMD_VEND2,
  61. + 0);
  62. +
  63. + /* Set core clock into 500Mhz */
  64. + core_write(priv, CORE_GSWPLL_GRP2,
  65. + RG_GSWPLL_POSDIV_500M(1) |
  66. + RG_GSWPLL_FBKDIV_500M(25));
  67. +
  68. + /* Enable PLL */
  69. + core_write(priv, CORE_GSWPLL_GRP1,
  70. + RG_GSWPLL_EN_PRE |
  71. + RG_GSWPLL_POSDIV_200M(2) |
  72. + RG_GSWPLL_FBKDIV_200M(32));
  73. +
  74. + /* Enable MT7530 core clock */
  75. + core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
  76. /* Setup the MT7530 TRGMII Tx Clock */
  77. core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);