bfb32d53816adcf5c67632c4718ca05a5ddb605d
[openwrt/staging/noltari.git] / target / linux / generic / hack-5.15 / 790-SFP-GE-T-ignore-TX_FAULT.patch
1 --- a/drivers/net/phy/sfp.c
2 +++ b/drivers/net/phy/sfp.c
3 @@ -1803,6 +1803,7 @@ static int sfp_sm_mod_probe(struct sfp *
4 struct sfp_eeprom_id id;
5 bool cotsworks_sfbg;
6 bool cotsworks;
7 + bool oem_ge_t;
8 u8 check;
9 int ret;
10
11 @@ -1851,6 +1852,10 @@ static int sfp_sm_mod_probe(struct sfp *
12 }
13 }
14
15 + /* Some cheap SFP-GE-T modules always indicate TX fault */
16 + oem_ge_t = !memcmp(id.base.vendor_name, "OEM ", 16) &&
17 + !memcmp(id.base.vendor_pn, "SFP-GE-T ", 12);
18 +
19 /* Cotsworks do not seem to update the checksums when they
20 * do the final programming with the final module part number,
21 * serial number and date code.
22 @@ -1946,8 +1951,8 @@ static int sfp_sm_mod_probe(struct sfp *
23 else
24 sfp->module_t_start_up = T_START_UP;
25
26 - if (!memcmp(id.base.vendor_name, "HUAWEI ", 16) &&
27 - !memcmp(id.base.vendor_pn, "MA5671A ", 16))
28 + if ((!memcmp(id.base.vendor_name, "HUAWEI ", 16) &&
29 + !memcmp(id.base.vendor_pn, "MA5671A ", 16)) || oem_ge_t)
30 sfp->tx_fault_ignore = true;
31 else
32 sfp->tx_fault_ignore = false;
33 @@ -2404,10 +2409,12 @@ static void sfp_check_state(struct sfp *
34 mutex_lock(&sfp->st_mutex);
35 state = sfp_get_state(sfp);
36 changed = state ^ sfp->state;
37 - if (sfp->tx_fault_ignore)
38 + if (sfp->tx_fault_ignore) {
39 changed &= SFP_F_PRESENT | SFP_F_LOS;
40 - else
41 + state &= ~SFP_F_TX_FAULT;
42 + } else {
43 changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
44 + }
45
46 for (i = 0; i < GPIO_MAX; i++)
47 if (changed & BIT(i))