diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2013-01-17 02:42:25 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-03-06 10:47:58 -0500 |
commit | 931d416049cdb6e8382792231317f76be0d922ce (patch) | |
tree | dd34fee8764e451bdd16c2be20b3dcfa19497bc3 /drivers/net/wireless/iwlwifi/mvm | |
parent | fb3ceb817503f3d89e3beb4f48a2f4d608a6697f (diff) |
iwlwifi: mvm: begin basic BT-Coex implementation
Send the PRIO table before the calibrations. This table
tells the fw what priority to give to what (WiFi / BT)
according to events.
Send a hardcoded BT_COEX command to the fw to enable basic
BT coexistence.
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/mvm')
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/bt-coex.c | 242 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/fw.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/mvm.h | 4 |
4 files changed, 259 insertions, 1 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/Makefile b/drivers/net/wireless/iwlwifi/mvm/Makefile index 807b250ec396..2acc44b40986 100644 --- a/drivers/net/wireless/iwlwifi/mvm/Makefile +++ b/drivers/net/wireless/iwlwifi/mvm/Makefile | |||
@@ -2,7 +2,7 @@ obj-$(CONFIG_IWLMVM) += iwlmvm.o | |||
2 | iwlmvm-y += fw.o mac80211.o nvm.o ops.o phy-ctxt.o mac-ctxt.o | 2 | iwlmvm-y += fw.o mac80211.o nvm.o ops.o phy-ctxt.o mac-ctxt.o |
3 | iwlmvm-y += utils.o rx.o tx.o binding.o quota.o sta.o | 3 | iwlmvm-y += utils.o rx.o tx.o binding.o quota.o sta.o |
4 | iwlmvm-y += scan.o time-event.o rs.o | 4 | iwlmvm-y += scan.o time-event.o rs.o |
5 | iwlmvm-y += power.o | 5 | iwlmvm-y += power.o bt-coex.o |
6 | iwlmvm-y += led.o | 6 | iwlmvm-y += led.o |
7 | iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o | 7 | iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o |
8 | iwlmvm-$(CONFIG_PM_SLEEP) += d3.o | 8 | iwlmvm-$(CONFIG_PM_SLEEP) += d3.o |
diff --git a/drivers/net/wireless/iwlwifi/mvm/bt-coex.c b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c new file mode 100644 index 000000000000..d37865af3254 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c | |||
@@ -0,0 +1,242 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * This file is provided under a dual BSD/GPLv2 license. When using or | ||
4 | * redistributing this file, you may do so under either license. | ||
5 | * | ||
6 | * GPL LICENSE SUMMARY | ||
7 | * | ||
8 | * Copyright(c) 2013 Intel Corporation. All rights reserved. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of version 2 of the GNU General Public License as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | ||
22 | * USA | ||
23 | * | ||
24 | * The full GNU General Public License is included in this distribution | ||
25 | * in the file called COPYING. | ||
26 | * | ||
27 | * Contact Information: | ||
28 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
30 | * | ||
31 | * BSD LICENSE | ||
32 | * | ||
33 | * Copyright(c) 2013 Intel Corporation. All rights reserved. | ||
34 | * All rights reserved. | ||
35 | * | ||
36 | * Redistribution and use in source and binary forms, with or without | ||
37 | * modification, are permitted provided that the following conditions | ||
38 | * are met: | ||
39 | * | ||
40 | * * Redistributions of source code must retain the above copyright | ||
41 | * notice, this list of conditions and the following disclaimer. | ||
42 | * * Redistributions in binary form must reproduce the above copyright | ||
43 | * notice, this list of conditions and the following disclaimer in | ||
44 | * the documentation and/or other materials provided with the | ||
45 | * distribution. | ||
46 | * * Neither the name Intel Corporation nor the names of its | ||
47 | * contributors may be used to endorse or promote products derived | ||
48 | * from this software without specific prior written permission. | ||
49 | * | ||
50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
61 | * | ||
62 | *****************************************************************************/ | ||
63 | |||
64 | #include "fw-api-bt-coex.h" | ||
65 | #include "iwl-modparams.h" | ||
66 | #include "mvm.h" | ||
67 | |||
68 | #define EVENT_PRIO_ANT(_evt, _prio, _shrd_ant) \ | ||
69 | [(_evt)] = (((_prio) << BT_COEX_PRIO_TBL_PRIO_POS) | \ | ||
70 | ((_shrd_ant) << BT_COEX_PRIO_TBL_SHRD_ANT_POS)) | ||
71 | |||
72 | static const u8 iwl_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { | ||
73 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_INIT_CALIB1, | ||
74 | BT_COEX_PRIO_TBL_PRIO_BYPASS, 0), | ||
75 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_INIT_CALIB2, | ||
76 | BT_COEX_PRIO_TBL_PRIO_BYPASS, 1), | ||
77 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1, | ||
78 | BT_COEX_PRIO_TBL_PRIO_LOW, 0), | ||
79 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2, | ||
80 | BT_COEX_PRIO_TBL_PRIO_LOW, 1), | ||
81 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1, | ||
82 | BT_COEX_PRIO_TBL_PRIO_HIGH, 0), | ||
83 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2, | ||
84 | BT_COEX_PRIO_TBL_PRIO_HIGH, 1), | ||
85 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_DTIM, | ||
86 | BT_COEX_PRIO_TBL_DISABLED, 0), | ||
87 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_SCAN52, | ||
88 | BT_COEX_PRIO_TBL_PRIO_COEX_OFF, 0), | ||
89 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_SCAN24, | ||
90 | BT_COEX_PRIO_TBL_PRIO_COEX_ON, 0), | ||
91 | EVENT_PRIO_ANT(BT_COEX_PRIO_TBL_EVT_IDLE, | ||
92 | BT_COEX_PRIO_TBL_PRIO_COEX_IDLE, 0), | ||
93 | 0, 0, 0, 0, 0, 0, | ||
94 | }; | ||
95 | |||
96 | #undef EVENT_PRIO_ANT | ||
97 | |||
98 | int iwl_send_bt_prio_tbl(struct iwl_mvm *mvm) | ||
99 | { | ||
100 | return iwl_mvm_send_cmd_pdu(mvm, BT_COEX_PRIO_TABLE, CMD_SYNC, | ||
101 | sizeof(struct iwl_bt_coex_prio_tbl_cmd), | ||
102 | &iwl_bt_prio_tbl); | ||
103 | } | ||
104 | |||
105 | static int iwl_send_bt_env(struct iwl_mvm *mvm, u8 action, u8 type) | ||
106 | { | ||
107 | struct iwl_bt_coex_prot_env_cmd env_cmd; | ||
108 | int ret; | ||
109 | |||
110 | env_cmd.action = action; | ||
111 | env_cmd.type = type; | ||
112 | ret = iwl_mvm_send_cmd_pdu(mvm, BT_COEX_PROT_ENV, CMD_SYNC, | ||
113 | sizeof(env_cmd), &env_cmd); | ||
114 | if (ret) | ||
115 | IWL_ERR(mvm, "failed to send BT env command\n"); | ||
116 | return ret; | ||
117 | } | ||
118 | |||
119 | enum iwl_bt_kill_msk { | ||
120 | BT_KILL_MSK_DEFAULT, | ||
121 | BT_KILL_MSK_SCO_HID_A2DP, | ||
122 | BT_KILL_MSK_REDUCED_TXPOW, | ||
123 | BT_KILL_MSK_MAX, | ||
124 | }; | ||
125 | |||
126 | static const u32 iwl_bt_ack_kill_msk[BT_KILL_MSK_MAX] = { | ||
127 | 0xffffffff, | ||
128 | 0xfffffc00, | ||
129 | 0, | ||
130 | }; | ||
131 | |||
132 | static const u32 iwl_bt_cts_kill_msk[BT_KILL_MSK_MAX] = { | ||
133 | 0xffffffff, | ||
134 | 0xfffffc00, | ||
135 | 0, | ||
136 | }; | ||
137 | |||
138 | #define IWL_BT_DEFAULT_BOOST (0xf0f0f0f0) | ||
139 | |||
140 | /* Tight Coex */ | ||
141 | static const __le32 iwl_tight_lookup[BT_COEX_LUT_SIZE] = { | ||
142 | cpu_to_le32(0xaaaaaaaa), | ||
143 | cpu_to_le32(0xaaaaaaaa), | ||
144 | cpu_to_le32(0xaeaaaaaa), | ||
145 | cpu_to_le32(0xaaaaaaaa), | ||
146 | cpu_to_le32(0xcc00ff28), | ||
147 | cpu_to_le32(0x0000aaaa), | ||
148 | cpu_to_le32(0xcc00aaaa), | ||
149 | cpu_to_le32(0x0000aaaa), | ||
150 | cpu_to_le32(0xc0004000), | ||
151 | cpu_to_le32(0x00000000), | ||
152 | cpu_to_le32(0xf0005000), | ||
153 | cpu_to_le32(0xf0005000), | ||
154 | }; | ||
155 | |||
156 | /* Loose Coex */ | ||
157 | static const __le32 iwl_loose_lookup[BT_COEX_LUT_SIZE] = { | ||
158 | cpu_to_le32(0xaaaaaaaa), | ||
159 | cpu_to_le32(0xaaaaaaaa), | ||
160 | cpu_to_le32(0xaeaaaaaa), | ||
161 | cpu_to_le32(0xaaaaaaaa), | ||
162 | cpu_to_le32(0xcc00ff28), | ||
163 | cpu_to_le32(0x0000aaaa), | ||
164 | cpu_to_le32(0xcc00aaaa), | ||
165 | cpu_to_le32(0x0000aaaa), | ||
166 | cpu_to_le32(0x00000000), | ||
167 | cpu_to_le32(0x00000000), | ||
168 | cpu_to_le32(0xf0005000), | ||
169 | cpu_to_le32(0xf0005000), | ||
170 | }; | ||
171 | |||
172 | /* Full concurrency */ | ||
173 | static const __le32 iwl_concurrent_lookup[BT_COEX_LUT_SIZE] = { | ||
174 | cpu_to_le32(0xaaaaaaaa), | ||
175 | cpu_to_le32(0xaaaaaaaa), | ||
176 | cpu_to_le32(0xaaaaaaaa), | ||
177 | cpu_to_le32(0xaaaaaaaa), | ||
178 | cpu_to_le32(0xaaaaaaaa), | ||
179 | cpu_to_le32(0xaaaaaaaa), | ||
180 | cpu_to_le32(0xaaaaaaaa), | ||
181 | cpu_to_le32(0xaaaaaaaa), | ||
182 | cpu_to_le32(0x00000000), | ||
183 | cpu_to_le32(0x00000000), | ||
184 | cpu_to_le32(0x00000000), | ||
185 | cpu_to_le32(0x00000000), | ||
186 | }; | ||
187 | |||
188 | /* BT Antenna Coupling Threshold (dB) */ | ||
189 | #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35) | ||
190 | |||
191 | int iwl_send_bt_init_conf(struct iwl_mvm *mvm) | ||
192 | { | ||
193 | struct iwl_bt_coex_cmd cmd = { | ||
194 | .max_kill = 5, | ||
195 | .bt3_time_t7_value = 1, | ||
196 | .bt3_prio_sample_time = 2, | ||
197 | .bt3_timer_t2_value = 0xc, | ||
198 | }; | ||
199 | int ret; | ||
200 | |||
201 | cmd.flags = iwlwifi_mod_params.bt_coex_active ? | ||
202 | BT_COEX_NW : BT_COEX_DISABLE; | ||
203 | cmd.flags |= iwlwifi_mod_params.bt_ch_announce ? | ||
204 | BT_CH_PRIMARY_EN | BT_CH_SECONDARY_EN : 0; | ||
205 | cmd.flags |= BT_SYNC_2_BT_DISABLE; | ||
206 | |||
207 | cmd.valid_bit_msk = cpu_to_le16(BT_VALID_ENABLE | | ||
208 | BT_VALID_BT_PRIO_BOOST | | ||
209 | BT_VALID_MAX_KILL | | ||
210 | BT_VALID_3W_TMRS | | ||
211 | BT_VALID_KILL_ACK | | ||
212 | BT_VALID_KILL_CTS | | ||
213 | BT_VALID_REDUCED_TX_POWER | | ||
214 | BT_VALID_LUT); | ||
215 | |||
216 | if (iwlwifi_mod_params.ant_coupling > IWL_BT_ANTENNA_COUPLING_THRESHOLD) | ||
217 | memcpy(&cmd.decision_lut, iwl_loose_lookup, | ||
218 | sizeof(iwl_tight_lookup)); | ||
219 | else | ||
220 | memcpy(&cmd.decision_lut, iwl_tight_lookup, | ||
221 | sizeof(iwl_tight_lookup)); | ||
222 | |||
223 | cmd.bt_prio_boost = cpu_to_le32(IWL_BT_DEFAULT_BOOST); | ||
224 | cmd.kill_ack_msk = | ||
225 | cpu_to_le32(iwl_bt_ack_kill_msk[BT_KILL_MSK_DEFAULT]); | ||
226 | cmd.kill_cts_msk = | ||
227 | cpu_to_le32(iwl_bt_cts_kill_msk[BT_KILL_MSK_DEFAULT]); | ||
228 | |||
229 | /* go to CALIB state in internal BT-Coex state machine */ | ||
230 | ret = iwl_send_bt_env(mvm, BT_COEX_ENV_OPEN, | ||
231 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); | ||
232 | if (ret) | ||
233 | return ret; | ||
234 | |||
235 | ret = iwl_send_bt_env(mvm, BT_COEX_ENV_CLOSE, | ||
236 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); | ||
237 | if (ret) | ||
238 | return ret; | ||
239 | |||
240 | return iwl_mvm_send_cmd_pdu(mvm, BT_CONFIG, CMD_SYNC, | ||
241 | sizeof(cmd), &cmd); | ||
242 | } | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c index 0f45fa583aa1..1006b3204e7b 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw.c +++ b/drivers/net/wireless/iwlwifi/mvm/fw.c | |||
@@ -309,6 +309,10 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) | |||
309 | goto error; | 309 | goto error; |
310 | } | 310 | } |
311 | 311 | ||
312 | ret = iwl_send_bt_prio_tbl(mvm); | ||
313 | if (ret) | ||
314 | goto error; | ||
315 | |||
312 | if (read_nvm) { | 316 | if (read_nvm) { |
313 | /* Read nvm */ | 317 | /* Read nvm */ |
314 | ret = iwl_nvm_init(mvm); | 318 | ret = iwl_nvm_init(mvm); |
@@ -414,6 +418,14 @@ int iwl_mvm_up(struct iwl_mvm *mvm) | |||
414 | if (ret) | 418 | if (ret) |
415 | goto error; | 419 | goto error; |
416 | 420 | ||
421 | ret = iwl_send_bt_prio_tbl(mvm); | ||
422 | if (ret) | ||
423 | goto error; | ||
424 | |||
425 | ret = iwl_send_bt_init_conf(mvm); | ||
426 | if (ret) | ||
427 | goto error; | ||
428 | |||
417 | /* Send phy db control command and then phy db calibration*/ | 429 | /* Send phy db control command and then phy db calibration*/ |
418 | ret = iwl_send_phy_db_data(mvm->phy_db); | 430 | ret = iwl_send_phy_db_data(mvm->phy_db); |
419 | if (ret) | 431 | if (ret) |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h index 234c5726d196..b7f27d59fc24 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h | |||
@@ -504,4 +504,8 @@ void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw, | |||
504 | void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw, | 504 | void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw, |
505 | struct ieee80211_vif *vif, int idx); | 505 | struct ieee80211_vif *vif, int idx); |
506 | 506 | ||
507 | /* BT Coex */ | ||
508 | int iwl_send_bt_prio_tbl(struct iwl_mvm *mvm); | ||
509 | int iwl_send_bt_init_conf(struct iwl_mvm *mvm); | ||
510 | |||
507 | #endif /* __IWL_MVM_H__ */ | 511 | #endif /* __IWL_MVM_H__ */ |