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 *****************************************************************************/
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 (cfg(priv)->iq_invert)
90 iwl_set_bit(trans(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 cfg(priv)->base_params->num_of_queues =
124 iwlagn_mod_params.num_of_queues;
126 hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
127 hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE;
128 hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE;
130 hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
132 hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
133 if (cfg(priv)->rx_with_siso_diversity)
134 hw_params(priv).rx_chains_num = 1;
136 hw_params(priv).rx_chains_num =
137 num_of_ant(cfg(priv)->valid_rx_ant);
138 hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
139 hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
141 iwl2000_set_ct_threshold(priv);
143 /* Set initial sensitivity parameters */
144 hw_params(priv).sens = &iwl2000_sensitivity;
149 static struct iwl_lib_ops iwl2000_lib = {
150 .set_hw_params = iwl2000_hw_set_hw_params,
151 .nic_config = iwl2000_nic_config,
153 .regulatory_bands = {
154 EEPROM_REG_BAND_1_CHANNELS,
155 EEPROM_REG_BAND_2_CHANNELS,
156 EEPROM_REG_BAND_3_CHANNELS,
157 EEPROM_REG_BAND_4_CHANNELS,
158 EEPROM_REG_BAND_5_CHANNELS,
159 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
160 EEPROM_REGULATORY_BAND_NO_HT40,
162 .update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
164 .temperature = iwlagn_temperature,
167 static struct iwl_lib_ops iwl2030_lib = {
168 .set_hw_params = iwl2000_hw_set_hw_params,
169 .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
170 .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
171 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
172 .nic_config = iwl2000_nic_config,
174 .regulatory_bands = {
175 EEPROM_REG_BAND_1_CHANNELS,
176 EEPROM_REG_BAND_2_CHANNELS,
177 EEPROM_REG_BAND_3_CHANNELS,
178 EEPROM_REG_BAND_4_CHANNELS,
179 EEPROM_REG_BAND_5_CHANNELS,
180 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
181 EEPROM_REGULATORY_BAND_NO_HT40,
183 .update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
185 .temperature = iwlagn_temperature,
188 static struct iwl_base_params iwl2000_base_params = {
189 .eeprom_size = OTP_LOW_IMAGE_SIZE,
190 .num_of_queues = IWLAGN_NUM_QUEUES,
191 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
193 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
194 .shadow_ram_support = true,
195 .led_compensation = 51,
196 .adv_thermal_throttle = true,
197 .support_ct_kill_exit = true,
198 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
199 .chain_noise_scale = 1000,
200 .wd_timeout = IWL_DEF_WD_TIMEOUT,
201 .max_event_log_size = 512,
202 .shadow_reg_enable = true,
207 static struct iwl_base_params iwl2030_base_params = {
208 .eeprom_size = OTP_LOW_IMAGE_SIZE,
209 .num_of_queues = IWLAGN_NUM_QUEUES,
210 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
212 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
213 .shadow_ram_support = true,
214 .led_compensation = 57,
215 .adv_thermal_throttle = true,
216 .support_ct_kill_exit = true,
217 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
218 .chain_noise_scale = 1000,
219 .wd_timeout = IWL_LONG_WD_TIMEOUT,
220 .max_event_log_size = 512,
221 .shadow_reg_enable = true,
225 static struct iwl_ht_params iwl2000_ht_params = {
226 .ht_greenfield_support = true,
227 .use_rts_for_aggregation = true, /* use rts/cts protection */
230 static struct iwl_bt_params iwl2030_bt_params = {
231 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
232 .advanced_bt_coexist = true,
233 .agg_time_limit = BT_AGG_THRESHOLD_DEF,
234 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
235 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
236 .bt_sco_disable = true,
237 .bt_session_2 = true,
240 #define IWL_DEVICE_2000 \
241 .fw_name_pre = IWL2000_FW_PRE, \
242 .ucode_api_max = IWL2000_UCODE_API_MAX, \
243 .ucode_api_ok = IWL2000_UCODE_API_OK, \
244 .ucode_api_min = IWL2000_UCODE_API_MIN, \
245 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
246 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
247 .lib = &iwl2000_lib, \
248 .base_params = &iwl2000_base_params, \
249 .need_temp_offset_calib = true, \
250 .temp_offset_v2 = true, \
251 .led_mode = IWL_LED_RF_STATE, \
254 struct iwl_cfg iwl2000_2bgn_cfg = {
255 .name = "Intel(R) Centrino(R) Wireless-N 2200 BGN",
257 .ht_params = &iwl2000_ht_params,
260 struct iwl_cfg iwl2000_2bgn_d_cfg = {
261 .name = "Intel(R) Centrino(R) Wireless-N 2200D BGN",
263 .ht_params = &iwl2000_ht_params,
266 #define IWL_DEVICE_2030 \
267 .fw_name_pre = IWL2030_FW_PRE, \
268 .ucode_api_max = IWL2030_UCODE_API_MAX, \
269 .ucode_api_ok = IWL2030_UCODE_API_OK, \
270 .ucode_api_min = IWL2030_UCODE_API_MIN, \
271 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
272 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
273 .lib = &iwl2030_lib, \
274 .base_params = &iwl2030_base_params, \
275 .bt_params = &iwl2030_bt_params, \
276 .need_temp_offset_calib = true, \
277 .temp_offset_v2 = true, \
278 .led_mode = IWL_LED_RF_STATE, \
282 struct iwl_cfg iwl2030_2bgn_cfg = {
283 .name = "Intel(R) Centrino(R) Wireless-N 2230 BGN",
285 .ht_params = &iwl2000_ht_params,
288 #define IWL_DEVICE_105 \
289 .fw_name_pre = IWL105_FW_PRE, \
290 .ucode_api_max = IWL105_UCODE_API_MAX, \
291 .ucode_api_ok = IWL105_UCODE_API_OK, \
292 .ucode_api_min = IWL105_UCODE_API_MIN, \
293 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
294 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
295 .lib = &iwl2000_lib, \
296 .base_params = &iwl2000_base_params, \
297 .need_temp_offset_calib = true, \
298 .temp_offset_v2 = true, \
299 .led_mode = IWL_LED_RF_STATE, \
301 .rx_with_siso_diversity = true, \
304 struct iwl_cfg iwl105_bgn_cfg = {
305 .name = "Intel(R) Centrino(R) Wireless-N 105 BGN",
307 .ht_params = &iwl2000_ht_params,
310 struct iwl_cfg iwl105_bgn_d_cfg = {
311 .name = "Intel(R) Centrino(R) Wireless-N 105D BGN",
313 .ht_params = &iwl2000_ht_params,
316 #define IWL_DEVICE_135 \
317 .fw_name_pre = IWL135_FW_PRE, \
318 .ucode_api_max = IWL135_UCODE_API_MAX, \
319 .ucode_api_ok = IWL135_UCODE_API_OK, \
320 .ucode_api_min = IWL135_UCODE_API_MIN, \
321 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
322 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
323 .lib = &iwl2030_lib, \
324 .base_params = &iwl2030_base_params, \
325 .bt_params = &iwl2030_bt_params, \
326 .need_temp_offset_calib = true, \
327 .temp_offset_v2 = true, \
328 .led_mode = IWL_LED_RF_STATE, \
330 .rx_with_siso_diversity = true, \
333 struct iwl_cfg iwl135_bgn_cfg = {
334 .name = "Intel(R) Centrino(R) Wireless-N 135 BGN",
336 .ht_params = &iwl2000_ht_params,
339 MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
340 MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
341 MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
342 MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));