1 /******************************************************************************
3 * Copyright(c) 2008 - 2011 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
56 #define IWL6050_UCODE_API_OK 5
57 #define IWL6000G2B_UCODE_API_OK 6
59 /* Lowest firmware API version supported */
60 #define IWL6000_UCODE_API_MIN 4
61 #define IWL6050_UCODE_API_MIN 4
62 #define IWL6000G2_UCODE_API_MIN 4
64 #define IWL6000_FW_PRE "iwlwifi-6000-"
65 #define IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE __stringify(api) ".ucode"
67 #define IWL6050_FW_PRE "iwlwifi-6050-"
68 #define IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE __stringify(api) ".ucode"
70 #define IWL6005_FW_PRE "iwlwifi-6000g2a-"
71 #define IWL6005_MODULE_FIRMWARE(api) IWL6005_FW_PRE __stringify(api) ".ucode"
73 #define IWL6030_FW_PRE "iwlwifi-6000g2b-"
74 #define IWL6030_MODULE_FIRMWARE(api) IWL6030_FW_PRE __stringify(api) ".ucode"
76 static void iwl6000_set_ct_threshold(struct iwl_priv
*priv
)
79 hw_params(priv
).ct_kill_threshold
= CT_KILL_THRESHOLD
;
80 hw_params(priv
).ct_kill_exit_threshold
= CT_KILL_EXIT_THRESHOLD
;
83 static void iwl6050_additional_nic_config(struct iwl_priv
*priv
)
85 /* Indicate calibration version to uCode. */
86 if (iwl_eeprom_calib_version(priv
->shrd
) >= 6)
87 iwl_set_bit(bus(priv
), CSR_GP_DRIVER_REG
,
88 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6
);
91 static void iwl6150_additional_nic_config(struct iwl_priv
*priv
)
93 /* Indicate calibration version to uCode. */
94 if (iwl_eeprom_calib_version(priv
->shrd
) >= 6)
95 iwl_set_bit(bus(priv
), CSR_GP_DRIVER_REG
,
96 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6
);
97 iwl_set_bit(bus(priv
), CSR_GP_DRIVER_REG
,
98 CSR_GP_DRIVER_REG_BIT_6050_1x2
);
101 /* NIC configuration for 6000 series */
102 static void iwl6000_nic_config(struct iwl_priv
*priv
)
106 /* no locking required for register write */
107 if (cfg(priv
)->pa_type
== IWL_PA_INTERNAL
) {
108 /* 2x2 IPA phy type */
109 iwl_write32(bus(priv
), CSR_GP_DRIVER_REG
,
110 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA
);
112 /* do additional nic configuration if needed */
113 if (cfg(priv
)->additional_nic_config
)
114 cfg(priv
)->additional_nic_config(priv
);
117 static struct iwl_sensitivity_ranges iwl6000_sensitivity
= {
119 .max_nrg_cck
= 0, /* not used, set to 0 */
120 .auto_corr_min_ofdm
= 80,
121 .auto_corr_min_ofdm_mrc
= 128,
122 .auto_corr_min_ofdm_x1
= 105,
123 .auto_corr_min_ofdm_mrc_x1
= 192,
125 .auto_corr_max_ofdm
= 145,
126 .auto_corr_max_ofdm_mrc
= 232,
127 .auto_corr_max_ofdm_x1
= 110,
128 .auto_corr_max_ofdm_mrc_x1
= 232,
130 .auto_corr_min_cck
= 125,
131 .auto_corr_max_cck
= 175,
132 .auto_corr_min_cck_mrc
= 160,
133 .auto_corr_max_cck_mrc
= 310,
137 .barker_corr_th_min
= 190,
138 .barker_corr_th_min_mrc
= 336,
142 static int iwl6000_hw_set_hw_params(struct iwl_priv
*priv
)
144 if (iwlagn_mod_params
.num_of_queues
>= IWL_MIN_NUM_QUEUES
&&
145 iwlagn_mod_params
.num_of_queues
<= IWLAGN_NUM_QUEUES
)
146 cfg(priv
)->base_params
->num_of_queues
=
147 iwlagn_mod_params
.num_of_queues
;
149 hw_params(priv
).max_txq_num
= cfg(priv
)->base_params
->num_of_queues
;
150 priv
->contexts
[IWL_RXON_CTX_BSS
].bcast_sta_id
= IWLAGN_BROADCAST_ID
;
152 hw_params(priv
).max_data_size
= IWL60_RTC_DATA_SIZE
;
153 hw_params(priv
).max_inst_size
= IWL60_RTC_INST_SIZE
;
155 hw_params(priv
).ht40_channel
= BIT(IEEE80211_BAND_2GHZ
) |
156 BIT(IEEE80211_BAND_5GHZ
);
158 hw_params(priv
).tx_chains_num
= num_of_ant(cfg(priv
)->valid_tx_ant
);
159 if (cfg(priv
)->rx_with_siso_diversity
)
160 hw_params(priv
).rx_chains_num
= 1;
162 hw_params(priv
).rx_chains_num
=
163 num_of_ant(cfg(priv
)->valid_rx_ant
);
164 hw_params(priv
).valid_tx_ant
= cfg(priv
)->valid_tx_ant
;
165 hw_params(priv
).valid_rx_ant
= cfg(priv
)->valid_rx_ant
;
167 iwl6000_set_ct_threshold(priv
);
169 /* Set initial sensitivity parameters */
170 hw_params(priv
).sens
= &iwl6000_sensitivity
;
175 static int iwl6000_hw_channel_switch(struct iwl_priv
*priv
,
176 struct ieee80211_channel_switch
*ch_switch
)
180 * See iwlagn_mac_channel_switch.
182 struct iwl_rxon_context
*ctx
= &priv
->contexts
[IWL_RXON_CTX_BSS
];
183 struct iwl6000_channel_switch_cmd cmd
;
184 const struct iwl_channel_info
*ch_info
;
185 u32 switch_time_in_usec
, ucode_switch_time
;
189 u16 beacon_interval
= le16_to_cpu(ctx
->timing
.beacon_interval
);
190 struct ieee80211_vif
*vif
= ctx
->vif
;
191 struct iwl_host_cmd hcmd
= {
192 .id
= REPLY_CHANNEL_SWITCH
,
193 .len
= { sizeof(cmd
), },
198 cmd
.band
= priv
->band
== IEEE80211_BAND_2GHZ
;
199 ch
= ch_switch
->channel
->hw_value
;
200 IWL_DEBUG_11H(priv
, "channel switch from %u to %u\n",
201 ctx
->active
.channel
, ch
);
202 cmd
.channel
= cpu_to_le16(ch
);
203 cmd
.rxon_flags
= ctx
->staging
.flags
;
204 cmd
.rxon_filter_flags
= ctx
->staging
.filter_flags
;
205 switch_count
= ch_switch
->count
;
206 tsf_low
= ch_switch
->timestamp
& 0x0ffffffff;
208 * calculate the ucode channel switch time
209 * adding TSF as one of the factor for when to switch
211 if ((priv
->ucode_beacon_time
> tsf_low
) && beacon_interval
) {
212 if (switch_count
> ((priv
->ucode_beacon_time
- tsf_low
) /
214 switch_count
-= (priv
->ucode_beacon_time
-
215 tsf_low
) / beacon_interval
;
219 if (switch_count
<= 1)
220 cmd
.switch_time
= cpu_to_le32(priv
->ucode_beacon_time
);
222 switch_time_in_usec
=
223 vif
->bss_conf
.beacon_int
* switch_count
* TIME_UNIT
;
224 ucode_switch_time
= iwl_usecs_to_beacons(priv
,
227 cmd
.switch_time
= iwl_add_beacon_time(priv
,
228 priv
->ucode_beacon_time
,
232 IWL_DEBUG_11H(priv
, "uCode time for the switch is 0x%x\n",
234 ch_info
= iwl_get_channel_info(priv
, priv
->band
, ch
);
236 cmd
.expect_beacon
= is_channel_radar(ch_info
);
238 IWL_ERR(priv
, "invalid channel switch from %u to %u\n",
239 ctx
->active
.channel
, ch
);
243 return iwl_trans_send_cmd(trans(priv
), &hcmd
);
246 static struct iwl_lib_ops iwl6000_lib
= {
247 .set_hw_params
= iwl6000_hw_set_hw_params
,
248 .set_channel_switch
= iwl6000_hw_channel_switch
,
249 .nic_config
= iwl6000_nic_config
,
251 .regulatory_bands
= {
252 EEPROM_REG_BAND_1_CHANNELS
,
253 EEPROM_REG_BAND_2_CHANNELS
,
254 EEPROM_REG_BAND_3_CHANNELS
,
255 EEPROM_REG_BAND_4_CHANNELS
,
256 EEPROM_REG_BAND_5_CHANNELS
,
257 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
258 EEPROM_REG_BAND_52_HT40_CHANNELS
260 .update_enhanced_txpower
= iwl_eeprom_enhanced_txpower
,
262 .temperature
= iwlagn_temperature
,
265 static struct iwl_lib_ops iwl6030_lib
= {
266 .set_hw_params
= iwl6000_hw_set_hw_params
,
267 .bt_rx_handler_setup
= iwlagn_bt_rx_handler_setup
,
268 .bt_setup_deferred_work
= iwlagn_bt_setup_deferred_work
,
269 .cancel_deferred_work
= iwlagn_bt_cancel_deferred_work
,
270 .set_channel_switch
= iwl6000_hw_channel_switch
,
271 .nic_config
= iwl6000_nic_config
,
273 .regulatory_bands
= {
274 EEPROM_REG_BAND_1_CHANNELS
,
275 EEPROM_REG_BAND_2_CHANNELS
,
276 EEPROM_REG_BAND_3_CHANNELS
,
277 EEPROM_REG_BAND_4_CHANNELS
,
278 EEPROM_REG_BAND_5_CHANNELS
,
279 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
280 EEPROM_REG_BAND_52_HT40_CHANNELS
282 .update_enhanced_txpower
= iwl_eeprom_enhanced_txpower
,
284 .temperature
= iwlagn_temperature
,
287 static struct iwl_base_params iwl6000_base_params
= {
288 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
289 .num_of_queues
= IWLAGN_NUM_QUEUES
,
290 .num_of_ampdu_queues
= IWLAGN_NUM_AMPDU_QUEUES
,
292 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
293 .shadow_ram_support
= true,
294 .led_compensation
= 51,
295 .adv_thermal_throttle
= true,
296 .support_ct_kill_exit
= true,
297 .plcp_delta_threshold
= IWL_MAX_PLCP_ERR_THRESHOLD_DEF
,
298 .chain_noise_scale
= 1000,
299 .wd_timeout
= IWL_DEF_WD_TIMEOUT
,
300 .max_event_log_size
= 512,
301 .shadow_reg_enable
= true,
304 static struct iwl_base_params iwl6050_base_params
= {
305 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
306 .num_of_queues
= IWLAGN_NUM_QUEUES
,
307 .num_of_ampdu_queues
= IWLAGN_NUM_AMPDU_QUEUES
,
309 .max_ll_items
= OTP_MAX_LL_ITEMS_6x50
,
310 .shadow_ram_support
= true,
311 .led_compensation
= 51,
312 .adv_thermal_throttle
= true,
313 .support_ct_kill_exit
= true,
314 .plcp_delta_threshold
= IWL_MAX_PLCP_ERR_THRESHOLD_DEF
,
315 .chain_noise_scale
= 1500,
316 .wd_timeout
= IWL_DEF_WD_TIMEOUT
,
317 .max_event_log_size
= 1024,
318 .shadow_reg_enable
= true,
320 static struct iwl_base_params iwl6000_g2_base_params
= {
321 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
322 .num_of_queues
= IWLAGN_NUM_QUEUES
,
323 .num_of_ampdu_queues
= IWLAGN_NUM_AMPDU_QUEUES
,
325 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
326 .shadow_ram_support
= true,
327 .led_compensation
= 57,
328 .adv_thermal_throttle
= true,
329 .support_ct_kill_exit
= true,
330 .plcp_delta_threshold
= IWL_MAX_PLCP_ERR_THRESHOLD_DEF
,
331 .chain_noise_scale
= 1000,
332 .wd_timeout
= IWL_LONG_WD_TIMEOUT
,
333 .max_event_log_size
= 512,
334 .shadow_reg_enable
= true,
337 static struct iwl_ht_params iwl6000_ht_params
= {
338 .ht_greenfield_support
= true,
339 .use_rts_for_aggregation
= true, /* use rts/cts protection */
342 static struct iwl_bt_params iwl6000_bt_params
= {
343 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
344 .advanced_bt_coexist
= true,
345 .agg_time_limit
= BT_AGG_THRESHOLD_DEF
,
346 .bt_init_traffic_load
= IWL_BT_COEX_TRAFFIC_LOAD_NONE
,
347 .bt_prio_boost
= IWLAGN_BT_PRIO_BOOST_DEFAULT
,
348 .bt_sco_disable
= true,
351 #define IWL_DEVICE_6005 \
352 .fw_name_pre = IWL6005_FW_PRE, \
353 .ucode_api_max = IWL6000G2_UCODE_API_MAX, \
354 .ucode_api_ok = IWL6000G2_UCODE_API_OK, \
355 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \
356 .eeprom_ver = EEPROM_6005_EEPROM_VERSION, \
357 .eeprom_calib_ver = EEPROM_6005_TX_POWER_VERSION, \
358 .lib = &iwl6000_lib, \
359 .base_params = &iwl6000_g2_base_params, \
360 .need_temp_offset_calib = true, \
361 .led_mode = IWL_LED_RF_STATE
363 struct iwl_cfg iwl6005_2agn_cfg
= {
364 .name
= "Intel(R) Centrino(R) Advanced-N 6205 AGN",
366 .ht_params
= &iwl6000_ht_params
,
369 struct iwl_cfg iwl6005_2abg_cfg
= {
370 .name
= "Intel(R) Centrino(R) Advanced-N 6205 ABG",
374 struct iwl_cfg iwl6005_2bg_cfg
= {
375 .name
= "Intel(R) Centrino(R) Advanced-N 6205 BG",
379 struct iwl_cfg iwl6005_2agn_sff_cfg
= {
380 .name
= "Intel(R) Centrino(R) Advanced-N 6205S AGN",
382 .ht_params
= &iwl6000_ht_params
,
385 struct iwl_cfg iwl6005_2agn_d_cfg
= {
386 .name
= "Intel(R) Centrino(R) Advanced-N 6205D AGN",
388 .ht_params
= &iwl6000_ht_params
,
391 #define IWL_DEVICE_6030 \
392 .fw_name_pre = IWL6030_FW_PRE, \
393 .ucode_api_max = IWL6000G2_UCODE_API_MAX, \
394 .ucode_api_ok = IWL6000G2B_UCODE_API_OK, \
395 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \
396 .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \
397 .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \
398 .lib = &iwl6030_lib, \
399 .base_params = &iwl6000_g2_base_params, \
400 .bt_params = &iwl6000_bt_params, \
401 .need_temp_offset_calib = true, \
402 .led_mode = IWL_LED_RF_STATE, \
405 struct iwl_cfg iwl6030_2agn_cfg = {
406 .name
= "Intel(R) Centrino(R) Advanced-N 6230 AGN",
408 .ht_params
= &iwl6000_ht_params
,
411 struct iwl_cfg iwl6030_2abg_cfg
= {
412 .name
= "Intel(R) Centrino(R) Advanced-N 6230 ABG",
416 struct iwl_cfg iwl6030_2bgn_cfg
= {
417 .name
= "Intel(R) Centrino(R) Advanced-N 6230 BGN",
419 .ht_params
= &iwl6000_ht_params
,
422 struct iwl_cfg iwl6030_2bg_cfg
= {
423 .name
= "Intel(R) Centrino(R) Advanced-N 6230 BG",
427 struct iwl_cfg iwl6035_2agn_cfg
= {
428 .name
= "Intel(R) Centrino(R) Advanced-N 6235 AGN",
430 .ht_params
= &iwl6000_ht_params
,
433 struct iwl_cfg iwl1030_bgn_cfg
= {
434 .name
= "Intel(R) Centrino(R) Wireless-N 1030 BGN",
436 .ht_params
= &iwl6000_ht_params
,
439 struct iwl_cfg iwl1030_bg_cfg
= {
440 .name
= "Intel(R) Centrino(R) Wireless-N 1030 BG",
444 struct iwl_cfg iwl130_bgn_cfg
= {
445 .name
= "Intel(R) Centrino(R) Wireless-N 130 BGN",
447 .ht_params
= &iwl6000_ht_params
,
448 .rx_with_siso_diversity
= true,
451 struct iwl_cfg iwl130_bg_cfg
= {
452 .name
= "Intel(R) Centrino(R) Wireless-N 130 BG",
454 .rx_with_siso_diversity
= true,
458 * "i": Internal configuration, use internal Power Amplifier
460 #define IWL_DEVICE_6000i \
461 .fw_name_pre = IWL6000_FW_PRE, \
462 .ucode_api_max = IWL6000_UCODE_API_MAX, \
463 .ucode_api_ok = IWL6000_UCODE_API_OK, \
464 .ucode_api_min = IWL6000_UCODE_API_MIN, \
465 .valid_tx_ant = ANT_BC, /* .cfg overwrite */ \
466 .valid_rx_ant = ANT_BC, /* .cfg overwrite */ \
467 .eeprom_ver = EEPROM_6000_EEPROM_VERSION, \
468 .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, \
469 .lib = &iwl6000_lib, \
470 .base_params = &iwl6000_base_params, \
471 .pa_type = IWL_PA_INTERNAL, \
472 .led_mode = IWL_LED_BLINK
474 struct iwl_cfg iwl6000i_2agn_cfg
= {
475 .name
= "Intel(R) Centrino(R) Advanced-N 6200 AGN",
477 .ht_params
= &iwl6000_ht_params
,
480 struct iwl_cfg iwl6000i_2abg_cfg
= {
481 .name
= "Intel(R) Centrino(R) Advanced-N 6200 ABG",
485 struct iwl_cfg iwl6000i_2bg_cfg
= {
486 .name
= "Intel(R) Centrino(R) Advanced-N 6200 BG",
490 #define IWL_DEVICE_6050 \
491 .fw_name_pre = IWL6050_FW_PRE, \
492 .ucode_api_max = IWL6050_UCODE_API_MAX, \
493 .ucode_api_min = IWL6050_UCODE_API_MIN, \
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 struct iwl_cfg iwl6050_2agn_cfg
= {
505 .name
= "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN",
507 .ht_params
= &iwl6000_ht_params
,
510 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 .lib = &iwl6000_lib, \
520 .additional_nic_config = iwl6150_additional_nic_config, \
521 .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \
522 .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, \
523 .base_params = &iwl6050_base_params, \
524 .led_mode = IWL_LED_BLINK, \
525 .internal_wimax_coex = true
527 struct iwl_cfg iwl6150_bgn_cfg
= {
528 .name
= "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN",
530 .ht_params
= &iwl6000_ht_params
,
533 struct iwl_cfg iwl6150_bg_cfg
= {
534 .name
= "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG",
538 struct iwl_cfg iwl6000_3agn_cfg
= {
539 .name
= "Intel(R) Centrino(R) Ultimate-N 6300 AGN",
540 .fw_name_pre
= IWL6000_FW_PRE
,
541 .ucode_api_max
= IWL6000_UCODE_API_MAX
,
542 .ucode_api_ok
= IWL6000_UCODE_API_OK
,
543 .ucode_api_min
= IWL6000_UCODE_API_MIN
,
544 .eeprom_ver
= EEPROM_6000_EEPROM_VERSION
,
545 .eeprom_calib_ver
= EEPROM_6000_TX_POWER_VERSION
,
547 .base_params
= &iwl6000_base_params
,
548 .ht_params
= &iwl6000_ht_params
,
549 .led_mode
= IWL_LED_BLINK
,
552 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_OK
));
553 MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_OK
));
554 MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_OK
));
555 MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2B_UCODE_API_OK
));