]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/net/wireless/iwlwifi/iwl-2000.c
iwlagn: Remove un-necessary indirect call
[mirror_ubuntu-artful-kernel.git] / drivers / net / wireless / iwlwifi / iwl-2000.c
CommitLineData
c5a5e185
WYG
1/******************************************************************************
2 *
901069c7 3 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
c5a5e185
WYG
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/pci.h>
31#include <linux/dma-mapping.h>
32#include <linux/delay.h>
33#include <linux/skbuff.h>
34#include <linux/netdevice.h>
35#include <linux/wireless.h>
36#include <net/mac80211.h>
37#include <linux/etherdevice.h>
38#include <asm/unaligned.h>
39
40#include "iwl-eeprom.h"
41#include "iwl-dev.h"
42#include "iwl-core.h"
43#include "iwl-io.h"
44#include "iwl-sta.h"
45#include "iwl-agn.h"
46#include "iwl-helpers.h"
47#include "iwl-agn-hw.h"
48#include "iwl-6000-hw.h"
c5a5e185
WYG
49
50/* Highest firmware API version supported */
51#define IWL2030_UCODE_API_MAX 5
52#define IWL2000_UCODE_API_MAX 5
b4ed221d 53#define IWL105_UCODE_API_MAX 5
c5a5e185
WYG
54
55/* Lowest firmware API version supported */
56#define IWL2030_UCODE_API_MIN 5
57#define IWL2000_UCODE_API_MIN 5
b4ed221d 58#define IWL105_UCODE_API_MIN 5
c5a5e185
WYG
59
60#define IWL2030_FW_PRE "iwlwifi-2030-"
1d5cc555 61#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE #api ".ucode"
c5a5e185
WYG
62
63#define IWL2000_FW_PRE "iwlwifi-2000-"
1d5cc555 64#define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE #api ".ucode"
c5a5e185 65
b4ed221d
WYG
66#define IWL105_FW_PRE "iwlwifi-105-"
67#define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE #api ".ucode"
c5a5e185
WYG
68
69static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
70{
71 /* want Celsius */
72 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
73 priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
74}
75
76/* NIC configuration for 2000 series */
77static void iwl2000_nic_config(struct iwl_priv *priv)
78{
79 u16 radio_cfg;
80
81 radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
82
83 /* write radio config values to register */
84 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX)
85 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
86 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
87 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
88 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
89
90 /* set CSR_HW_CONFIG_REG for uCode use */
91 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
92 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
93 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
94
52e6b85f
WYG
95 if (priv->cfg->iq_invert)
96 iwl_set_bit(priv, CSR_GP_DRIVER_REG,
97 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
98
dcf6640f
WYG
99 if (priv->cfg->disable_otp_refresh)
100 iwl_write_prph(priv, APMG_ANALOG_SVR_REG, 0x80000010);
c5a5e185
WYG
101}
102
103static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
104 .min_nrg_cck = 97,
105 .max_nrg_cck = 0, /* not used, set to 0 */
106 .auto_corr_min_ofdm = 80,
107 .auto_corr_min_ofdm_mrc = 128,
108 .auto_corr_min_ofdm_x1 = 105,
109 .auto_corr_min_ofdm_mrc_x1 = 192,
110
111 .auto_corr_max_ofdm = 145,
112 .auto_corr_max_ofdm_mrc = 232,
113 .auto_corr_max_ofdm_x1 = 110,
114 .auto_corr_max_ofdm_mrc_x1 = 232,
115
116 .auto_corr_min_cck = 125,
117 .auto_corr_max_cck = 175,
118 .auto_corr_min_cck_mrc = 160,
119 .auto_corr_max_cck_mrc = 310,
120 .nrg_th_cck = 97,
121 .nrg_th_ofdm = 100,
122
123 .barker_corr_th_min = 190,
124 .barker_corr_th_min_mrc = 390,
125 .nrg_th_cca = 62,
126};
127
128static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
129{
9d143e9a
DF
130 if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
131 iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
c5a5e185 132 priv->cfg->base_params->num_of_queues =
9d143e9a 133 iwlagn_mod_params.num_of_queues;
c5a5e185
WYG
134
135 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
136 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
137 priv->hw_params.scd_bc_tbls_size =
138 priv->cfg->base_params->num_of_queues *
139 sizeof(struct iwlagn_scd_bc_tbl);
140 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
141 priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
142 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
143
144 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
145 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
146
c5a5e185
WYG
147 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
148 BIT(IEEE80211_BAND_5GHZ);
149 priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
150
151 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
152 if (priv->cfg->rx_with_siso_diversity)
153 priv->hw_params.rx_chains_num = 1;
154 else
155 priv->hw_params.rx_chains_num =
156 num_of_ant(priv->cfg->valid_rx_ant);
157 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
158 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
159
160 iwl2000_set_ct_threshold(priv);
161
162 /* Set initial sensitivity parameters */
163 /* Set initial calibration set */
164 priv->hw_params.sens = &iwl2000_sensitivity;
165 priv->hw_params.calib_init_cfg =
166 BIT(IWL_CALIB_XTAL) |
167 BIT(IWL_CALIB_LO) |
168 BIT(IWL_CALIB_TX_IQ) |
169 BIT(IWL_CALIB_BASE_BAND);
170 if (priv->cfg->need_dc_calib)
171 priv->hw_params.calib_rt_cfg |= BIT(IWL_CALIB_CFG_DC_IDX);
172 if (priv->cfg->need_temp_offset_calib)
173 priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
174
175 priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
176
177 return 0;
178}
179
c5a5e185
WYG
180static struct iwl_lib_ops iwl2000_lib = {
181 .set_hw_params = iwl2000_hw_set_hw_params,
c5a5e185 182 .rx_handler_setup = iwlagn_rx_handler_setup,
caebbb7a
WYG
183 .setup_deferred_work = iwlagn_bt_setup_deferred_work,
184 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
c5a5e185 185 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
c5a5e185 186 .update_chain_flags = iwl_update_chain_flags,
c5a5e185
WYG
187 .apm_ops = {
188 .init = iwl_apm_init,
189 .config = iwl2000_nic_config,
190 },
191 .eeprom_ops = {
192 .regulatory_bands = {
193 EEPROM_REG_BAND_1_CHANNELS,
194 EEPROM_REG_BAND_2_CHANNELS,
195 EEPROM_REG_BAND_3_CHANNELS,
196 EEPROM_REG_BAND_4_CHANNELS,
197 EEPROM_REG_BAND_5_CHANNELS,
198 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
5cab35e7 199 EEPROM_REGULATORY_BAND_NO_HT40,
c5a5e185 200 },
c5a5e185
WYG
201 .query_addr = iwlagn_eeprom_query_addr,
202 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
203 },
c5a5e185
WYG
204 .temp_ops = {
205 .temperature = iwlagn_temperature,
206 },
c5a5e185
WYG
207};
208
209static const struct iwl_ops iwl2000_ops = {
210 .lib = &iwl2000_lib,
211 .hcmd = &iwlagn_hcmd,
212 .utils = &iwlagn_hcmd_utils,
c5a5e185
WYG
213};
214
215static const struct iwl_ops iwl2030_ops = {
216 .lib = &iwl2000_lib,
217 .hcmd = &iwlagn_bt_hcmd,
218 .utils = &iwlagn_hcmd_utils,
c5a5e185
WYG
219};
220
b4ed221d 221static const struct iwl_ops iwl105_ops = {
c5a5e185
WYG
222 .lib = &iwl2000_lib,
223 .hcmd = &iwlagn_hcmd,
224 .utils = &iwlagn_hcmd_utils,
c5a5e185
WYG
225};
226
b4ed221d 227static const struct iwl_ops iwl135_ops = {
c5a5e185
WYG
228 .lib = &iwl2000_lib,
229 .hcmd = &iwlagn_bt_hcmd,
230 .utils = &iwlagn_hcmd_utils,
c5a5e185
WYG
231};
232
233static struct iwl_base_params iwl2000_base_params = {
234 .eeprom_size = OTP_LOW_IMAGE_SIZE,
235 .num_of_queues = IWLAGN_NUM_QUEUES,
236 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
237 .pll_cfg_val = 0,
c5a5e185
WYG
238 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
239 .shadow_ram_support = true,
240 .led_compensation = 51,
241 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
c5a5e185
WYG
242 .adv_thermal_throttle = true,
243 .support_ct_kill_exit = true,
244 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
245 .chain_noise_scale = 1000,
246 .wd_timeout = IWL_DEF_WD_TIMEOUT,
247 .max_event_log_size = 512,
c5a5e185
WYG
248 .shadow_reg_enable = true,
249};
250
251
252static struct iwl_base_params iwl2030_base_params = {
253 .eeprom_size = OTP_LOW_IMAGE_SIZE,
254 .num_of_queues = IWLAGN_NUM_QUEUES,
255 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
256 .pll_cfg_val = 0,
c5a5e185
WYG
257 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
258 .shadow_ram_support = true,
259 .led_compensation = 57,
260 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
c5a5e185
WYG
261 .adv_thermal_throttle = true,
262 .support_ct_kill_exit = true,
263 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
264 .chain_noise_scale = 1000,
265 .wd_timeout = IWL_LONG_WD_TIMEOUT,
266 .max_event_log_size = 512,
c5a5e185
WYG
267 .shadow_reg_enable = true,
268};
269
270static struct iwl_ht_params iwl2000_ht_params = {
271 .ht_greenfield_support = true,
272 .use_rts_for_aggregation = true, /* use rts/cts protection */
273};
274
275static struct iwl_bt_params iwl2030_bt_params = {
c5a5e185
WYG
276 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
277 .advanced_bt_coexist = true,
278 .agg_time_limit = BT_AGG_THRESHOLD_DEF,
279 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
280 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
281 .bt_sco_disable = true,
6013270a 282 .bt_session_2 = true,
c5a5e185
WYG
283};
284
285#define IWL_DEVICE_2000 \
286 .fw_name_pre = IWL2000_FW_PRE, \
287 .ucode_api_max = IWL2000_UCODE_API_MAX, \
288 .ucode_api_min = IWL2000_UCODE_API_MIN, \
289 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
290 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
291 .ops = &iwl2000_ops, \
c5a5e185
WYG
292 .base_params = &iwl2000_base_params, \
293 .need_dc_calib = true, \
294 .need_temp_offset_calib = true, \
52e6b85f 295 .led_mode = IWL_LED_RF_STATE, \
dcf6640f
WYG
296 .iq_invert = true, \
297 .disable_otp_refresh = true \
c5a5e185
WYG
298
299struct iwl_cfg iwl2000_2bgn_cfg = {
300 .name = "2000 Series 2x2 BGN",
301 IWL_DEVICE_2000,
302 .ht_params = &iwl2000_ht_params,
303};
304
305struct iwl_cfg iwl2000_2bg_cfg = {
306 .name = "2000 Series 2x2 BG",
307 IWL_DEVICE_2000,
308};
309
310#define IWL_DEVICE_2030 \
311 .fw_name_pre = IWL2030_FW_PRE, \
312 .ucode_api_max = IWL2030_UCODE_API_MAX, \
313 .ucode_api_min = IWL2030_UCODE_API_MIN, \
314 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
315 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
316 .ops = &iwl2030_ops, \
c5a5e185
WYG
317 .base_params = &iwl2030_base_params, \
318 .bt_params = &iwl2030_bt_params, \
319 .need_dc_calib = true, \
320 .need_temp_offset_calib = true, \
321 .led_mode = IWL_LED_RF_STATE, \
52e6b85f
WYG
322 .adv_pm = true, \
323 .iq_invert = true \
c5a5e185
WYG
324
325struct iwl_cfg iwl2030_2bgn_cfg = {
326 .name = "2000 Series 2x2 BGN/BT",
96234cc8 327 IWL_DEVICE_2030,
c5a5e185
WYG
328 .ht_params = &iwl2000_ht_params,
329};
330
331struct iwl_cfg iwl2030_2bg_cfg = {
332 .name = "2000 Series 2x2 BG/BT",
96234cc8 333 IWL_DEVICE_2030,
c5a5e185
WYG
334};
335
b4ed221d
WYG
336#define IWL_DEVICE_105 \
337 .fw_name_pre = IWL105_FW_PRE, \
338 .ucode_api_max = IWL105_UCODE_API_MAX, \
339 .ucode_api_min = IWL105_UCODE_API_MIN, \
c5a5e185
WYG
340 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
341 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
b4ed221d 342 .ops = &iwl105_ops, \
c5a5e185
WYG
343 .base_params = &iwl2000_base_params, \
344 .need_dc_calib = true, \
345 .need_temp_offset_calib = true, \
346 .led_mode = IWL_LED_RF_STATE, \
347 .adv_pm = true, \
348 .rx_with_siso_diversity = true \
349
b4ed221d
WYG
350struct iwl_cfg iwl105_bg_cfg = {
351 .name = "105 Series 1x1 BG",
352 IWL_DEVICE_105,
c5a5e185
WYG
353};
354
b4ed221d
WYG
355struct iwl_cfg iwl105_bgn_cfg = {
356 .name = "105 Series 1x1 BGN",
357 IWL_DEVICE_105,
c5a5e185
WYG
358 .ht_params = &iwl2000_ht_params,
359};
360
b4ed221d
WYG
361#define IWL_DEVICE_135 \
362 .fw_name_pre = IWL105_FW_PRE, \
363 .ucode_api_max = IWL105_UCODE_API_MAX, \
364 .ucode_api_min = IWL105_UCODE_API_MIN, \
c5a5e185
WYG
365 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
366 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
b4ed221d 367 .ops = &iwl135_ops, \
c5a5e185
WYG
368 .base_params = &iwl2030_base_params, \
369 .bt_params = &iwl2030_bt_params, \
370 .need_dc_calib = true, \
371 .need_temp_offset_calib = true, \
372 .led_mode = IWL_LED_RF_STATE, \
373 .adv_pm = true, \
374 .rx_with_siso_diversity = true \
375
b4ed221d
WYG
376struct iwl_cfg iwl135_bg_cfg = {
377 .name = "105 Series 1x1 BG/BT",
378 IWL_DEVICE_135,
c5a5e185
WYG
379};
380
b4ed221d
WYG
381struct iwl_cfg iwl135_bgn_cfg = {
382 .name = "105 Series 1x1 BGN/BT",
383 IWL_DEVICE_135,
c5a5e185
WYG
384 .ht_params = &iwl2000_ht_params,
385};
386
387MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
388MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
b4ed221d 389MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));