1 From 73472c830eae5fce2107f7f086f1e6827d215caf Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Tue, 13 Sep 2022 20:06:48 +0100
4 Subject: [PATCH 1/1] net: sfp: add support for HALNy GPON SFP
6 Add a quirk for the HALNy HL-GSFP module, which appears to have an
7 inverted RX_LOS signal, and maybe uses TX_FAULT as a serial port
8 transmit pin. Rather than use these hardware signals, switch to
9 using software polling for these status signals.
11 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
12 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
14 drivers/net/phy/sfp-bus.c | 2 +-
15 drivers/net/phy/sfp.c | 21 ++++++++++++++++++---
16 2 files changed, 19 insertions(+), 4 deletions(-)
18 --- a/drivers/net/phy/sfp-bus.c
19 +++ b/drivers/net/phy/sfp-bus.c
20 @@ -283,7 +283,7 @@ void sfp_parse_support(struct sfp_bus *b
21 phylink_set(modes, 2500baseX_Full);
25 + if (bus->sfp_quirk && bus->sfp_quirk->modes)
26 bus->sfp_quirk->modes(id, modes);
28 linkmode_or(support, support, modes);
29 --- a/drivers/net/phy/sfp.c
30 +++ b/drivers/net/phy/sfp.c
31 @@ -321,6 +321,15 @@ static void sfp_fixup_ignore_tx_fault(st
32 sfp->tx_fault_ignore = true;
35 +static void sfp_fixup_halny_gsfp(struct sfp *sfp)
37 + /* Ignore the TX_FAULT and LOS signals on this module.
38 + * these are possibly used for other purposes on this
39 + * module, e.g. a serial port.
41 + sfp->state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS);
44 static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
47 @@ -353,6 +362,10 @@ static const struct sfp_quirk sfp_quirks
48 .modes = sfp_quirk_2500basex,
49 .fixup = sfp_fixup_long_startup,
53 + .fixup = sfp_fixup_halny_gsfp,
55 // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
56 // NRZ in their EEPROM
58 @@ -369,16 +382,18 @@ static const struct sfp_quirk sfp_quirks
61 .modes = sfp_quirk_ubnt_uf_instant,
66 static size_t sfp_strlen(const char *str, size_t maxlen)
70 - /* Trailing characters should be filled with space chars */
71 + /* Trailing characters should be filled with space chars, but
72 + * some manufacturers can't read SFF-8472 and use NUL.
74 for (i = 0, size = 0; i < maxlen; i++)
76 + if (str[i] != ' ' && str[i] != '\0')