1 /******************************************************************************
3 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *****************************************************************************/
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/delay.h>
31 #include <linux/skbuff.h>
32 #include <linux/netdevice.h>
33 #include <net/mac80211.h>
34 #include <linux/etherdevice.h>
35 #include <asm/unaligned.h>
36 #include <linux/stringify.h>
38 #include "iwl-eeprom.h"
43 #include "iwl-agn-hw.h"
44 #include "iwl-trans.h"
45 #include "iwl-shared.h"
48 /* Highest firmware API version supported */
49 #define IWL6000_UCODE_API_MAX 6
50 #define IWL6050_UCODE_API_MAX 5
51 #define IWL6000G2_UCODE_API_MAX 6
53 /* Oldest version we won't warn about */
54 #define IWL6000_UCODE_API_OK 4
55 #define IWL6000G2_UCODE_API_OK 5
57 /* Lowest firmware API version supported */
58 #define IWL6000_UCODE_API_MIN 4
59 #define IWL6050_UCODE_API_MIN 4
60 #define IWL6000G2_UCODE_API_MIN 4
62 #define IWL6000_FW_PRE "iwlwifi-6000-"
63 #define IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE __stringify(api) ".ucode"
65 #define IWL6050_FW_PRE "iwlwifi-6050-"
66 #define IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE __stringify(api) ".ucode"
68 #define IWL6005_FW_PRE "iwlwifi-6000g2a-"
69 #define IWL6005_MODULE_FIRMWARE(api) IWL6005_FW_PRE __stringify(api) ".ucode"
71 #define IWL6030_FW_PRE "iwlwifi-6000g2b-"
72 #define IWL6030_MODULE_FIRMWARE(api) IWL6030_FW_PRE __stringify(api) ".ucode"
74 static void iwl6000_set_ct_threshold(struct iwl_priv
*priv
)
77 hw_params(priv
).ct_kill_threshold
= CT_KILL_THRESHOLD
;
78 hw_params(priv
).ct_kill_exit_threshold
= CT_KILL_EXIT_THRESHOLD
;
81 static void iwl6050_additional_nic_config(struct iwl_priv
*priv
)
83 /* Indicate calibration version to uCode. */
84 if (iwl_eeprom_calib_version(priv
->shrd
) >= 6)
85 iwl_set_bit(trans(priv
), CSR_GP_DRIVER_REG
,
86 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6
);
89 static void iwl6150_additional_nic_config(struct iwl_priv
*priv
)
91 /* Indicate calibration version to uCode. */
92 if (iwl_eeprom_calib_version(priv
->shrd
) >= 6)
93 iwl_set_bit(trans(priv
), CSR_GP_DRIVER_REG
,
94 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6
);
95 iwl_set_bit(trans(priv
), CSR_GP_DRIVER_REG
,
96 CSR_GP_DRIVER_REG_BIT_6050_1x2
);
99 static void iwl6000i_additional_nic_config(struct iwl_priv
*priv
)
101 /* 2x2 IPA phy type */
102 iwl_write32(trans(priv
), CSR_GP_DRIVER_REG
,
103 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA
);
106 /* NIC configuration for 6000 series */
107 static void iwl6000_nic_config(struct iwl_priv
*priv
)
111 /* do additional nic configuration if needed */
112 if (cfg(priv
)->additional_nic_config
)
113 cfg(priv
)->additional_nic_config(priv
);
116 static const struct iwl_sensitivity_ranges iwl6000_sensitivity
= {
118 .auto_corr_min_ofdm
= 80,
119 .auto_corr_min_ofdm_mrc
= 128,
120 .auto_corr_min_ofdm_x1
= 105,
121 .auto_corr_min_ofdm_mrc_x1
= 192,
123 .auto_corr_max_ofdm
= 145,
124 .auto_corr_max_ofdm_mrc
= 232,
125 .auto_corr_max_ofdm_x1
= 110,
126 .auto_corr_max_ofdm_mrc_x1
= 232,
128 .auto_corr_min_cck
= 125,
129 .auto_corr_max_cck
= 175,
130 .auto_corr_min_cck_mrc
= 160,
131 .auto_corr_max_cck_mrc
= 310,
135 .barker_corr_th_min
= 190,
136 .barker_corr_th_min_mrc
= 336,
140 static void iwl6000_hw_set_hw_params(struct iwl_priv
*priv
)
142 hw_params(priv
).ht40_channel
= BIT(IEEE80211_BAND_2GHZ
) |
143 BIT(IEEE80211_BAND_5GHZ
);
145 hw_params(priv
).tx_chains_num
=
146 num_of_ant(hw_params(priv
).valid_tx_ant
);
147 if (cfg(priv
)->rx_with_siso_diversity
)
148 hw_params(priv
).rx_chains_num
= 1;
150 hw_params(priv
).rx_chains_num
=
151 num_of_ant(hw_params(priv
).valid_rx_ant
);
153 iwl6000_set_ct_threshold(priv
);
155 /* Set initial sensitivity parameters */
156 hw_params(priv
).sens
= &iwl6000_sensitivity
;
160 static int iwl6000_hw_channel_switch(struct iwl_priv
*priv
,
161 struct ieee80211_channel_switch
*ch_switch
)
165 * See iwlagn_mac_channel_switch.
167 struct iwl_rxon_context
*ctx
= &priv
->contexts
[IWL_RXON_CTX_BSS
];
168 struct iwl6000_channel_switch_cmd cmd
;
169 const struct iwl_channel_info
*ch_info
;
170 u32 switch_time_in_usec
, ucode_switch_time
;
174 u16 beacon_interval
= le16_to_cpu(ctx
->timing
.beacon_interval
);
175 struct ieee80211_vif
*vif
= ctx
->vif
;
176 struct iwl_host_cmd hcmd
= {
177 .id
= REPLY_CHANNEL_SWITCH
,
178 .len
= { sizeof(cmd
), },
183 cmd
.band
= priv
->band
== IEEE80211_BAND_2GHZ
;
184 ch
= ch_switch
->channel
->hw_value
;
185 IWL_DEBUG_11H(priv
, "channel switch from %u to %u\n",
186 ctx
->active
.channel
, ch
);
187 cmd
.channel
= cpu_to_le16(ch
);
188 cmd
.rxon_flags
= ctx
->staging
.flags
;
189 cmd
.rxon_filter_flags
= ctx
->staging
.filter_flags
;
190 switch_count
= ch_switch
->count
;
191 tsf_low
= ch_switch
->timestamp
& 0x0ffffffff;
193 * calculate the ucode channel switch time
194 * adding TSF as one of the factor for when to switch
196 if ((priv
->ucode_beacon_time
> tsf_low
) && beacon_interval
) {
197 if (switch_count
> ((priv
->ucode_beacon_time
- tsf_low
) /
199 switch_count
-= (priv
->ucode_beacon_time
-
200 tsf_low
) / beacon_interval
;
204 if (switch_count
<= 1)
205 cmd
.switch_time
= cpu_to_le32(priv
->ucode_beacon_time
);
207 switch_time_in_usec
=
208 vif
->bss_conf
.beacon_int
* switch_count
* TIME_UNIT
;
209 ucode_switch_time
= iwl_usecs_to_beacons(priv
,
212 cmd
.switch_time
= iwl_add_beacon_time(priv
,
213 priv
->ucode_beacon_time
,
217 IWL_DEBUG_11H(priv
, "uCode time for the switch is 0x%x\n",
219 ch_info
= iwl_get_channel_info(priv
, priv
->band
, ch
);
221 cmd
.expect_beacon
= is_channel_radar(ch_info
);
223 IWL_ERR(priv
, "invalid channel switch from %u to %u\n",
224 ctx
->active
.channel
, ch
);
228 return iwl_dvm_send_cmd(priv
, &hcmd
);
231 static struct iwl_lib_ops iwl6000_lib
= {
232 .set_hw_params
= iwl6000_hw_set_hw_params
,
233 .set_channel_switch
= iwl6000_hw_channel_switch
,
234 .nic_config
= iwl6000_nic_config
,
236 .regulatory_bands
= {
237 EEPROM_REG_BAND_1_CHANNELS
,
238 EEPROM_REG_BAND_2_CHANNELS
,
239 EEPROM_REG_BAND_3_CHANNELS
,
240 EEPROM_REG_BAND_4_CHANNELS
,
241 EEPROM_REG_BAND_5_CHANNELS
,
242 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
243 EEPROM_REG_BAND_52_HT40_CHANNELS
245 .enhanced_txpower
= true,
247 .temperature
= iwlagn_temperature
,
250 static struct iwl_lib_ops iwl6030_lib
= {
251 .set_hw_params
= iwl6000_hw_set_hw_params
,
252 .set_channel_switch
= iwl6000_hw_channel_switch
,
253 .nic_config
= iwl6000_nic_config
,
255 .regulatory_bands
= {
256 EEPROM_REG_BAND_1_CHANNELS
,
257 EEPROM_REG_BAND_2_CHANNELS
,
258 EEPROM_REG_BAND_3_CHANNELS
,
259 EEPROM_REG_BAND_4_CHANNELS
,
260 EEPROM_REG_BAND_5_CHANNELS
,
261 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
262 EEPROM_REG_BAND_52_HT40_CHANNELS
264 .enhanced_txpower
= true,
266 .temperature
= iwlagn_temperature
,
269 static const struct iwl_base_params iwl6000_base_params
= {
270 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
271 .num_of_queues
= IWLAGN_NUM_QUEUES
,
273 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
274 .shadow_ram_support
= true,
275 .led_compensation
= 51,
276 .adv_thermal_throttle
= true,
277 .support_ct_kill_exit
= true,
278 .plcp_delta_threshold
= IWL_MAX_PLCP_ERR_THRESHOLD_DEF
,
279 .chain_noise_scale
= 1000,
280 .wd_timeout
= IWL_DEF_WD_TIMEOUT
,
281 .max_event_log_size
= 512,
282 .shadow_reg_enable
= true,
285 static const struct iwl_base_params iwl6050_base_params
= {
286 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
287 .num_of_queues
= IWLAGN_NUM_QUEUES
,
289 .max_ll_items
= OTP_MAX_LL_ITEMS_6x50
,
290 .shadow_ram_support
= true,
291 .led_compensation
= 51,
292 .adv_thermal_throttle
= true,
293 .support_ct_kill_exit
= true,
294 .plcp_delta_threshold
= IWL_MAX_PLCP_ERR_THRESHOLD_DEF
,
295 .chain_noise_scale
= 1500,
296 .wd_timeout
= IWL_DEF_WD_TIMEOUT
,
297 .max_event_log_size
= 1024,
298 .shadow_reg_enable
= true,
301 static const struct iwl_base_params iwl6000_g2_base_params
= {
302 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
303 .num_of_queues
= IWLAGN_NUM_QUEUES
,
305 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
306 .shadow_ram_support
= true,
307 .led_compensation
= 57,
308 .adv_thermal_throttle
= true,
309 .support_ct_kill_exit
= true,
310 .plcp_delta_threshold
= IWL_MAX_PLCP_ERR_THRESHOLD_DEF
,
311 .chain_noise_scale
= 1000,
312 .wd_timeout
= IWL_LONG_WD_TIMEOUT
,
313 .max_event_log_size
= 512,
314 .shadow_reg_enable
= true,
317 static const struct iwl_ht_params iwl6000_ht_params
= {
318 .ht_greenfield_support
= true,
319 .use_rts_for_aggregation
= true, /* use rts/cts protection */
322 static const struct iwl_bt_params iwl6000_bt_params
= {
323 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
324 .advanced_bt_coexist
= true,
325 .agg_time_limit
= BT_AGG_THRESHOLD_DEF
,
326 .bt_init_traffic_load
= IWL_BT_COEX_TRAFFIC_LOAD_NONE
,
327 .bt_prio_boost
= IWLAGN_BT_PRIO_BOOST_DEFAULT
,
328 .bt_sco_disable
= true,
331 #define IWL_DEVICE_6005 \
332 .fw_name_pre = IWL6005_FW_PRE, \
333 .ucode_api_max = IWL6000G2_UCODE_API_MAX, \
334 .ucode_api_ok = IWL6000G2_UCODE_API_OK, \
335 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \
336 .max_inst_size = IWL60_RTC_INST_SIZE, \
337 .max_data_size = IWL60_RTC_DATA_SIZE, \
338 .eeprom_ver = EEPROM_6005_EEPROM_VERSION, \
339 .eeprom_calib_ver = EEPROM_6005_TX_POWER_VERSION, \
340 .lib = &iwl6000_lib, \
341 .base_params = &iwl6000_g2_base_params, \
342 .need_temp_offset_calib = true, \
343 .led_mode = IWL_LED_RF_STATE
345 const struct iwl_cfg iwl6005_2agn_cfg
= {
346 .name
= "Intel(R) Centrino(R) Advanced-N 6205 AGN",
348 .ht_params
= &iwl6000_ht_params
,
351 const struct iwl_cfg iwl6005_2abg_cfg
= {
352 .name
= "Intel(R) Centrino(R) Advanced-N 6205 ABG",
356 const struct iwl_cfg iwl6005_2bg_cfg
= {
357 .name
= "Intel(R) Centrino(R) Advanced-N 6205 BG",
361 const struct iwl_cfg iwl6005_2agn_sff_cfg
= {
362 .name
= "Intel(R) Centrino(R) Advanced-N 6205S AGN",
364 .ht_params
= &iwl6000_ht_params
,
367 const struct iwl_cfg iwl6005_2agn_d_cfg
= {
368 .name
= "Intel(R) Centrino(R) Advanced-N 6205D AGN",
370 .ht_params
= &iwl6000_ht_params
,
373 const struct iwl_cfg iwl6005_2agn_mow1_cfg
= {
374 .name
= "Intel(R) Centrino(R) Advanced-N 6206 AGN",
376 .ht_params
= &iwl6000_ht_params
,
379 const struct iwl_cfg iwl6005_2agn_mow2_cfg
= {
380 .name
= "Intel(R) Centrino(R) Advanced-N 6207 AGN",
382 .ht_params
= &iwl6000_ht_params
,
385 #define IWL_DEVICE_6030 \
386 .fw_name_pre = IWL6030_FW_PRE, \
387 .ucode_api_max = IWL6000G2_UCODE_API_MAX, \
388 .ucode_api_ok = IWL6000G2_UCODE_API_OK, \
389 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \
390 .max_inst_size = IWL60_RTC_INST_SIZE, \
391 .max_data_size = IWL60_RTC_DATA_SIZE, \
392 .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \
393 .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \
394 .lib = &iwl6030_lib, \
395 .base_params = &iwl6000_g2_base_params, \
396 .bt_params = &iwl6000_bt_params, \
397 .need_temp_offset_calib = true, \
398 .led_mode = IWL_LED_RF_STATE, \
401 const struct iwl_cfg iwl6030_2agn_cfg = {
402 .name
= "Intel(R) Centrino(R) Advanced-N 6230 AGN",
404 .ht_params
= &iwl6000_ht_params
,
407 const struct iwl_cfg iwl6030_2abg_cfg
= {
408 .name
= "Intel(R) Centrino(R) Advanced-N 6230 ABG",
412 const struct iwl_cfg iwl6030_2bgn_cfg
= {
413 .name
= "Intel(R) Centrino(R) Advanced-N 6230 BGN",
415 .ht_params
= &iwl6000_ht_params
,
418 const struct iwl_cfg iwl6030_2bg_cfg
= {
419 .name
= "Intel(R) Centrino(R) Advanced-N 6230 BG",
423 const struct iwl_cfg iwl6035_2agn_cfg
= {
424 .name
= "Intel(R) Centrino(R) Advanced-N 6235 AGN",
426 .ht_params
= &iwl6000_ht_params
,
429 const struct iwl_cfg iwl1030_bgn_cfg
= {
430 .name
= "Intel(R) Centrino(R) Wireless-N 1030 BGN",
432 .ht_params
= &iwl6000_ht_params
,
435 const struct iwl_cfg iwl1030_bg_cfg
= {
436 .name
= "Intel(R) Centrino(R) Wireless-N 1030 BG",
440 const struct iwl_cfg iwl130_bgn_cfg
= {
441 .name
= "Intel(R) Centrino(R) Wireless-N 130 BGN",
443 .ht_params
= &iwl6000_ht_params
,
444 .rx_with_siso_diversity
= true,
447 const struct iwl_cfg iwl130_bg_cfg
= {
448 .name
= "Intel(R) Centrino(R) Wireless-N 130 BG",
450 .rx_with_siso_diversity
= true,
454 * "i": Internal configuration, use internal Power Amplifier
456 #define IWL_DEVICE_6000i \
457 .fw_name_pre = IWL6000_FW_PRE, \
458 .ucode_api_max = IWL6000_UCODE_API_MAX, \
459 .ucode_api_ok = IWL6000_UCODE_API_OK, \
460 .ucode_api_min = IWL6000_UCODE_API_MIN, \
461 .max_inst_size = IWL60_RTC_INST_SIZE, \
462 .max_data_size = IWL60_RTC_DATA_SIZE, \
463 .valid_tx_ant = ANT_BC, /* .cfg overwrite */ \
464 .valid_rx_ant = ANT_BC, /* .cfg overwrite */ \
465 .eeprom_ver = EEPROM_6000_EEPROM_VERSION, \
466 .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, \
467 .lib = &iwl6000_lib, \
468 .additional_nic_config = iwl6000i_additional_nic_config,\
469 .base_params = &iwl6000_base_params, \
470 .led_mode = IWL_LED_BLINK
472 const struct iwl_cfg iwl6000i_2agn_cfg
= {
473 .name
= "Intel(R) Centrino(R) Advanced-N 6200 AGN",
475 .ht_params
= &iwl6000_ht_params
,
478 const struct iwl_cfg iwl6000i_2abg_cfg
= {
479 .name
= "Intel(R) Centrino(R) Advanced-N 6200 ABG",
483 const struct iwl_cfg iwl6000i_2bg_cfg
= {
484 .name
= "Intel(R) Centrino(R) Advanced-N 6200 BG",
488 #define IWL_DEVICE_6050 \
489 .fw_name_pre = IWL6050_FW_PRE, \
490 .ucode_api_max = IWL6050_UCODE_API_MAX, \
491 .ucode_api_min = IWL6050_UCODE_API_MIN, \
492 .max_inst_size = IWL60_RTC_INST_SIZE, \
493 .max_data_size = IWL60_RTC_DATA_SIZE, \
494 .valid_tx_ant = ANT_AB, /* .cfg overwrite */ \
495 .valid_rx_ant = ANT_AB, /* .cfg overwrite */ \
496 .lib = &iwl6000_lib, \
497 .additional_nic_config = iwl6050_additional_nic_config, \
498 .eeprom_ver = EEPROM_6050_EEPROM_VERSION, \
499 .eeprom_calib_ver = EEPROM_6050_TX_POWER_VERSION, \
500 .base_params = &iwl6050_base_params, \
501 .led_mode = IWL_LED_BLINK, \
502 .internal_wimax_coex = true
504 const struct iwl_cfg iwl6050_2agn_cfg
= {
505 .name
= "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN",
507 .ht_params
= &iwl6000_ht_params
,
510 const struct iwl_cfg iwl6050_2abg_cfg
= {
511 .name
= "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 ABG",
515 #define IWL_DEVICE_6150 \
516 .fw_name_pre = IWL6050_FW_PRE, \
517 .ucode_api_max = IWL6050_UCODE_API_MAX, \
518 .ucode_api_min = IWL6050_UCODE_API_MIN, \
519 .max_inst_size = IWL60_RTC_INST_SIZE, \
520 .max_data_size = IWL60_RTC_DATA_SIZE, \
521 .lib = &iwl6000_lib, \
522 .additional_nic_config = iwl6150_additional_nic_config, \
523 .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \
524 .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, \
525 .base_params = &iwl6050_base_params, \
526 .led_mode = IWL_LED_BLINK, \
527 .internal_wimax_coex = true
529 const struct iwl_cfg iwl6150_bgn_cfg
= {
530 .name
= "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN",
532 .ht_params
= &iwl6000_ht_params
,
535 const struct iwl_cfg iwl6150_bg_cfg
= {
536 .name
= "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG",
540 const struct iwl_cfg iwl6000_3agn_cfg
= {
541 .name
= "Intel(R) Centrino(R) Ultimate-N 6300 AGN",
542 .fw_name_pre
= IWL6000_FW_PRE
,
543 .ucode_api_max
= IWL6000_UCODE_API_MAX
,
544 .ucode_api_ok
= IWL6000_UCODE_API_OK
,
545 .ucode_api_min
= IWL6000_UCODE_API_MIN
,
546 .max_inst_size
= IWL60_RTC_INST_SIZE
,
547 .max_data_size
= IWL60_RTC_DATA_SIZE
,
548 .eeprom_ver
= EEPROM_6000_EEPROM_VERSION
,
549 .eeprom_calib_ver
= EEPROM_6000_TX_POWER_VERSION
,
551 .base_params
= &iwl6000_base_params
,
552 .ht_params
= &iwl6000_ht_params
,
553 .led_mode
= IWL_LED_BLINK
,
556 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_OK
));
557 MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX
));
558 MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX
));
559 MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX
));