summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_iwn.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci/if_iwn.c')
-rw-r--r--sys/dev/pci/if_iwn.c77
1 files changed, 68 insertions, 9 deletions
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index 729ff223cbc..8b33eb3e2f5 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.122 2013/08/08 23:32:50 syl Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.123 2013/08/29 19:06:39 syl Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -210,6 +210,7 @@ int iwn_send_sensitivity(struct iwn_softc *);
int iwn_set_pslevel(struct iwn_softc *, int, int, int);
int iwn_send_temperature_offset(struct iwn_softc *);
int iwn_send_btcoex(struct iwn_softc *);
+int iwn_send_advanced_btcoex(struct iwn_softc *);
int iwn5000_runtime_calib(struct iwn_softc *);
int iwn_config(struct iwn_softc *);
int iwn_scan(struct iwn_softc *, uint16_t);
@@ -4144,6 +4145,65 @@ iwn_send_btcoex(struct iwn_softc *sc)
}
int
+iwn_send_advanced_btcoex(struct iwn_softc *sc)
+{
+ static const uint32_t btcoex_3wire[12] = {
+ 0xaaaaaaaa, 0xaaaaaaaa, 0xaeaaaaaa, 0xaaaaaaaa,
+ 0xcc00ff28, 0x0000aaaa, 0xcc00aaaa, 0x0000aaaa,
+ 0xc0004000, 0x00004000, 0xf0005000, 0xf0005000,
+ };
+ struct iwn6000_btcoex_config btconfig;
+ struct iwn_btcoex_priotable btprio;
+ struct iwn_btcoex_prot btprot;
+ int error, i;
+
+ memset(&btconfig, 0, sizeof btconfig);
+ btconfig.flags = IWN_BT_FLAG_COEX6000_CHAN_INHIBITION |
+ (IWN_BT_FLAG_COEX6000_MODE_3W << IWN_BT_FLAG_COEX6000_MODE_SHIFT) |
+ IWN_BT_FLAG_SYNC_2_BT_DISABLE;
+ btconfig.max_kill = 5;
+ btconfig.bt3_t7_timer = 1;
+ btconfig.kill_ack = htole32(0xffff0000);
+ btconfig.kill_cts = htole32(0xffff0000);
+ btconfig.sample_time = 2;
+ btconfig.bt3_t2_timer = 0xc;
+ for (i = 0; i < 12; i++)
+ btconfig.lookup_table[i] = htole32(btcoex_3wire[i]);
+ btconfig.valid = htole16(0xff);
+ btconfig.prio_boost = 0xf0;
+ DPRINTF(("configuring advanced bluetooth coexistence\n"));
+ error = iwn_cmd(sc, IWN_CMD_BT_COEX, &btconfig, sizeof(btconfig), 1);
+ if (error != 0)
+ return (error);
+
+ memset(&btprio, 0, sizeof btprio);
+ btprio.calib_init1 = 0x6;
+ btprio.calib_init2 = 0x7;
+ btprio.calib_periodic_low1 = 0x2;
+ btprio.calib_periodic_low2 = 0x3;
+ btprio.calib_periodic_high1 = 0x4;
+ btprio.calib_periodic_high2 = 0x5;
+ btprio.dtim = 0x6;
+ btprio.scan52 = 0x8;
+ btprio.scan24 = 0xa;
+ error = iwn_cmd(sc, IWN_CMD_BT_COEX_PRIOTABLE, &btprio, sizeof(btprio),
+ 1);
+ if (error != 0)
+ return (error);
+
+ /* Force BT state machine change */
+ memset(&btprot, 0, sizeof btprot);
+ btprot.open = 1;
+ btprot.type = 1;
+ error = iwn_cmd(sc, IWN_CMD_BT_COEX_PROT, &btprot, sizeof(btprot), 1);
+ if (error != 0)
+ return (error);
+
+ btprot.open = 0;
+ return (iwn_cmd(sc, IWN_CMD_BT_COEX_PROT, &btprot, sizeof(btprot), 1));
+}
+
+int
iwn5000_runtime_calib(struct iwn_softc *sc)
{
struct iwn5000_calib_config cmd;
@@ -4200,15 +4260,14 @@ iwn_config(struct iwn_softc *sc)
}
/* Configure bluetooth coexistence. */
- if (sc->sc_flags & IWN_FLAG_ADV_BT_COEX) {
- /* XXX Advanced bluetooth coexistence isn't implemented yet. */
- } else {
+ if (sc->sc_flags & IWN_FLAG_ADV_BT_COEX)
+ error = iwn_send_advanced_btcoex(sc);
+ else
error = iwn_send_btcoex(sc);
- if (error != 0) {
- printf("%s: could not configure bluetooth coexistence\n",
- sc->sc_dev.dv_xname);
- return error;
- }
+ if (error != 0) {
+ printf("%s: could not configure bluetooth coexistence\n",
+ sc->sc_dev.dv_xname);
+ return error;
}
/* Set mode, channel, RX filter and enable RX. */