f14eb0b53c6f055791c875765d3fcd6f9d803998
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / iwl-2000.c
1 /******************************************************************************
2 *
3 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
4 *
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.
8 *
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
12 * more details.
13 *
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
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
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>
37
38 #include "iwl-eeprom.h"
39 #include "iwl-dev.h"
40 #include "iwl-core.h"
41 #include "iwl-io.h"
42 #include "iwl-agn.h"
43 #include "iwl-helpers.h"
44 #include "iwl-agn-hw.h"
45 #include "iwl-shared.h"
46 #include "iwl-cfg.h"
47
48 /* Highest firmware API version supported */
49 #define IWL2030_UCODE_API_MAX 6
50 #define IWL2000_UCODE_API_MAX 6
51 #define IWL105_UCODE_API_MAX 6
52 #define IWL135_UCODE_API_MAX 6
53
54 /* Oldest version we won't warn about */
55 #define IWL2030_UCODE_API_OK 5
56 #define IWL2000_UCODE_API_OK 5
57 #define IWL105_UCODE_API_OK 5
58 #define IWL135_UCODE_API_OK 5
59
60 /* Lowest firmware API version supported */
61 #define IWL2030_UCODE_API_MIN 5
62 #define IWL2000_UCODE_API_MIN 5
63 #define IWL105_UCODE_API_MIN 5
64 #define IWL135_UCODE_API_MIN 5
65
66 #define IWL2030_FW_PRE "iwlwifi-2030-"
67 #define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode"
68
69 #define IWL2000_FW_PRE "iwlwifi-2000-"
70 #define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE __stringify(api) ".ucode"
71
72 #define IWL105_FW_PRE "iwlwifi-105-"
73 #define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE __stringify(api) ".ucode"
74
75 #define IWL135_FW_PRE "iwlwifi-135-"
76 #define IWL135_MODULE_FIRMWARE(api) IWL135_FW_PRE __stringify(api) ".ucode"
77
78 static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
79 {
80 /* want Celsius */
81 hw_params(priv).ct_kill_threshold = CT_KILL_THRESHOLD;
82 hw_params(priv).ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
83 }
84
85 /* NIC configuration for 2000 series */
86 static void iwl2000_nic_config(struct iwl_priv *priv)
87 {
88 iwl_rf_config(priv);
89
90 if (priv->cfg->iq_invert)
91 iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG,
92 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
93 }
94
95 static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
96 .min_nrg_cck = 97,
97 .max_nrg_cck = 0, /* not used, set to 0 */
98 .auto_corr_min_ofdm = 80,
99 .auto_corr_min_ofdm_mrc = 128,
100 .auto_corr_min_ofdm_x1 = 105,
101 .auto_corr_min_ofdm_mrc_x1 = 192,
102
103 .auto_corr_max_ofdm = 145,
104 .auto_corr_max_ofdm_mrc = 232,
105 .auto_corr_max_ofdm_x1 = 110,
106 .auto_corr_max_ofdm_mrc_x1 = 232,
107
108 .auto_corr_min_cck = 125,
109 .auto_corr_max_cck = 175,
110 .auto_corr_min_cck_mrc = 160,
111 .auto_corr_max_cck_mrc = 310,
112 .nrg_th_cck = 97,
113 .nrg_th_ofdm = 100,
114
115 .barker_corr_th_min = 190,
116 .barker_corr_th_min_mrc = 390,
117 .nrg_th_cca = 62,
118 };
119
120 static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
121 {
122 if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
123 iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
124 priv->cfg->base_params->num_of_queues =
125 iwlagn_mod_params.num_of_queues;
126
127 hw_params(priv).max_txq_num = priv->cfg->base_params->num_of_queues;
128 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
129
130 hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE;
131 hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE;
132
133 hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
134
135 hw_params(priv).tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
136 if (priv->cfg->rx_with_siso_diversity)
137 hw_params(priv).rx_chains_num = 1;
138 else
139 hw_params(priv).rx_chains_num =
140 num_of_ant(priv->cfg->valid_rx_ant);
141 hw_params(priv).valid_tx_ant = priv->cfg->valid_tx_ant;
142 hw_params(priv).valid_rx_ant = priv->cfg->valid_rx_ant;
143
144 iwl2000_set_ct_threshold(priv);
145
146 /* Set initial sensitivity parameters */
147 /* Set initial calibration set */
148 hw_params(priv).sens = &iwl2000_sensitivity;
149 hw_params(priv).calib_init_cfg =
150 BIT(IWL_CALIB_XTAL) |
151 BIT(IWL_CALIB_LO) |
152 BIT(IWL_CALIB_TX_IQ) |
153 BIT(IWL_CALIB_BASE_BAND);
154 if (priv->cfg->need_dc_calib)
155 hw_params(priv).calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
156 if (priv->cfg->need_temp_offset_calib)
157 hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
158
159 return 0;
160 }
161
162 static struct iwl_lib_ops iwl2000_lib = {
163 .set_hw_params = iwl2000_hw_set_hw_params,
164 .nic_config = iwl2000_nic_config,
165 .eeprom_ops = {
166 .regulatory_bands = {
167 EEPROM_REG_BAND_1_CHANNELS,
168 EEPROM_REG_BAND_2_CHANNELS,
169 EEPROM_REG_BAND_3_CHANNELS,
170 EEPROM_REG_BAND_4_CHANNELS,
171 EEPROM_REG_BAND_5_CHANNELS,
172 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
173 EEPROM_REGULATORY_BAND_NO_HT40,
174 },
175 .update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
176 },
177 .temperature = iwlagn_temperature,
178 };
179
180 static struct iwl_lib_ops iwl2030_lib = {
181 .set_hw_params = iwl2000_hw_set_hw_params,
182 .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
183 .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
184 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
185 .nic_config = iwl2000_nic_config,
186 .eeprom_ops = {
187 .regulatory_bands = {
188 EEPROM_REG_BAND_1_CHANNELS,
189 EEPROM_REG_BAND_2_CHANNELS,
190 EEPROM_REG_BAND_3_CHANNELS,
191 EEPROM_REG_BAND_4_CHANNELS,
192 EEPROM_REG_BAND_5_CHANNELS,
193 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
194 EEPROM_REGULATORY_BAND_NO_HT40,
195 },
196 .update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
197 },
198 .temperature = iwlagn_temperature,
199 };
200
201 static struct iwl_base_params iwl2000_base_params = {
202 .eeprom_size = OTP_LOW_IMAGE_SIZE,
203 .num_of_queues = IWLAGN_NUM_QUEUES,
204 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
205 .pll_cfg_val = 0,
206 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
207 .shadow_ram_support = true,
208 .led_compensation = 51,
209 .adv_thermal_throttle = true,
210 .support_ct_kill_exit = true,
211 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
212 .chain_noise_scale = 1000,
213 .wd_timeout = IWL_DEF_WD_TIMEOUT,
214 .max_event_log_size = 512,
215 .shadow_reg_enable = true,
216 .hd_v2 = true,
217 };
218
219
220 static struct iwl_base_params iwl2030_base_params = {
221 .eeprom_size = OTP_LOW_IMAGE_SIZE,
222 .num_of_queues = IWLAGN_NUM_QUEUES,
223 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
224 .pll_cfg_val = 0,
225 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
226 .shadow_ram_support = true,
227 .led_compensation = 57,
228 .adv_thermal_throttle = true,
229 .support_ct_kill_exit = true,
230 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
231 .chain_noise_scale = 1000,
232 .wd_timeout = IWL_LONG_WD_TIMEOUT,
233 .max_event_log_size = 512,
234 .shadow_reg_enable = true,
235 .hd_v2 = true,
236 };
237
238 static struct iwl_ht_params iwl2000_ht_params = {
239 .ht_greenfield_support = true,
240 .use_rts_for_aggregation = true, /* use rts/cts protection */
241 };
242
243 static struct iwl_bt_params iwl2030_bt_params = {
244 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
245 .advanced_bt_coexist = true,
246 .agg_time_limit = BT_AGG_THRESHOLD_DEF,
247 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
248 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
249 .bt_sco_disable = true,
250 .bt_session_2 = true,
251 };
252
253 #define IWL_DEVICE_2000 \
254 .fw_name_pre = IWL2000_FW_PRE, \
255 .ucode_api_max = IWL2000_UCODE_API_MAX, \
256 .ucode_api_ok = IWL2000_UCODE_API_OK, \
257 .ucode_api_min = IWL2000_UCODE_API_MIN, \
258 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
259 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
260 .lib = &iwl2000_lib, \
261 .base_params = &iwl2000_base_params, \
262 .need_dc_calib = true, \
263 .need_temp_offset_calib = true, \
264 .temp_offset_v2 = true, \
265 .led_mode = IWL_LED_RF_STATE, \
266 .iq_invert = true \
267
268 struct iwl_cfg iwl2000_2bgn_cfg = {
269 .name = "2000 Series 2x2 BGN",
270 IWL_DEVICE_2000,
271 .ht_params = &iwl2000_ht_params,
272 };
273
274 struct iwl_cfg iwl2000_2bg_cfg = {
275 .name = "2000 Series 2x2 BG",
276 IWL_DEVICE_2000,
277 };
278
279 struct iwl_cfg iwl2000_2bgn_d_cfg = {
280 .name = "2000D Series 2x2 BGN",
281 IWL_DEVICE_2000,
282 .ht_params = &iwl2000_ht_params,
283 };
284
285 #define IWL_DEVICE_2030 \
286 .fw_name_pre = IWL2030_FW_PRE, \
287 .ucode_api_max = IWL2030_UCODE_API_MAX, \
288 .ucode_api_ok = IWL2030_UCODE_API_OK, \
289 .ucode_api_min = IWL2030_UCODE_API_MIN, \
290 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
291 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
292 .lib = &iwl2030_lib, \
293 .base_params = &iwl2030_base_params, \
294 .bt_params = &iwl2030_bt_params, \
295 .need_dc_calib = true, \
296 .need_temp_offset_calib = true, \
297 .temp_offset_v2 = true, \
298 .led_mode = IWL_LED_RF_STATE, \
299 .adv_pm = true, \
300 .iq_invert = true \
301
302 struct iwl_cfg iwl2030_2bgn_cfg = {
303 .name = "2000 Series 2x2 BGN/BT",
304 IWL_DEVICE_2030,
305 .ht_params = &iwl2000_ht_params,
306 };
307
308 struct iwl_cfg iwl2030_2bg_cfg = {
309 .name = "2000 Series 2x2 BG/BT",
310 IWL_DEVICE_2030,
311 };
312
313 #define IWL_DEVICE_105 \
314 .fw_name_pre = IWL105_FW_PRE, \
315 .ucode_api_max = IWL105_UCODE_API_MAX, \
316 .ucode_api_ok = IWL105_UCODE_API_OK, \
317 .ucode_api_min = IWL105_UCODE_API_MIN, \
318 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
319 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
320 .lib = &iwl2000_lib, \
321 .base_params = &iwl2000_base_params, \
322 .need_dc_calib = true, \
323 .need_temp_offset_calib = true, \
324 .temp_offset_v2 = true, \
325 .led_mode = IWL_LED_RF_STATE, \
326 .adv_pm = true, \
327 .rx_with_siso_diversity = true, \
328 .iq_invert = true \
329
330 struct iwl_cfg iwl105_bg_cfg = {
331 .name = "105 Series 1x1 BG",
332 IWL_DEVICE_105,
333 };
334
335 struct iwl_cfg iwl105_bgn_cfg = {
336 .name = "105 Series 1x1 BGN",
337 IWL_DEVICE_105,
338 .ht_params = &iwl2000_ht_params,
339 };
340
341 struct iwl_cfg iwl105_bgn_d_cfg = {
342 .name = "105D Series 1x1 BGN",
343 IWL_DEVICE_105,
344 .ht_params = &iwl2000_ht_params,
345 };
346
347 #define IWL_DEVICE_135 \
348 .fw_name_pre = IWL135_FW_PRE, \
349 .ucode_api_max = IWL135_UCODE_API_MAX, \
350 .ucode_api_ok = IWL135_UCODE_API_OK, \
351 .ucode_api_min = IWL135_UCODE_API_MIN, \
352 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
353 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
354 .lib = &iwl2030_lib, \
355 .base_params = &iwl2030_base_params, \
356 .bt_params = &iwl2030_bt_params, \
357 .need_dc_calib = true, \
358 .need_temp_offset_calib = true, \
359 .temp_offset_v2 = true, \
360 .led_mode = IWL_LED_RF_STATE, \
361 .adv_pm = true, \
362 .rx_with_siso_diversity = true, \
363 .iq_invert = true \
364
365 struct iwl_cfg iwl135_bg_cfg = {
366 .name = "135 Series 1x1 BG/BT",
367 IWL_DEVICE_135,
368 };
369
370 struct iwl_cfg iwl135_bgn_cfg = {
371 .name = "135 Series 1x1 BGN/BT",
372 IWL_DEVICE_135,
373 .ht_params = &iwl2000_ht_params,
374 };
375
376 MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
377 MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
378 MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
379 MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));
This page took 0.039341 seconds and 4 git commands to generate.