aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-08-23 10:56:55 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-25 14:33:21 -0400
commit670245ed4515cbc5e39e39d44965cb7add2c8aa9 (patch)
tree2cea9f64dba71f0aed837812eefc26e96425c05f
parent0288d237fff4cbe54879e3c3433ae5782874f98c (diff)
iwlagn: implement advance BT config command
6000g2b hardware implements advance bluetooth coexist command, implement base on the new API command strucutre. Also increment the API 5 to support the advance BT/WIfi coex. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c140
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h62
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h5
4 files changed, 203 insertions, 7 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 9e390f698641..fc2eeb00c78c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -52,7 +52,7 @@
52/* Highest firmware API version supported */ 52/* Highest firmware API version supported */
53#define IWL6000_UCODE_API_MAX 4 53#define IWL6000_UCODE_API_MAX 4
54#define IWL6050_UCODE_API_MAX 4 54#define IWL6050_UCODE_API_MAX 4
55#define IWL6000G2_UCODE_API_MAX 4 55#define IWL6000G2_UCODE_API_MAX 5
56 56
57/* Lowest firmware API version supported */ 57/* Lowest firmware API version supported */
58#define IWL6000_UCODE_API_MIN 4 58#define IWL6000_UCODE_API_MIN 4
@@ -122,6 +122,120 @@ static void iwl6000_nic_config(struct iwl_priv *priv)
122 priv->cfg->ops->lib->temp_ops.set_calib_version(priv); 122 priv->cfg->ops->lib->temp_ops.set_calib_version(priv);
123} 123}
124 124
125/*
126 * Macros to access the lookup table.
127 *
128 * The lookup table has 7 inputs: bt3_prio, bt3_txrx, bt_rf_act, wifi_req,
129 * wifi_prio, wifi_txrx and wifi_sh_ant_req.
130 *
131 * It has three outputs: WLAN_ACTIVE, WLAN_KILL and ANT_SWITCH
132 *
133 * The format is that "registers" 8 through 11 contain the WLAN_ACTIVE bits
134 * one after another in 32-bit registers, and "registers" 0 through 7 contain
135 * the WLAN_KILL and ANT_SWITCH bits interleaved (in that order).
136 *
137 * These macros encode that format.
138 */
139#define LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, wifi_req, wifi_prio, \
140 wifi_txrx, wifi_sh_ant_req) \
141 (bt3_prio | (bt3_txrx << 1) | (bt_rf_act << 2) | (wifi_req << 3) | \
142 (wifi_prio << 4) | (wifi_txrx << 5) | (wifi_sh_ant_req << 6))
143
144#define LUT_PTA_WLAN_ACTIVE_OP(lut, op, val) \
145 lut[8 + ((val) >> 5)] op (cpu_to_le32(BIT((val) & 0x1f)))
146#define LUT_TEST_PTA_WLAN_ACTIVE(lut, bt3_prio, bt3_txrx, bt_rf_act, \
147 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req) \
148 (!!(LUT_PTA_WLAN_ACTIVE_OP(lut, &, LUT_VALUE(bt3_prio, bt3_txrx,\
149 bt_rf_act, wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))))
150#define LUT_SET_PTA_WLAN_ACTIVE(lut, bt3_prio, bt3_txrx, bt_rf_act, \
151 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req) \
152 LUT_PTA_WLAN_ACTIVE_OP(lut, |=, LUT_VALUE(bt3_prio, bt3_txrx, \
153 bt_rf_act, wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
154#define LUT_CLEAR_PTA_WLAN_ACTIVE(lut, bt3_prio, bt3_txrx, bt_rf_act, \
155 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req) \
156 LUT_PTA_WLAN_ACTIVE_OP(lut, &= ~, LUT_VALUE(bt3_prio, bt3_txrx, \
157 bt_rf_act, wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
158
159#define LUT_WLAN_KILL_OP(lut, op, val) \
160 lut[(val) >> 4] op (cpu_to_le32(BIT(((val) << 1) & 0x1e)))
161#define LUT_TEST_WLAN_KILL(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
162 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
163 (!!(LUT_WLAN_KILL_OP(lut, &, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
164 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))))
165#define LUT_SET_WLAN_KILL(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
166 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
167 LUT_WLAN_KILL_OP(lut, |=, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
168 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
169#define LUT_CLEAR_WLAN_KILL(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
170 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
171 LUT_WLAN_KILL_OP(lut, &= ~, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
172 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
173
174#define LUT_ANT_SWITCH_OP(lut, op, val) \
175 lut[(val) >> 4] op (cpu_to_le32(BIT((((val) << 1) & 0x1e) + 1)))
176#define LUT_TEST_ANT_SWITCH(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
177 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
178 (!!(LUT_ANT_SWITCH_OP(lut, &, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
179 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))))
180#define LUT_SET_ANT_SWITCH(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
181 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
182 LUT_ANT_SWITCH_OP(lut, |=, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
183 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
184#define LUT_CLEAR_ANT_SWITCH(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
185 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
186 LUT_ANT_SWITCH_OP(lut, &= ~, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
187 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
188
189static const __le32 iwl6000g2b_def_3w_lookup[12] = {
190 cpu_to_le32(0xaaaaaaaa),
191 cpu_to_le32(0xaaaaaaaa),
192 cpu_to_le32(0xaeaaaaaa),
193 cpu_to_le32(0xaaaaaaaa),
194 cpu_to_le32(0xcc00ff28),
195 cpu_to_le32(0x0000aaaa),
196 cpu_to_le32(0xcc00aaaa),
197 cpu_to_le32(0x0000aaaa),
198 cpu_to_le32(0xc0004000),
199 cpu_to_le32(0x00004000),
200 cpu_to_le32(0xf0005000),
201 cpu_to_le32(0xf0004000),
202};
203
204static void iwl6000g2b_send_bt_config(struct iwl_priv *priv)
205{
206 struct iwl6000g2b_bt_cmd bt_cmd = {
207 .prio_boost = IWL6000G2B_BT_PRIO_BOOST_DEFAULT,
208 .max_kill = IWL6000G2B_BT_MAX_KILL_DEFAULT,
209 .bt3_timer_t7_value = IWL6000G2B_BT3_T7_DEFAULT,
210 .kill_ack_mask = IWL6000G2B_BT_KILL_ACK_MASK_DEFAULT,
211 .kill_cts_mask = IWL6000G2B_BT_KILL_CTS_MASK_DEFAULT,
212 .bt3_prio_sample_time = IWL6000G2B_BT3_PRIO_SAMPLE_DEFAULT,
213 .bt3_timer_t2_value = IWL6000G2B_BT3_T2_DEFAULT,
214 .valid = IWL6000G2B_BT_VALID_ENABLE_FLAGS,
215 };
216
217 BUILD_BUG_ON(sizeof(iwl6000g2b_def_3w_lookup) !=
218 sizeof(bt_cmd.bt3_lookup_table));
219
220 if (!bt_coex_active) {
221 bt_cmd.flags = 0;
222 } else {
223 bt_cmd.flags = IWL6000G2B_BT_FLAG_CHANNEL_INHIBITION |
224 IWL6000G2B_BT_FLAG_COEX_MODE_3W <<
225 IWL6000G2B_BT_FLAG_COEX_MODE_SHIFT;
226 bt_cmd.valid |= IWL6000G2B_BT_ALL_VALID_MSK;
227 }
228
229 memcpy(bt_cmd.bt3_lookup_table, iwl6000g2b_def_3w_lookup,
230 sizeof(iwl6000g2b_def_3w_lookup));
231
232 IWL_DEBUG_INFO(priv, "BT coex %s\n",
233 bt_cmd.flags ? "active" : "disabled");
234
235 if (iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, sizeof(bt_cmd), &bt_cmd))
236 IWL_ERR(priv, "failed to send BT Coex Config\n");
237}
238
125static struct iwl_sensitivity_ranges iwl6000_sensitivity = { 239static struct iwl_sensitivity_ranges iwl6000_sensitivity = {
126 .min_nrg_cck = 97, 240 .min_nrg_cck = 97,
127 .max_nrg_cck = 0, /* not used, set to 0 */ 241 .max_nrg_cck = 0, /* not used, set to 0 */
@@ -344,16 +458,12 @@ static const struct iwl_ops iwl6000_ops = {
344 .led = &iwlagn_led_ops, 458 .led = &iwlagn_led_ops,
345}; 459};
346 460
347static void do_not_send_bt_config(struct iwl_priv *priv)
348{
349}
350
351static struct iwl_hcmd_ops iwl6000g2b_hcmd = { 461static struct iwl_hcmd_ops iwl6000g2b_hcmd = {
352 .rxon_assoc = iwlagn_send_rxon_assoc, 462 .rxon_assoc = iwlagn_send_rxon_assoc,
353 .commit_rxon = iwl_commit_rxon, 463 .commit_rxon = iwl_commit_rxon,
354 .set_rxon_chain = iwl_set_rxon_chain, 464 .set_rxon_chain = iwl_set_rxon_chain,
355 .set_tx_ant = iwlagn_send_tx_ant_config, 465 .set_tx_ant = iwlagn_send_tx_ant_config,
356 .send_bt_config = do_not_send_bt_config, 466 .send_bt_config = iwl6000g2b_send_bt_config,
357}; 467};
358 468
359static const struct iwl_ops iwl6000g2b_ops = { 469static const struct iwl_ops iwl6000g2b_ops = {
@@ -507,6 +617,9 @@ struct iwl_cfg iwl6000g2b_2agn_cfg = {
507 .chain_noise_calib_by_driver = true, 617 .chain_noise_calib_by_driver = true,
508 .need_dc_calib = true, 618 .need_dc_calib = true,
509 .bt_statistics = true, 619 .bt_statistics = true,
620 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
621 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
622 .advanced_bt_coexist = true,
510}; 623};
511 624
512struct iwl_cfg iwl6000g2b_2abg_cfg = { 625struct iwl_cfg iwl6000g2b_2abg_cfg = {
@@ -543,6 +656,9 @@ struct iwl_cfg iwl6000g2b_2abg_cfg = {
543 .chain_noise_calib_by_driver = true, 656 .chain_noise_calib_by_driver = true,
544 .need_dc_calib = true, 657 .need_dc_calib = true,
545 .bt_statistics = true, 658 .bt_statistics = true,
659 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
660 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
661 .advanced_bt_coexist = true,
546}; 662};
547 663
548struct iwl_cfg iwl6000g2b_2bgn_cfg = { 664struct iwl_cfg iwl6000g2b_2bgn_cfg = {
@@ -581,6 +697,9 @@ struct iwl_cfg iwl6000g2b_2bgn_cfg = {
581 .chain_noise_calib_by_driver = true, 697 .chain_noise_calib_by_driver = true,
582 .need_dc_calib = true, 698 .need_dc_calib = true,
583 .bt_statistics = true, 699 .bt_statistics = true,
700 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
701 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
702 .advanced_bt_coexist = true,
584}; 703};
585 704
586struct iwl_cfg iwl6000g2b_2bg_cfg = { 705struct iwl_cfg iwl6000g2b_2bg_cfg = {
@@ -617,6 +736,9 @@ struct iwl_cfg iwl6000g2b_2bg_cfg = {
617 .chain_noise_calib_by_driver = true, 736 .chain_noise_calib_by_driver = true,
618 .need_dc_calib = true, 737 .need_dc_calib = true,
619 .bt_statistics = true, 738 .bt_statistics = true,
739 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
740 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
741 .advanced_bt_coexist = true,
620}; 742};
621 743
622struct iwl_cfg iwl6000g2b_bgn_cfg = { 744struct iwl_cfg iwl6000g2b_bgn_cfg = {
@@ -655,6 +777,9 @@ struct iwl_cfg iwl6000g2b_bgn_cfg = {
655 .chain_noise_calib_by_driver = true, 777 .chain_noise_calib_by_driver = true,
656 .need_dc_calib = true, 778 .need_dc_calib = true,
657 .bt_statistics = true, 779 .bt_statistics = true,
780 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
781 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
782 .advanced_bt_coexist = true,
658}; 783};
659 784
660struct iwl_cfg iwl6000g2b_bg_cfg = { 785struct iwl_cfg iwl6000g2b_bg_cfg = {
@@ -691,6 +816,9 @@ struct iwl_cfg iwl6000g2b_bg_cfg = {
691 .chain_noise_calib_by_driver = true, 816 .chain_noise_calib_by_driver = true,
692 .need_dc_calib = true, 817 .need_dc_calib = true,
693 .bt_statistics = true, 818 .bt_statistics = true,
819 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
820 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
821 .advanced_bt_coexist = true,
694}; 822};
695 823
696/* 824/*
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 78086ad6b72e..69fc7745edaa 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -2394,6 +2394,68 @@ struct iwl_bt_cmd {
2394 __le32 kill_cts_mask; 2394 __le32 kill_cts_mask;
2395} __packed; 2395} __packed;
2396 2396
2397#define IWL6000G2B_BT_FLAG_CHANNEL_INHIBITION BIT(0)
2398
2399#define IWL6000G2B_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
2400#define IWL6000G2B_BT_FLAG_COEX_MODE_SHIFT 3
2401#define IWL6000G2B_BT_FLAG_COEX_MODE_DISABLED 0
2402#define IWL6000G2B_BT_FLAG_COEX_MODE_LEGACY_2W 1
2403#define IWL6000G2B_BT_FLAG_COEX_MODE_3W 2
2404#define IWL6000G2B_BT_FLAG_COEX_MODE_4W 3
2405
2406#define IWL6000G2B_BT_FLAG_UCODE_DEFAULT BIT(6)
2407#define IWL6000G2B_BT_FLAG_NOCOEX_NOTIF BIT(7)
2408
2409#define IWL6000G2B_BT_PRIO_BOOST_MAX 0xFF
2410#define IWL6000G2B_BT_PRIO_BOOST_MIN 0x00
2411#define IWL6000G2B_BT_PRIO_BOOST_DEFAULT 0x00
2412
2413#define IWL6000G2B_BT_MAX_KILL_DEFAULT 5
2414
2415#define IWL6000G2B_BT3_T7_DEFAULT 1
2416
2417#define IWL6000G2B_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffffffff)
2418#define IWL6000G2B_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffffffff)
2419
2420#define IWL6000G2B_BT3_PRIO_SAMPLE_DEFAULT 2
2421
2422#define IWL6000G2B_BT3_T2_DEFAULT 0xc
2423
2424#define IWL6000G2B_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
2425#define IWL6000G2B_BT_VALID_BOOST cpu_to_le16(BIT(1))
2426#define IWL6000G2B_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
2427#define IWL6000G2B_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
2428#define IWL6000G2B_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
2429#define IWL6000G2B_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
2430#define IWL6000G2B_BT_VALID_BT4_TIMES cpu_to_le16(BIT(6))
2431#define IWL6000G2B_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
2432
2433#define IWL6000G2B_BT_ALL_VALID_MSK (IWL6000G2B_BT_VALID_ENABLE_FLAGS | \
2434 IWL6000G2B_BT_VALID_BOOST | \
2435 IWL6000G2B_BT_VALID_MAX_KILL | \
2436 IWL6000G2B_BT_VALID_3W_TIMERS | \
2437 IWL6000G2B_BT_VALID_KILL_ACK_MASK | \
2438 IWL6000G2B_BT_VALID_KILL_CTS_MASK | \
2439 IWL6000G2B_BT_VALID_BT4_TIMES | \
2440 IWL6000G2B_BT_VALID_3W_LUT)
2441
2442struct iwl6000g2b_bt_cmd {
2443 u8 flags;
2444 u8 ledtime; /* unused */
2445 u8 max_kill;
2446 u8 bt3_timer_t7_value;
2447 __le32 kill_ack_mask;
2448 __le32 kill_cts_mask;
2449 u8 bt3_prio_sample_time;
2450 u8 bt3_timer_t2_value;
2451 __le16 bt4_reaction_time; /* unused */
2452 __le32 bt3_lookup_table[12];
2453 __le16 bt4_decision_time; /* unused */
2454 __le16 valid;
2455 u8 prio_boost;
2456 u8 reserved[3];
2457};
2458
2397/****************************************************************************** 2459/******************************************************************************
2398 * (6) 2460 * (6)
2399 * Spectrum Management (802.11h) Commands, Responses, Notifications: 2461 * Spectrum Management (802.11h) Commands, Responses, Notifications:
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 3d9443b9bec1..4beddade7423 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -64,7 +64,8 @@ MODULE_LICENSE("GPL");
64 * 64 *
65 * default: bt_coex_active = true (BT_COEX_ENABLE) 65 * default: bt_coex_active = true (BT_COEX_ENABLE)
66 */ 66 */
67static bool bt_coex_active = true; 67bool bt_coex_active = true;
68EXPORT_SYMBOL_GPL(bt_coex_active);
68module_param(bt_coex_active, bool, S_IRUGO); 69module_param(bt_coex_active, bool, S_IRUGO);
69MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); 70MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist");
70 71
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 7b1e832bae56..d77337987156 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -278,6 +278,7 @@ struct iwl_mod_params {
278 * @chain_noise_calib_by_driver: driver has the capability to perform 278 * @chain_noise_calib_by_driver: driver has the capability to perform
279 * chain noise calibration operation 279 * chain noise calibration operation
280 * @scan_antennas: available antenna for scan operation 280 * @scan_antennas: available antenna for scan operation
281 * @advanced_bt_coexist: support advanced bt coexist
281 * @need_dc_calib: need to perform init dc calibration 282 * @need_dc_calib: need to perform init dc calibration
282 * @bt_statistics: use BT version of statistics notification 283 * @bt_statistics: use BT version of statistics notification
283 * @agg_time_limit: maximum number of uSec in aggregation 284 * @agg_time_limit: maximum number of uSec in aggregation
@@ -351,6 +352,7 @@ struct iwl_cfg {
351 const bool chain_noise_calib_by_driver; 352 const bool chain_noise_calib_by_driver;
352 u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; 353 u8 scan_rx_antennas[IEEE80211_NUM_BANDS];
353 u8 scan_tx_antennas[IEEE80211_NUM_BANDS]; 354 u8 scan_tx_antennas[IEEE80211_NUM_BANDS];
355 bool advanced_bt_coexist;
354 const bool need_dc_calib; 356 const bool need_dc_calib;
355 const bool bt_statistics; 357 const bool bt_statistics;
356 u16 agg_time_limit; 358 u16 agg_time_limit;
@@ -732,4 +734,7 @@ static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
732{ 734{
733 return priv->hw->wiphy->bands[band]; 735 return priv->hw->wiphy->bands[band];
734} 736}
737
738extern bool bt_coex_active;
739
735#endif /* __iwl_core_h__ */ 740#endif /* __iwl_core_h__ */