7a9de8ee1e05a707d1034b73055ebb05589557dd
[openwrt/staging/dedeckeh.git] /
1 From f81d97cb646ab8b90fb181d66fccaf9589990de6 Mon Sep 17 00:00:00 2001
2 From: Matthew Hagan <mnhagan88@gmail.com>
3 Date: Sat, 30 Apr 2022 11:00:49 +0100
4 Subject: [PATCH v2] net: sfp: Add tx-fault workaround for Huawei MA5671A SFP
5 ONT
6
7 As noted elsewhere, various GPON SFP modules exhibit non-standard
8 TX-fault behaviour. In the tested case, the Huawei MA5671A, when used
9 in combination with a Marvell mv88e6085 switch, was found to
10 persistently assert TX-fault, resulting in the module being disabled.
11
12 This patch adds a quirk to ignore the SFP_F_TX_FAULT state, allowing the
13 module to function.
14
15 Change from v1: removal of erroneous return statment (Andrew Lunn)
16
17 Signed-off-by: Matthew Hagan <mnhagan88@gmail.com>
18 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
19 ---
20 drivers/net/phy/sfp.c | 12 +++++++++++-
21 1 file changed, 11 insertions(+), 1 deletion(-)
22
23 --- a/drivers/net/phy/sfp.c
24 +++ b/drivers/net/phy/sfp.c
25 @@ -249,6 +249,7 @@ struct sfp {
26 struct sfp_eeprom_id id;
27 unsigned int module_power_mW;
28 unsigned int module_t_start_up;
29 + bool tx_fault_ignore;
30
31 #if IS_ENABLED(CONFIG_HWMON)
32 struct sfp_diag diag;
33 @@ -1893,6 +1894,12 @@ static int sfp_sm_mod_probe(struct sfp *
34 else
35 sfp->module_t_start_up = T_START_UP;
36
37 + if (!memcmp(id.base.vendor_name, "HUAWEI ", 16) &&
38 + !memcmp(id.base.vendor_pn, "MA5671A ", 16))
39 + sfp->tx_fault_ignore = true;
40 + else
41 + sfp->tx_fault_ignore = false;
42 +
43 return 0;
44 }
45
46 @@ -2320,7 +2327,10 @@ static void sfp_check_state(struct sfp *
47 mutex_lock(&sfp->st_mutex);
48 state = sfp_get_state(sfp);
49 changed = state ^ sfp->state;
50 - changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
51 + if (sfp->tx_fault_ignore)
52 + changed &= SFP_F_PRESENT | SFP_F_LOS;
53 + else
54 + changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
55
56 for (i = 0; i < GPIO_MAX; i++)
57 if (changed & BIT(i))