generic: add quirk for HG MXPD-483II 2500M fiber SFP
[openwrt/staging/dedeckeh.git] / target / linux / generic / hack-5.15 / 790-SFP-GE-T-ignore-TX_FAULT.patch
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>
15
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.
20
21 Co-authored-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
22 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
23 ---
24 drivers/net/phy/sfp.c | 14 +++++++++++---
25 1 file changed, 11 insertions(+), 3 deletions(-)
26
27 --- a/drivers/net/phy/sfp.c
28 +++ b/drivers/net/phy/sfp.c
29 @@ -377,6 +377,11 @@ static const struct sfp_quirk sfp_quirks
30 .modes = sfp_quirk_2500basex,
31 .fixup = sfp_fixup_ignore_tx_fault,
32 }, {
33 + // OEM SFP-GE-T is 1000Base-T module
34 + .vendor = "OEM",
35 + .part = "SFP-GE-T",
36 + .fixup = sfp_fixup_ignore_tx_fault,
37 + }, {
38 // Lantech 8330-262D-E can operate at 2500base-X, but
39 // incorrectly report 2500MBd NRZ in their EEPROM
40 .vendor = "Lantech",
41 @@ -2310,7 +2315,8 @@ static void sfp_sm_main(struct sfp *sfp,
42 * or t_start_up, so assume there is a fault.
43 */
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) {
49 init_done:
50 sfp->sm_phy_retries = R_PHY_RETRY;
51 @@ -2533,10 +2539,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;
58 - else
59 + state &= ~SFP_F_TX_FAULT;
60 + } else {
61 changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
62 + }
63
64 for (i = 0; i < GPIO_MAX; i++)
65 if (changed & BIT(i))