blob: 0e13f0bb2e178151789b5363006131ecd90b23d8 [file] [log] [blame]
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -08001/******************************************************************************
2 *
Wey-Yi Guy901069c2011-04-05 09:42:00 -07003 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -08004 *
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>
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080030#include <linux/delay.h>
31#include <linux/skbuff.h>
32#include <linux/netdevice.h>
33#include <linux/wireless.h>
34#include <net/mac80211.h>
35#include <linux/etherdevice.h>
36#include <asm/unaligned.h>
Evgeni Golov8fcbd4dc2011-06-12 05:34:31 -070037#include <linux/stringify.h>
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080038
39#include "iwl-eeprom.h"
40#include "iwl-dev.h"
41#include "iwl-core.h"
42#include "iwl-io.h"
43#include "iwl-sta.h"
44#include "iwl-agn.h"
45#include "iwl-helpers.h"
46#include "iwl-agn-hw.h"
47#include "iwl-6000-hw.h"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080048
49/* Highest firmware API version supported */
50#define IWL2030_UCODE_API_MAX 5
51#define IWL2000_UCODE_API_MAX 5
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -070052#define IWL105_UCODE_API_MAX 5
Wey-Yi Guy54e9c402011-07-01 07:47:59 -070053#define IWL135_UCODE_API_MAX 5
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080054
55/* Lowest firmware API version supported */
56#define IWL2030_UCODE_API_MIN 5
57#define IWL2000_UCODE_API_MIN 5
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -070058#define IWL105_UCODE_API_MIN 5
Wey-Yi Guy54e9c402011-07-01 07:47:59 -070059#define IWL135_UCODE_API_MIN 5
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080060
61#define IWL2030_FW_PRE "iwlwifi-2030-"
Evgeni Golov8fcbd4dc2011-06-12 05:34:31 -070062#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080063
64#define IWL2000_FW_PRE "iwlwifi-2000-"
Evgeni Golov8fcbd4dc2011-06-12 05:34:31 -070065#define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE __stringify(api) ".ucode"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080066
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -070067#define IWL105_FW_PRE "iwlwifi-105-"
Evgeni Golov8fcbd4dc2011-06-12 05:34:31 -070068#define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE __stringify(api) ".ucode"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080069
Wey-Yi Guy54e9c402011-07-01 07:47:59 -070070#define IWL135_FW_PRE "iwlwifi-135-"
71#define IWL135_MODULE_FIRMWARE(api) IWL135_FW_PRE #api ".ucode"
72
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080073static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
74{
75 /* want Celsius */
76 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
77 priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
78}
79
80/* NIC configuration for 2000 series */
81static void iwl2000_nic_config(struct iwl_priv *priv)
82{
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -070083 iwl_rf_config(priv);
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080084
Wey-Yi Guy52e6b852011-01-18 08:58:48 -080085 if (priv->cfg->iq_invert)
86 iwl_set_bit(priv, CSR_GP_DRIVER_REG,
87 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080088}
89
90static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
91 .min_nrg_cck = 97,
92 .max_nrg_cck = 0, /* not used, set to 0 */
93 .auto_corr_min_ofdm = 80,
94 .auto_corr_min_ofdm_mrc = 128,
95 .auto_corr_min_ofdm_x1 = 105,
96 .auto_corr_min_ofdm_mrc_x1 = 192,
97
98 .auto_corr_max_ofdm = 145,
99 .auto_corr_max_ofdm_mrc = 232,
100 .auto_corr_max_ofdm_x1 = 110,
101 .auto_corr_max_ofdm_mrc_x1 = 232,
102
103 .auto_corr_min_cck = 125,
104 .auto_corr_max_cck = 175,
105 .auto_corr_min_cck_mrc = 160,
106 .auto_corr_max_cck_mrc = 310,
107 .nrg_th_cck = 97,
108 .nrg_th_ofdm = 100,
109
110 .barker_corr_th_min = 190,
111 .barker_corr_th_min_mrc = 390,
112 .nrg_th_cca = 62,
113};
114
115static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
116{
Don Fry9d143e92011-04-20 15:23:57 -0700117 if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
118 iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800119 priv->cfg->base_params->num_of_queues =
Don Fry9d143e92011-04-20 15:23:57 -0700120 iwlagn_mod_params.num_of_queues;
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800121
122 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800123 priv->hw_params.scd_bc_tbls_size =
124 priv->cfg->base_params->num_of_queues *
125 sizeof(struct iwlagn_scd_bc_tbl);
126 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
127 priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
128 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
129
130 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
131 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
132
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800133 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
134 BIT(IEEE80211_BAND_5GHZ);
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800135
136 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
137 if (priv->cfg->rx_with_siso_diversity)
138 priv->hw_params.rx_chains_num = 1;
139 else
140 priv->hw_params.rx_chains_num =
141 num_of_ant(priv->cfg->valid_rx_ant);
142 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
143 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
144
145 iwl2000_set_ct_threshold(priv);
146
147 /* Set initial sensitivity parameters */
148 /* Set initial calibration set */
149 priv->hw_params.sens = &iwl2000_sensitivity;
150 priv->hw_params.calib_init_cfg =
151 BIT(IWL_CALIB_XTAL) |
152 BIT(IWL_CALIB_LO) |
153 BIT(IWL_CALIB_TX_IQ) |
154 BIT(IWL_CALIB_BASE_BAND);
155 if (priv->cfg->need_dc_calib)
Wey-Yi Guy45d50022011-07-07 12:24:46 -0700156 priv->hw_params.calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800157 if (priv->cfg->need_temp_offset_calib)
158 priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
159
160 priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
161
162 return 0;
163}
164
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800165static struct iwl_lib_ops iwl2000_lib = {
166 .set_hw_params = iwl2000_hw_set_hw_params,
Wey-Yi Guy0a49b2c2011-07-08 08:46:21 -0700167 .nic_config = iwl2000_nic_config,
168 .eeprom_ops = {
169 .regulatory_bands = {
170 EEPROM_REG_BAND_1_CHANNELS,
171 EEPROM_REG_BAND_2_CHANNELS,
172 EEPROM_REG_BAND_3_CHANNELS,
173 EEPROM_REG_BAND_4_CHANNELS,
174 EEPROM_REG_BAND_5_CHANNELS,
175 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
176 EEPROM_REGULATORY_BAND_NO_HT40,
177 },
178 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
179 },
180 .temperature = iwlagn_temperature,
181};
182
183static struct iwl_lib_ops iwl2030_lib = {
184 .set_hw_params = iwl2000_hw_set_hw_params,
Emmanuel Grumbach8d301192011-07-03 15:45:34 +0300185 .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
Emmanuel Grumbach6bd4dba2011-07-03 15:45:34 +0300186 .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
Wey-Yi Guycaebbb72011-02-06 11:29:42 -0800187 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
Fry, Donald He4c598b2011-07-08 08:46:18 -0700188 .nic_config = iwl2000_nic_config,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800189 .eeprom_ops = {
190 .regulatory_bands = {
191 EEPROM_REG_BAND_1_CHANNELS,
192 EEPROM_REG_BAND_2_CHANNELS,
193 EEPROM_REG_BAND_3_CHANNELS,
194 EEPROM_REG_BAND_4_CHANNELS,
195 EEPROM_REG_BAND_5_CHANNELS,
196 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
Wey-Yi Guy5cab35e2011-04-06 15:55:27 -0700197 EEPROM_REGULATORY_BAND_NO_HT40,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800198 },
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800199 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
200 },
Wey-Yi Guy909fc3c2011-07-08 08:46:20 -0700201 .temperature = iwlagn_temperature,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800202};
203
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800204static struct iwl_base_params iwl2000_base_params = {
205 .eeprom_size = OTP_LOW_IMAGE_SIZE,
206 .num_of_queues = IWLAGN_NUM_QUEUES,
207 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
208 .pll_cfg_val = 0,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800209 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
210 .shadow_ram_support = true,
211 .led_compensation = 51,
212 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800213 .adv_thermal_throttle = true,
214 .support_ct_kill_exit = true,
215 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
216 .chain_noise_scale = 1000,
217 .wd_timeout = IWL_DEF_WD_TIMEOUT,
218 .max_event_log_size = 512,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800219 .shadow_reg_enable = true,
220};
221
222
223static struct iwl_base_params iwl2030_base_params = {
224 .eeprom_size = OTP_LOW_IMAGE_SIZE,
225 .num_of_queues = IWLAGN_NUM_QUEUES,
226 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
227 .pll_cfg_val = 0,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800228 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
229 .shadow_ram_support = true,
230 .led_compensation = 57,
231 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800232 .adv_thermal_throttle = true,
233 .support_ct_kill_exit = true,
234 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
235 .chain_noise_scale = 1000,
236 .wd_timeout = IWL_LONG_WD_TIMEOUT,
237 .max_event_log_size = 512,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800238 .shadow_reg_enable = true,
239};
240
241static struct iwl_ht_params iwl2000_ht_params = {
242 .ht_greenfield_support = true,
243 .use_rts_for_aggregation = true, /* use rts/cts protection */
244};
245
246static struct iwl_bt_params iwl2030_bt_params = {
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800247 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
248 .advanced_bt_coexist = true,
249 .agg_time_limit = BT_AGG_THRESHOLD_DEF,
250 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
251 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
252 .bt_sco_disable = true,
Wey-Yi Guy60132702011-02-18 17:23:54 -0800253 .bt_session_2 = true,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800254};
255
256#define IWL_DEVICE_2000 \
257 .fw_name_pre = IWL2000_FW_PRE, \
258 .ucode_api_max = IWL2000_UCODE_API_MAX, \
259 .ucode_api_min = IWL2000_UCODE_API_MIN, \
260 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
261 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
Wey-Yi Guy90c300c2011-07-07 08:33:01 -0700262 .lib = &iwl2000_lib, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800263 .base_params = &iwl2000_base_params, \
264 .need_dc_calib = true, \
265 .need_temp_offset_calib = true, \
Wey-Yi Guy52e6b852011-01-18 08:58:48 -0800266 .led_mode = IWL_LED_RF_STATE, \
Wey-Yi Guyd62b39e2011-07-18 16:58:58 -0700267 .iq_invert = true \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800268
269struct iwl_cfg iwl2000_2bgn_cfg = {
270 .name = "2000 Series 2x2 BGN",
271 IWL_DEVICE_2000,
272 .ht_params = &iwl2000_ht_params,
273};
274
275struct iwl_cfg iwl2000_2bg_cfg = {
276 .name = "2000 Series 2x2 BG",
277 IWL_DEVICE_2000,
278};
279
280#define IWL_DEVICE_2030 \
281 .fw_name_pre = IWL2030_FW_PRE, \
282 .ucode_api_max = IWL2030_UCODE_API_MAX, \
283 .ucode_api_min = IWL2030_UCODE_API_MIN, \
284 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
285 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
Wey-Yi Guy90c300c2011-07-07 08:33:01 -0700286 .lib = &iwl2030_lib, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800287 .base_params = &iwl2030_base_params, \
288 .bt_params = &iwl2030_bt_params, \
289 .need_dc_calib = true, \
290 .need_temp_offset_calib = true, \
291 .led_mode = IWL_LED_RF_STATE, \
Wey-Yi Guy52e6b852011-01-18 08:58:48 -0800292 .adv_pm = true, \
293 .iq_invert = true \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800294
295struct iwl_cfg iwl2030_2bgn_cfg = {
296 .name = "2000 Series 2x2 BGN/BT",
Wey-Yi Guy96234cc2011-01-24 11:44:42 -0800297 IWL_DEVICE_2030,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800298 .ht_params = &iwl2000_ht_params,
299};
300
301struct iwl_cfg iwl2030_2bg_cfg = {
302 .name = "2000 Series 2x2 BG/BT",
Wey-Yi Guy96234cc2011-01-24 11:44:42 -0800303 IWL_DEVICE_2030,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800304};
305
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700306#define IWL_DEVICE_105 \
307 .fw_name_pre = IWL105_FW_PRE, \
308 .ucode_api_max = IWL105_UCODE_API_MAX, \
309 .ucode_api_min = IWL105_UCODE_API_MIN, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800310 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
311 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
Wey-Yi Guy90c300c2011-07-07 08:33:01 -0700312 .lib = &iwl2000_lib, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800313 .base_params = &iwl2000_base_params, \
314 .need_dc_calib = true, \
315 .need_temp_offset_calib = true, \
316 .led_mode = IWL_LED_RF_STATE, \
317 .adv_pm = true, \
Wey-Yi Guy21489ec2011-07-18 13:59:23 -0700318 .rx_with_siso_diversity = true, \
319 .iq_invert = true \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800320
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700321struct iwl_cfg iwl105_bg_cfg = {
322 .name = "105 Series 1x1 BG",
323 IWL_DEVICE_105,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800324};
325
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700326struct iwl_cfg iwl105_bgn_cfg = {
327 .name = "105 Series 1x1 BGN",
328 IWL_DEVICE_105,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800329 .ht_params = &iwl2000_ht_params,
330};
331
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700332#define IWL_DEVICE_135 \
Wey-Yi Guy54e9c402011-07-01 07:47:59 -0700333 .fw_name_pre = IWL135_FW_PRE, \
334 .ucode_api_max = IWL135_UCODE_API_MAX, \
335 .ucode_api_min = IWL135_UCODE_API_MIN, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800336 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
337 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
Wey-Yi Guy90c300c2011-07-07 08:33:01 -0700338 .lib = &iwl2030_lib, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800339 .base_params = &iwl2030_base_params, \
340 .bt_params = &iwl2030_bt_params, \
341 .need_dc_calib = true, \
342 .need_temp_offset_calib = true, \
343 .led_mode = IWL_LED_RF_STATE, \
344 .adv_pm = true, \
Wey-Yi Guy21489ec2011-07-18 13:59:23 -0700345 .rx_with_siso_diversity = true, \
346 .iq_invert = true \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800347
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700348struct iwl_cfg iwl135_bg_cfg = {
Wey-Yi Guy54e9c402011-07-01 07:47:59 -0700349 .name = "135 Series 1x1 BG/BT",
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700350 IWL_DEVICE_135,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800351};
352
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700353struct iwl_cfg iwl135_bgn_cfg = {
Wey-Yi Guy54e9c402011-07-01 07:47:59 -0700354 .name = "135 Series 1x1 BGN/BT",
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700355 IWL_DEVICE_135,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800356 .ht_params = &iwl2000_ht_params,
357};
358
359MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
360MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700361MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
Wey-Yi Guy54e9c402011-07-01 07:47:59 -0700362MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));