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 1
56 #define IWL6050_UCODE_API_MIN 1
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_HYBRID) {
94 /* 2x2 hybrid phy type */
95 iwl_write32(priv, CSR_GP_DRIVER_REG,
96 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_HYB);
97 } else if (priv->cfg->pa_type == IWL_PA_INTERNAL) {
98 /* 2x2 IPA phy type */
99 iwl_write32(priv, CSR_GP_DRIVER_REG,
100 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
102 /* else do nothing, uCode configured */
105 static struct iwl_sensitivity_ranges iwl6000_sensitivity = {
107 .max_nrg_cck = 0, /* not used, set to 0 */
108 .auto_corr_min_ofdm = 80,
109 .auto_corr_min_ofdm_mrc = 128,
110 .auto_corr_min_ofdm_x1 = 105,
111 .auto_corr_min_ofdm_mrc_x1 = 192,
113 .auto_corr_max_ofdm = 145,
114 .auto_corr_max_ofdm_mrc = 232,
115 .auto_corr_max_ofdm_x1 = 145,
116 .auto_corr_max_ofdm_mrc_x1 = 232,
118 .auto_corr_min_cck = 125,
119 .auto_corr_max_cck = 175,
120 .auto_corr_min_cck_mrc = 160,
121 .auto_corr_max_cck_mrc = 310,
125 .barker_corr_th_min = 190,
126 .barker_corr_th_min_mrc = 390,
130 static int iwl6000_hw_set_hw_params(struct iwl_priv *priv)
132 if ((priv->cfg->mod_params->num_of_queues > IWL50_NUM_QUEUES) ||
133 (priv->cfg->mod_params->num_of_queues < IWL_MIN_NUM_QUEUES)) {
135 "invalid queues_num, should be between %d and %d\n",
136 IWL_MIN_NUM_QUEUES, IWL50_NUM_QUEUES);
140 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
141 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
142 priv->hw_params.scd_bc_tbls_size =
143 IWL50_NUM_QUEUES * sizeof(struct iwl5000_scd_bc_tbl);
144 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
145 priv->hw_params.max_stations = IWL5000_STATION_COUNT;
146 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
148 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
149 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
151 priv->hw_params.max_bsm_size = 0;
152 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
153 BIT(IEEE80211_BAND_5GHZ);
154 priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
156 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
157 priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
158 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
159 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
161 if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
162 priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
164 /* Set initial sensitivity parameters */
165 /* Set initial calibration set */
166 priv->hw_params.sens = &iwl6000_sensitivity;
167 priv->hw_params.calib_init_cfg =
168 BIT(IWL_CALIB_XTAL) |
170 BIT(IWL_CALIB_TX_IQ) |
171 BIT(IWL_CALIB_TX_IQ_PERD) |
172 BIT(IWL_CALIB_BASE_BAND);
177 static struct iwl_lib_ops iwl6000_lib = {
178 .set_hw_params = iwl6000_hw_set_hw_params,
179 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
180 .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
181 .txq_set_sched = iwl5000_txq_set_sched,
182 .txq_agg_enable = iwl5000_txq_agg_enable,
183 .txq_agg_disable = iwl5000_txq_agg_disable,
184 .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
185 .txq_free_tfd = iwl_hw_txq_free_tfd,
186 .txq_init = iwl_hw_tx_queue_init,
187 .rx_handler_setup = iwl5000_rx_handler_setup,
188 .setup_deferred_work = iwl5000_setup_deferred_work,
189 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
190 .load_ucode = iwl5000_load_ucode,
191 .dump_nic_event_log = iwl_dump_nic_event_log,
192 .dump_nic_error_log = iwl_dump_nic_error_log,
193 .init_alive_start = iwl5000_init_alive_start,
194 .alive_notify = iwl5000_alive_notify,
195 .send_tx_power = iwl5000_send_tx_power,
196 .update_chain_flags = iwl_update_chain_flags,
198 .init = iwl5000_apm_init,
199 .stop = iwl_apm_stop,
200 .config = iwl6000_nic_config,
201 .set_pwr_src = iwl_set_pwr_src,
204 .regulatory_bands = {
205 EEPROM_5000_REG_BAND_1_CHANNELS,
206 EEPROM_5000_REG_BAND_2_CHANNELS,
207 EEPROM_5000_REG_BAND_3_CHANNELS,
208 EEPROM_5000_REG_BAND_4_CHANNELS,
209 EEPROM_5000_REG_BAND_5_CHANNELS,
210 EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
211 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
213 .verify_signature = iwlcore_eeprom_verify_signature,
214 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
215 .release_semaphore = iwlcore_eeprom_release_semaphore,
216 .calib_version = iwl5000_eeprom_calib_version,
217 .query_addr = iwl5000_eeprom_query_addr,
218 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
220 .post_associate = iwl_post_associate,
222 .config_ap = iwl_config_ap,
224 .temperature = iwl5000_temperature,
225 .set_ct_kill = iwl6000_set_ct_threshold,
229 static struct iwl_ops iwl6000_ops = {
230 .ucode = &iwl5000_ucode,
232 .hcmd = &iwl5000_hcmd,
233 .utils = &iwl5000_hcmd_utils,
234 .led = &iwlagn_led_ops,
239 * "h": Hybrid configuration, use both internal and external Power Amplifier
241 struct iwl_cfg iwl6000h_2agn_cfg = {
242 .name = "6000 Series 2x2 AGN",
243 .fw_name_pre = IWL6000_FW_PRE,
244 .ucode_api_max = IWL6000_UCODE_API_MAX,
245 .ucode_api_min = IWL6000_UCODE_API_MIN,
246 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
248 .eeprom_size = OTP_LOW_IMAGE_SIZE,
249 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
250 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
251 .mod_params = &iwl50_mod_params,
252 .valid_tx_ant = ANT_AB,
253 .valid_rx_ant = ANT_AB,
254 .need_pll_cfg = false,
255 .pa_type = IWL_PA_HYBRID,
256 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
257 .shadow_ram_support = true,
258 .ht_greenfield_support = true,
259 .led_compensation = 51,
260 .use_rts_for_ht = true, /* use rts/cts protection */
261 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
262 .supports_idle = true,
265 struct iwl_cfg iwl6000h_2abg_cfg = {
266 .name = "6000 Series 2x2 ABG",
267 .fw_name_pre = IWL6000_FW_PRE,
268 .ucode_api_max = IWL6000_UCODE_API_MAX,
269 .ucode_api_min = IWL6000_UCODE_API_MIN,
270 .sku = IWL_SKU_A|IWL_SKU_G,
272 .eeprom_size = OTP_LOW_IMAGE_SIZE,
273 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
274 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
275 .mod_params = &iwl50_mod_params,
276 .valid_tx_ant = ANT_AB,
277 .valid_rx_ant = ANT_AB,
278 .need_pll_cfg = false,
279 .pa_type = IWL_PA_HYBRID,
280 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
281 .shadow_ram_support = true,
282 .ht_greenfield_support = true,
283 .led_compensation = 51,
284 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
285 .supports_idle = true,
288 struct iwl_cfg iwl6000h_2bg_cfg = {
289 .name = "6000 Series 2x2 BG",
290 .fw_name_pre = IWL6000_FW_PRE,
291 .ucode_api_max = IWL6000_UCODE_API_MAX,
292 .ucode_api_min = IWL6000_UCODE_API_MIN,
295 .eeprom_size = OTP_LOW_IMAGE_SIZE,
296 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
297 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
298 .mod_params = &iwl50_mod_params,
299 .valid_tx_ant = ANT_AB,
300 .valid_rx_ant = ANT_AB,
301 .need_pll_cfg = false,
302 .pa_type = IWL_PA_HYBRID,
303 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
304 .shadow_ram_support = true,
305 .ht_greenfield_support = true,
306 .led_compensation = 51,
307 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
308 .supports_idle = true,
312 * "i": Internal configuration, use internal Power Amplifier
314 struct iwl_cfg iwl6000i_2agn_cfg = {
315 .name = "6000 Series 2x2 AGN",
316 .fw_name_pre = IWL6000_FW_PRE,
317 .ucode_api_max = IWL6000_UCODE_API_MAX,
318 .ucode_api_min = IWL6000_UCODE_API_MIN,
319 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
321 .eeprom_size = OTP_LOW_IMAGE_SIZE,
322 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
323 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
324 .mod_params = &iwl50_mod_params,
325 .valid_tx_ant = ANT_BC,
326 .valid_rx_ant = ANT_BC,
327 .need_pll_cfg = false,
328 .pa_type = IWL_PA_INTERNAL,
329 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
330 .shadow_ram_support = true,
331 .ht_greenfield_support = true,
332 .led_compensation = 51,
333 .use_rts_for_ht = true, /* use rts/cts protection */
334 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
335 .supports_idle = true,
338 struct iwl_cfg iwl6000i_2abg_cfg = {
339 .name = "6000 Series 2x2 ABG",
340 .fw_name_pre = IWL6000_FW_PRE,
341 .ucode_api_max = IWL6000_UCODE_API_MAX,
342 .ucode_api_min = IWL6000_UCODE_API_MIN,
343 .sku = IWL_SKU_A|IWL_SKU_G,
345 .eeprom_size = OTP_LOW_IMAGE_SIZE,
346 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
347 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
348 .mod_params = &iwl50_mod_params,
349 .valid_tx_ant = ANT_BC,
350 .valid_rx_ant = ANT_BC,
351 .need_pll_cfg = false,
352 .pa_type = IWL_PA_INTERNAL,
353 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
354 .shadow_ram_support = true,
355 .ht_greenfield_support = true,
356 .led_compensation = 51,
357 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
358 .supports_idle = true,
361 struct iwl_cfg iwl6000i_2bg_cfg = {
362 .name = "6000 Series 2x2 BG",
363 .fw_name_pre = IWL6000_FW_PRE,
364 .ucode_api_max = IWL6000_UCODE_API_MAX,
365 .ucode_api_min = IWL6000_UCODE_API_MIN,
368 .eeprom_size = OTP_LOW_IMAGE_SIZE,
369 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
370 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
371 .mod_params = &iwl50_mod_params,
372 .valid_tx_ant = ANT_BC,
373 .valid_rx_ant = ANT_BC,
374 .need_pll_cfg = false,
375 .pa_type = IWL_PA_INTERNAL,
376 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
377 .shadow_ram_support = true,
378 .ht_greenfield_support = true,
379 .led_compensation = 51,
380 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
381 .supports_idle = true,
384 struct iwl_cfg iwl6050_2agn_cfg = {
385 .name = "6050 Series 2x2 AGN",
386 .fw_name_pre = IWL6050_FW_PRE,
387 .ucode_api_max = IWL6050_UCODE_API_MAX,
388 .ucode_api_min = IWL6050_UCODE_API_MIN,
389 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
391 .eeprom_size = OTP_LOW_IMAGE_SIZE,
392 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
393 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
394 .mod_params = &iwl50_mod_params,
395 .valid_tx_ant = ANT_AB,
396 .valid_rx_ant = ANT_AB,
397 .need_pll_cfg = false,
398 .pa_type = IWL_PA_SYSTEM,
399 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
400 .shadow_ram_support = true,
401 .ht_greenfield_support = true,
402 .led_compensation = 51,
403 .use_rts_for_ht = true, /* use rts/cts protection */
404 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
405 .supports_idle = true,
408 struct iwl_cfg iwl6050_2abg_cfg = {
409 .name = "6050 Series 2x2 ABG",
410 .fw_name_pre = IWL6050_FW_PRE,
411 .ucode_api_max = IWL6050_UCODE_API_MAX,
412 .ucode_api_min = IWL6050_UCODE_API_MIN,
413 .sku = IWL_SKU_A|IWL_SKU_G,
415 .eeprom_size = OTP_LOW_IMAGE_SIZE,
416 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
417 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
418 .mod_params = &iwl50_mod_params,
419 .valid_tx_ant = ANT_AB,
420 .valid_rx_ant = ANT_AB,
421 .need_pll_cfg = false,
422 .pa_type = IWL_PA_SYSTEM,
423 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
424 .shadow_ram_support = true,
425 .ht_greenfield_support = true,
426 .led_compensation = 51,
427 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
428 .supports_idle = true,
431 struct iwl_cfg iwl6000_3agn_cfg = {
432 .name = "6000 Series 3x3 AGN",
433 .fw_name_pre = IWL6000_FW_PRE,
434 .ucode_api_max = IWL6000_UCODE_API_MAX,
435 .ucode_api_min = IWL6000_UCODE_API_MIN,
436 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
438 .eeprom_size = OTP_LOW_IMAGE_SIZE,
439 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
440 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
441 .mod_params = &iwl50_mod_params,
442 .valid_tx_ant = ANT_ABC,
443 .valid_rx_ant = ANT_ABC,
444 .need_pll_cfg = false,
445 .pa_type = IWL_PA_SYSTEM,
446 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
447 .shadow_ram_support = true,
448 .ht_greenfield_support = true,
449 .led_compensation = 51,
450 .use_rts_for_ht = true, /* use rts/cts protection */
451 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
452 .supports_idle = true,
455 struct iwl_cfg iwl6050_3agn_cfg = {
456 .name = "6050 Series 3x3 AGN",
457 .fw_name_pre = IWL6050_FW_PRE,
458 .ucode_api_max = IWL6050_UCODE_API_MAX,
459 .ucode_api_min = IWL6050_UCODE_API_MIN,
460 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
462 .eeprom_size = OTP_LOW_IMAGE_SIZE,
463 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
464 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
465 .mod_params = &iwl50_mod_params,
466 .valid_tx_ant = ANT_ABC,
467 .valid_rx_ant = ANT_ABC,
468 .need_pll_cfg = false,
469 .pa_type = IWL_PA_SYSTEM,
470 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
471 .shadow_ram_support = true,
472 .ht_greenfield_support = true,
473 .led_compensation = 51,
474 .use_rts_for_ht = true, /* use rts/cts protection */
475 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
476 .supports_idle = true,
479 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
480 MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));