1 /******************************************************************************
3 * Copyright(c) 2008 - 2012 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 *****************************************************************************/
28 * DVM device-specific data & functions
33 #include "iwl-commands.h"
43 * For 1000, use advance thermal throttling critical temperature threshold,
44 * but legacy thermal management implementation for now.
45 * This is for the reason of 1000 uCode using advance thermal throttling API
46 * but not implement ct_kill_exit based on ct_kill exit temperature
47 * so the thermal throttling will still based on legacy thermal throttling
49 * The code here need to be modified once 1000 uCode has the advanced thermal
50 * throttling algorithm in place
52 static void iwl1000_set_ct_threshold(struct iwl_priv
*priv
)
55 priv
->hw_params
.ct_kill_threshold
= CT_KILL_THRESHOLD_LEGACY
;
56 priv
->hw_params
.ct_kill_exit_threshold
= CT_KILL_EXIT_THRESHOLD
;
59 /* NIC configuration for 1000 series */
60 static void iwl1000_nic_config(struct iwl_priv
*priv
)
62 /* set CSR_HW_CONFIG_REG for uCode use */
63 iwl_set_bit(trans(priv
), CSR_HW_IF_CONFIG_REG
,
64 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI
|
65 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI
);
67 /* Setting digital SVR for 1000 card to 1.32V */
68 /* locking is acquired in iwl_set_bits_mask_prph() function */
69 iwl_set_bits_mask_prph(trans(priv
), APMG_DIGITAL_SVR_REG
,
70 APMG_SVR_DIGITAL_VOLTAGE_1_32
,
71 ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK
);
75 * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time
76 * @priv -- pointer to iwl_priv data structure
77 * @tsf_bits -- number of bits need to shift for masking)
79 static inline u32
iwl_beacon_time_mask_low(struct iwl_priv
*priv
,
82 return (1 << tsf_bits
) - 1;
86 * iwl_beacon_time_mask_high - mask of higher 32 bit of beacon time
87 * @priv -- pointer to iwl_priv data structure
88 * @tsf_bits -- number of bits need to shift for masking)
90 static inline u32
iwl_beacon_time_mask_high(struct iwl_priv
*priv
,
93 return ((1 << (32 - tsf_bits
)) - 1) << tsf_bits
;
97 * extended beacon time format
98 * time in usec will be changed into a 32-bit value in extended:internal format
99 * the extended part is the beacon counts
100 * the internal part is the time in usec within one beacon interval
102 static u32
iwl_usecs_to_beacons(struct iwl_priv
*priv
, u32 usec
,
107 u32 interval
= beacon_interval
* TIME_UNIT
;
109 if (!interval
|| !usec
)
112 quot
= (usec
/ interval
) &
113 (iwl_beacon_time_mask_high(priv
, IWLAGN_EXT_BEACON_TIME_POS
) >>
114 IWLAGN_EXT_BEACON_TIME_POS
);
115 rem
= (usec
% interval
) & iwl_beacon_time_mask_low(priv
,
116 IWLAGN_EXT_BEACON_TIME_POS
);
118 return (quot
<< IWLAGN_EXT_BEACON_TIME_POS
) + rem
;
121 /* base is usually what we get from ucode with each received frame,
122 * the same as HW timer counter counting down
124 static __le32
iwl_add_beacon_time(struct iwl_priv
*priv
, u32 base
,
125 u32 addon
, u32 beacon_interval
)
127 u32 base_low
= base
& iwl_beacon_time_mask_low(priv
,
128 IWLAGN_EXT_BEACON_TIME_POS
);
129 u32 addon_low
= addon
& iwl_beacon_time_mask_low(priv
,
130 IWLAGN_EXT_BEACON_TIME_POS
);
131 u32 interval
= beacon_interval
* TIME_UNIT
;
132 u32 res
= (base
& iwl_beacon_time_mask_high(priv
,
133 IWLAGN_EXT_BEACON_TIME_POS
)) +
134 (addon
& iwl_beacon_time_mask_high(priv
,
135 IWLAGN_EXT_BEACON_TIME_POS
));
137 if (base_low
> addon_low
)
138 res
+= base_low
- addon_low
;
139 else if (base_low
< addon_low
) {
140 res
+= interval
+ base_low
- addon_low
;
141 res
+= (1 << IWLAGN_EXT_BEACON_TIME_POS
);
143 res
+= (1 << IWLAGN_EXT_BEACON_TIME_POS
);
145 return cpu_to_le32(res
);
148 static const struct iwl_sensitivity_ranges iwl1000_sensitivity
= {
150 .auto_corr_min_ofdm
= 90,
151 .auto_corr_min_ofdm_mrc
= 170,
152 .auto_corr_min_ofdm_x1
= 120,
153 .auto_corr_min_ofdm_mrc_x1
= 240,
155 .auto_corr_max_ofdm
= 120,
156 .auto_corr_max_ofdm_mrc
= 210,
157 .auto_corr_max_ofdm_x1
= 155,
158 .auto_corr_max_ofdm_mrc_x1
= 290,
160 .auto_corr_min_cck
= 125,
161 .auto_corr_max_cck
= 200,
162 .auto_corr_min_cck_mrc
= 170,
163 .auto_corr_max_cck_mrc
= 400,
167 .barker_corr_th_min
= 190,
168 .barker_corr_th_min_mrc
= 390,
172 static void iwl1000_hw_set_hw_params(struct iwl_priv
*priv
)
174 priv
->hw_params
.ht40_channel
= BIT(IEEE80211_BAND_2GHZ
);
176 priv
->hw_params
.tx_chains_num
=
177 num_of_ant(priv
->hw_params
.valid_tx_ant
);
178 if (cfg(priv
)->rx_with_siso_diversity
)
179 priv
->hw_params
.rx_chains_num
= 1;
181 priv
->hw_params
.rx_chains_num
=
182 num_of_ant(priv
->hw_params
.valid_rx_ant
);
184 iwl1000_set_ct_threshold(priv
);
186 /* Set initial sensitivity parameters */
187 priv
->hw_params
.sens
= &iwl1000_sensitivity
;
190 struct iwl_lib_ops iwl1000_lib
= {
191 .set_hw_params
= iwl1000_hw_set_hw_params
,
192 .nic_config
= iwl1000_nic_config
,
194 .regulatory_bands
= {
195 EEPROM_REG_BAND_1_CHANNELS
,
196 EEPROM_REG_BAND_2_CHANNELS
,
197 EEPROM_REG_BAND_3_CHANNELS
,
198 EEPROM_REG_BAND_4_CHANNELS
,
199 EEPROM_REG_BAND_5_CHANNELS
,
200 EEPROM_REG_BAND_24_HT40_CHANNELS
,
201 EEPROM_REGULATORY_BAND_NO_HT40
,
204 .temperature
= iwlagn_temperature
,
213 static void iwl2000_set_ct_threshold(struct iwl_priv
*priv
)
216 priv
->hw_params
.ct_kill_threshold
= CT_KILL_THRESHOLD
;
217 priv
->hw_params
.ct_kill_exit_threshold
= CT_KILL_EXIT_THRESHOLD
;
220 /* NIC configuration for 2000 series */
221 static void iwl2000_nic_config(struct iwl_priv
*priv
)
225 iwl_set_bit(trans(priv
), CSR_GP_DRIVER_REG
,
226 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER
);
229 static const struct iwl_sensitivity_ranges iwl2000_sensitivity
= {
231 .auto_corr_min_ofdm
= 80,
232 .auto_corr_min_ofdm_mrc
= 128,
233 .auto_corr_min_ofdm_x1
= 105,
234 .auto_corr_min_ofdm_mrc_x1
= 192,
236 .auto_corr_max_ofdm
= 145,
237 .auto_corr_max_ofdm_mrc
= 232,
238 .auto_corr_max_ofdm_x1
= 110,
239 .auto_corr_max_ofdm_mrc_x1
= 232,
241 .auto_corr_min_cck
= 125,
242 .auto_corr_max_cck
= 175,
243 .auto_corr_min_cck_mrc
= 160,
244 .auto_corr_max_cck_mrc
= 310,
248 .barker_corr_th_min
= 190,
249 .barker_corr_th_min_mrc
= 390,
253 static void iwl2000_hw_set_hw_params(struct iwl_priv
*priv
)
255 priv
->hw_params
.ht40_channel
= BIT(IEEE80211_BAND_2GHZ
);
257 priv
->hw_params
.tx_chains_num
=
258 num_of_ant(priv
->hw_params
.valid_tx_ant
);
259 if (cfg(priv
)->rx_with_siso_diversity
)
260 priv
->hw_params
.rx_chains_num
= 1;
262 priv
->hw_params
.rx_chains_num
=
263 num_of_ant(priv
->hw_params
.valid_rx_ant
);
265 iwl2000_set_ct_threshold(priv
);
267 /* Set initial sensitivity parameters */
268 priv
->hw_params
.sens
= &iwl2000_sensitivity
;
271 struct iwl_lib_ops iwl2000_lib
= {
272 .set_hw_params
= iwl2000_hw_set_hw_params
,
273 .nic_config
= iwl2000_nic_config
,
275 .regulatory_bands
= {
276 EEPROM_REG_BAND_1_CHANNELS
,
277 EEPROM_REG_BAND_2_CHANNELS
,
278 EEPROM_REG_BAND_3_CHANNELS
,
279 EEPROM_REG_BAND_4_CHANNELS
,
280 EEPROM_REG_BAND_5_CHANNELS
,
281 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
282 EEPROM_REGULATORY_BAND_NO_HT40
,
284 .enhanced_txpower
= true,
286 .temperature
= iwlagn_temperature
,
289 struct iwl_lib_ops iwl2030_lib
= {
290 .set_hw_params
= iwl2000_hw_set_hw_params
,
291 .nic_config
= iwl2000_nic_config
,
293 .regulatory_bands
= {
294 EEPROM_REG_BAND_1_CHANNELS
,
295 EEPROM_REG_BAND_2_CHANNELS
,
296 EEPROM_REG_BAND_3_CHANNELS
,
297 EEPROM_REG_BAND_4_CHANNELS
,
298 EEPROM_REG_BAND_5_CHANNELS
,
299 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
300 EEPROM_REGULATORY_BAND_NO_HT40
,
302 .enhanced_txpower
= true,
304 .temperature
= iwlagn_temperature
,
312 /* NIC configuration for 5000 series */
313 static void iwl5000_nic_config(struct iwl_priv
*priv
)
317 /* W/A : NIC is stuck in a reset state after Early PCIe power off
318 * (PCIe power is lost before PERST# is asserted),
319 * causing ME FW to lose ownership and not being able to obtain it back.
321 iwl_set_bits_mask_prph(trans(priv
), APMG_PS_CTRL_REG
,
322 APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS
,
323 ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS
);
326 static const struct iwl_sensitivity_ranges iwl5000_sensitivity
= {
328 .auto_corr_min_ofdm
= 90,
329 .auto_corr_min_ofdm_mrc
= 170,
330 .auto_corr_min_ofdm_x1
= 105,
331 .auto_corr_min_ofdm_mrc_x1
= 220,
333 .auto_corr_max_ofdm
= 120,
334 .auto_corr_max_ofdm_mrc
= 210,
335 .auto_corr_max_ofdm_x1
= 120,
336 .auto_corr_max_ofdm_mrc_x1
= 240,
338 .auto_corr_min_cck
= 125,
339 .auto_corr_max_cck
= 200,
340 .auto_corr_min_cck_mrc
= 200,
341 .auto_corr_max_cck_mrc
= 400,
345 .barker_corr_th_min
= 190,
346 .barker_corr_th_min_mrc
= 390,
350 static struct iwl_sensitivity_ranges iwl5150_sensitivity
= {
352 .auto_corr_min_ofdm
= 90,
353 .auto_corr_min_ofdm_mrc
= 170,
354 .auto_corr_min_ofdm_x1
= 105,
355 .auto_corr_min_ofdm_mrc_x1
= 220,
357 .auto_corr_max_ofdm
= 120,
358 .auto_corr_max_ofdm_mrc
= 210,
359 /* max = min for performance bug in 5150 DSP */
360 .auto_corr_max_ofdm_x1
= 105,
361 .auto_corr_max_ofdm_mrc_x1
= 220,
363 .auto_corr_min_cck
= 125,
364 .auto_corr_max_cck
= 200,
365 .auto_corr_min_cck_mrc
= 170,
366 .auto_corr_max_cck_mrc
= 400,
370 .barker_corr_th_min
= 190,
371 .barker_corr_th_min_mrc
= 390,
375 #define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF (-5)
377 static s32
iwl_temp_calib_to_offset(struct iwl_priv
*priv
)
379 u16 temperature
, voltage
;
380 __le16
*temp_calib
= (__le16
*)iwl_eeprom_query_addr(priv
,
381 EEPROM_KELVIN_TEMPERATURE
);
383 temperature
= le16_to_cpu(temp_calib
[0]);
384 voltage
= le16_to_cpu(temp_calib
[1]);
386 /* offset = temp - volt / coeff */
387 return (s32
)(temperature
-
388 voltage
/ IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF
);
391 static void iwl5150_set_ct_threshold(struct iwl_priv
*priv
)
393 const s32 volt2temp_coef
= IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF
;
394 s32 threshold
= (s32
)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY
) -
395 iwl_temp_calib_to_offset(priv
);
397 priv
->hw_params
.ct_kill_threshold
= threshold
* volt2temp_coef
;
400 static void iwl5000_set_ct_threshold(struct iwl_priv
*priv
)
403 priv
->hw_params
.ct_kill_threshold
= CT_KILL_THRESHOLD_LEGACY
;
406 static void iwl5000_hw_set_hw_params(struct iwl_priv
*priv
)
408 priv
->hw_params
.ht40_channel
= BIT(IEEE80211_BAND_2GHZ
) |
409 BIT(IEEE80211_BAND_5GHZ
);
411 priv
->hw_params
.tx_chains_num
=
412 num_of_ant(priv
->hw_params
.valid_tx_ant
);
413 priv
->hw_params
.rx_chains_num
=
414 num_of_ant(priv
->hw_params
.valid_rx_ant
);
416 iwl5000_set_ct_threshold(priv
);
418 /* Set initial sensitivity parameters */
419 priv
->hw_params
.sens
= &iwl5000_sensitivity
;
422 static void iwl5150_hw_set_hw_params(struct iwl_priv
*priv
)
424 priv
->hw_params
.ht40_channel
= BIT(IEEE80211_BAND_2GHZ
) |
425 BIT(IEEE80211_BAND_5GHZ
);
427 priv
->hw_params
.tx_chains_num
=
428 num_of_ant(priv
->hw_params
.valid_tx_ant
);
429 priv
->hw_params
.rx_chains_num
=
430 num_of_ant(priv
->hw_params
.valid_rx_ant
);
432 iwl5150_set_ct_threshold(priv
);
434 /* Set initial sensitivity parameters */
435 priv
->hw_params
.sens
= &iwl5150_sensitivity
;
438 static void iwl5150_temperature(struct iwl_priv
*priv
)
441 s32 offset
= iwl_temp_calib_to_offset(priv
);
443 vt
= le32_to_cpu(priv
->statistics
.common
.temperature
);
444 vt
= vt
/ IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF
+ offset
;
445 /* now vt hold the temperature in Kelvin */
446 priv
->temperature
= KELVIN_TO_CELSIUS(vt
);
447 iwl_tt_handler(priv
);
450 static int iwl5000_hw_channel_switch(struct iwl_priv
*priv
,
451 struct ieee80211_channel_switch
*ch_switch
)
455 * See iwlagn_mac_channel_switch.
457 struct iwl_rxon_context
*ctx
= &priv
->contexts
[IWL_RXON_CTX_BSS
];
458 struct iwl5000_channel_switch_cmd cmd
;
459 const struct iwl_channel_info
*ch_info
;
460 u32 switch_time_in_usec
, ucode_switch_time
;
464 u16 beacon_interval
= le16_to_cpu(ctx
->timing
.beacon_interval
);
465 struct ieee80211_vif
*vif
= ctx
->vif
;
466 struct iwl_host_cmd hcmd
= {
467 .id
= REPLY_CHANNEL_SWITCH
,
468 .len
= { sizeof(cmd
), },
473 cmd
.band
= priv
->band
== IEEE80211_BAND_2GHZ
;
474 ch
= ch_switch
->channel
->hw_value
;
475 IWL_DEBUG_11H(priv
, "channel switch from %d to %d\n",
476 ctx
->active
.channel
, ch
);
477 cmd
.channel
= cpu_to_le16(ch
);
478 cmd
.rxon_flags
= ctx
->staging
.flags
;
479 cmd
.rxon_filter_flags
= ctx
->staging
.filter_flags
;
480 switch_count
= ch_switch
->count
;
481 tsf_low
= ch_switch
->timestamp
& 0x0ffffffff;
483 * calculate the ucode channel switch time
484 * adding TSF as one of the factor for when to switch
486 if ((priv
->ucode_beacon_time
> tsf_low
) && beacon_interval
) {
487 if (switch_count
> ((priv
->ucode_beacon_time
- tsf_low
) /
489 switch_count
-= (priv
->ucode_beacon_time
-
490 tsf_low
) / beacon_interval
;
494 if (switch_count
<= 1)
495 cmd
.switch_time
= cpu_to_le32(priv
->ucode_beacon_time
);
497 switch_time_in_usec
=
498 vif
->bss_conf
.beacon_int
* switch_count
* TIME_UNIT
;
499 ucode_switch_time
= iwl_usecs_to_beacons(priv
,
502 cmd
.switch_time
= iwl_add_beacon_time(priv
,
503 priv
->ucode_beacon_time
,
507 IWL_DEBUG_11H(priv
, "uCode time for the switch is 0x%x\n",
509 ch_info
= iwl_get_channel_info(priv
, priv
->band
, ch
);
511 cmd
.expect_beacon
= is_channel_radar(ch_info
);
513 IWL_ERR(priv
, "invalid channel switch from %u to %u\n",
514 ctx
->active
.channel
, ch
);
518 return iwl_dvm_send_cmd(priv
, &hcmd
);
521 struct iwl_lib_ops iwl5000_lib
= {
522 .set_hw_params
= iwl5000_hw_set_hw_params
,
523 .set_channel_switch
= iwl5000_hw_channel_switch
,
524 .nic_config
= iwl5000_nic_config
,
526 .regulatory_bands
= {
527 EEPROM_REG_BAND_1_CHANNELS
,
528 EEPROM_REG_BAND_2_CHANNELS
,
529 EEPROM_REG_BAND_3_CHANNELS
,
530 EEPROM_REG_BAND_4_CHANNELS
,
531 EEPROM_REG_BAND_5_CHANNELS
,
532 EEPROM_REG_BAND_24_HT40_CHANNELS
,
533 EEPROM_REG_BAND_52_HT40_CHANNELS
536 .temperature
= iwlagn_temperature
,
539 struct iwl_lib_ops iwl5150_lib
= {
540 .set_hw_params
= iwl5150_hw_set_hw_params
,
541 .set_channel_switch
= iwl5000_hw_channel_switch
,
542 .nic_config
= iwl5000_nic_config
,
544 .regulatory_bands
= {
545 EEPROM_REG_BAND_1_CHANNELS
,
546 EEPROM_REG_BAND_2_CHANNELS
,
547 EEPROM_REG_BAND_3_CHANNELS
,
548 EEPROM_REG_BAND_4_CHANNELS
,
549 EEPROM_REG_BAND_5_CHANNELS
,
550 EEPROM_REG_BAND_24_HT40_CHANNELS
,
551 EEPROM_REG_BAND_52_HT40_CHANNELS
554 .temperature
= iwl5150_temperature
,
564 static void iwl6000_set_ct_threshold(struct iwl_priv
*priv
)
567 priv
->hw_params
.ct_kill_threshold
= CT_KILL_THRESHOLD
;
568 priv
->hw_params
.ct_kill_exit_threshold
= CT_KILL_EXIT_THRESHOLD
;
571 /* NIC configuration for 6000 series */
572 static void iwl6000_nic_config(struct iwl_priv
*priv
)
576 switch (cfg(priv
)->device_family
) {
577 case IWL_DEVICE_FAMILY_6005
:
578 case IWL_DEVICE_FAMILY_6030
:
579 case IWL_DEVICE_FAMILY_6000
:
581 case IWL_DEVICE_FAMILY_6000i
:
582 /* 2x2 IPA phy type */
583 iwl_write32(trans(priv
), CSR_GP_DRIVER_REG
,
584 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA
);
586 case IWL_DEVICE_FAMILY_6050
:
587 /* Indicate calibration version to uCode. */
588 if (iwl_eeprom_calib_version(priv
) >= 6)
589 iwl_set_bit(trans(priv
), CSR_GP_DRIVER_REG
,
590 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6
);
592 case IWL_DEVICE_FAMILY_6150
:
593 /* Indicate calibration version to uCode. */
594 if (iwl_eeprom_calib_version(priv
) >= 6)
595 iwl_set_bit(trans(priv
), CSR_GP_DRIVER_REG
,
596 CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6
);
597 iwl_set_bit(trans(priv
), CSR_GP_DRIVER_REG
,
598 CSR_GP_DRIVER_REG_BIT_6050_1x2
);
605 static const struct iwl_sensitivity_ranges iwl6000_sensitivity
= {
607 .auto_corr_min_ofdm
= 80,
608 .auto_corr_min_ofdm_mrc
= 128,
609 .auto_corr_min_ofdm_x1
= 105,
610 .auto_corr_min_ofdm_mrc_x1
= 192,
612 .auto_corr_max_ofdm
= 145,
613 .auto_corr_max_ofdm_mrc
= 232,
614 .auto_corr_max_ofdm_x1
= 110,
615 .auto_corr_max_ofdm_mrc_x1
= 232,
617 .auto_corr_min_cck
= 125,
618 .auto_corr_max_cck
= 175,
619 .auto_corr_min_cck_mrc
= 160,
620 .auto_corr_max_cck_mrc
= 310,
624 .barker_corr_th_min
= 190,
625 .barker_corr_th_min_mrc
= 336,
629 static void iwl6000_hw_set_hw_params(struct iwl_priv
*priv
)
631 priv
->hw_params
.ht40_channel
= BIT(IEEE80211_BAND_2GHZ
) |
632 BIT(IEEE80211_BAND_5GHZ
);
634 priv
->hw_params
.tx_chains_num
=
635 num_of_ant(priv
->hw_params
.valid_tx_ant
);
636 if (cfg(priv
)->rx_with_siso_diversity
)
637 priv
->hw_params
.rx_chains_num
= 1;
639 priv
->hw_params
.rx_chains_num
=
640 num_of_ant(priv
->hw_params
.valid_rx_ant
);
642 iwl6000_set_ct_threshold(priv
);
644 /* Set initial sensitivity parameters */
645 priv
->hw_params
.sens
= &iwl6000_sensitivity
;
649 static int iwl6000_hw_channel_switch(struct iwl_priv
*priv
,
650 struct ieee80211_channel_switch
*ch_switch
)
654 * See iwlagn_mac_channel_switch.
656 struct iwl_rxon_context
*ctx
= &priv
->contexts
[IWL_RXON_CTX_BSS
];
657 struct iwl6000_channel_switch_cmd cmd
;
658 const struct iwl_channel_info
*ch_info
;
659 u32 switch_time_in_usec
, ucode_switch_time
;
663 u16 beacon_interval
= le16_to_cpu(ctx
->timing
.beacon_interval
);
664 struct ieee80211_vif
*vif
= ctx
->vif
;
665 struct iwl_host_cmd hcmd
= {
666 .id
= REPLY_CHANNEL_SWITCH
,
667 .len
= { sizeof(cmd
), },
672 cmd
.band
= priv
->band
== IEEE80211_BAND_2GHZ
;
673 ch
= ch_switch
->channel
->hw_value
;
674 IWL_DEBUG_11H(priv
, "channel switch from %u to %u\n",
675 ctx
->active
.channel
, ch
);
676 cmd
.channel
= cpu_to_le16(ch
);
677 cmd
.rxon_flags
= ctx
->staging
.flags
;
678 cmd
.rxon_filter_flags
= ctx
->staging
.filter_flags
;
679 switch_count
= ch_switch
->count
;
680 tsf_low
= ch_switch
->timestamp
& 0x0ffffffff;
682 * calculate the ucode channel switch time
683 * adding TSF as one of the factor for when to switch
685 if ((priv
->ucode_beacon_time
> tsf_low
) && beacon_interval
) {
686 if (switch_count
> ((priv
->ucode_beacon_time
- tsf_low
) /
688 switch_count
-= (priv
->ucode_beacon_time
-
689 tsf_low
) / beacon_interval
;
693 if (switch_count
<= 1)
694 cmd
.switch_time
= cpu_to_le32(priv
->ucode_beacon_time
);
696 switch_time_in_usec
=
697 vif
->bss_conf
.beacon_int
* switch_count
* TIME_UNIT
;
698 ucode_switch_time
= iwl_usecs_to_beacons(priv
,
701 cmd
.switch_time
= iwl_add_beacon_time(priv
,
702 priv
->ucode_beacon_time
,
706 IWL_DEBUG_11H(priv
, "uCode time for the switch is 0x%x\n",
708 ch_info
= iwl_get_channel_info(priv
, priv
->band
, ch
);
710 cmd
.expect_beacon
= is_channel_radar(ch_info
);
712 IWL_ERR(priv
, "invalid channel switch from %u to %u\n",
713 ctx
->active
.channel
, ch
);
717 return iwl_dvm_send_cmd(priv
, &hcmd
);
720 struct iwl_lib_ops iwl6000_lib
= {
721 .set_hw_params
= iwl6000_hw_set_hw_params
,
722 .set_channel_switch
= iwl6000_hw_channel_switch
,
723 .nic_config
= iwl6000_nic_config
,
725 .regulatory_bands
= {
726 EEPROM_REG_BAND_1_CHANNELS
,
727 EEPROM_REG_BAND_2_CHANNELS
,
728 EEPROM_REG_BAND_3_CHANNELS
,
729 EEPROM_REG_BAND_4_CHANNELS
,
730 EEPROM_REG_BAND_5_CHANNELS
,
731 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
732 EEPROM_REG_BAND_52_HT40_CHANNELS
734 .enhanced_txpower
= true,
736 .temperature
= iwlagn_temperature
,
739 struct iwl_lib_ops iwl6030_lib
= {
740 .set_hw_params
= iwl6000_hw_set_hw_params
,
741 .set_channel_switch
= iwl6000_hw_channel_switch
,
742 .nic_config
= iwl6000_nic_config
,
744 .regulatory_bands
= {
745 EEPROM_REG_BAND_1_CHANNELS
,
746 EEPROM_REG_BAND_2_CHANNELS
,
747 EEPROM_REG_BAND_3_CHANNELS
,
748 EEPROM_REG_BAND_4_CHANNELS
,
749 EEPROM_REG_BAND_5_CHANNELS
,
750 EEPROM_6000_REG_BAND_24_HT40_CHANNELS
,
751 EEPROM_REG_BAND_52_HT40_CHANNELS
753 .enhanced_txpower
= true,
755 .temperature
= iwlagn_temperature
,