1 From 7cc39a6bedbd85f3ff7e16845f310e4ce8d9833f Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
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: netdev@vger.kernel.org,
6 linux-kernel@vger.kernel.org,
7 Russell King <linux@armlinux.org.uk>,
8 Andrew Lunn <andrew@lunn.ch>,
9 Heiner Kallweit <hkallweit1@gmail.com>
10 Cc: David S. Miller <davem@davemloft.net>,
11 Eric Dumazet <edumazet@google.com>,
12 Jakub Kicinski <kuba@kernel.org>,
13 Paolo Abeni <pabeni@redhat.com>,
14 Josef Schlehofer <pepe.schlehofer@gmail.com>
16 This copper module comes with broken TX_FAULT indicator which must be
17 ignored for it to work. Implement ignoring TX_FAULT state bit also
18 during reset/insertion and mute the warning telling the user that the
19 module indicates TX_FAULT.
21 Co-authored-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
22 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
24 drivers/net/phy/sfp.c | 14 +++++++++++---
25 1 file changed, 11 insertions(+), 3 deletions(-)
27 --- a/drivers/net/phy/sfp.c
28 +++ b/drivers/net/phy/sfp.c
29 @@ -373,6 +373,11 @@ static const struct sfp_quirk sfp_quirks
30 .modes = sfp_quirk_2500basex,
31 .fixup = sfp_fixup_ignore_tx_fault,
33 + // OEM SFP-GE-T is 1000Base-T module
36 + .fixup = sfp_fixup_ignore_tx_fault,
38 // Lantech 8330-262D-E can operate at 2500base-X, but
39 // incorrectly report 2500MBd NRZ in their EEPROM
41 @@ -2306,7 +2311,8 @@ static void sfp_sm_main(struct sfp *sfp,
42 * or t_start_up, so assume there is a fault.
44 sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT,
45 - sfp->sm_fault_retries == N_FAULT_INIT);
46 + !sfp->tx_fault_ignore &&
47 + (sfp->sm_fault_retries == N_FAULT_INIT));
48 } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
50 sfp->sm_phy_retries = R_PHY_RETRY;
51 @@ -2529,10 +2535,12 @@ static void sfp_check_state(struct sfp *
52 mutex_lock(&sfp->st_mutex);
53 state = sfp_get_state(sfp);
54 changed = state ^ sfp->state;
55 - if (sfp->tx_fault_ignore)
56 + if (sfp->tx_fault_ignore) {
57 changed &= SFP_F_PRESENT | SFP_F_LOS;
59 + state &= ~SFP_F_TX_FAULT;
61 changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
64 for (i = 0; i < GPIO_MAX; i++)