1 /******************************************************************************
3 * Copyright(c) 2008-2009 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/pci.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/delay.h>
33 #include <linux/skbuff.h>
34 #include <linux/netdevice.h>
35 #include <linux/wireless.h>
36 #include <net/mac80211.h>
37 #include <linux/etherdevice.h>
38 #include <asm/unaligned.h>
40 #include "iwl-eeprom.h"
45 #include "iwl-helpers.h"
46 #include "iwl-5000-hw.h"
47 #include "iwl-6000-hw.h"
48 #include "iwl-agn-led.h"
50 /* Highest firmware API version supported */
51 #define IWL6000_UCODE_API_MAX 4
52 #define IWL6050_UCODE_API_MAX 4
54 /* Lowest firmware API version supported */
55 #define IWL6000_UCODE_API_MIN 4
56 #define IWL6050_UCODE_API_MIN 4
58 #define IWL6000_FW_PRE "iwlwifi-6000-"
59 #define _IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE #api ".ucode"
60 #define IWL6000_MODULE_FIRMWARE(api) _IWL6000_MODULE_FIRMWARE(api)
62 #define IWL6050_FW_PRE "iwlwifi-6050-"
63 #define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode"
64 #define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api)
66 static void iwl6000_set_ct_threshold(struct iwl_priv
*priv
)
69 priv
->hw_params
.ct_kill_threshold
= CT_KILL_THRESHOLD
;
70 priv
->hw_params
.ct_kill_exit_threshold
= CT_KILL_EXIT_THRESHOLD
;
73 /* NIC configuration for 6000 series */
74 static void iwl6000_nic_config(struct iwl_priv
*priv
)
78 radio_cfg
= iwl_eeprom_query16(priv
, EEPROM_RADIO_CONFIG
);
80 /* write radio config values to register */
81 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg
) <= EEPROM_RF_CONFIG_TYPE_MAX
)
82 iwl_set_bit(priv
, CSR_HW_IF_CONFIG_REG
,
83 EEPROM_RF_CFG_TYPE_MSK(radio_cfg
) |
84 EEPROM_RF_CFG_STEP_MSK(radio_cfg
) |
85 EEPROM_RF_CFG_DASH_MSK(radio_cfg
));
87 /* set CSR_HW_CONFIG_REG for uCode use */
88 iwl_set_bit(priv
, CSR_HW_IF_CONFIG_REG
,
89 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI
|
90 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI
);
92 /* no locking required for register write */
93 if (priv
->cfg
->pa_type
== IWL_PA_INTERNAL
) {
94 /* 2x2 IPA phy type */
95 iwl_write32(priv
, CSR_GP_DRIVER_REG
,
96 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA
);
98 /* else do nothing, uCode configured */
101 static struct iwl_sensitivity_ranges iwl6000_sensitivity
= {
103 .max_nrg_cck
= 0, /* not used, set to 0 */
104 .auto_corr_min_ofdm
= 80,
105 .auto_corr_min_ofdm_mrc
= 128,
106 .auto_corr_min_ofdm_x1
= 105,
107 .auto_corr_min_ofdm_mrc_x1
= 192,
109 .auto_corr_max_ofdm
= 145,
110 .auto_corr_max_ofdm_mrc
= 232,
111 .auto_corr_max_ofdm_x1
= 145,
112 .auto_corr_max_ofdm_mrc_x1
= 232,
114 .auto_corr_min_cck
= 125,
115 .auto_corr_max_cck
= 175,
116 .auto_corr_min_cck_mrc
= 160,
117 .auto_corr_max_cck_mrc
= 310,
121 .barker_corr_th_min
= 190,
122 .barker_corr_th_min_mrc
= 390,
126 static int iwl6000_hw_set_hw_params(struct iwl_priv
*priv
)
128 if (priv
->cfg
->mod_params
->num_of_queues
>= IWL_MIN_NUM_QUEUES
&&
129 priv
->cfg
->mod_params
->num_of_queues
<= IWL50_NUM_QUEUES
)
130 priv
->cfg
->num_of_queues
=
131 priv
->cfg
->mod_params
->num_of_queues
;
133 priv
->hw_params
.max_txq_num
= priv
->cfg
->num_of_queues
;
134 priv
->hw_params
.dma_chnl_num
= FH50_TCSR_CHNL_NUM
;
135 priv
->hw_params
.scd_bc_tbls_size
=
136 priv
->cfg
->num_of_queues
*
137 sizeof(struct iwl5000_scd_bc_tbl
);
138 priv
->hw_params
.tfd_size
= sizeof(struct iwl_tfd
);
139 priv
->hw_params
.max_stations
= IWL5000_STATION_COUNT
;
140 priv
->hw_params
.bcast_sta_id
= IWL5000_BROADCAST_ID
;
142 priv
->hw_params
.max_data_size
= IWL60_RTC_DATA_SIZE
;
143 priv
->hw_params
.max_inst_size
= IWL60_RTC_INST_SIZE
;
145 priv
->hw_params
.max_bsm_size
= 0;
146 priv
->hw_params
.ht40_channel
= BIT(IEEE80211_BAND_2GHZ
) |
147 BIT(IEEE80211_BAND_5GHZ
);
148 priv
->hw_params
.rx_wrt_ptr_reg
= FH_RSCSR_CHNL0_WPTR
;
150 priv
->hw_params
.tx_chains_num
= num_of_ant(priv
->cfg
->valid_tx_ant
);
151 priv
->hw_params
.rx_chains_num
= num_of_ant(priv
->cfg
->valid_rx_ant
);
152 priv
->hw_params
.valid_tx_ant
= priv
->cfg
->valid_tx_ant
;
153 priv
->hw_params
.valid_rx_ant
= priv
->cfg
->valid_rx_ant
;
155 if (priv
->cfg
->ops
->lib
->temp_ops
.set_ct_kill
)
156 priv
->cfg
->ops
->lib
->temp_ops
.set_ct_kill(priv
);
158 /* Set initial sensitivity parameters */
159 /* Set initial calibration set */
160 priv
->hw_params
.sens
= &iwl6000_sensitivity
;
161 priv
->hw_params
.calib_init_cfg
=
162 BIT(IWL_CALIB_XTAL
) |
164 BIT(IWL_CALIB_TX_IQ
) |
165 BIT(IWL_CALIB_BASE_BAND
);
169 static int iwl6000_hw_channel_switch(struct iwl_priv
*priv
, u16 channel
)
171 struct iwl6000_channel_switch_cmd cmd
;
172 const struct iwl_channel_info
*ch_info
;
173 struct iwl_host_cmd hcmd
= {
174 .id
= REPLY_CHANNEL_SWITCH
,
176 .flags
= CMD_SIZE_HUGE
,
180 IWL_DEBUG_11H(priv
, "channel switch from %d to %d\n",
181 priv
->active_rxon
.channel
, channel
);
183 cmd
.band
= priv
->band
== IEEE80211_BAND_2GHZ
;
184 cmd
.channel
= cpu_to_le16(channel
);
185 cmd
.rxon_flags
= priv
->staging_rxon
.flags
;
186 cmd
.rxon_filter_flags
= priv
->staging_rxon
.filter_flags
;
187 cmd
.switch_time
= cpu_to_le32(priv
->ucode_beacon_time
);
188 ch_info
= iwl_get_channel_info(priv
, priv
->band
, channel
);
190 cmd
.expect_beacon
= is_channel_radar(ch_info
);
192 IWL_ERR(priv
, "invalid channel switch from %u to %u\n",
193 priv
->active_rxon
.channel
, channel
);
196 priv
->switch_rxon
.channel
= cpu_to_le16(channel
);
197 priv
->switch_rxon
.switch_in_progress
= true;
199 return iwl_send_cmd_sync(priv
, &hcmd
);
202 static struct iwl_lib_ops iwl6000_lib
= {
203 .set_hw_params
= iwl6000_hw_set_hw_params
,
204 .txq_update_byte_cnt_tbl
= iwl5000_txq_update_byte_cnt_tbl
,
205 .txq_inval_byte_cnt_tbl
= iwl5000_txq_inval_byte_cnt_tbl
,
206 .txq_set_sched
= iwl5000_txq_set_sched
,
207 .txq_agg_enable
= iwl5000_txq_agg_enable
,
208 .txq_agg_disable
= iwl5000_txq_agg_disable
,
209 .txq_attach_buf_to_tfd
= iwl_hw_txq_attach_buf_to_tfd
,
210 .txq_free_tfd
= iwl_hw_txq_free_tfd
,
211 .txq_init
= iwl_hw_tx_queue_init
,
212 .rx_handler_setup
= iwl5000_rx_handler_setup
,
213 .setup_deferred_work
= iwl5000_setup_deferred_work
,
214 .is_valid_rtc_data_addr
= iwl5000_hw_valid_rtc_data_addr
,
215 .load_ucode
= iwl5000_load_ucode
,
216 .dump_nic_event_log
= iwl_dump_nic_event_log
,
217 .dump_nic_error_log
= iwl_dump_nic_error_log
,
218 .dump_csr
= iwl_dump_csr
,
219 .dump_fh
= iwl_dump_fh
,
220 .init_alive_start
= iwl5000_init_alive_start
,
221 .alive_notify
= iwl5000_alive_notify
,
222 .send_tx_power
= iwl5000_send_tx_power
,
223 .update_chain_flags
= iwl_update_chain_flags
,
224 .set_channel_switch
= iwl6000_hw_channel_switch
,
226 .init
= iwl_apm_init
,
227 .stop
= iwl_apm_stop
,
228 .config
= iwl6000_nic_config
,
229 .set_pwr_src
= iwl_set_pwr_src
,
232 .regulatory_bands
= {
233 EEPROM_5000_REG_BAND_1_CHANNELS
,
234 EEPROM_5000_REG_BAND_2_CHANNELS
,
235 EEPROM_5000_REG_BAND_3_CHANNELS
,
236 EEPROM_5000_REG_BAND_4_CHANNELS
,
237 EEPROM_5000_REG_BAND_5_CHANNELS
,
238 EEPROM_5000_REG_BAND_24_HT40_CHANNELS
,
239 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
241 .verify_signature
= iwlcore_eeprom_verify_signature
,
242 .acquire_semaphore
= iwlcore_eeprom_acquire_semaphore
,
243 .release_semaphore
= iwlcore_eeprom_release_semaphore
,
244 .calib_version
= iwl5000_eeprom_calib_version
,
245 .query_addr
= iwl5000_eeprom_query_addr
,
246 .update_enhanced_txpower
= iwlcore_eeprom_enhanced_txpower
,
248 .post_associate
= iwl_post_associate
,
250 .config_ap
= iwl_config_ap
,
252 .temperature
= iwl5000_temperature
,
253 .set_ct_kill
= iwl6000_set_ct_threshold
,
257 static const struct iwl_ops iwl6000_ops
= {
258 .ucode
= &iwl5000_ucode
,
260 .hcmd
= &iwl5000_hcmd
,
261 .utils
= &iwl5000_hcmd_utils
,
262 .led
= &iwlagn_led_ops
,
265 static struct iwl_hcmd_utils_ops iwl6050_hcmd_utils
= {
266 .get_hcmd_size
= iwl5000_get_hcmd_size
,
267 .build_addsta_hcmd
= iwl5000_build_addsta_hcmd
,
268 .rts_tx_cmd_flag
= iwl5000_rts_tx_cmd_flag
,
269 .calc_rssi
= iwl5000_calc_rssi
,
272 static const struct iwl_ops iwl6050_ops
= {
273 .ucode
= &iwl5000_ucode
,
275 .hcmd
= &iwl5000_hcmd
,
276 .utils
= &iwl6050_hcmd_utils
,
277 .led
= &iwlagn_led_ops
,
281 * "i": Internal configuration, use internal Power Amplifier
283 struct iwl_cfg iwl6000i_2agn_cfg
= {
284 .name
= "6000 Series 2x2 AGN",
285 .fw_name_pre
= IWL6000_FW_PRE
,
286 .ucode_api_max
= IWL6000_UCODE_API_MAX
,
287 .ucode_api_min
= IWL6000_UCODE_API_MIN
,
288 .sku
= IWL_SKU_A
|IWL_SKU_G
|IWL_SKU_N
,
290 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
291 .eeprom_ver
= EEPROM_6000_EEPROM_VERSION
,
292 .eeprom_calib_ver
= EEPROM_5000_TX_POWER_VERSION
,
293 .num_of_queues
= IWL50_NUM_QUEUES
,
294 .num_of_ampdu_queues
= IWL50_NUM_AMPDU_QUEUES
,
295 .mod_params
= &iwl50_mod_params
,
296 .valid_tx_ant
= ANT_BC
,
297 .valid_rx_ant
= ANT_BC
,
301 .pa_type
= IWL_PA_INTERNAL
,
302 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
303 .shadow_ram_support
= true,
304 .ht_greenfield_support
= true,
305 .led_compensation
= 51,
306 .use_rts_for_ht
= true, /* use rts/cts protection */
307 .chain_noise_num_beacons
= IWL_CAL_NUM_BEACONS
,
308 .supports_idle
= true,
309 .adv_thermal_throttle
= true,
310 .support_ct_kill_exit
= true,
313 struct iwl_cfg iwl6000i_2abg_cfg
= {
314 .name
= "6000 Series 2x2 ABG",
315 .fw_name_pre
= IWL6000_FW_PRE
,
316 .ucode_api_max
= IWL6000_UCODE_API_MAX
,
317 .ucode_api_min
= IWL6000_UCODE_API_MIN
,
318 .sku
= IWL_SKU_A
|IWL_SKU_G
,
320 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
321 .eeprom_ver
= EEPROM_6000_EEPROM_VERSION
,
322 .eeprom_calib_ver
= EEPROM_5000_TX_POWER_VERSION
,
323 .num_of_queues
= IWL50_NUM_QUEUES
,
324 .num_of_ampdu_queues
= IWL50_NUM_AMPDU_QUEUES
,
325 .mod_params
= &iwl50_mod_params
,
326 .valid_tx_ant
= ANT_BC
,
327 .valid_rx_ant
= ANT_BC
,
331 .pa_type
= IWL_PA_INTERNAL
,
332 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
333 .shadow_ram_support
= true,
334 .ht_greenfield_support
= true,
335 .led_compensation
= 51,
336 .chain_noise_num_beacons
= IWL_CAL_NUM_BEACONS
,
337 .supports_idle
= true,
338 .adv_thermal_throttle
= true,
339 .support_ct_kill_exit
= true,
342 struct iwl_cfg iwl6000i_2bg_cfg
= {
343 .name
= "6000 Series 2x2 BG",
344 .fw_name_pre
= IWL6000_FW_PRE
,
345 .ucode_api_max
= IWL6000_UCODE_API_MAX
,
346 .ucode_api_min
= IWL6000_UCODE_API_MIN
,
349 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
350 .eeprom_ver
= EEPROM_6000_EEPROM_VERSION
,
351 .eeprom_calib_ver
= EEPROM_5000_TX_POWER_VERSION
,
352 .num_of_queues
= IWL50_NUM_QUEUES
,
353 .num_of_ampdu_queues
= IWL50_NUM_AMPDU_QUEUES
,
354 .mod_params
= &iwl50_mod_params
,
355 .valid_tx_ant
= ANT_BC
,
356 .valid_rx_ant
= ANT_BC
,
360 .pa_type
= IWL_PA_INTERNAL
,
361 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
362 .shadow_ram_support
= true,
363 .ht_greenfield_support
= true,
364 .led_compensation
= 51,
365 .chain_noise_num_beacons
= IWL_CAL_NUM_BEACONS
,
366 .supports_idle
= true,
367 .adv_thermal_throttle
= true,
368 .support_ct_kill_exit
= true,
371 struct iwl_cfg iwl6050_2agn_cfg
= {
372 .name
= "6050 Series 2x2 AGN",
373 .fw_name_pre
= IWL6050_FW_PRE
,
374 .ucode_api_max
= IWL6050_UCODE_API_MAX
,
375 .ucode_api_min
= IWL6050_UCODE_API_MIN
,
376 .sku
= IWL_SKU_A
|IWL_SKU_G
|IWL_SKU_N
,
378 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
379 .eeprom_ver
= EEPROM_6050_EEPROM_VERSION
,
380 .eeprom_calib_ver
= EEPROM_5000_TX_POWER_VERSION
,
381 .num_of_queues
= IWL50_NUM_QUEUES
,
382 .num_of_ampdu_queues
= IWL50_NUM_AMPDU_QUEUES
,
383 .mod_params
= &iwl50_mod_params
,
384 .valid_tx_ant
= ANT_AB
,
385 .valid_rx_ant
= ANT_AB
,
389 .pa_type
= IWL_PA_SYSTEM
,
390 .max_ll_items
= OTP_MAX_LL_ITEMS_6x50
,
391 .shadow_ram_support
= true,
392 .ht_greenfield_support
= true,
393 .led_compensation
= 51,
394 .use_rts_for_ht
= true, /* use rts/cts protection */
395 .chain_noise_num_beacons
= IWL_CAL_NUM_BEACONS
,
396 .supports_idle
= true,
397 .adv_thermal_throttle
= true,
398 .support_ct_kill_exit
= true,
401 struct iwl_cfg iwl6050_2abg_cfg
= {
402 .name
= "6050 Series 2x2 ABG",
403 .fw_name_pre
= IWL6050_FW_PRE
,
404 .ucode_api_max
= IWL6050_UCODE_API_MAX
,
405 .ucode_api_min
= IWL6050_UCODE_API_MIN
,
406 .sku
= IWL_SKU_A
|IWL_SKU_G
,
408 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
409 .eeprom_ver
= EEPROM_6050_EEPROM_VERSION
,
410 .eeprom_calib_ver
= EEPROM_5000_TX_POWER_VERSION
,
411 .num_of_queues
= IWL50_NUM_QUEUES
,
412 .num_of_ampdu_queues
= IWL50_NUM_AMPDU_QUEUES
,
413 .mod_params
= &iwl50_mod_params
,
414 .valid_tx_ant
= ANT_AB
,
415 .valid_rx_ant
= ANT_AB
,
419 .pa_type
= IWL_PA_SYSTEM
,
420 .max_ll_items
= OTP_MAX_LL_ITEMS_6x50
,
421 .shadow_ram_support
= true,
422 .ht_greenfield_support
= true,
423 .led_compensation
= 51,
424 .chain_noise_num_beacons
= IWL_CAL_NUM_BEACONS
,
425 .supports_idle
= true,
426 .adv_thermal_throttle
= true,
427 .support_ct_kill_exit
= true,
430 struct iwl_cfg iwl6000_3agn_cfg
= {
431 .name
= "6000 Series 3x3 AGN",
432 .fw_name_pre
= IWL6000_FW_PRE
,
433 .ucode_api_max
= IWL6000_UCODE_API_MAX
,
434 .ucode_api_min
= IWL6000_UCODE_API_MIN
,
435 .sku
= IWL_SKU_A
|IWL_SKU_G
|IWL_SKU_N
,
437 .eeprom_size
= OTP_LOW_IMAGE_SIZE
,
438 .eeprom_ver
= EEPROM_6000_EEPROM_VERSION
,
439 .eeprom_calib_ver
= EEPROM_5000_TX_POWER_VERSION
,
440 .num_of_queues
= IWL50_NUM_QUEUES
,
441 .num_of_ampdu_queues
= IWL50_NUM_AMPDU_QUEUES
,
442 .mod_params
= &iwl50_mod_params
,
443 .valid_tx_ant
= ANT_ABC
,
444 .valid_rx_ant
= ANT_ABC
,
448 .pa_type
= IWL_PA_SYSTEM
,
449 .max_ll_items
= OTP_MAX_LL_ITEMS_6x00
,
450 .shadow_ram_support
= true,
451 .ht_greenfield_support
= true,
452 .led_compensation
= 51,
453 .use_rts_for_ht
= true, /* use rts/cts protection */
454 .chain_noise_num_beacons
= IWL_CAL_NUM_BEACONS
,
455 .supports_idle
= true,
456 .adv_thermal_throttle
= true,
457 .support_ct_kill_exit
= true,
460 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX
));
461 MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX
));