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-shared.h"
47
/* Highest firmware API version supported */
48
#define IWL2030_UCODE_API_MAX 6
49
#define IWL2000_UCODE_API_MAX 6
50
#define IWL105_UCODE_API_MAX 6
51
#define IWL135_UCODE_API_MAX 6
53
/* Oldest version we won't warn about */
54
#define IWL2030_UCODE_API_OK 5
55
#define IWL2000_UCODE_API_OK 5
56
#define IWL105_UCODE_API_OK 5
57
#define IWL135_UCODE_API_OK 5
59
/* Lowest firmware API version supported */
60
#define IWL2030_UCODE_API_MIN 5
61
#define IWL2000_UCODE_API_MIN 5
62
#define IWL105_UCODE_API_MIN 5
63
#define IWL135_UCODE_API_MIN 5
65
#define IWL2030_FW_PRE "iwlwifi-2030-"
66
#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode"
68
#define IWL2000_FW_PRE "iwlwifi-2000-"
69
#define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE __stringify(api) ".ucode"
71
#define IWL105_FW_PRE "iwlwifi-105-"
72
#define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE __stringify(api) ".ucode"
74
#define IWL135_FW_PRE "iwlwifi-135-"
75
#define IWL135_MODULE_FIRMWARE(api) IWL135_FW_PRE __stringify(api) ".ucode"
77
static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
80
hw_params(priv).ct_kill_threshold = CT_KILL_THRESHOLD;
81
hw_params(priv).ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
84
/* NIC configuration for 2000 series */
85
static void iwl2000_nic_config(struct iwl_priv *priv)
89
if (priv->cfg->iq_invert)
90
iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG,
91
CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
94
static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
96
.max_nrg_cck = 0, /* not used, set to 0 */
97
.auto_corr_min_ofdm = 80,
98
.auto_corr_min_ofdm_mrc = 128,
99
.auto_corr_min_ofdm_x1 = 105,
100
.auto_corr_min_ofdm_mrc_x1 = 192,
102
.auto_corr_max_ofdm = 145,
103
.auto_corr_max_ofdm_mrc = 232,
104
.auto_corr_max_ofdm_x1 = 110,
105
.auto_corr_max_ofdm_mrc_x1 = 232,
107
.auto_corr_min_cck = 125,
108
.auto_corr_max_cck = 175,
109
.auto_corr_min_cck_mrc = 160,
110
.auto_corr_max_cck_mrc = 310,
114
.barker_corr_th_min = 190,
115
.barker_corr_th_min_mrc = 390,
119
static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
121
if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
122
iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
123
priv->cfg->base_params->num_of_queues =
124
iwlagn_mod_params.num_of_queues;
126
hw_params(priv).max_txq_num = priv->cfg->base_params->num_of_queues;
127
priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
129
hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE;
130
hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE;
132
hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
134
hw_params(priv).tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
135
if (priv->cfg->rx_with_siso_diversity)
136
hw_params(priv).rx_chains_num = 1;
138
hw_params(priv).rx_chains_num =
139
num_of_ant(priv->cfg->valid_rx_ant);
140
hw_params(priv).valid_tx_ant = priv->cfg->valid_tx_ant;
141
hw_params(priv).valid_rx_ant = priv->cfg->valid_rx_ant;
143
iwl2000_set_ct_threshold(priv);
145
/* Set initial sensitivity parameters */
146
/* Set initial calibration set */
147
hw_params(priv).sens = &iwl2000_sensitivity;
148
hw_params(priv).calib_init_cfg =
149
BIT(IWL_CALIB_XTAL) |
151
BIT(IWL_CALIB_TX_IQ) |
152
BIT(IWL_CALIB_BASE_BAND);
153
if (priv->cfg->need_dc_calib)
154
hw_params(priv).calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
155
if (priv->cfg->need_temp_offset_calib)
156
hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
161
static struct iwl_lib_ops iwl2000_lib = {
162
.set_hw_params = iwl2000_hw_set_hw_params,
163
.nic_config = iwl2000_nic_config,
165
.regulatory_bands = {
166
EEPROM_REG_BAND_1_CHANNELS,
167
EEPROM_REG_BAND_2_CHANNELS,
168
EEPROM_REG_BAND_3_CHANNELS,
169
EEPROM_REG_BAND_4_CHANNELS,
170
EEPROM_REG_BAND_5_CHANNELS,
171
EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
172
EEPROM_REGULATORY_BAND_NO_HT40,
174
.update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
176
.temperature = iwlagn_temperature,
179
static struct iwl_lib_ops iwl2030_lib = {
180
.set_hw_params = iwl2000_hw_set_hw_params,
181
.bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
182
.bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
183
.cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
184
.nic_config = iwl2000_nic_config,
186
.regulatory_bands = {
187
EEPROM_REG_BAND_1_CHANNELS,
188
EEPROM_REG_BAND_2_CHANNELS,
189
EEPROM_REG_BAND_3_CHANNELS,
190
EEPROM_REG_BAND_4_CHANNELS,
191
EEPROM_REG_BAND_5_CHANNELS,
192
EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
193
EEPROM_REGULATORY_BAND_NO_HT40,
195
.update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
197
.temperature = iwlagn_temperature,
200
static struct iwl_base_params iwl2000_base_params = {
201
.eeprom_size = OTP_LOW_IMAGE_SIZE,
202
.num_of_queues = IWLAGN_NUM_QUEUES,
203
.num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
205
.max_ll_items = OTP_MAX_LL_ITEMS_2x00,
206
.shadow_ram_support = true,
207
.led_compensation = 51,
208
.adv_thermal_throttle = true,
209
.support_ct_kill_exit = true,
210
.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
211
.chain_noise_scale = 1000,
212
.wd_timeout = IWL_DEF_WD_TIMEOUT,
213
.max_event_log_size = 512,
214
.shadow_reg_enable = true,
219
static struct iwl_base_params iwl2030_base_params = {
220
.eeprom_size = OTP_LOW_IMAGE_SIZE,
221
.num_of_queues = IWLAGN_NUM_QUEUES,
222
.num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
224
.max_ll_items = OTP_MAX_LL_ITEMS_2x00,
225
.shadow_ram_support = true,
226
.led_compensation = 57,
227
.adv_thermal_throttle = true,
228
.support_ct_kill_exit = true,
229
.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
230
.chain_noise_scale = 1000,
231
.wd_timeout = IWL_LONG_WD_TIMEOUT,
232
.max_event_log_size = 512,
233
.shadow_reg_enable = true,
237
static struct iwl_ht_params iwl2000_ht_params = {
238
.ht_greenfield_support = true,
239
.use_rts_for_aggregation = true, /* use rts/cts protection */
242
static struct iwl_bt_params iwl2030_bt_params = {
243
/* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
244
.advanced_bt_coexist = true,
245
.agg_time_limit = BT_AGG_THRESHOLD_DEF,
246
.bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
247
.bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
248
.bt_sco_disable = true,
249
.bt_session_2 = true,
252
#define IWL_DEVICE_2000 \
253
.fw_name_pre = IWL2000_FW_PRE, \
254
.ucode_api_max = IWL2000_UCODE_API_MAX, \
255
.ucode_api_ok = IWL2000_UCODE_API_OK, \
256
.ucode_api_min = IWL2000_UCODE_API_MIN, \
257
.eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
258
.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
259
.lib = &iwl2000_lib, \
260
.base_params = &iwl2000_base_params, \
261
.need_dc_calib = true, \
262
.need_temp_offset_calib = true, \
263
.temp_offset_v2 = true, \
264
.led_mode = IWL_LED_RF_STATE, \
267
struct iwl_cfg iwl2000_2bgn_cfg = {
268
.name = "2000 Series 2x2 BGN",
270
.ht_params = &iwl2000_ht_params,
273
struct iwl_cfg iwl2000_2bg_cfg = {
274
.name = "2000 Series 2x2 BG",
278
struct iwl_cfg iwl2000_2bgn_d_cfg = {
279
.name = "2000D Series 2x2 BGN",
281
.ht_params = &iwl2000_ht_params,
284
#define IWL_DEVICE_2030 \
285
.fw_name_pre = IWL2030_FW_PRE, \
286
.ucode_api_max = IWL2030_UCODE_API_MAX, \
287
.ucode_api_ok = IWL2030_UCODE_API_OK, \
288
.ucode_api_min = IWL2030_UCODE_API_MIN, \
289
.eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
290
.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
291
.lib = &iwl2030_lib, \
292
.base_params = &iwl2030_base_params, \
293
.bt_params = &iwl2030_bt_params, \
294
.need_dc_calib = true, \
295
.need_temp_offset_calib = true, \
296
.temp_offset_v2 = true, \
297
.led_mode = IWL_LED_RF_STATE, \
301
struct iwl_cfg iwl2030_2bgn_cfg = {
302
.name = "2000 Series 2x2 BGN/BT",
304
.ht_params = &iwl2000_ht_params,
307
struct iwl_cfg iwl2030_2bg_cfg = {
308
.name = "2000 Series 2x2 BG/BT",
312
#define IWL_DEVICE_105 \
313
.fw_name_pre = IWL105_FW_PRE, \
314
.ucode_api_max = IWL105_UCODE_API_MAX, \
315
.ucode_api_ok = IWL105_UCODE_API_OK, \
316
.ucode_api_min = IWL105_UCODE_API_MIN, \
317
.eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
318
.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
319
.lib = &iwl2000_lib, \
320
.base_params = &iwl2000_base_params, \
321
.need_dc_calib = true, \
322
.need_temp_offset_calib = true, \
323
.temp_offset_v2 = true, \
324
.led_mode = IWL_LED_RF_STATE, \
326
.rx_with_siso_diversity = true, \
329
struct iwl_cfg iwl105_bg_cfg = {
330
.name = "105 Series 1x1 BG",
334
struct iwl_cfg iwl105_bgn_cfg = {
335
.name = "105 Series 1x1 BGN",
337
.ht_params = &iwl2000_ht_params,
340
struct iwl_cfg iwl105_bgn_d_cfg = {
341
.name = "105D Series 1x1 BGN",
343
.ht_params = &iwl2000_ht_params,
346
#define IWL_DEVICE_135 \
347
.fw_name_pre = IWL135_FW_PRE, \
348
.ucode_api_max = IWL135_UCODE_API_MAX, \
349
.ucode_api_ok = IWL135_UCODE_API_OK, \
350
.ucode_api_min = IWL135_UCODE_API_MIN, \
351
.eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
352
.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
353
.lib = &iwl2030_lib, \
354
.base_params = &iwl2030_base_params, \
355
.bt_params = &iwl2030_bt_params, \
356
.need_dc_calib = true, \
357
.need_temp_offset_calib = true, \
358
.temp_offset_v2 = true, \
359
.led_mode = IWL_LED_RF_STATE, \
361
.rx_with_siso_diversity = true, \
364
struct iwl_cfg iwl135_bg_cfg = {
365
.name = "135 Series 1x1 BG/BT",
369
struct iwl_cfg iwl135_bgn_cfg = {
370
.name = "135 Series 1x1 BGN/BT",
372
.ht_params = &iwl2000_ht_params,
375
MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
376
MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
377
MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
378
MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));