blob: 529cdac6f7391b22c8ab82b35c1932611bfffb53 [file] [log] [blame]
Johannes Berge9676692012-04-10 14:10:28 -07001/******************************************************************************
2 *
3 * Copyright(c) 2008 - 2012 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/*
28 * DVM device-specific data & functions
29 */
Johannes Berge9676692012-04-10 14:10:28 -070030#include "iwl-agn.h"
31#include "iwl-dev.h"
32#include "iwl-commands.h"
33#include "iwl-io.h"
34#include "iwl-prph.h"
35
36/*
37 * 1000 series
38 * ===========
39 */
40
41/*
42 * For 1000, use advance thermal throttling critical temperature threshold,
43 * but legacy thermal management implementation for now.
44 * This is for the reason of 1000 uCode using advance thermal throttling API
45 * but not implement ct_kill_exit based on ct_kill exit temperature
46 * so the thermal throttling will still based on legacy thermal throttling
47 * management.
48 * The code here need to be modified once 1000 uCode has the advanced thermal
49 * throttling algorithm in place
50 */
51static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
52{
53 /* want Celsius */
54 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
55 priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
56}
57
58/* NIC configuration for 1000 series */
59static void iwl1000_nic_config(struct iwl_priv *priv)
60{
61 /* set CSR_HW_CONFIG_REG for uCode use */
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -070062 iwl_set_bit(priv->trans, CSR_HW_IF_CONFIG_REG,
Johannes Berge9676692012-04-10 14:10:28 -070063 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
64 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
65
66 /* Setting digital SVR for 1000 card to 1.32V */
67 /* locking is acquired in iwl_set_bits_mask_prph() function */
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -070068 iwl_set_bits_mask_prph(priv->trans, APMG_DIGITAL_SVR_REG,
Johannes Berge9676692012-04-10 14:10:28 -070069 APMG_SVR_DIGITAL_VOLTAGE_1_32,
70 ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
71}
72
Meenakshi Venkataramane381b212012-03-13 15:18:07 -070073/**
74 * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time
75 * @priv -- pointer to iwl_priv data structure
76 * @tsf_bits -- number of bits need to shift for masking)
77 */
78static inline u32 iwl_beacon_time_mask_low(struct iwl_priv *priv,
79 u16 tsf_bits)
80{
81 return (1 << tsf_bits) - 1;
82}
83
84/**
85 * iwl_beacon_time_mask_high - mask of higher 32 bit of beacon time
86 * @priv -- pointer to iwl_priv data structure
87 * @tsf_bits -- number of bits need to shift for masking)
88 */
89static inline u32 iwl_beacon_time_mask_high(struct iwl_priv *priv,
90 u16 tsf_bits)
91{
92 return ((1 << (32 - tsf_bits)) - 1) << tsf_bits;
93}
94
95/*
96 * extended beacon time format
97 * time in usec will be changed into a 32-bit value in extended:internal format
98 * the extended part is the beacon counts
99 * the internal part is the time in usec within one beacon interval
100 */
101static u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec,
102 u32 beacon_interval)
103{
104 u32 quot;
105 u32 rem;
106 u32 interval = beacon_interval * TIME_UNIT;
107
108 if (!interval || !usec)
109 return 0;
110
111 quot = (usec / interval) &
112 (iwl_beacon_time_mask_high(priv, IWLAGN_EXT_BEACON_TIME_POS) >>
113 IWLAGN_EXT_BEACON_TIME_POS);
114 rem = (usec % interval) & iwl_beacon_time_mask_low(priv,
115 IWLAGN_EXT_BEACON_TIME_POS);
116
117 return (quot << IWLAGN_EXT_BEACON_TIME_POS) + rem;
118}
119
120/* base is usually what we get from ucode with each received frame,
121 * the same as HW timer counter counting down
122 */
123static __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
124 u32 addon, u32 beacon_interval)
125{
126 u32 base_low = base & iwl_beacon_time_mask_low(priv,
127 IWLAGN_EXT_BEACON_TIME_POS);
128 u32 addon_low = addon & iwl_beacon_time_mask_low(priv,
129 IWLAGN_EXT_BEACON_TIME_POS);
130 u32 interval = beacon_interval * TIME_UNIT;
131 u32 res = (base & iwl_beacon_time_mask_high(priv,
132 IWLAGN_EXT_BEACON_TIME_POS)) +
133 (addon & iwl_beacon_time_mask_high(priv,
134 IWLAGN_EXT_BEACON_TIME_POS));
135
136 if (base_low > addon_low)
137 res += base_low - addon_low;
138 else if (base_low < addon_low) {
139 res += interval + base_low - addon_low;
140 res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
141 } else
142 res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
143
144 return cpu_to_le32(res);
145}
146
Johannes Berge9676692012-04-10 14:10:28 -0700147static const struct iwl_sensitivity_ranges iwl1000_sensitivity = {
148 .min_nrg_cck = 95,
149 .auto_corr_min_ofdm = 90,
150 .auto_corr_min_ofdm_mrc = 170,
151 .auto_corr_min_ofdm_x1 = 120,
152 .auto_corr_min_ofdm_mrc_x1 = 240,
153
154 .auto_corr_max_ofdm = 120,
155 .auto_corr_max_ofdm_mrc = 210,
156 .auto_corr_max_ofdm_x1 = 155,
157 .auto_corr_max_ofdm_mrc_x1 = 290,
158
159 .auto_corr_min_cck = 125,
160 .auto_corr_max_cck = 200,
161 .auto_corr_min_cck_mrc = 170,
162 .auto_corr_max_cck_mrc = 400,
163 .nrg_th_cck = 95,
164 .nrg_th_ofdm = 95,
165
166 .barker_corr_th_min = 190,
167 .barker_corr_th_min_mrc = 390,
168 .nrg_th_cca = 62,
169};
170
171static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
172{
173 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ);
174
175 priv->hw_params.tx_chains_num =
176 num_of_ant(priv->hw_params.valid_tx_ant);
Emmanuel Grumbach21522682012-03-22 17:51:44 +0200177 if (priv->cfg->rx_with_siso_diversity)
Johannes Berge9676692012-04-10 14:10:28 -0700178 priv->hw_params.rx_chains_num = 1;
179 else
180 priv->hw_params.rx_chains_num =
181 num_of_ant(priv->hw_params.valid_rx_ant);
182
183 iwl1000_set_ct_threshold(priv);
184
185 /* Set initial sensitivity parameters */
186 priv->hw_params.sens = &iwl1000_sensitivity;
187}
188
189struct iwl_lib_ops iwl1000_lib = {
190 .set_hw_params = iwl1000_hw_set_hw_params,
191 .nic_config = iwl1000_nic_config,
192 .eeprom_ops = {
193 .regulatory_bands = {
194 EEPROM_REG_BAND_1_CHANNELS,
195 EEPROM_REG_BAND_2_CHANNELS,
196 EEPROM_REG_BAND_3_CHANNELS,
197 EEPROM_REG_BAND_4_CHANNELS,
198 EEPROM_REG_BAND_5_CHANNELS,
199 EEPROM_REG_BAND_24_HT40_CHANNELS,
200 EEPROM_REGULATORY_BAND_NO_HT40,
201 },
202 },
203 .temperature = iwlagn_temperature,
204};
205
206
207/*
208 * 2000 series
209 * ===========
210 */
211
212static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
213{
214 /* want Celsius */
215 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
216 priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
217}
218
219/* NIC configuration for 2000 series */
220static void iwl2000_nic_config(struct iwl_priv *priv)
221{
222 iwl_rf_config(priv);
223
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700224 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
Johannes Berge9676692012-04-10 14:10:28 -0700225 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
226}
227
228static const struct iwl_sensitivity_ranges iwl2000_sensitivity = {
229 .min_nrg_cck = 97,
230 .auto_corr_min_ofdm = 80,
231 .auto_corr_min_ofdm_mrc = 128,
232 .auto_corr_min_ofdm_x1 = 105,
233 .auto_corr_min_ofdm_mrc_x1 = 192,
234
235 .auto_corr_max_ofdm = 145,
236 .auto_corr_max_ofdm_mrc = 232,
237 .auto_corr_max_ofdm_x1 = 110,
238 .auto_corr_max_ofdm_mrc_x1 = 232,
239
240 .auto_corr_min_cck = 125,
241 .auto_corr_max_cck = 175,
242 .auto_corr_min_cck_mrc = 160,
243 .auto_corr_max_cck_mrc = 310,
244 .nrg_th_cck = 97,
245 .nrg_th_ofdm = 100,
246
247 .barker_corr_th_min = 190,
248 .barker_corr_th_min_mrc = 390,
249 .nrg_th_cca = 62,
250};
251
252static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
253{
254 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ);
255
256 priv->hw_params.tx_chains_num =
257 num_of_ant(priv->hw_params.valid_tx_ant);
Emmanuel Grumbach21522682012-03-22 17:51:44 +0200258 if (priv->cfg->rx_with_siso_diversity)
Johannes Berge9676692012-04-10 14:10:28 -0700259 priv->hw_params.rx_chains_num = 1;
260 else
261 priv->hw_params.rx_chains_num =
262 num_of_ant(priv->hw_params.valid_rx_ant);
263
264 iwl2000_set_ct_threshold(priv);
265
266 /* Set initial sensitivity parameters */
267 priv->hw_params.sens = &iwl2000_sensitivity;
268}
269
270struct iwl_lib_ops iwl2000_lib = {
271 .set_hw_params = iwl2000_hw_set_hw_params,
272 .nic_config = iwl2000_nic_config,
273 .eeprom_ops = {
274 .regulatory_bands = {
275 EEPROM_REG_BAND_1_CHANNELS,
276 EEPROM_REG_BAND_2_CHANNELS,
277 EEPROM_REG_BAND_3_CHANNELS,
278 EEPROM_REG_BAND_4_CHANNELS,
279 EEPROM_REG_BAND_5_CHANNELS,
280 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
281 EEPROM_REGULATORY_BAND_NO_HT40,
282 },
283 .enhanced_txpower = true,
284 },
285 .temperature = iwlagn_temperature,
286};
287
288struct iwl_lib_ops iwl2030_lib = {
289 .set_hw_params = iwl2000_hw_set_hw_params,
290 .nic_config = iwl2000_nic_config,
291 .eeprom_ops = {
292 .regulatory_bands = {
293 EEPROM_REG_BAND_1_CHANNELS,
294 EEPROM_REG_BAND_2_CHANNELS,
295 EEPROM_REG_BAND_3_CHANNELS,
296 EEPROM_REG_BAND_4_CHANNELS,
297 EEPROM_REG_BAND_5_CHANNELS,
298 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
299 EEPROM_REGULATORY_BAND_NO_HT40,
300 },
301 .enhanced_txpower = true,
302 },
303 .temperature = iwlagn_temperature,
304};
305
306/*
307 * 5000 series
308 * ===========
309 */
310
311/* NIC configuration for 5000 series */
312static void iwl5000_nic_config(struct iwl_priv *priv)
313{
314 iwl_rf_config(priv);
315
316 /* W/A : NIC is stuck in a reset state after Early PCIe power off
317 * (PCIe power is lost before PERST# is asserted),
318 * causing ME FW to lose ownership and not being able to obtain it back.
319 */
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700320 iwl_set_bits_mask_prph(priv->trans, APMG_PS_CTRL_REG,
Johannes Berge9676692012-04-10 14:10:28 -0700321 APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
322 ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
323}
324
325static const struct iwl_sensitivity_ranges iwl5000_sensitivity = {
326 .min_nrg_cck = 100,
327 .auto_corr_min_ofdm = 90,
328 .auto_corr_min_ofdm_mrc = 170,
329 .auto_corr_min_ofdm_x1 = 105,
330 .auto_corr_min_ofdm_mrc_x1 = 220,
331
332 .auto_corr_max_ofdm = 120,
333 .auto_corr_max_ofdm_mrc = 210,
334 .auto_corr_max_ofdm_x1 = 120,
335 .auto_corr_max_ofdm_mrc_x1 = 240,
336
337 .auto_corr_min_cck = 125,
338 .auto_corr_max_cck = 200,
339 .auto_corr_min_cck_mrc = 200,
340 .auto_corr_max_cck_mrc = 400,
341 .nrg_th_cck = 100,
342 .nrg_th_ofdm = 100,
343
344 .barker_corr_th_min = 190,
345 .barker_corr_th_min_mrc = 390,
346 .nrg_th_cca = 62,
347};
348
349static struct iwl_sensitivity_ranges iwl5150_sensitivity = {
350 .min_nrg_cck = 95,
351 .auto_corr_min_ofdm = 90,
352 .auto_corr_min_ofdm_mrc = 170,
353 .auto_corr_min_ofdm_x1 = 105,
354 .auto_corr_min_ofdm_mrc_x1 = 220,
355
356 .auto_corr_max_ofdm = 120,
357 .auto_corr_max_ofdm_mrc = 210,
358 /* max = min for performance bug in 5150 DSP */
359 .auto_corr_max_ofdm_x1 = 105,
360 .auto_corr_max_ofdm_mrc_x1 = 220,
361
362 .auto_corr_min_cck = 125,
363 .auto_corr_max_cck = 200,
364 .auto_corr_min_cck_mrc = 170,
365 .auto_corr_max_cck_mrc = 400,
366 .nrg_th_cck = 95,
367 .nrg_th_ofdm = 95,
368
369 .barker_corr_th_min = 190,
370 .barker_corr_th_min_mrc = 390,
371 .nrg_th_cca = 62,
372};
373
374#define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF (-5)
375
376static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
377{
378 u16 temperature, voltage;
379 __le16 *temp_calib = (__le16 *)iwl_eeprom_query_addr(priv,
380 EEPROM_KELVIN_TEMPERATURE);
381
382 temperature = le16_to_cpu(temp_calib[0]);
383 voltage = le16_to_cpu(temp_calib[1]);
384
385 /* offset = temp - volt / coeff */
386 return (s32)(temperature -
387 voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
388}
389
390static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
391{
392 const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
393 s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) -
394 iwl_temp_calib_to_offset(priv);
395
396 priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
397}
398
399static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
400{
401 /* want Celsius */
402 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
403}
404
405static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
406{
407 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
408 BIT(IEEE80211_BAND_5GHZ);
409
410 priv->hw_params.tx_chains_num =
411 num_of_ant(priv->hw_params.valid_tx_ant);
412 priv->hw_params.rx_chains_num =
413 num_of_ant(priv->hw_params.valid_rx_ant);
414
415 iwl5000_set_ct_threshold(priv);
416
417 /* Set initial sensitivity parameters */
418 priv->hw_params.sens = &iwl5000_sensitivity;
419}
420
421static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
422{
423 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
424 BIT(IEEE80211_BAND_5GHZ);
425
426 priv->hw_params.tx_chains_num =
427 num_of_ant(priv->hw_params.valid_tx_ant);
428 priv->hw_params.rx_chains_num =
429 num_of_ant(priv->hw_params.valid_rx_ant);
430
431 iwl5150_set_ct_threshold(priv);
432
433 /* Set initial sensitivity parameters */
434 priv->hw_params.sens = &iwl5150_sensitivity;
435}
436
437static void iwl5150_temperature(struct iwl_priv *priv)
438{
439 u32 vt = 0;
440 s32 offset = iwl_temp_calib_to_offset(priv);
441
442 vt = le32_to_cpu(priv->statistics.common.temperature);
443 vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
444 /* now vt hold the temperature in Kelvin */
445 priv->temperature = KELVIN_TO_CELSIUS(vt);
446 iwl_tt_handler(priv);
447}
448
449static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
450 struct ieee80211_channel_switch *ch_switch)
451{
452 /*
453 * MULTI-FIXME
454 * See iwlagn_mac_channel_switch.
455 */
456 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
457 struct iwl5000_channel_switch_cmd cmd;
Johannes Berge9676692012-04-10 14:10:28 -0700458 u32 switch_time_in_usec, ucode_switch_time;
459 u16 ch;
460 u32 tsf_low;
461 u8 switch_count;
462 u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
463 struct ieee80211_vif *vif = ctx->vif;
464 struct iwl_host_cmd hcmd = {
465 .id = REPLY_CHANNEL_SWITCH,
466 .len = { sizeof(cmd), },
467 .flags = CMD_SYNC,
468 .data = { &cmd, },
469 };
470
471 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
472 ch = ch_switch->channel->hw_value;
473 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
474 ctx->active.channel, ch);
475 cmd.channel = cpu_to_le16(ch);
476 cmd.rxon_flags = ctx->staging.flags;
477 cmd.rxon_filter_flags = ctx->staging.filter_flags;
478 switch_count = ch_switch->count;
479 tsf_low = ch_switch->timestamp & 0x0ffffffff;
480 /*
481 * calculate the ucode channel switch time
482 * adding TSF as one of the factor for when to switch
483 */
484 if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
485 if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
486 beacon_interval)) {
487 switch_count -= (priv->ucode_beacon_time -
488 tsf_low) / beacon_interval;
489 } else
490 switch_count = 0;
491 }
492 if (switch_count <= 1)
493 cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
494 else {
495 switch_time_in_usec =
496 vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
497 ucode_switch_time = iwl_usecs_to_beacons(priv,
498 switch_time_in_usec,
499 beacon_interval);
500 cmd.switch_time = iwl_add_beacon_time(priv,
501 priv->ucode_beacon_time,
502 ucode_switch_time,
503 beacon_interval);
504 }
505 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
506 cmd.switch_time);
Johannes Bergcc668802012-05-16 16:37:57 +0200507 cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
Johannes Berge9676692012-04-10 14:10:28 -0700508
509 return iwl_dvm_send_cmd(priv, &hcmd);
510}
511
512struct iwl_lib_ops iwl5000_lib = {
513 .set_hw_params = iwl5000_hw_set_hw_params,
514 .set_channel_switch = iwl5000_hw_channel_switch,
515 .nic_config = iwl5000_nic_config,
516 .eeprom_ops = {
517 .regulatory_bands = {
518 EEPROM_REG_BAND_1_CHANNELS,
519 EEPROM_REG_BAND_2_CHANNELS,
520 EEPROM_REG_BAND_3_CHANNELS,
521 EEPROM_REG_BAND_4_CHANNELS,
522 EEPROM_REG_BAND_5_CHANNELS,
523 EEPROM_REG_BAND_24_HT40_CHANNELS,
524 EEPROM_REG_BAND_52_HT40_CHANNELS
525 },
526 },
527 .temperature = iwlagn_temperature,
528};
529
530struct iwl_lib_ops iwl5150_lib = {
531 .set_hw_params = iwl5150_hw_set_hw_params,
532 .set_channel_switch = iwl5000_hw_channel_switch,
533 .nic_config = iwl5000_nic_config,
534 .eeprom_ops = {
535 .regulatory_bands = {
536 EEPROM_REG_BAND_1_CHANNELS,
537 EEPROM_REG_BAND_2_CHANNELS,
538 EEPROM_REG_BAND_3_CHANNELS,
539 EEPROM_REG_BAND_4_CHANNELS,
540 EEPROM_REG_BAND_5_CHANNELS,
541 EEPROM_REG_BAND_24_HT40_CHANNELS,
542 EEPROM_REG_BAND_52_HT40_CHANNELS
543 },
544 },
545 .temperature = iwl5150_temperature,
546};
547
548
549
550/*
551 * 6000 series
552 * ===========
553 */
554
555static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
556{
557 /* want Celsius */
558 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
559 priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
560}
561
562/* NIC configuration for 6000 series */
563static void iwl6000_nic_config(struct iwl_priv *priv)
564{
565 iwl_rf_config(priv);
566
Emmanuel Grumbach21522682012-03-22 17:51:44 +0200567 switch (priv->cfg->device_family) {
Johannes Berge9676692012-04-10 14:10:28 -0700568 case IWL_DEVICE_FAMILY_6005:
569 case IWL_DEVICE_FAMILY_6030:
570 case IWL_DEVICE_FAMILY_6000:
571 break;
572 case IWL_DEVICE_FAMILY_6000i:
573 /* 2x2 IPA phy type */
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700574 iwl_write32(priv->trans, CSR_GP_DRIVER_REG,
Johannes Berge9676692012-04-10 14:10:28 -0700575 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
576 break;
577 case IWL_DEVICE_FAMILY_6050:
578 /* Indicate calibration version to uCode. */
579 if (iwl_eeprom_calib_version(priv) >= 6)
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700580 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
Johannes Berge9676692012-04-10 14:10:28 -0700581 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
582 break;
583 case IWL_DEVICE_FAMILY_6150:
584 /* Indicate calibration version to uCode. */
585 if (iwl_eeprom_calib_version(priv) >= 6)
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700586 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
Johannes Berge9676692012-04-10 14:10:28 -0700587 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700588 iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
Johannes Berge9676692012-04-10 14:10:28 -0700589 CSR_GP_DRIVER_REG_BIT_6050_1x2);
590 break;
591 default:
592 WARN_ON(1);
593 }
594}
595
596static const struct iwl_sensitivity_ranges iwl6000_sensitivity = {
597 .min_nrg_cck = 110,
598 .auto_corr_min_ofdm = 80,
599 .auto_corr_min_ofdm_mrc = 128,
600 .auto_corr_min_ofdm_x1 = 105,
601 .auto_corr_min_ofdm_mrc_x1 = 192,
602
603 .auto_corr_max_ofdm = 145,
604 .auto_corr_max_ofdm_mrc = 232,
605 .auto_corr_max_ofdm_x1 = 110,
606 .auto_corr_max_ofdm_mrc_x1 = 232,
607
608 .auto_corr_min_cck = 125,
609 .auto_corr_max_cck = 175,
610 .auto_corr_min_cck_mrc = 160,
611 .auto_corr_max_cck_mrc = 310,
612 .nrg_th_cck = 110,
613 .nrg_th_ofdm = 110,
614
615 .barker_corr_th_min = 190,
616 .barker_corr_th_min_mrc = 336,
617 .nrg_th_cca = 62,
618};
619
620static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
621{
622 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
623 BIT(IEEE80211_BAND_5GHZ);
624
625 priv->hw_params.tx_chains_num =
626 num_of_ant(priv->hw_params.valid_tx_ant);
Emmanuel Grumbach21522682012-03-22 17:51:44 +0200627 if (priv->cfg->rx_with_siso_diversity)
Johannes Berge9676692012-04-10 14:10:28 -0700628 priv->hw_params.rx_chains_num = 1;
629 else
630 priv->hw_params.rx_chains_num =
631 num_of_ant(priv->hw_params.valid_rx_ant);
632
633 iwl6000_set_ct_threshold(priv);
634
635 /* Set initial sensitivity parameters */
636 priv->hw_params.sens = &iwl6000_sensitivity;
637
638}
639
640static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
641 struct ieee80211_channel_switch *ch_switch)
642{
643 /*
644 * MULTI-FIXME
645 * See iwlagn_mac_channel_switch.
646 */
647 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
648 struct iwl6000_channel_switch_cmd cmd;
Johannes Berge9676692012-04-10 14:10:28 -0700649 u32 switch_time_in_usec, ucode_switch_time;
650 u16 ch;
651 u32 tsf_low;
652 u8 switch_count;
653 u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
654 struct ieee80211_vif *vif = ctx->vif;
655 struct iwl_host_cmd hcmd = {
656 .id = REPLY_CHANNEL_SWITCH,
657 .len = { sizeof(cmd), },
658 .flags = CMD_SYNC,
659 .data = { &cmd, },
660 };
661
662 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
663 ch = ch_switch->channel->hw_value;
664 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
665 ctx->active.channel, ch);
666 cmd.channel = cpu_to_le16(ch);
667 cmd.rxon_flags = ctx->staging.flags;
668 cmd.rxon_filter_flags = ctx->staging.filter_flags;
669 switch_count = ch_switch->count;
670 tsf_low = ch_switch->timestamp & 0x0ffffffff;
671 /*
672 * calculate the ucode channel switch time
673 * adding TSF as one of the factor for when to switch
674 */
675 if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
676 if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
677 beacon_interval)) {
678 switch_count -= (priv->ucode_beacon_time -
679 tsf_low) / beacon_interval;
680 } else
681 switch_count = 0;
682 }
683 if (switch_count <= 1)
684 cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
685 else {
686 switch_time_in_usec =
687 vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
688 ucode_switch_time = iwl_usecs_to_beacons(priv,
689 switch_time_in_usec,
690 beacon_interval);
691 cmd.switch_time = iwl_add_beacon_time(priv,
692 priv->ucode_beacon_time,
693 ucode_switch_time,
694 beacon_interval);
695 }
696 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
697 cmd.switch_time);
Johannes Bergcc668802012-05-16 16:37:57 +0200698 cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
Johannes Berge9676692012-04-10 14:10:28 -0700699
700 return iwl_dvm_send_cmd(priv, &hcmd);
701}
702
703struct iwl_lib_ops iwl6000_lib = {
704 .set_hw_params = iwl6000_hw_set_hw_params,
705 .set_channel_switch = iwl6000_hw_channel_switch,
706 .nic_config = iwl6000_nic_config,
707 .eeprom_ops = {
708 .regulatory_bands = {
709 EEPROM_REG_BAND_1_CHANNELS,
710 EEPROM_REG_BAND_2_CHANNELS,
711 EEPROM_REG_BAND_3_CHANNELS,
712 EEPROM_REG_BAND_4_CHANNELS,
713 EEPROM_REG_BAND_5_CHANNELS,
714 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
715 EEPROM_REG_BAND_52_HT40_CHANNELS
716 },
717 .enhanced_txpower = true,
718 },
719 .temperature = iwlagn_temperature,
720};
721
722struct iwl_lib_ops iwl6030_lib = {
723 .set_hw_params = iwl6000_hw_set_hw_params,
724 .set_channel_switch = iwl6000_hw_channel_switch,
725 .nic_config = iwl6000_nic_config,
726 .eeprom_ops = {
727 .regulatory_bands = {
728 EEPROM_REG_BAND_1_CHANNELS,
729 EEPROM_REG_BAND_2_CHANNELS,
730 EEPROM_REG_BAND_3_CHANNELS,
731 EEPROM_REG_BAND_4_CHANNELS,
732 EEPROM_REG_BAND_5_CHANNELS,
733 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
734 EEPROM_REG_BAND_52_HT40_CHANNELS
735 },
736 .enhanced_txpower = true,
737 },
738 .temperature = iwlagn_temperature,
739};