From 8cf53c1244bda50c26203e9dfcb1c50bf249a11e Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Fri, 25 Oct 2013 19:46:52 +0000 Subject: [PATCH] Begin fleshing out a knob to enable/disable bluetooth coexistence. Some firmware versions seem to get very unhappy if they're sent btcoex commands when they don't actually have bluetooth hardware in them. So, disable sending them those commands. Tested: * 5100 (which has bluetooth, no problems) * 4965 (which doesn't have bluetooth, but didn't seem to crash) * 6200 (no bluetooth, seems to get unhappy being sent bluetooth commands.) --- sys/dev/iwn/if_iwn.c | 39 +++++++++++++++++++++++++++++++++++++-- sys/dev/iwn/if_iwnvar.h | 1 + 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 72f4d8a39b3d..2e9ffd51d4bc 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -705,6 +705,8 @@ iwn4965_attach(struct iwn_softc *sc, uint16_t pid) /* Override chains masks, ROM is known to be broken. */ sc->txchainmask = IWN_ANT_AB; sc->rxchainmask = IWN_ANT_ABC; + /* Enable normal btcoex */ + sc->sc_flags |= IWN_FLAG_BTCOEX; DPRINTF(sc, IWN_DEBUG_TRACE, "%s: end\n",__func__); @@ -752,23 +754,40 @@ iwn5000_attach(struct iwn_softc *sc, uint16_t pid) /* Override chains masks, ROM is known to be broken. */ sc->txchainmask = IWN_ANT_B; sc->rxchainmask = IWN_ANT_AB; + /* Enable normal btcoex */ + sc->sc_flags |= IWN_FLAG_BTCOEX; break; case IWN_HW_REV_TYPE_5150: sc->limits = &iwn5150_sensitivity_limits; sc->fwname = "iwn5150fw"; + /* Enable normal btcoex */ + sc->sc_flags |= IWN_FLAG_BTCOEX; break; case IWN_HW_REV_TYPE_5300: case IWN_HW_REV_TYPE_5350: sc->limits = &iwn5000_sensitivity_limits; sc->fwname = "iwn5000fw"; + /* Enable normal btcoex */ + sc->sc_flags |= IWN_FLAG_BTCOEX; break; case IWN_HW_REV_TYPE_1000: sc->limits = &iwn1000_sensitivity_limits; sc->fwname = "iwn1000fw"; + /* Enable normal btcoex */ + sc->sc_flags |= IWN_FLAG_BTCOEX; break; case IWN_HW_REV_TYPE_6000: sc->limits = &iwn6000_sensitivity_limits; sc->fwname = "iwn6000fw"; + /* + * Disable btcoex for 6200. + * XXX TODO: disable for 6205; no btcoex as well + * (6230/6235 - enable bluetooth) + */ + if (pid != 0x422c) { + /* Enable normal btcoex */ + sc->sc_flags |= IWN_FLAG_BTCOEX; + } if (pid == 0x422c || pid == 0x4239) { sc->sc_flags |= IWN_FLAG_INTERNAL_PA; /* Override chains masks, ROM is known to be broken. */ @@ -782,14 +801,20 @@ iwn5000_attach(struct iwn_softc *sc, uint16_t pid) /* Override chains masks, ROM is known to be broken. */ sc->txchainmask = IWN_ANT_AB; sc->rxchainmask = IWN_ANT_AB; + /* Enable normal btcoex */ + sc->sc_flags |= IWN_FLAG_BTCOEX; break; case IWN_HW_REV_TYPE_6005: sc->limits = &iwn6000_sensitivity_limits; if (pid != 0x0082 && pid != 0x0085) { sc->fwname = "iwn6000g2bfw"; sc->sc_flags |= IWN_FLAG_ADV_BTCOEX; - } else + } else { sc->fwname = "iwn6000g2afw"; + /* + * 6250 - disable bluetooth coexistence. + */ + } break; default: device_printf(sc->sc_dev, "adapter type %d not supported\n", @@ -797,6 +822,15 @@ iwn5000_attach(struct iwn_softc *sc, uint16_t pid) DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end in error\n",__func__); return ENOTSUP; } + if (sc->sc_flags & IWN_FLAG_BTCOEX) + device_printf(sc->sc_dev, + "enable basic bluetooth coexistence\n"); + else if (sc->sc_flags & IWN_FLAG_ADV_BTCOEX) + device_printf(sc->sc_dev, + "enable advanced bluetooth coexistence\n"); + else + device_printf(sc->sc_dev, + "disable bluetooth coexistence\n"); return 0; } @@ -5404,9 +5438,10 @@ iwn_config(struct iwn_softc *sc) } /* Configure bluetooth coexistence. */ + error = 0; if (sc->sc_flags & IWN_FLAG_ADV_BTCOEX) error = iwn_send_advanced_btcoex(sc); - else + else if (sc->sc_flags & IWN_FLAG_BTCOEX) error = iwn_send_btcoex(sc); if (error != 0) { device_printf(sc->sc_dev, diff --git a/sys/dev/iwn/if_iwnvar.h b/sys/dev/iwn/if_iwnvar.h index d1c0b76ab920..6a9241a04de3 100644 --- a/sys/dev/iwn/if_iwnvar.h +++ b/sys/dev/iwn/if_iwnvar.h @@ -249,6 +249,7 @@ struct iwn_softc { #define IWN_FLAG_ENH_SENS (1 << 7) #define IWN_FLAG_ADV_BTCOEX (1 << 8) #define IWN_FLAG_PAN_SUPPORT (1 << 9) +#define IWN_FLAG_BTCOEX (1 << 10) uint8_t hw_type; /* subdevice_id used to adjust configuration */