blob: a41af47c1926c8256908afef9555244e64d9b4fd [file] [log] [blame]
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001/******************************************************************************
2 *
Reinette Chatre1f447802010-01-15 13:43:41 -08003 * Copyright(c) 2007 - 2010 Intel Corporation. All rights reserved.
Tomas Winkler5a6a2562008-04-24 11:55:23 -07004 *
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 Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
23 *
24 *****************************************************************************/
25
26#include <linux/kernel.h>
27#include <linux/module.h>
Tomas Winkler5a6a2562008-04-24 11:55:23 -070028#include <linux/init.h>
29#include <linux/pci.h>
30#include <linux/dma-mapping.h>
31#include <linux/delay.h>
Alexey Dobriyand43c36d2009-10-07 17:09:06 +040032#include <linux/sched.h>
Tomas Winkler5a6a2562008-04-24 11:55:23 -070033#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"
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070041#include "iwl-dev.h"
Tomas Winkler5a6a2562008-04-24 11:55:23 -070042#include "iwl-core.h"
43#include "iwl-io.h"
Tomas Winklere26e47d2008-06-12 09:46:56 +080044#include "iwl-sta.h"
Tomas Winkler5a6a2562008-04-24 11:55:23 -070045#include "iwl-helpers.h"
Johannes Berga1175122010-01-21 06:21:10 -080046#include "iwl-agn.h"
Johannes Berge932a602009-10-02 13:44:03 -070047#include "iwl-agn-led.h"
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -070048#include "iwl-agn-hw.h"
Tomas Winkler5a6a2562008-04-24 11:55:23 -070049#include "iwl-5000-hw.h"
Jay Sternbergc0bac762009-02-02 16:21:14 -080050#include "iwl-6000-hw.h"
Tomas Winkler5a6a2562008-04-24 11:55:23 -070051
Reinette Chatrea0987a82008-12-02 12:14:06 -080052/* Highest firmware API version supported */
Jay Sternbergc9d2fbf2009-05-19 14:56:36 -070053#define IWL5000_UCODE_API_MAX 2
Jay Sternberg39e6d222009-02-27 16:21:19 -080054#define IWL5150_UCODE_API_MAX 2
Tomas Winkler5a6a2562008-04-24 11:55:23 -070055
Reinette Chatrea0987a82008-12-02 12:14:06 -080056/* Lowest firmware API version supported */
57#define IWL5000_UCODE_API_MIN 1
58#define IWL5150_UCODE_API_MIN 1
59
60#define IWL5000_FW_PRE "iwlwifi-5000-"
61#define _IWL5000_MODULE_FIRMWARE(api) IWL5000_FW_PRE #api ".ucode"
62#define IWL5000_MODULE_FIRMWARE(api) _IWL5000_MODULE_FIRMWARE(api)
63
64#define IWL5150_FW_PRE "iwlwifi-5150-"
65#define _IWL5150_MODULE_FIRMWARE(api) IWL5150_FW_PRE #api ".ucode"
66#define IWL5150_MODULE_FIRMWARE(api) _IWL5150_MODULE_FIRMWARE(api)
Jay Sternberg4e062f92008-10-14 12:32:41 -070067
Johannes Bergedc1a3a2010-02-24 01:57:19 -080068static const s8 iwl5000_default_queue_to_tx_fifo[] = {
69 IWL_TX_FIFO_VO,
70 IWL_TX_FIFO_VI,
71 IWL_TX_FIFO_BE,
72 IWL_TX_FIFO_BK,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -070073 IWLAGN_CMD_FIFO_NUM,
Johannes Bergedc1a3a2010-02-24 01:57:19 -080074 IWL_TX_FIFO_UNUSED,
75 IWL_TX_FIFO_UNUSED,
76 IWL_TX_FIFO_UNUSED,
77 IWL_TX_FIFO_UNUSED,
78 IWL_TX_FIFO_UNUSED,
Ron Rindjunsky99da1b42008-05-15 13:54:13 +080079};
80
Wey-Yi Guy9371d4e2009-09-11 10:38:10 -070081/* NIC configuration for 5000 series */
Wey-Yi Guy672639d2009-07-24 11:13:01 -070082void iwl5000_nic_config(struct iwl_priv *priv)
Tomas Winklere86fe9f2008-04-24 11:55:36 -070083{
84 unsigned long flags;
85 u16 radio_cfg;
Tomas Winklere86fe9f2008-04-24 11:55:36 -070086
87 spin_lock_irqsave(&priv->lock, flags);
88
Tomas Winklere86fe9f2008-04-24 11:55:36 -070089 radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
90
91 /* write radio config values to register */
Wey-Yi Guy9371d4e2009-09-11 10:38:10 -070092 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) < EEPROM_RF_CONFIG_TYPE_MAX)
Tomas Winklere86fe9f2008-04-24 11:55:36 -070093 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
94 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
95 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
96 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
97
98 /* set CSR_HW_CONFIG_REG for uCode use */
99 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
100 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
101 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
102
Tomas Winkler4c43e0d2008-08-04 16:00:39 +0800103 /* W/A : NIC is stuck in a reset state after Early PCIe power off
104 * (PCIe power is lost before PERST# is asserted),
105 * causing ME FW to lose ownership and not being able to obtain it back.
106 */
Tomas Winkler2d3db672008-08-04 16:00:47 +0800107 iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
Tomas Winkler4c43e0d2008-08-04 16:00:39 +0800108 APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
109 ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
110
Wey-Yi Guy02c06e42009-07-17 09:30:14 -0700111
Tomas Winklere86fe9f2008-04-24 11:55:36 -0700112 spin_unlock_irqrestore(&priv->lock, flags);
113}
114
115
Tomas Winkler25ae3982008-04-24 11:55:27 -0700116/*
117 * EEPROM
118 */
119static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address)
120{
121 u16 offset = 0;
122
123 if ((address & INDIRECT_ADDRESS) == 0)
124 return address;
125
126 switch (address & INDIRECT_TYPE_MSK) {
127 case INDIRECT_HOST:
128 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_HOST);
129 break;
130 case INDIRECT_GENERAL:
131 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_GENERAL);
132 break;
133 case INDIRECT_REGULATORY:
134 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_REGULATORY);
135 break;
136 case INDIRECT_CALIBRATION:
137 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_CALIBRATION);
138 break;
139 case INDIRECT_PROCESS_ADJST:
140 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_PROCESS_ADJST);
141 break;
142 case INDIRECT_OTHERS:
143 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_OTHERS);
144 break;
145 default:
Winkler, Tomas15b16872008-12-19 10:37:33 +0800146 IWL_ERR(priv, "illegal indirect type: 0x%X\n",
Tomas Winkler25ae3982008-04-24 11:55:27 -0700147 address & INDIRECT_TYPE_MSK);
148 break;
149 }
150
151 /* translate the offset from words to byte */
152 return (address & ADDRESS_MSK) + (offset << 1);
153}
154
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700155u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv)
Tomas Winklerf1f69412008-04-24 11:55:35 -0700156{
Tomas Winklerf1f69412008-04-24 11:55:35 -0700157 struct iwl_eeprom_calib_hdr {
158 u8 version;
159 u8 pa_type;
160 u16 voltage;
161 } *hdr;
162
Tomas Winklerf1f69412008-04-24 11:55:35 -0700163 hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv,
164 EEPROM_5000_CALIB_ALL);
Tomas Winkler0ef2ca62008-10-23 23:48:51 -0700165 return hdr->version;
Tomas Winklerf1f69412008-04-24 11:55:35 -0700166
167}
168
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -0700169static struct iwl_sensitivity_ranges iwl5000_sensitivity = {
170 .min_nrg_cck = 95,
Wey-Yi Guyfe6efb42009-06-12 13:22:54 -0700171 .max_nrg_cck = 0, /* not used, set to 0 */
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -0700172 .auto_corr_min_ofdm = 90,
173 .auto_corr_min_ofdm_mrc = 170,
174 .auto_corr_min_ofdm_x1 = 120,
175 .auto_corr_min_ofdm_mrc_x1 = 240,
176
177 .auto_corr_max_ofdm = 120,
178 .auto_corr_max_ofdm_mrc = 210,
Wey-Yi Guy9bead762010-01-20 12:22:53 -0800179 .auto_corr_max_ofdm_x1 = 120,
180 .auto_corr_max_ofdm_mrc_x1 = 240,
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -0700181
182 .auto_corr_min_cck = 125,
183 .auto_corr_max_cck = 200,
184 .auto_corr_min_cck_mrc = 170,
185 .auto_corr_max_cck_mrc = 400,
186 .nrg_th_cck = 95,
187 .nrg_th_ofdm = 95,
Wey-Yi Guy55036d62009-10-09 13:20:24 -0700188
189 .barker_corr_th_min = 190,
190 .barker_corr_th_min_mrc = 390,
191 .nrg_th_cca = 62,
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -0700192};
193
Wey-Yi Guy9d671872009-06-12 13:22:53 -0700194static struct iwl_sensitivity_ranges iwl5150_sensitivity = {
195 .min_nrg_cck = 95,
196 .max_nrg_cck = 0, /* not used, set to 0 */
197 .auto_corr_min_ofdm = 90,
198 .auto_corr_min_ofdm_mrc = 170,
199 .auto_corr_min_ofdm_x1 = 105,
200 .auto_corr_min_ofdm_mrc_x1 = 220,
201
202 .auto_corr_max_ofdm = 120,
203 .auto_corr_max_ofdm_mrc = 210,
204 /* max = min for performance bug in 5150 DSP */
205 .auto_corr_max_ofdm_x1 = 105,
206 .auto_corr_max_ofdm_mrc_x1 = 220,
207
208 .auto_corr_min_cck = 125,
209 .auto_corr_max_cck = 200,
210 .auto_corr_min_cck_mrc = 170,
211 .auto_corr_max_cck_mrc = 400,
212 .nrg_th_cck = 95,
213 .nrg_th_ofdm = 95,
Wey-Yi Guy55036d62009-10-09 13:20:24 -0700214
215 .barker_corr_th_min = 190,
216 .barker_corr_th_min_mrc = 390,
217 .nrg_th_cca = 62,
Wey-Yi Guy9d671872009-06-12 13:22:53 -0700218};
219
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700220const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
Tomas Winkler25ae3982008-04-24 11:55:27 -0700221 size_t offset)
222{
223 u32 address = eeprom_indirect_address(priv, offset);
224 BUG_ON(address >= priv->cfg->eeprom_size);
225 return &priv->eeprom[address];
226}
227
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700228static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
Tomas Winkler339afc892008-12-01 16:32:20 -0800229{
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700230 const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700231 s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) -
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700232 iwl_temp_calib_to_offset(priv);
233
234 priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
235}
236
237static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
238{
239 /* want Celsius */
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700240 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
Tomas Winkler339afc892008-12-01 16:32:20 -0800241}
242
Ron Rindjunskydbb983b2008-05-15 13:54:12 +0800243/*
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800244 * Calibration
245 */
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800246static int iwl5000_set_Xtal_calib(struct iwl_priv *priv)
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800247{
Tomas Winkler0d950d82008-11-25 13:36:01 -0800248 struct iwl_calib_xtal_freq_cmd cmd;
Johannes Bergb7bb1752009-12-14 14:12:09 -0800249 __le16 *xtal_calib =
250 (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800251
Tomas Winkler0d950d82008-11-25 13:36:01 -0800252 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
253 cmd.hdr.first_group = 0;
254 cmd.hdr.groups_num = 1;
255 cmd.hdr.data_valid = 1;
Johannes Bergb7bb1752009-12-14 14:12:09 -0800256 cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]);
257 cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]);
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700258 return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL],
Tomas Winkler0d950d82008-11-25 13:36:01 -0800259 (u8 *)&cmd, sizeof(cmd));
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800260}
261
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800262static int iwl5000_send_calib_cfg(struct iwl_priv *priv)
263{
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700264 struct iwl_calib_cfg_cmd calib_cfg_cmd;
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800265 struct iwl_host_cmd cmd = {
266 .id = CALIBRATION_CFG_CMD,
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700267 .len = sizeof(struct iwl_calib_cfg_cmd),
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800268 .data = &calib_cfg_cmd,
269 };
270
271 memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd));
272 calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
273 calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL;
274 calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL;
275 calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL;
276
277 return iwl_send_cmd(priv, &cmd);
278}
279
280static void iwl5000_rx_calib_result(struct iwl_priv *priv,
281 struct iwl_rx_mem_buffer *rxb)
282{
Zhu Yi2f301222009-10-09 17:19:45 +0800283 struct iwl_rx_packet *pkt = rxb_addr(rxb);
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700284 struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw;
Daniel C Halperin396887a2009-08-13 13:31:01 -0700285 int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
Tomas Winkler6e21f2c2008-09-03 11:26:37 +0800286 int index;
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800287
288 /* reduce the size of the length field itself */
289 len -= 4;
290
Tomas Winkler6e21f2c2008-09-03 11:26:37 +0800291 /* Define the order in which the results will be sent to the runtime
292 * uCode. iwl_send_calib_results sends them in a row according to their
293 * index. We sort them here */
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800294 switch (hdr->op_code) {
Tomas Winkler819500c2008-12-01 16:32:19 -0800295 case IWL_PHY_CALIBRATE_DC_CMD:
296 index = IWL_CALIB_DC;
297 break;
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700298 case IWL_PHY_CALIBRATE_LO_CMD:
299 index = IWL_CALIB_LO;
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800300 break;
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700301 case IWL_PHY_CALIBRATE_TX_IQ_CMD:
302 index = IWL_CALIB_TX_IQ;
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800303 break;
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700304 case IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD:
305 index = IWL_CALIB_TX_IQ_PERD;
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800306 break;
Tomas Winkler201706a2008-11-19 15:32:24 -0800307 case IWL_PHY_CALIBRATE_BASE_BAND_CMD:
308 index = IWL_CALIB_BASE_BAND;
309 break;
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800310 default:
Winkler, Tomas15b16872008-12-19 10:37:33 +0800311 IWL_ERR(priv, "Unknown calibration notification %d\n",
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800312 hdr->op_code);
313 return;
314 }
Tomas Winkler6e21f2c2008-09-03 11:26:37 +0800315 iwl_calib_set(&priv->calib_results[index], pkt->u.raw, len);
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800316}
317
318static void iwl5000_rx_calib_complete(struct iwl_priv *priv,
319 struct iwl_rx_mem_buffer *rxb)
320{
Tomas Winklere1623442009-01-27 14:27:56 -0800321 IWL_DEBUG_INFO(priv, "Init. calibration is completed, restarting fw.\n");
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800322 queue_work(priv->workqueue, &priv->restart);
323}
324
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700325void iwl5000_init_alive_start(struct iwl_priv *priv)
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800326{
327 int ret = 0;
328
329 /* Check alive response for "valid" sign from uCode */
330 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
331 /* We had an error bringing up the hardware, so take it
332 * all the way back down so we can try again */
Tomas Winklere1623442009-01-27 14:27:56 -0800333 IWL_DEBUG_INFO(priv, "Initialize Alive failed.\n");
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800334 goto restart;
335 }
336
337 /* initialize uCode was loaded... verify inst image.
338 * This is a paranoid check, because we would not have gotten the
339 * "initialize" alive if code weren't properly loaded. */
340 if (iwl_verify_ucode(priv)) {
341 /* Runtime instruction load was bad;
342 * take it all the way back down so we can try again */
Tomas Winklere1623442009-01-27 14:27:56 -0800343 IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n");
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800344 goto restart;
345 }
346
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800347 ret = priv->cfg->ops->lib->alive_notify(priv);
348 if (ret) {
Winkler, Tomas39aadf82008-12-19 10:37:32 +0800349 IWL_WARN(priv,
350 "Could not complete ALIVE transition: %d\n", ret);
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800351 goto restart;
352 }
353
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800354 iwl5000_send_calib_cfg(priv);
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800355 return;
356
357restart:
358 /* real restart (first load init_ucode) */
359 queue_work(priv->workqueue, &priv->restart);
360}
361
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700362int iwl5000_alive_notify(struct iwl_priv *priv)
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800363{
364 u32 a;
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800365 unsigned long flags;
Winkler, Tomas31a73fe2008-11-19 15:32:26 -0800366 int i, chan;
Winkler, Tomas40fc95d2008-11-19 15:32:27 -0800367 u32 reg_val;
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800368
369 spin_lock_irqsave(&priv->lock, flags);
370
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800371 priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR);
372 a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET;
373 for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET;
374 a += 4)
375 iwl_write_targ_mem(priv, a, 0);
376 for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET;
377 a += 4)
378 iwl_write_targ_mem(priv, a, 0);
Huaxu Wan39d5e0c2009-10-02 13:44:00 -0700379 for (; a < priv->scd_base_addr +
380 IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4)
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800381 iwl_write_targ_mem(priv, a, 0);
382
383 iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
Tomas Winkler4ddbb7d2008-11-07 09:58:40 -0800384 priv->scd_bc_tbls.dma >> 10);
Winkler, Tomas31a73fe2008-11-19 15:32:26 -0800385
386 /* Enable DMA channel */
387 for (chan = 0; chan < FH50_TCSR_CHNL_NUM ; chan++)
388 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
389 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
390 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
391
Winkler, Tomas40fc95d2008-11-19 15:32:27 -0800392 /* Update FH chicken bits */
393 reg_val = iwl_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
394 iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
395 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
396
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800397 iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL,
Tomas Winkler4ddbb7d2008-11-07 09:58:40 -0800398 IWL50_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num));
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800399 iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0);
400
401 /* initiate the queues */
402 for (i = 0; i < priv->hw_params.max_txq_num; i++) {
403 iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(i), 0);
404 iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
405 iwl_write_targ_mem(priv, priv->scd_base_addr +
406 IWL50_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
407 iwl_write_targ_mem(priv, priv->scd_base_addr +
408 IWL50_SCD_CONTEXT_QUEUE_OFFSET(i) +
409 sizeof(u32),
410 ((SCD_WIN_SIZE <<
411 IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
412 IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
413 ((SCD_FRAME_LIMIT <<
414 IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
415 IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
416 }
417
418 iwl_write_prph(priv, IWL50_SCD_INTERRUPT_MASK,
Tomas Winklerda1bc452008-05-29 16:35:00 +0800419 IWL_MASK(0, priv->hw_params.max_txq_num));
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800420
Tomas Winklerda1bc452008-05-29 16:35:00 +0800421 /* Activate all Tx DMA/FIFO channels */
422 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800423
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700424 iwlagn_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
Winkler, Tomas9c80c502008-10-29 14:05:43 -0700425
Wey-Yi Guya9e10fb2010-02-09 08:14:11 -0800426 /* make sure all queue are not stopped */
427 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
428 for (i = 0; i < 4; i++)
429 atomic_set(&priv->queue_stop_count[i], 0);
430
Wey-Yi Guydff010a2010-02-02 16:58:34 -0800431 /* reset to 0 to enable all the queue first */
432 priv->txq_ctx_active_msk = 0;
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800433 /* map qos queues to fifos one-to-one */
Johannes Bergedc1a3a2010-02-24 01:57:19 -0800434 BUILD_BUG_ON(ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo) != 10);
435
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800436 for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
437 int ac = iwl5000_default_queue_to_tx_fifo[i];
Johannes Bergedc1a3a2010-02-24 01:57:19 -0800438
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800439 iwl_txq_ctx_activate(priv, i);
Johannes Bergedc1a3a2010-02-24 01:57:19 -0800440
441 if (ac == IWL_TX_FIFO_UNUSED)
442 continue;
443
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700444 iwlagn_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800445 }
Johannes Berga221e6f2009-11-06 14:52:50 -0800446
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800447 spin_unlock_irqrestore(&priv->lock, flags);
448
Wey-Yi Guy1933ac42009-10-30 14:36:18 -0700449 iwl_send_wimax_coex(priv);
Ron Rindjunsky9636e582008-05-15 13:54:14 +0800450
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800451 iwl5000_set_Xtal_calib(priv);
452 iwl_send_calib_results(priv);
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800453
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800454 return 0;
455}
456
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700457int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
Tomas Winklerfdd3e8a2008-04-24 11:55:28 -0700458{
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700459 if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES &&
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700460 priv->cfg->mod_params->num_of_queues <= IWLAGN_NUM_QUEUES)
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700461 priv->cfg->num_of_queues =
462 priv->cfg->mod_params->num_of_queues;
Tomas Winkler25ae3982008-04-24 11:55:27 -0700463
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700464 priv->hw_params.max_txq_num = priv->cfg->num_of_queues;
Zhu Yif3f911d2008-12-02 12:14:04 -0800465 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
Tomas Winkler4ddbb7d2008-11-07 09:58:40 -0800466 priv->hw_params.scd_bc_tbls_size =
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700467 priv->cfg->num_of_queues *
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700468 sizeof(struct iwlagn_scd_bc_tbl);
Samuel Ortiza8e74e272009-01-23 13:45:14 -0800469 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
Tomas Winklerfdd3e8a2008-04-24 11:55:28 -0700470 priv->hw_params.max_stations = IWL5000_STATION_COUNT;
471 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
Jay Sternbergc0bac762009-02-02 16:21:14 -0800472
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700473 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
474 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
Jay Sternbergc0bac762009-02-02 16:21:14 -0800475
Ron Rindjunskyda154e302008-06-30 17:23:20 +0800476 priv->hw_params.max_bsm_size = 0;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700477 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
Tomas Winklerfdd3e8a2008-04-24 11:55:28 -0700478 BIT(IEEE80211_BAND_5GHZ);
Winkler, Tomas141c43a2009-01-08 10:19:53 -0800479 priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
480
Jay Sternbergc0bac762009-02-02 16:21:14 -0800481 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
482 priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
483 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
484 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
Emmanuel Grumbachc031bf82008-04-24 11:55:29 -0700485
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700486 if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
487 priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
Emmanuel Grumbachc031bf82008-04-24 11:55:29 -0700488
Wey-Yi Guy9d671872009-06-12 13:22:53 -0700489 /* Set initial sensitivity parameters */
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800490 /* Set initial calibration set */
491 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800492 case CSR_HW_REV_TYPE_5150:
Wey-Yi Guy9d671872009-06-12 13:22:53 -0700493 priv->hw_params.sens = &iwl5150_sensitivity;
Tomas Winkler819500c2008-12-01 16:32:19 -0800494 priv->hw_params.calib_init_cfg =
Winkler, Tomas7470d7f2008-12-01 16:32:22 -0800495 BIT(IWL_CALIB_DC) |
496 BIT(IWL_CALIB_LO) |
497 BIT(IWL_CALIB_TX_IQ) |
498 BIT(IWL_CALIB_BASE_BAND);
Tomas Winkler819500c2008-12-01 16:32:19 -0800499
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800500 break;
Jay Sternbergc0bac762009-02-02 16:21:14 -0800501 default:
Wey-Yi Guy9d671872009-06-12 13:22:53 -0700502 priv->hw_params.sens = &iwl5000_sensitivity;
Jay Sternbergc0bac762009-02-02 16:21:14 -0800503 priv->hw_params.calib_init_cfg =
504 BIT(IWL_CALIB_XTAL) |
505 BIT(IWL_CALIB_LO) |
506 BIT(IWL_CALIB_TX_IQ) |
507 BIT(IWL_CALIB_TX_IQ_PERD) |
508 BIT(IWL_CALIB_BASE_BAND);
509 break;
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800510 }
511
Tomas Winklerfdd3e8a2008-04-24 11:55:28 -0700512 return 0;
513}
Ron Rindjunskyd4100dd2008-04-24 11:55:33 -0700514
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800515static inline u32 iwl5000_get_scd_ssn(struct iwl5000_tx_resp *tx_resp)
516{
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300517 return le32_to_cpup((__le32 *)&tx_resp->status +
Tomas Winkler25a65722008-06-12 09:47:07 +0800518 tx_resp->frame_count) & MAX_SN;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800519}
520
521static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
522 struct iwl_ht_agg *agg,
523 struct iwl5000_tx_resp *tx_resp,
Tomas Winkler25a65722008-06-12 09:47:07 +0800524 int txq_id, u16 start_idx)
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800525{
526 u16 status;
527 struct agg_tx_status *frame_status = &tx_resp->status;
528 struct ieee80211_tx_info *info = NULL;
529 struct ieee80211_hdr *hdr = NULL;
Tomas Winklere7d326ac2008-06-12 09:47:11 +0800530 u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
Tomas Winkler25a65722008-06-12 09:47:07 +0800531 int i, sh, idx;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800532 u16 seq;
533
534 if (agg->wait_for_ba)
Tomas Winklere1623442009-01-27 14:27:56 -0800535 IWL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n");
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800536
537 agg->frame_count = tx_resp->frame_count;
538 agg->start_idx = start_idx;
Tomas Winklere7d326ac2008-06-12 09:47:11 +0800539 agg->rate_n_flags = rate_n_flags;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800540 agg->bitmap = 0;
541
542 /* # frames attempted by Tx command */
543 if (agg->frame_count == 1) {
544 /* Only one frame was attempted; no block-ack will arrive */
545 status = le16_to_cpu(frame_status[0].status);
Tomas Winkler25a65722008-06-12 09:47:07 +0800546 idx = start_idx;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800547
548 /* FIXME: code repetition */
Tomas Winklere1623442009-01-27 14:27:56 -0800549 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n",
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800550 agg->frame_count, agg->start_idx, idx);
551
552 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
Johannes Berge6a98542008-10-21 12:40:02 +0200553 info->status.rates[0].count = tx_resp->failure_frame + 1;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800554 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
Johannes Bergc397bf12009-11-13 11:56:35 -0800555 info->flags |= iwl_tx_status_to_mac80211(status);
Tomas Winklere7d326ac2008-06-12 09:47:11 +0800556 iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
557
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800558 /* FIXME: code repetition end */
559
Tomas Winklere1623442009-01-27 14:27:56 -0800560 IWL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n",
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800561 status & 0xff, tx_resp->failure_frame);
Tomas Winklere1623442009-01-27 14:27:56 -0800562 IWL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800563
564 agg->wait_for_ba = 0;
565 } else {
566 /* Two or more frames were attempted; expect block-ack */
567 u64 bitmap = 0;
568 int start = agg->start_idx;
569
570 /* Construct bit-map of pending frames within Tx window */
571 for (i = 0; i < agg->frame_count; i++) {
572 u16 sc;
573 status = le16_to_cpu(frame_status[i].status);
574 seq = le16_to_cpu(frame_status[i].sequence);
575 idx = SEQ_TO_INDEX(seq);
576 txq_id = SEQ_TO_QUEUE(seq);
577
578 if (status & (AGG_TX_STATE_FEW_BYTES_MSK |
579 AGG_TX_STATE_ABORT_MSK))
580 continue;
581
Tomas Winklere1623442009-01-27 14:27:56 -0800582 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n",
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800583 agg->frame_count, txq_id, idx);
584
585 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
Stanislaw Gruszka6c6a22e2009-09-23 10:51:34 +0200586 if (!hdr) {
587 IWL_ERR(priv,
588 "BUG_ON idx doesn't point to valid skb"
589 " idx=%d, txq_id=%d\n", idx, txq_id);
590 return -1;
591 }
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800592
593 sc = le16_to_cpu(hdr->seq_ctrl);
594 if (idx != (SEQ_TO_SN(sc) & 0xff)) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800595 IWL_ERR(priv,
596 "BUG_ON idx doesn't match seq control"
597 " idx=%d, seq_idx=%d, seq=%d\n",
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800598 idx, SEQ_TO_SN(sc),
599 hdr->seq_ctrl);
600 return -1;
601 }
602
Tomas Winklere1623442009-01-27 14:27:56 -0800603 IWL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n",
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800604 i, idx, SEQ_TO_SN(sc));
605
606 sh = idx - start;
607 if (sh > 64) {
608 sh = (start - idx) + 0xff;
609 bitmap = bitmap << sh;
610 sh = 0;
611 start = idx;
612 } else if (sh < -64)
613 sh = 0xff - (start - idx);
614 else if (sh < 0) {
615 sh = start - idx;
616 start = idx;
617 bitmap = bitmap << sh;
618 sh = 0;
619 }
Emmanuel Grumbach4aa41f12008-07-18 13:53:09 +0800620 bitmap |= 1ULL << sh;
Tomas Winklere1623442009-01-27 14:27:56 -0800621 IWL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n",
Emmanuel Grumbach4aa41f12008-07-18 13:53:09 +0800622 start, (unsigned long long)bitmap);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800623 }
624
625 agg->bitmap = bitmap;
626 agg->start_idx = start;
Tomas Winklere1623442009-01-27 14:27:56 -0800627 IWL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n",
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800628 agg->frame_count, agg->start_idx,
629 (unsigned long long)agg->bitmap);
630
631 if (bitmap)
632 agg->wait_for_ba = 1;
633 }
634 return 0;
635}
636
637static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
638 struct iwl_rx_mem_buffer *rxb)
639{
Zhu Yi2f301222009-10-09 17:19:45 +0800640 struct iwl_rx_packet *pkt = rxb_addr(rxb);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800641 u16 sequence = le16_to_cpu(pkt->hdr.sequence);
642 int txq_id = SEQ_TO_QUEUE(sequence);
643 int index = SEQ_TO_INDEX(sequence);
644 struct iwl_tx_queue *txq = &priv->txq[txq_id];
645 struct ieee80211_tx_info *info;
646 struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
647 u32 status = le16_to_cpu(tx_resp->status.status);
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700648 int tid;
649 int sta_id;
650 int freed;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800651
652 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800653 IWL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d "
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800654 "is out of range [0-%d] %d %d\n", txq_id,
655 index, txq->q.n_bd, txq->q.write_ptr,
656 txq->q.read_ptr);
657 return;
658 }
659
660 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
661 memset(&info->status, 0, sizeof(info->status));
662
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700663 tid = (tx_resp->ra_tid & IWL50_TX_RES_TID_MSK) >> IWL50_TX_RES_TID_POS;
664 sta_id = (tx_resp->ra_tid & IWL50_TX_RES_RA_MSK) >> IWL50_TX_RES_RA_POS;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800665
666 if (txq->sched_retry) {
667 const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp);
668 struct iwl_ht_agg *agg = NULL;
669
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800670 agg = &priv->stations[sta_id].tid[tid].agg;
671
Tomas Winkler25a65722008-06-12 09:47:07 +0800672 iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800673
Ron Rindjunsky32354272008-07-01 10:44:51 +0300674 /* check if BAR is needed */
675 if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status))
676 info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800677
678 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800679 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
Tomas Winklere1623442009-01-27 14:27:56 -0800680 IWL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim "
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700681 "scd_ssn=%d idx=%d txq=%d swq=%d\n",
682 scd_ssn , index, txq_id, txq->swq_id);
683
Tomas Winkler17b88922008-05-29 16:35:12 +0800684 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
Wey-Yi Guya239a8b2010-02-19 15:47:32 -0800685 iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800686
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700687 if (priv->mac80211_registered &&
688 (iwl_queue_space(&txq->q) > txq->q.low_mark) &&
689 (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) {
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800690 if (agg->state == IWL_AGG_OFF)
Johannes Berge4e72fb2009-03-23 17:28:42 +0100691 iwl_wake_queue(priv, txq_id);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800692 else
Johannes Berge4e72fb2009-03-23 17:28:42 +0100693 iwl_wake_queue(priv, txq->swq_id);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800694 }
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800695 }
696 } else {
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700697 BUG_ON(txq_id != txq->swq_id);
698
Johannes Berge6a98542008-10-21 12:40:02 +0200699 info->status.rates[0].count = tx_resp->failure_frame + 1;
Johannes Bergc397bf12009-11-13 11:56:35 -0800700 info->flags |= iwl_tx_status_to_mac80211(status);
Tomas Winklere7d326ac2008-06-12 09:47:11 +0800701 iwl_hwrate_to_tx_control(priv,
Ron Rindjunsky4f85f5b2008-06-09 22:54:35 +0300702 le32_to_cpu(tx_resp->rate_n_flags),
703 info);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800704
Tomas Winklere1623442009-01-27 14:27:56 -0800705 IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) rate_n_flags "
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700706 "0x%x retries %d\n",
707 txq_id,
708 iwl_get_tx_fail_reason(status), status,
709 le32_to_cpu(tx_resp->rate_n_flags),
710 tx_resp->failure_frame);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800711
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700712 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
Stanislaw Gruszkaa120e912010-02-19 15:47:33 -0800713 iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700714
715 if (priv->mac80211_registered &&
716 (iwl_queue_space(&txq->q) > txq->q.low_mark))
Johannes Berge4e72fb2009-03-23 17:28:42 +0100717 iwl_wake_queue(priv, txq_id);
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800718 }
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800719
Stanislaw Gruszkaa120e912010-02-19 15:47:33 -0800720 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700721
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800722 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
Winkler, Tomas15b16872008-12-19 10:37:33 +0800723 IWL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n");
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800724}
725
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700726void iwl5000_setup_deferred_work(struct iwl_priv *priv)
Emmanuel Grumbach203566f2008-06-12 09:46:54 +0800727{
728 /* in 5000 the tx power calibration is done in uCode */
729 priv->disable_tx_power_cal = 1;
730}
731
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700732void iwl5000_rx_handler_setup(struct iwl_priv *priv)
Ron Rindjunskyb600e4e2008-05-15 13:54:11 +0800733{
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800734 /* init calibration handlers */
735 priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
736 iwl5000_rx_calib_result;
737 priv->rx_handlers[CALIBRATION_COMPLETE_NOTIFICATION] =
738 iwl5000_rx_calib_complete;
Ron Rindjunskye532fa02008-05-29 16:35:09 +0800739 priv->rx_handlers[REPLY_TX] = iwl5000_rx_reply_tx;
Ron Rindjunskyb600e4e2008-05-15 13:54:11 +0800740}
741
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800742
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700743int iwl5000_hw_valid_rtc_data_addr(u32 addr)
Ron Rindjunsky87283cc2008-05-29 16:34:47 +0800744{
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700745 return (addr >= IWLAGN_RTC_DATA_LOWER_BOUND) &&
746 (addr < IWLAGN_RTC_DATA_UPPER_BOUND);
Ron Rindjunsky87283cc2008-05-29 16:34:47 +0800747}
748
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700749int iwl5000_send_tx_power(struct iwl_priv *priv)
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800750{
751 struct iwl5000_tx_power_dbm_cmd tx_power_cmd;
Jay Sternberg76a24072009-01-29 11:09:14 -0800752 u8 tx_ant_cfg_cmd;
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800753
754 /* half dBm need to multiply */
755 tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
Wey-Yi Guyae16fc32009-11-13 11:56:30 -0800756
757 if (priv->tx_power_lmt_in_half_dbm &&
758 priv->tx_power_lmt_in_half_dbm < tx_power_cmd.global_lmt) {
759 /*
760 * For the newer devices which using enhanced/extend tx power
761 * table in EEPROM, the format is in half dBm. driver need to
762 * convert to dBm format before report to mac80211.
763 * By doing so, there is a possibility of 1/2 dBm resolution
764 * lost. driver will perform "round-up" operation before
765 * reporting, but it will cause 1/2 dBm tx power over the
766 * regulatory limit. Perform the checking here, if the
767 * "tx_power_user_lmt" is higher than EEPROM value (in
768 * half-dBm format), lower the tx power based on EEPROM
769 */
770 tx_power_cmd.global_lmt = priv->tx_power_lmt_in_half_dbm;
771 }
Gregory Greenman853554a2008-06-30 17:23:01 +0800772 tx_power_cmd.flags = IWL50_TX_POWER_NO_CLOSED;
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800773 tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO;
Jay Sternberg76a24072009-01-29 11:09:14 -0800774
775 if (IWL_UCODE_API(priv->ucode_ver) == 1)
776 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD_V1;
777 else
778 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD;
779
780 return iwl_send_cmd_pdu_async(priv, tx_ant_cfg_cmd,
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800781 sizeof(tx_power_cmd), &tx_power_cmd,
782 NULL);
783}
784
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700785void iwl5000_temperature(struct iwl_priv *priv)
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +0800786{
787 /* store temperature from statistics (in Celsius) */
Zhu Yi52256402008-06-30 17:23:31 +0800788 priv->temperature = le32_to_cpu(priv->statistics.general.temperature);
Wey-Yi Guy39b73fb12009-07-24 11:13:02 -0700789 iwl_tt_handler(priv);
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +0800790}
Ron Rindjunskyfe7a90c2008-05-29 16:35:14 +0800791
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700792static void iwl5150_temperature(struct iwl_priv *priv)
793{
794 u32 vt = 0;
795 s32 offset = iwl_temp_calib_to_offset(priv);
796
797 vt = le32_to_cpu(priv->statistics.general.temperature);
798 vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
799 /* now vt hold the temperature in Kelvin */
800 priv->temperature = KELVIN_TO_CELSIUS(vt);
Wey-Yi Guy15993e02009-08-13 13:31:00 -0700801 iwl_tt_handler(priv);
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700802}
803
Wey-Yi Guy4a56e962009-10-23 13:42:29 -0700804static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel)
805{
806 struct iwl5000_channel_switch_cmd cmd;
807 const struct iwl_channel_info *ch_info;
808 struct iwl_host_cmd hcmd = {
809 .id = REPLY_CHANNEL_SWITCH,
810 .len = sizeof(cmd),
811 .flags = CMD_SIZE_HUGE,
812 .data = &cmd,
813 };
814
815 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
816 priv->active_rxon.channel, channel);
817 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
818 cmd.channel = cpu_to_le16(channel);
Wey-Yi Guy0924e5192009-11-06 14:52:54 -0800819 cmd.rxon_flags = priv->staging_rxon.flags;
820 cmd.rxon_filter_flags = priv->staging_rxon.filter_flags;
Wey-Yi Guy4a56e962009-10-23 13:42:29 -0700821 cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
822 ch_info = iwl_get_channel_info(priv, priv->band, channel);
823 if (ch_info)
824 cmd.expect_beacon = is_channel_radar(ch_info);
825 else {
826 IWL_ERR(priv, "invalid channel switch from %u to %u\n",
827 priv->active_rxon.channel, channel);
828 return -EFAULT;
829 }
Wey-Yi Guy0924e5192009-11-06 14:52:54 -0800830 priv->switch_rxon.channel = cpu_to_le16(channel);
831 priv->switch_rxon.switch_in_progress = true;
Wey-Yi Guy4a56e962009-10-23 13:42:29 -0700832
833 return iwl_send_cmd_sync(priv, &hcmd);
834}
835
Jay Sternberge8c00dc2009-01-29 11:09:15 -0800836struct iwl_lib_ops iwl5000_lib = {
Tomas Winklerfdd3e8a2008-04-24 11:55:28 -0700837 .set_hw_params = iwl5000_hw_set_hw_params,
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700838 .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl,
839 .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl,
840 .txq_set_sched = iwlagn_txq_set_sched,
841 .txq_agg_enable = iwlagn_txq_agg_enable,
842 .txq_agg_disable = iwlagn_txq_agg_disable,
Samuel Ortiz7aaa1d72009-01-19 15:30:26 -0800843 .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
844 .txq_free_tfd = iwl_hw_txq_free_tfd,
Samuel Ortiza8e74e272009-01-23 13:45:14 -0800845 .txq_init = iwl_hw_tx_queue_init,
Ron Rindjunskyb600e4e2008-05-15 13:54:11 +0800846 .rx_handler_setup = iwl5000_rx_handler_setup,
Emmanuel Grumbach203566f2008-06-12 09:46:54 +0800847 .setup_deferred_work = iwl5000_setup_deferred_work,
Ron Rindjunsky87283cc2008-05-29 16:34:47 +0800848 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
Reinette Chatreb7a79402009-09-25 14:24:23 -0700849 .dump_nic_event_log = iwl_dump_nic_event_log,
850 .dump_nic_error_log = iwl_dump_nic_error_log,
Wey-Yi Guy696bdee2009-12-10 14:37:25 -0800851 .dump_csr = iwl_dump_csr,
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -0800852 .dump_fh = iwl_dump_fh,
Wey-Yi Guy81b81762010-03-16 10:23:30 -0700853 .load_ucode = iwlagn_load_ucode,
Ron Rindjunsky99da1b42008-05-15 13:54:13 +0800854 .init_alive_start = iwl5000_init_alive_start,
855 .alive_notify = iwl5000_alive_notify,
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800856 .send_tx_power = iwl5000_send_tx_power,
Emmanuel Grumbach5b9f8cd2008-10-29 14:05:46 -0700857 .update_chain_flags = iwl_update_chain_flags,
Wey-Yi Guy4a56e962009-10-23 13:42:29 -0700858 .set_channel_switch = iwl5000_hw_channel_switch,
Tomas Winkler30d59262008-04-24 11:55:25 -0700859 .apm_ops = {
Ben Cahillfadb3582009-10-23 13:42:21 -0700860 .init = iwl_apm_init,
Abhijeet Kolekard68b6032009-10-02 13:44:04 -0700861 .stop = iwl_apm_stop,
Ron Rindjunsky5a835352008-05-05 10:22:29 +0800862 .config = iwl5000_nic_config,
Emmanuel Grumbach5b9f8cd2008-10-29 14:05:46 -0700863 .set_pwr_src = iwl_set_pwr_src,
Tomas Winkler30d59262008-04-24 11:55:25 -0700864 },
Tomas Winklerda8dec22008-04-24 11:55:24 -0700865 .eeprom_ops = {
Tomas Winkler25ae3982008-04-24 11:55:27 -0700866 .regulatory_bands = {
867 EEPROM_5000_REG_BAND_1_CHANNELS,
868 EEPROM_5000_REG_BAND_2_CHANNELS,
869 EEPROM_5000_REG_BAND_3_CHANNELS,
870 EEPROM_5000_REG_BAND_4_CHANNELS,
871 EEPROM_5000_REG_BAND_5_CHANNELS,
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700872 EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
873 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
Tomas Winkler25ae3982008-04-24 11:55:27 -0700874 },
Tomas Winklerda8dec22008-04-24 11:55:24 -0700875 .verify_signature = iwlcore_eeprom_verify_signature,
876 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
877 .release_semaphore = iwlcore_eeprom_release_semaphore,
Tomas Winkler0ef2ca62008-10-23 23:48:51 -0700878 .calib_version = iwl5000_eeprom_calib_version,
Tomas Winkler25ae3982008-04-24 11:55:27 -0700879 .query_addr = iwl5000_eeprom_query_addr,
Tomas Winklerda8dec22008-04-24 11:55:24 -0700880 },
Abhijeet Kolekar5bbe2332009-04-08 11:26:35 -0700881 .post_associate = iwl_post_associate,
Mohamed Abbasef850d72009-05-22 11:01:50 -0700882 .isr = iwl_isr_ict,
Abhijeet Kolekar60690a62009-04-08 11:26:49 -0700883 .config_ap = iwl_config_ap,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700884 .temp_ops = {
885 .temperature = iwl5000_temperature,
886 .set_ct_kill = iwl5000_set_ct_threshold,
887 },
Reinette Chatre3459ab52010-01-22 14:22:49 -0800888 .add_bcast_station = iwl_add_bcast_station,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800889 .recover_from_tx_stall = iwl_bg_monitor_recover,
Wey-Yi Guyfa8f130c2010-03-05 14:22:46 -0800890 .check_plcp_health = iwl_good_plcp_health,
891 .check_ack_health = iwl_good_ack_health,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700892};
893
894static struct iwl_lib_ops iwl5150_lib = {
895 .set_hw_params = iwl5000_hw_set_hw_params,
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700896 .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl,
897 .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl,
898 .txq_set_sched = iwlagn_txq_set_sched,
899 .txq_agg_enable = iwlagn_txq_agg_enable,
900 .txq_agg_disable = iwlagn_txq_agg_disable,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700901 .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
902 .txq_free_tfd = iwl_hw_txq_free_tfd,
903 .txq_init = iwl_hw_tx_queue_init,
904 .rx_handler_setup = iwl5000_rx_handler_setup,
905 .setup_deferred_work = iwl5000_setup_deferred_work,
906 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
Reinette Chatreb7a79402009-09-25 14:24:23 -0700907 .dump_nic_event_log = iwl_dump_nic_event_log,
908 .dump_nic_error_log = iwl_dump_nic_error_log,
Wey-Yi Guy696bdee2009-12-10 14:37:25 -0800909 .dump_csr = iwl_dump_csr,
Wey-Yi Guy81b81762010-03-16 10:23:30 -0700910 .load_ucode = iwlagn_load_ucode,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700911 .init_alive_start = iwl5000_init_alive_start,
912 .alive_notify = iwl5000_alive_notify,
913 .send_tx_power = iwl5000_send_tx_power,
914 .update_chain_flags = iwl_update_chain_flags,
Wey-Yi Guy4a56e962009-10-23 13:42:29 -0700915 .set_channel_switch = iwl5000_hw_channel_switch,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700916 .apm_ops = {
Ben Cahillfadb3582009-10-23 13:42:21 -0700917 .init = iwl_apm_init,
Abhijeet Kolekard68b6032009-10-02 13:44:04 -0700918 .stop = iwl_apm_stop,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700919 .config = iwl5000_nic_config,
920 .set_pwr_src = iwl_set_pwr_src,
921 },
922 .eeprom_ops = {
923 .regulatory_bands = {
924 EEPROM_5000_REG_BAND_1_CHANNELS,
925 EEPROM_5000_REG_BAND_2_CHANNELS,
926 EEPROM_5000_REG_BAND_3_CHANNELS,
927 EEPROM_5000_REG_BAND_4_CHANNELS,
928 EEPROM_5000_REG_BAND_5_CHANNELS,
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700929 EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
930 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700931 },
932 .verify_signature = iwlcore_eeprom_verify_signature,
933 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
934 .release_semaphore = iwlcore_eeprom_release_semaphore,
935 .calib_version = iwl5000_eeprom_calib_version,
936 .query_addr = iwl5000_eeprom_query_addr,
937 },
938 .post_associate = iwl_post_associate,
Mohamed Abbasef850d72009-05-22 11:01:50 -0700939 .isr = iwl_isr_ict,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700940 .config_ap = iwl_config_ap,
941 .temp_ops = {
942 .temperature = iwl5150_temperature,
943 .set_ct_kill = iwl5150_set_ct_threshold,
944 },
Reinette Chatre3459ab52010-01-22 14:22:49 -0800945 .add_bcast_station = iwl_add_bcast_station,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800946 .recover_from_tx_stall = iwl_bg_monitor_recover,
Wey-Yi Guyfa8f130c2010-03-05 14:22:46 -0800947 .check_plcp_health = iwl_good_plcp_health,
948 .check_ack_health = iwl_good_ack_health,
Tomas Winklerda8dec22008-04-24 11:55:24 -0700949};
950
Emese Revfy45d5d802009-12-14 00:59:53 +0100951static const struct iwl_ops iwl5000_ops = {
Wey-Yi Guy792bc3c2010-03-16 10:23:29 -0700952 .ucode = &iwlagn_ucode,
Tomas Winklerda8dec22008-04-24 11:55:24 -0700953 .lib = &iwl5000_lib,
Wey-Yi Guy7dc77db2010-03-16 10:23:31 -0700954 .hcmd = &iwlagn_hcmd,
955 .utils = &iwlagn_hcmd_utils,
Johannes Berge932a602009-10-02 13:44:03 -0700956 .led = &iwlagn_led_ops,
Tomas Winklerda8dec22008-04-24 11:55:24 -0700957};
958
Emese Revfy45d5d802009-12-14 00:59:53 +0100959static const struct iwl_ops iwl5150_ops = {
Wey-Yi Guy792bc3c2010-03-16 10:23:29 -0700960 .ucode = &iwlagn_ucode,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700961 .lib = &iwl5150_lib,
Wey-Yi Guy7dc77db2010-03-16 10:23:31 -0700962 .hcmd = &iwlagn_hcmd,
963 .utils = &iwlagn_hcmd_utils,
Johannes Berge932a602009-10-02 13:44:03 -0700964 .led = &iwlagn_led_ops,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700965};
966
Jay Sternbergcec2d3f2009-01-19 15:30:33 -0800967struct iwl_mod_params iwl50_mod_params = {
Tomas Winkler5a6a2562008-04-24 11:55:23 -0700968 .amsdu_size_8K = 1,
Ester Kummer3a1081e2008-05-06 11:05:14 +0800969 .restart_fw = 1,
Tomas Winkler5a6a2562008-04-24 11:55:23 -0700970 /* the rest are 0 by default */
971};
972
973
974struct iwl_cfg iwl5300_agn_cfg = {
Shanyu Zhaoc11362c2010-03-05 17:05:20 -0800975 .name = "Intel(R) Ultimate N WiFi Link 5300 AGN",
Reinette Chatrea0987a82008-12-02 12:14:06 -0800976 .fw_name_pre = IWL5000_FW_PRE,
977 .ucode_api_max = IWL5000_UCODE_API_MAX,
978 .ucode_api_min = IWL5000_UCODE_API_MIN,
Tomas Winkler5a6a2562008-04-24 11:55:23 -0700979 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Tomas Winklerda8dec22008-04-24 11:55:24 -0700980 .ops = &iwl5000_ops,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700981 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
Tomas Winkler0ef2ca62008-10-23 23:48:51 -0700982 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
983 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700984 .num_of_queues = IWLAGN_NUM_QUEUES,
985 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
Tomas Winkler5a6a2562008-04-24 11:55:23 -0700986 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -0800987 .valid_tx_ant = ANT_ABC,
988 .valid_rx_ant = ANT_ABC,
Ben Cahillfadb3582009-10-23 13:42:21 -0700989 .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
990 .set_l0s = true,
991 .use_bsm = false,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700992 .ht_greenfield_support = true,
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -0700993 .led_compensation = 51,
Wey-Yi Guy1152dcc2010-01-15 13:42:58 -0800994 .use_rts_for_ht = true, /* use rts/cts protection */
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -0700995 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800996 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
Ben Cahilld4fe5ac2010-02-05 11:33:46 -0800997 .chain_noise_scale = 1000,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800998 .monitor_recover_period = IWL_MONITORING_PERIOD,
Tomas Winkler5a6a2562008-04-24 11:55:23 -0700999};
1000
Wey-Yi Guyac592572009-11-20 12:05:03 -08001001struct iwl_cfg iwl5100_bgn_cfg = {
Shanyu Zhaoc11362c2010-03-05 17:05:20 -08001002 .name = "Intel(R) WiFi Link 5100 BGN",
Reinette Chatrea0987a82008-12-02 12:14:06 -08001003 .fw_name_pre = IWL5000_FW_PRE,
1004 .ucode_api_max = IWL5000_UCODE_API_MAX,
1005 .ucode_api_min = IWL5000_UCODE_API_MIN,
Wey-Yi Guyac592572009-11-20 12:05:03 -08001006 .sku = IWL_SKU_G|IWL_SKU_N,
Esti Kummer47408632008-07-11 11:53:30 +08001007 .ops = &iwl5000_ops,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001008 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
Tomas Winkler0ef2ca62008-10-23 23:48:51 -07001009 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1010 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001011 .num_of_queues = IWLAGN_NUM_QUEUES,
1012 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
Esti Kummer47408632008-07-11 11:53:30 +08001013 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -08001014 .valid_tx_ant = ANT_B,
1015 .valid_rx_ant = ANT_AB,
Ben Cahillfadb3582009-10-23 13:42:21 -07001016 .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
1017 .set_l0s = true,
1018 .use_bsm = false,
Daniel C Halperinb2617932009-08-13 13:30:59 -07001019 .ht_greenfield_support = true,
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -07001020 .led_compensation = 51,
Wey-Yi Guy1152dcc2010-01-15 13:42:58 -08001021 .use_rts_for_ht = true, /* use rts/cts protection */
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -07001022 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001023 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
Ben Cahilld4fe5ac2010-02-05 11:33:46 -08001024 .chain_noise_scale = 1000,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -08001025 .monitor_recover_period = IWL_MONITORING_PERIOD,
Esti Kummer47408632008-07-11 11:53:30 +08001026};
1027
1028struct iwl_cfg iwl5100_abg_cfg = {
Shanyu Zhaoc11362c2010-03-05 17:05:20 -08001029 .name = "Intel(R) WiFi Link 5100 ABG",
Reinette Chatrea0987a82008-12-02 12:14:06 -08001030 .fw_name_pre = IWL5000_FW_PRE,
1031 .ucode_api_max = IWL5000_UCODE_API_MAX,
1032 .ucode_api_min = IWL5000_UCODE_API_MIN,
Esti Kummer47408632008-07-11 11:53:30 +08001033 .sku = IWL_SKU_A|IWL_SKU_G,
1034 .ops = &iwl5000_ops,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001035 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
Tomas Winkler0ef2ca62008-10-23 23:48:51 -07001036 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1037 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001038 .num_of_queues = IWLAGN_NUM_QUEUES,
1039 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
Esti Kummer47408632008-07-11 11:53:30 +08001040 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -08001041 .valid_tx_ant = ANT_B,
1042 .valid_rx_ant = ANT_AB,
Ben Cahillfadb3582009-10-23 13:42:21 -07001043 .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
1044 .set_l0s = true,
1045 .use_bsm = false,
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -07001046 .led_compensation = 51,
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -07001047 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001048 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
Ben Cahilld4fe5ac2010-02-05 11:33:46 -08001049 .chain_noise_scale = 1000,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -08001050 .monitor_recover_period = IWL_MONITORING_PERIOD,
Esti Kummer47408632008-07-11 11:53:30 +08001051};
1052
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001053struct iwl_cfg iwl5100_agn_cfg = {
Shanyu Zhaoc11362c2010-03-05 17:05:20 -08001054 .name = "Intel(R) WiFi Link 5100 AGN",
Reinette Chatrea0987a82008-12-02 12:14:06 -08001055 .fw_name_pre = IWL5000_FW_PRE,
1056 .ucode_api_max = IWL5000_UCODE_API_MAX,
1057 .ucode_api_min = IWL5000_UCODE_API_MIN,
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001058 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Tomas Winklerda8dec22008-04-24 11:55:24 -07001059 .ops = &iwl5000_ops,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001060 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
Tomas Winkler0ef2ca62008-10-23 23:48:51 -07001061 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1062 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001063 .num_of_queues = IWLAGN_NUM_QUEUES,
1064 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001065 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -08001066 .valid_tx_ant = ANT_B,
1067 .valid_rx_ant = ANT_AB,
Ben Cahillfadb3582009-10-23 13:42:21 -07001068 .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
1069 .set_l0s = true,
1070 .use_bsm = false,
Daniel C Halperinb2617932009-08-13 13:30:59 -07001071 .ht_greenfield_support = true,
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -07001072 .led_compensation = 51,
Wey-Yi Guy1152dcc2010-01-15 13:42:58 -08001073 .use_rts_for_ht = true, /* use rts/cts protection */
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -07001074 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001075 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
Ben Cahilld4fe5ac2010-02-05 11:33:46 -08001076 .chain_noise_scale = 1000,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -08001077 .monitor_recover_period = IWL_MONITORING_PERIOD,
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001078};
1079
1080struct iwl_cfg iwl5350_agn_cfg = {
Shanyu Zhaoc11362c2010-03-05 17:05:20 -08001081 .name = "Intel(R) WiMAX/WiFi Link 5350 AGN",
Reinette Chatrea0987a82008-12-02 12:14:06 -08001082 .fw_name_pre = IWL5000_FW_PRE,
1083 .ucode_api_max = IWL5000_UCODE_API_MAX,
1084 .ucode_api_min = IWL5000_UCODE_API_MIN,
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001085 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Tomas Winklerda8dec22008-04-24 11:55:24 -07001086 .ops = &iwl5000_ops,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001087 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
Tomas Winkler0ef2ca62008-10-23 23:48:51 -07001088 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1089 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001090 .num_of_queues = IWLAGN_NUM_QUEUES,
1091 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001092 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -08001093 .valid_tx_ant = ANT_ABC,
1094 .valid_rx_ant = ANT_ABC,
Ben Cahillfadb3582009-10-23 13:42:21 -07001095 .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
1096 .set_l0s = true,
1097 .use_bsm = false,
Daniel C Halperinb2617932009-08-13 13:30:59 -07001098 .ht_greenfield_support = true,
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -07001099 .led_compensation = 51,
Wey-Yi Guy1152dcc2010-01-15 13:42:58 -08001100 .use_rts_for_ht = true, /* use rts/cts protection */
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -07001101 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001102 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
Ben Cahilld4fe5ac2010-02-05 11:33:46 -08001103 .chain_noise_scale = 1000,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -08001104 .monitor_recover_period = IWL_MONITORING_PERIOD,
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001105};
1106
Tomas Winkler7100e922008-12-01 16:32:18 -08001107struct iwl_cfg iwl5150_agn_cfg = {
Shanyu Zhaoc11362c2010-03-05 17:05:20 -08001108 .name = "Intel(R) WiMAX/WiFi Link 5150 AGN",
Reinette Chatrea0987a82008-12-02 12:14:06 -08001109 .fw_name_pre = IWL5150_FW_PRE,
1110 .ucode_api_max = IWL5150_UCODE_API_MAX,
1111 .ucode_api_min = IWL5150_UCODE_API_MIN,
Tomas Winkler7100e922008-12-01 16:32:18 -08001112 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Wey-Yi Guy62161ae2009-05-21 13:44:23 -07001113 .ops = &iwl5150_ops,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001114 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
Tomas Winklerfd63edb2008-12-01 16:32:21 -08001115 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1116 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001117 .num_of_queues = IWLAGN_NUM_QUEUES,
1118 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
Tomas Winkler7100e922008-12-01 16:32:18 -08001119 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -08001120 .valid_tx_ant = ANT_A,
1121 .valid_rx_ant = ANT_AB,
Ben Cahillfadb3582009-10-23 13:42:21 -07001122 .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
1123 .set_l0s = true,
1124 .use_bsm = false,
Daniel C Halperinb2617932009-08-13 13:30:59 -07001125 .ht_greenfield_support = true,
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -07001126 .led_compensation = 51,
Wey-Yi Guy1152dcc2010-01-15 13:42:58 -08001127 .use_rts_for_ht = true, /* use rts/cts protection */
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -07001128 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001129 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
Ben Cahilld4fe5ac2010-02-05 11:33:46 -08001130 .chain_noise_scale = 1000,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -08001131 .monitor_recover_period = IWL_MONITORING_PERIOD,
Tomas Winkler7100e922008-12-01 16:32:18 -08001132};
1133
Wey-Yi Guyac592572009-11-20 12:05:03 -08001134struct iwl_cfg iwl5150_abg_cfg = {
Shanyu Zhaoc11362c2010-03-05 17:05:20 -08001135 .name = "Intel(R) WiMAX/WiFi Link 5150 ABG",
Wey-Yi Guyac592572009-11-20 12:05:03 -08001136 .fw_name_pre = IWL5150_FW_PRE,
1137 .ucode_api_max = IWL5150_UCODE_API_MAX,
1138 .ucode_api_min = IWL5150_UCODE_API_MIN,
1139 .sku = IWL_SKU_A|IWL_SKU_G,
1140 .ops = &iwl5150_ops,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001141 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
Wey-Yi Guyac592572009-11-20 12:05:03 -08001142 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1143 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -07001144 .num_of_queues = IWLAGN_NUM_QUEUES,
1145 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
Wey-Yi Guyac592572009-11-20 12:05:03 -08001146 .mod_params = &iwl50_mod_params,
1147 .valid_tx_ant = ANT_A,
1148 .valid_rx_ant = ANT_AB,
1149 .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
1150 .set_l0s = true,
1151 .use_bsm = false,
1152 .led_compensation = 51,
1153 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001154 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
Ben Cahilld4fe5ac2010-02-05 11:33:46 -08001155 .chain_noise_scale = 1000,
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -08001156 .monitor_recover_period = IWL_MONITORING_PERIOD,
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001157};
1158
Reinette Chatrea0987a82008-12-02 12:14:06 -08001159MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
1160MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
Tomas Winklerc9f79ed2008-09-11 11:45:21 +08001161
Wey-Yi Guy4e30cb62009-09-17 10:43:47 -07001162module_param_named(swcrypto50, iwl50_mod_params.sw_crypto, bool, S_IRUGO);
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001163MODULE_PARM_DESC(swcrypto50,
1164 "using software crypto engine (default 0 [hardware])\n");
Wey-Yi Guy4e30cb62009-09-17 10:43:47 -07001165module_param_named(queues_num50, iwl50_mod_params.num_of_queues, int, S_IRUGO);
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001166MODULE_PARM_DESC(queues_num50, "number of hw queues in 50xx series");
Wey-Yi Guy4e30cb62009-09-17 10:43:47 -07001167module_param_named(11n_disable50, iwl50_mod_params.disable_11n, int, S_IRUGO);
Ron Rindjunsky49779292008-06-30 17:23:21 +08001168MODULE_PARM_DESC(11n_disable50, "disable 50XX 11n functionality");
Wey-Yi Guy4e30cb62009-09-17 10:43:47 -07001169module_param_named(amsdu_size_8K50, iwl50_mod_params.amsdu_size_8K,
1170 int, S_IRUGO);
Tomas Winkler5a6a2562008-04-24 11:55:23 -07001171MODULE_PARM_DESC(amsdu_size_8K50, "enable 8K amsdu size in 50XX series");
Wey-Yi Guy4e30cb62009-09-17 10:43:47 -07001172module_param_named(fw_restart50, iwl50_mod_params.restart_fw, int, S_IRUGO);
Ester Kummer3a1081e2008-05-06 11:05:14 +08001173MODULE_PARM_DESC(fw_restart50, "restart firmware in case of error");