790-28-v6.9-net-dsa-mt7530-disable-LEDs-before-reset.patch 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From de16cf680331cd0bd7db97c3f8d376f5eac39cae Mon Sep 17 00:00:00 2001
  2. From: Justin Swartz <[email protected]>
  3. Date: Tue, 5 Mar 2024 06:39:51 +0200
  4. Subject: [PATCH 28/30] net: dsa: mt7530: disable LEDs before reset
  5. Disable LEDs just before resetting the MT7530 to avoid
  6. situations where the ESW_P4_LED_0 and ESW_P3_LED_0 pin
  7. states may cause an unintended external crystal frequency
  8. to be selected.
  9. The HT_XTAL_FSEL (External Crystal Frequency Selection)
  10. field of HWTRAP (the Hardware Trap register) stores a
  11. 2-bit value that represents the state of the ESW_P4_LED_0
  12. and ESW_P4_LED_0 pins (seemingly) sampled just after the
  13. MT7530 has been reset, as:
  14. ESW_P4_LED_0 ESW_P3_LED_0 Frequency
  15. -----------------------------------------
  16. 0 1 20MHz
  17. 1 0 40MHz
  18. 1 1 25MHz
  19. The value of HT_XTAL_FSEL is bootstrapped by pulling
  20. ESW_P4_LED_0 and ESW_P3_LED_0 up or down accordingly,
  21. but:
  22. if a 40MHz crystal has been selected and
  23. the ESW_P3_LED_0 pin is high during reset,
  24. or a 20MHz crystal has been selected and
  25. the ESW_P4_LED_0 pin is high during reset,
  26. then the value of HT_XTAL_FSEL will indicate
  27. that a 25MHz crystal is present.
  28. By default, the state of the LED pins is PHY controlled
  29. to reflect the link state.
  30. To illustrate, if a board has:
  31. 5 ports with active low LED control,
  32. and HT_XTAL_FSEL bootstrapped for 40MHz.
  33. When the MT7530 is powered up without any external
  34. connection, only the LED associated with Port 3 is
  35. illuminated as ESW_P3_LED_0 is low.
  36. In this state, directly after mt7530_setup()'s reset
  37. is performed, the HWTRAP register (0x7800) reflects
  38. the intended HT_XTAL_FSEL (HWTRAP bits 10:9) of 40MHz:
  39. mt7530-mdio mdio-bus:1f: mt7530_read: 00007800 == 00007dcf
  40. >>> bin(0x7dcf >> 9 & 0b11)
  41. '0b10'
  42. But if a cable is connected to Port 3 and the link
  43. is active before mt7530_setup()'s reset takes place,
  44. then HT_XTAL_FSEL seems to be set for 25MHz:
  45. mt7530-mdio mdio-bus:1f: mt7530_read: 00007800 == 00007fcf
  46. >>> bin(0x7fcf >> 9 & 0b11)
  47. '0b11'
  48. Once HT_XTAL_FSEL reflects 25MHz, none of the ports
  49. are functional until the MT7621 (or MT7530 itself)
  50. is reset.
  51. By disabling the LED pins just before reset, the chance
  52. of an unintended HT_XTAL_FSEL value is reduced.
  53. Signed-off-by: Justin Swartz <[email protected]>
  54. Link: https://lore.kernel.org/r/[email protected]
  55. Signed-off-by: Jakub Kicinski <[email protected]>
  56. ---
  57. drivers/net/dsa/mt7530.c | 6 ++++++
  58. 1 file changed, 6 insertions(+)
  59. --- a/drivers/net/dsa/mt7530.c
  60. +++ b/drivers/net/dsa/mt7530.c
  61. @@ -2391,6 +2391,12 @@ mt7530_setup(struct dsa_switch *ds)
  62. }
  63. }
  64. + /* Disable LEDs before reset to prevent the MT7530 sampling a
  65. + * potentially incorrect HT_XTAL_FSEL value.
  66. + */
  67. + mt7530_write(priv, MT7530_LED_EN, 0);
  68. + usleep_range(1000, 1100);
  69. +
  70. /* Reset whole chip through gpio pin or memory-mapped registers for
  71. * different type of hardware
  72. */