blob: 56a22de847dae850ef7e4a546ce9edac1a3a71ee [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>
37
38#include "iwl-eeprom.h"
39#include "iwl-dev.h"
40#include "iwl-core.h"
41#include "iwl-io.h"
42#include "iwl-sta.h"
43#include "iwl-agn.h"
44#include "iwl-helpers.h"
45#include "iwl-agn-hw.h"
46#include "iwl-6000-hw.h"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080047
48/* Highest firmware API version supported */
49#define IWL2030_UCODE_API_MAX 5
50#define IWL2000_UCODE_API_MAX 5
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -070051#define IWL105_UCODE_API_MAX 5
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080052
53/* Lowest firmware API version supported */
54#define IWL2030_UCODE_API_MIN 5
55#define IWL2000_UCODE_API_MIN 5
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -070056#define IWL105_UCODE_API_MIN 5
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080057
58#define IWL2030_FW_PRE "iwlwifi-2030-"
root1d5cc5552011-03-28 16:12:43 -070059#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE #api ".ucode"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080060
61#define IWL2000_FW_PRE "iwlwifi-2000-"
root1d5cc5552011-03-28 16:12:43 -070062#define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE #api ".ucode"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080063
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -070064#define IWL105_FW_PRE "iwlwifi-105-"
65#define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE #api ".ucode"
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080066
67static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
68{
69 /* want Celsius */
70 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
71 priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
72}
73
74/* NIC configuration for 2000 series */
75static void iwl2000_nic_config(struct iwl_priv *priv)
76{
77 u16 radio_cfg;
78
79 radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
80
81 /* write radio config values to register */
82 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX)
Wey-Yi Guy916b3372011-06-14 13:00:07 -070083 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
84 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
85 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
86 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080087
88 /* set CSR_HW_CONFIG_REG for uCode use */
89 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
90 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
91 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
92
Wey-Yi Guy52e6b852011-01-18 08:58:48 -080093 if (priv->cfg->iq_invert)
94 iwl_set_bit(priv, CSR_GP_DRIVER_REG,
95 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
96
Wey-Yi Guydcf66402011-04-01 13:20:44 -070097 if (priv->cfg->disable_otp_refresh)
98 iwl_write_prph(priv, APMG_ANALOG_SVR_REG, 0x80000010);
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -080099}
100
101static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
102 .min_nrg_cck = 97,
103 .max_nrg_cck = 0, /* not used, set to 0 */
104 .auto_corr_min_ofdm = 80,
105 .auto_corr_min_ofdm_mrc = 128,
106 .auto_corr_min_ofdm_x1 = 105,
107 .auto_corr_min_ofdm_mrc_x1 = 192,
108
109 .auto_corr_max_ofdm = 145,
110 .auto_corr_max_ofdm_mrc = 232,
111 .auto_corr_max_ofdm_x1 = 110,
112 .auto_corr_max_ofdm_mrc_x1 = 232,
113
114 .auto_corr_min_cck = 125,
115 .auto_corr_max_cck = 175,
116 .auto_corr_min_cck_mrc = 160,
117 .auto_corr_max_cck_mrc = 310,
118 .nrg_th_cck = 97,
119 .nrg_th_ofdm = 100,
120
121 .barker_corr_th_min = 190,
122 .barker_corr_th_min_mrc = 390,
123 .nrg_th_cca = 62,
124};
125
126static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
127{
Don Fry9d143e92011-04-20 15:23:57 -0700128 if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
129 iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800130 priv->cfg->base_params->num_of_queues =
Don Fry9d143e92011-04-20 15:23:57 -0700131 iwlagn_mod_params.num_of_queues;
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800132
133 priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
134 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
135 priv->hw_params.scd_bc_tbls_size =
136 priv->cfg->base_params->num_of_queues *
137 sizeof(struct iwlagn_scd_bc_tbl);
138 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
139 priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
140 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
141
142 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
143 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
144
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800145 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
146 BIT(IEEE80211_BAND_5GHZ);
147 priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
148
149 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
150 if (priv->cfg->rx_with_siso_diversity)
151 priv->hw_params.rx_chains_num = 1;
152 else
153 priv->hw_params.rx_chains_num =
154 num_of_ant(priv->cfg->valid_rx_ant);
155 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
156 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
157
158 iwl2000_set_ct_threshold(priv);
159
160 /* Set initial sensitivity parameters */
161 /* Set initial calibration set */
162 priv->hw_params.sens = &iwl2000_sensitivity;
163 priv->hw_params.calib_init_cfg =
164 BIT(IWL_CALIB_XTAL) |
165 BIT(IWL_CALIB_LO) |
166 BIT(IWL_CALIB_TX_IQ) |
167 BIT(IWL_CALIB_BASE_BAND);
168 if (priv->cfg->need_dc_calib)
169 priv->hw_params.calib_rt_cfg |= BIT(IWL_CALIB_CFG_DC_IDX);
170 if (priv->cfg->need_temp_offset_calib)
171 priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
172
173 priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
174
175 return 0;
176}
177
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800178static struct iwl_lib_ops iwl2000_lib = {
179 .set_hw_params = iwl2000_hw_set_hw_params,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800180 .rx_handler_setup = iwlagn_rx_handler_setup,
Wey-Yi Guycaebbb72011-02-06 11:29:42 -0800181 .setup_deferred_work = iwlagn_bt_setup_deferred_work,
182 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800183 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800184 .update_chain_flags = iwl_update_chain_flags,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800185 .apm_ops = {
186 .init = iwl_apm_init,
187 .config = iwl2000_nic_config,
188 },
189 .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 .query_addr = iwlagn_eeprom_query_addr,
200 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
201 },
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800202 .temp_ops = {
203 .temperature = iwlagn_temperature,
204 },
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800205};
206
207static const struct iwl_ops iwl2000_ops = {
208 .lib = &iwl2000_lib,
209 .hcmd = &iwlagn_hcmd,
210 .utils = &iwlagn_hcmd_utils,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800211};
212
213static const struct iwl_ops iwl2030_ops = {
214 .lib = &iwl2000_lib,
215 .hcmd = &iwlagn_bt_hcmd,
216 .utils = &iwlagn_hcmd_utils,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800217};
218
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700219static const struct iwl_ops iwl105_ops = {
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800220 .lib = &iwl2000_lib,
221 .hcmd = &iwlagn_hcmd,
222 .utils = &iwlagn_hcmd_utils,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800223};
224
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700225static const struct iwl_ops iwl135_ops = {
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800226 .lib = &iwl2000_lib,
227 .hcmd = &iwlagn_bt_hcmd,
228 .utils = &iwlagn_hcmd_utils,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800229};
230
231static struct iwl_base_params iwl2000_base_params = {
232 .eeprom_size = OTP_LOW_IMAGE_SIZE,
233 .num_of_queues = IWLAGN_NUM_QUEUES,
234 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
235 .pll_cfg_val = 0,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800236 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
237 .shadow_ram_support = true,
238 .led_compensation = 51,
239 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800240 .adv_thermal_throttle = true,
241 .support_ct_kill_exit = true,
242 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
243 .chain_noise_scale = 1000,
244 .wd_timeout = IWL_DEF_WD_TIMEOUT,
245 .max_event_log_size = 512,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800246 .shadow_reg_enable = true,
247};
248
249
250static struct iwl_base_params iwl2030_base_params = {
251 .eeprom_size = OTP_LOW_IMAGE_SIZE,
252 .num_of_queues = IWLAGN_NUM_QUEUES,
253 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
254 .pll_cfg_val = 0,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800255 .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
256 .shadow_ram_support = true,
257 .led_compensation = 57,
258 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800259 .adv_thermal_throttle = true,
260 .support_ct_kill_exit = true,
261 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
262 .chain_noise_scale = 1000,
263 .wd_timeout = IWL_LONG_WD_TIMEOUT,
264 .max_event_log_size = 512,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800265 .shadow_reg_enable = true,
266};
267
268static struct iwl_ht_params iwl2000_ht_params = {
269 .ht_greenfield_support = true,
270 .use_rts_for_aggregation = true, /* use rts/cts protection */
271};
272
273static struct iwl_bt_params iwl2030_bt_params = {
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800274 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
275 .advanced_bt_coexist = true,
276 .agg_time_limit = BT_AGG_THRESHOLD_DEF,
277 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
278 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
279 .bt_sco_disable = true,
Wey-Yi Guy60132702011-02-18 17:23:54 -0800280 .bt_session_2 = true,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800281};
282
283#define IWL_DEVICE_2000 \
284 .fw_name_pre = IWL2000_FW_PRE, \
285 .ucode_api_max = IWL2000_UCODE_API_MAX, \
286 .ucode_api_min = IWL2000_UCODE_API_MIN, \
287 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
288 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
289 .ops = &iwl2000_ops, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800290 .base_params = &iwl2000_base_params, \
291 .need_dc_calib = true, \
292 .need_temp_offset_calib = true, \
Wey-Yi Guy52e6b852011-01-18 08:58:48 -0800293 .led_mode = IWL_LED_RF_STATE, \
Wey-Yi Guydcf66402011-04-01 13:20:44 -0700294 .iq_invert = true, \
295 .disable_otp_refresh = true \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800296
297struct iwl_cfg iwl2000_2bgn_cfg = {
298 .name = "2000 Series 2x2 BGN",
299 IWL_DEVICE_2000,
300 .ht_params = &iwl2000_ht_params,
301};
302
303struct iwl_cfg iwl2000_2bg_cfg = {
304 .name = "2000 Series 2x2 BG",
305 IWL_DEVICE_2000,
306};
307
308#define IWL_DEVICE_2030 \
309 .fw_name_pre = IWL2030_FW_PRE, \
310 .ucode_api_max = IWL2030_UCODE_API_MAX, \
311 .ucode_api_min = IWL2030_UCODE_API_MIN, \
312 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
313 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
314 .ops = &iwl2030_ops, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800315 .base_params = &iwl2030_base_params, \
316 .bt_params = &iwl2030_bt_params, \
317 .need_dc_calib = true, \
318 .need_temp_offset_calib = true, \
319 .led_mode = IWL_LED_RF_STATE, \
Wey-Yi Guy52e6b852011-01-18 08:58:48 -0800320 .adv_pm = true, \
321 .iq_invert = true \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800322
323struct iwl_cfg iwl2030_2bgn_cfg = {
324 .name = "2000 Series 2x2 BGN/BT",
Wey-Yi Guy96234cc2011-01-24 11:44:42 -0800325 IWL_DEVICE_2030,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800326 .ht_params = &iwl2000_ht_params,
327};
328
329struct iwl_cfg iwl2030_2bg_cfg = {
330 .name = "2000 Series 2x2 BG/BT",
Wey-Yi Guy96234cc2011-01-24 11:44:42 -0800331 IWL_DEVICE_2030,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800332};
333
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700334#define IWL_DEVICE_105 \
335 .fw_name_pre = IWL105_FW_PRE, \
336 .ucode_api_max = IWL105_UCODE_API_MAX, \
337 .ucode_api_min = IWL105_UCODE_API_MIN, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800338 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
339 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700340 .ops = &iwl105_ops, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800341 .base_params = &iwl2000_base_params, \
342 .need_dc_calib = true, \
343 .need_temp_offset_calib = true, \
344 .led_mode = IWL_LED_RF_STATE, \
345 .adv_pm = true, \
346 .rx_with_siso_diversity = true \
347
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700348struct iwl_cfg iwl105_bg_cfg = {
349 .name = "105 Series 1x1 BG",
350 IWL_DEVICE_105,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800351};
352
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700353struct iwl_cfg iwl105_bgn_cfg = {
354 .name = "105 Series 1x1 BGN",
355 IWL_DEVICE_105,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800356 .ht_params = &iwl2000_ht_params,
357};
358
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700359#define IWL_DEVICE_135 \
360 .fw_name_pre = IWL105_FW_PRE, \
361 .ucode_api_max = IWL105_UCODE_API_MAX, \
362 .ucode_api_min = IWL105_UCODE_API_MIN, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800363 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
364 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700365 .ops = &iwl135_ops, \
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800366 .base_params = &iwl2030_base_params, \
367 .bt_params = &iwl2030_bt_params, \
368 .need_dc_calib = true, \
369 .need_temp_offset_calib = true, \
370 .led_mode = IWL_LED_RF_STATE, \
371 .adv_pm = true, \
372 .rx_with_siso_diversity = true \
373
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700374struct iwl_cfg iwl135_bg_cfg = {
375 .name = "105 Series 1x1 BG/BT",
376 IWL_DEVICE_135,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800377};
378
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700379struct iwl_cfg iwl135_bgn_cfg = {
380 .name = "105 Series 1x1 BGN/BT",
381 IWL_DEVICE_135,
Wey-Yi Guyc5a5e182011-01-21 15:47:21 -0800382 .ht_params = &iwl2000_ht_params,
383};
384
385MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
386MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
Wey-Yi Guyb4ed2212011-04-30 08:55:16 -0700387MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));