790-SFP-GE-T-ignore-TX_FAULT.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From 7cc39a6bedbd85f3ff7e16845f310e4ce8d9833f Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Tue, 6 Sep 2022 00:31:19 +0100
  4. Subject: [PATCH] net: sfp: add quirk for ATS SFP-GE-T 1000Base-TX module
  5. To: [email protected],
  6. [email protected],
  7. Russell King <[email protected]>,
  8. Andrew Lunn <[email protected]>,
  9. Heiner Kallweit <[email protected]>
  10. Cc: David S. Miller <[email protected]>,
  11. Eric Dumazet <[email protected]>,
  12. Jakub Kicinski <[email protected]>,
  13. Paolo Abeni <[email protected]>,
  14. Josef Schlehofer <[email protected]>
  15. This copper module comes with broken TX_FAULT indicator which must be
  16. ignored for it to work. Implement ignoring TX_FAULT state bit also
  17. during reset/insertion and mute the warning telling the user that the
  18. module indicates TX_FAULT.
  19. Co-authored-by: Josef Schlehofer <[email protected]>
  20. Signed-off-by: Daniel Golle <[email protected]>
  21. ---
  22. drivers/net/phy/sfp.c | 14 +++++++++++---
  23. 1 file changed, 11 insertions(+), 3 deletions(-)
  24. --- a/drivers/net/phy/sfp.c
  25. +++ b/drivers/net/phy/sfp.c
  26. @@ -390,6 +390,11 @@ static const struct sfp_quirk sfp_quirks
  27. .modes = sfp_quirk_2500basex,
  28. .fixup = sfp_fixup_ignore_tx_fault,
  29. }, {
  30. + // OEM SFP-GE-T is 1000Base-T module
  31. + .vendor = "OEM",
  32. + .part = "SFP-GE-T",
  33. + .fixup = sfp_fixup_ignore_tx_fault,
  34. + }, {
  35. // Lantech 8330-262D-E can operate at 2500base-X, but
  36. // incorrectly report 2500MBd NRZ in their EEPROM
  37. .vendor = "Lantech",
  38. @@ -2319,7 +2324,8 @@ static void sfp_sm_main(struct sfp *sfp,
  39. * or t_start_up, so assume there is a fault.
  40. */
  41. sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT,
  42. - sfp->sm_fault_retries == N_FAULT_INIT);
  43. + !sfp->tx_fault_ignore &&
  44. + (sfp->sm_fault_retries == N_FAULT_INIT));
  45. } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
  46. init_done:
  47. sfp->sm_phy_retries = R_PHY_RETRY;
  48. @@ -2542,10 +2548,12 @@ static void sfp_check_state(struct sfp *
  49. mutex_lock(&sfp->st_mutex);
  50. state = sfp_get_state(sfp);
  51. changed = state ^ sfp->state;
  52. - if (sfp->tx_fault_ignore)
  53. + if (sfp->tx_fault_ignore) {
  54. changed &= SFP_F_PRESENT | SFP_F_LOS;
  55. - else
  56. + state &= ~SFP_F_TX_FAULT;
  57. + } else {
  58. changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
  59. + }
  60. for (i = 0; i < GPIO_MAX; i++)
  61. if (changed & BIT(i))