Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[cascardo/linux.git] / drivers / net / wireless / iwlwifi / iwl-6000.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  * The full GNU General Public License is included in this distribution in the
19  * file called LICENSE.
20  *
21  * Contact Information:
22  *  Intel Linux Wireless <ilw@linux.intel.com>
23  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24  *
25  *****************************************************************************/
26
27 #include <linux/module.h>
28 #include <linux/stringify.h>
29 #include "iwl-config.h"
30 #include "iwl-agn-hw.h"
31 #include "dvm/commands.h" /* needed for BT for now */
32
33 /* Highest firmware API version supported */
34 #define IWL6000_UCODE_API_MAX 6
35 #define IWL6050_UCODE_API_MAX 5
36 #define IWL6000G2_UCODE_API_MAX 6
37 #define IWL6035_UCODE_API_MAX 6
38
39 /* Oldest version we won't warn about */
40 #define IWL6000_UCODE_API_OK 4
41 #define IWL6000G2_UCODE_API_OK 5
42 #define IWL6050_UCODE_API_OK 5
43 #define IWL6000G2B_UCODE_API_OK 6
44 #define IWL6035_UCODE_API_OK 6
45
46 /* Lowest firmware API version supported */
47 #define IWL6000_UCODE_API_MIN 4
48 #define IWL6050_UCODE_API_MIN 4
49 #define IWL6000G2_UCODE_API_MIN 5
50 #define IWL6035_UCODE_API_MIN 6
51
52 /* EEPROM versions */
53 #define EEPROM_6000_TX_POWER_VERSION    (4)
54 #define EEPROM_6000_EEPROM_VERSION      (0x423)
55 #define EEPROM_6050_TX_POWER_VERSION    (4)
56 #define EEPROM_6050_EEPROM_VERSION      (0x532)
57 #define EEPROM_6150_TX_POWER_VERSION    (6)
58 #define EEPROM_6150_EEPROM_VERSION      (0x553)
59 #define EEPROM_6005_TX_POWER_VERSION    (6)
60 #define EEPROM_6005_EEPROM_VERSION      (0x709)
61 #define EEPROM_6030_TX_POWER_VERSION    (6)
62 #define EEPROM_6030_EEPROM_VERSION      (0x709)
63 #define EEPROM_6035_TX_POWER_VERSION    (6)
64 #define EEPROM_6035_EEPROM_VERSION      (0x753)
65
66 #define IWL6000_FW_PRE "iwlwifi-6000-"
67 #define IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE __stringify(api) ".ucode"
68
69 #define IWL6050_FW_PRE "iwlwifi-6050-"
70 #define IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE __stringify(api) ".ucode"
71
72 #define IWL6005_FW_PRE "iwlwifi-6000g2a-"
73 #define IWL6005_MODULE_FIRMWARE(api) IWL6005_FW_PRE __stringify(api) ".ucode"
74
75 #define IWL6030_FW_PRE "iwlwifi-6000g2b-"
76 #define IWL6030_MODULE_FIRMWARE(api) IWL6030_FW_PRE __stringify(api) ".ucode"
77
78 static const struct iwl_base_params iwl6000_base_params = {
79         .eeprom_size = OTP_LOW_IMAGE_SIZE,
80         .num_of_queues = IWLAGN_NUM_QUEUES,
81         .pll_cfg_val = 0,
82         .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
83         .shadow_ram_support = true,
84         .led_compensation = 51,
85         .wd_timeout = IWL_DEF_WD_TIMEOUT,
86         .max_event_log_size = 512,
87         .shadow_reg_enable = false, /* TODO: fix bugs using this feature */
88         .scd_chain_ext_wa = true,
89 };
90
91 static const struct iwl_base_params iwl6050_base_params = {
92         .eeprom_size = OTP_LOW_IMAGE_SIZE,
93         .num_of_queues = IWLAGN_NUM_QUEUES,
94         .pll_cfg_val = 0,
95         .max_ll_items = OTP_MAX_LL_ITEMS_6x50,
96         .shadow_ram_support = true,
97         .led_compensation = 51,
98         .wd_timeout = IWL_DEF_WD_TIMEOUT,
99         .max_event_log_size = 1024,
100         .shadow_reg_enable = false, /* TODO: fix bugs using this feature */
101         .scd_chain_ext_wa = true,
102 };
103
104 static const struct iwl_base_params iwl6000_g2_base_params = {
105         .eeprom_size = OTP_LOW_IMAGE_SIZE,
106         .num_of_queues = IWLAGN_NUM_QUEUES,
107         .pll_cfg_val = 0,
108         .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
109         .shadow_ram_support = true,
110         .led_compensation = 57,
111         .wd_timeout = IWL_LONG_WD_TIMEOUT,
112         .max_event_log_size = 512,
113         .shadow_reg_enable = false, /* TODO: fix bugs using this feature */
114         .scd_chain_ext_wa = true,
115 };
116
117 static const struct iwl_ht_params iwl6000_ht_params = {
118         .ht_greenfield_support = true,
119         .use_rts_for_aggregation = true, /* use rts/cts protection */
120         .ht40_bands = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ),
121 };
122
123 static const struct iwl_eeprom_params iwl6000_eeprom_params = {
124         .regulatory_bands = {
125                 EEPROM_REG_BAND_1_CHANNELS,
126                 EEPROM_REG_BAND_2_CHANNELS,
127                 EEPROM_REG_BAND_3_CHANNELS,
128                 EEPROM_REG_BAND_4_CHANNELS,
129                 EEPROM_REG_BAND_5_CHANNELS,
130                 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
131                 EEPROM_REG_BAND_52_HT40_CHANNELS
132         },
133         .enhanced_txpower = true,
134 };
135
136 #define IWL_DEVICE_6005                                         \
137         .fw_name_pre = IWL6005_FW_PRE,                          \
138         .ucode_api_max = IWL6000G2_UCODE_API_MAX,               \
139         .ucode_api_ok = IWL6000G2_UCODE_API_OK,                 \
140         .ucode_api_min = IWL6000G2_UCODE_API_MIN,               \
141         .device_family = IWL_DEVICE_FAMILY_6005,                \
142         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
143         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
144         .nvm_ver = EEPROM_6005_EEPROM_VERSION,          \
145         .nvm_calib_ver = EEPROM_6005_TX_POWER_VERSION,  \
146         .base_params = &iwl6000_g2_base_params,                 \
147         .eeprom_params = &iwl6000_eeprom_params,                \
148         .led_mode = IWL_LED_RF_STATE
149
150 const struct iwl_cfg iwl6005_2agn_cfg = {
151         .name = "Intel(R) Centrino(R) Advanced-N 6205 AGN",
152         IWL_DEVICE_6005,
153         .ht_params = &iwl6000_ht_params,
154 };
155
156 const struct iwl_cfg iwl6005_2abg_cfg = {
157         .name = "Intel(R) Centrino(R) Advanced-N 6205 ABG",
158         IWL_DEVICE_6005,
159 };
160
161 const struct iwl_cfg iwl6005_2bg_cfg = {
162         .name = "Intel(R) Centrino(R) Advanced-N 6205 BG",
163         IWL_DEVICE_6005,
164 };
165
166 const struct iwl_cfg iwl6005_2agn_sff_cfg = {
167         .name = "Intel(R) Centrino(R) Advanced-N 6205S AGN",
168         IWL_DEVICE_6005,
169         .ht_params = &iwl6000_ht_params,
170 };
171
172 const struct iwl_cfg iwl6005_2agn_d_cfg = {
173         .name = "Intel(R) Centrino(R) Advanced-N 6205D AGN",
174         IWL_DEVICE_6005,
175         .ht_params = &iwl6000_ht_params,
176 };
177
178 const struct iwl_cfg iwl6005_2agn_mow1_cfg = {
179         .name = "Intel(R) Centrino(R) Advanced-N 6206 AGN",
180         IWL_DEVICE_6005,
181         .ht_params = &iwl6000_ht_params,
182 };
183
184 const struct iwl_cfg iwl6005_2agn_mow2_cfg = {
185         .name = "Intel(R) Centrino(R) Advanced-N 6207 AGN",
186         IWL_DEVICE_6005,
187         .ht_params = &iwl6000_ht_params,
188 };
189
190 #define IWL_DEVICE_6030                                         \
191         .fw_name_pre = IWL6030_FW_PRE,                          \
192         .ucode_api_max = IWL6000G2_UCODE_API_MAX,               \
193         .ucode_api_ok = IWL6000G2B_UCODE_API_OK,                \
194         .ucode_api_min = IWL6000G2_UCODE_API_MIN,               \
195         .device_family = IWL_DEVICE_FAMILY_6030,                \
196         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
197         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
198         .nvm_ver = EEPROM_6030_EEPROM_VERSION,          \
199         .nvm_calib_ver = EEPROM_6030_TX_POWER_VERSION,  \
200         .base_params = &iwl6000_g2_base_params,                 \
201         .eeprom_params = &iwl6000_eeprom_params,                \
202         .led_mode = IWL_LED_RF_STATE
203
204 const struct iwl_cfg iwl6030_2agn_cfg = {
205         .name = "Intel(R) Centrino(R) Advanced-N 6230 AGN",
206         IWL_DEVICE_6030,
207         .ht_params = &iwl6000_ht_params,
208 };
209
210 const struct iwl_cfg iwl6030_2abg_cfg = {
211         .name = "Intel(R) Centrino(R) Advanced-N 6230 ABG",
212         IWL_DEVICE_6030,
213 };
214
215 const struct iwl_cfg iwl6030_2bgn_cfg = {
216         .name = "Intel(R) Centrino(R) Advanced-N 6230 BGN",
217         IWL_DEVICE_6030,
218         .ht_params = &iwl6000_ht_params,
219 };
220
221 const struct iwl_cfg iwl6030_2bg_cfg = {
222         .name = "Intel(R) Centrino(R) Advanced-N 6230 BG",
223         IWL_DEVICE_6030,
224 };
225
226 #define IWL_DEVICE_6035                                         \
227         .fw_name_pre = IWL6030_FW_PRE,                          \
228         .ucode_api_max = IWL6035_UCODE_API_MAX,                 \
229         .ucode_api_ok = IWL6035_UCODE_API_OK,                   \
230         .ucode_api_min = IWL6035_UCODE_API_MIN,                 \
231         .device_family = IWL_DEVICE_FAMILY_6030,                \
232         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
233         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
234         .nvm_ver = EEPROM_6030_EEPROM_VERSION,          \
235         .nvm_calib_ver = EEPROM_6030_TX_POWER_VERSION,  \
236         .base_params = &iwl6000_g2_base_params,                 \
237         .eeprom_params = &iwl6000_eeprom_params,                \
238         .led_mode = IWL_LED_RF_STATE
239
240 const struct iwl_cfg iwl6035_2agn_cfg = {
241         .name = "Intel(R) Centrino(R) Advanced-N 6235 AGN",
242         IWL_DEVICE_6035,
243         .ht_params = &iwl6000_ht_params,
244 };
245
246 const struct iwl_cfg iwl6035_2agn_sff_cfg = {
247         .name = "Intel(R) Centrino(R) Ultimate-N 6235 AGN",
248         IWL_DEVICE_6035,
249         .ht_params = &iwl6000_ht_params,
250 };
251
252 const struct iwl_cfg iwl1030_bgn_cfg = {
253         .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN",
254         IWL_DEVICE_6030,
255         .ht_params = &iwl6000_ht_params,
256 };
257
258 const struct iwl_cfg iwl1030_bg_cfg = {
259         .name = "Intel(R) Centrino(R) Wireless-N 1030 BG",
260         IWL_DEVICE_6030,
261 };
262
263 const struct iwl_cfg iwl130_bgn_cfg = {
264         .name = "Intel(R) Centrino(R) Wireless-N 130 BGN",
265         IWL_DEVICE_6030,
266         .ht_params = &iwl6000_ht_params,
267         .rx_with_siso_diversity = true,
268 };
269
270 const struct iwl_cfg iwl130_bg_cfg = {
271         .name = "Intel(R) Centrino(R) Wireless-N 130 BG",
272         IWL_DEVICE_6030,
273         .rx_with_siso_diversity = true,
274 };
275
276 /*
277  * "i": Internal configuration, use internal Power Amplifier
278  */
279 #define IWL_DEVICE_6000i                                        \
280         .fw_name_pre = IWL6000_FW_PRE,                          \
281         .ucode_api_max = IWL6000_UCODE_API_MAX,                 \
282         .ucode_api_ok = IWL6000_UCODE_API_OK,                   \
283         .ucode_api_min = IWL6000_UCODE_API_MIN,                 \
284         .device_family = IWL_DEVICE_FAMILY_6000i,               \
285         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
286         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
287         .valid_tx_ant = ANT_BC,         /* .cfg overwrite */    \
288         .valid_rx_ant = ANT_BC,         /* .cfg overwrite */    \
289         .nvm_ver = EEPROM_6000_EEPROM_VERSION,          \
290         .nvm_calib_ver = EEPROM_6000_TX_POWER_VERSION,  \
291         .base_params = &iwl6000_base_params,                    \
292         .eeprom_params = &iwl6000_eeprom_params,                \
293         .led_mode = IWL_LED_BLINK
294
295 const struct iwl_cfg iwl6000i_2agn_cfg = {
296         .name = "Intel(R) Centrino(R) Advanced-N 6200 AGN",
297         IWL_DEVICE_6000i,
298         .ht_params = &iwl6000_ht_params,
299 };
300
301 const struct iwl_cfg iwl6000i_2abg_cfg = {
302         .name = "Intel(R) Centrino(R) Advanced-N 6200 ABG",
303         IWL_DEVICE_6000i,
304 };
305
306 const struct iwl_cfg iwl6000i_2bg_cfg = {
307         .name = "Intel(R) Centrino(R) Advanced-N 6200 BG",
308         IWL_DEVICE_6000i,
309 };
310
311 #define IWL_DEVICE_6050                                         \
312         .fw_name_pre = IWL6050_FW_PRE,                          \
313         .ucode_api_max = IWL6050_UCODE_API_MAX,                 \
314         .ucode_api_min = IWL6050_UCODE_API_MIN,                 \
315         .device_family = IWL_DEVICE_FAMILY_6050,                \
316         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
317         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
318         .valid_tx_ant = ANT_AB,         /* .cfg overwrite */    \
319         .valid_rx_ant = ANT_AB,         /* .cfg overwrite */    \
320         .nvm_ver = EEPROM_6050_EEPROM_VERSION,          \
321         .nvm_calib_ver = EEPROM_6050_TX_POWER_VERSION,  \
322         .base_params = &iwl6050_base_params,                    \
323         .eeprom_params = &iwl6000_eeprom_params,                \
324         .led_mode = IWL_LED_BLINK,                              \
325         .internal_wimax_coex = true
326
327 const struct iwl_cfg iwl6050_2agn_cfg = {
328         .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN",
329         IWL_DEVICE_6050,
330         .ht_params = &iwl6000_ht_params,
331 };
332
333 const struct iwl_cfg iwl6050_2abg_cfg = {
334         .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 ABG",
335         IWL_DEVICE_6050,
336 };
337
338 #define IWL_DEVICE_6150                                         \
339         .fw_name_pre = IWL6050_FW_PRE,                          \
340         .ucode_api_max = IWL6050_UCODE_API_MAX,                 \
341         .ucode_api_min = IWL6050_UCODE_API_MIN,                 \
342         .device_family = IWL_DEVICE_FAMILY_6150,                \
343         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
344         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
345         .nvm_ver = EEPROM_6150_EEPROM_VERSION,          \
346         .nvm_calib_ver = EEPROM_6150_TX_POWER_VERSION,  \
347         .base_params = &iwl6050_base_params,                    \
348         .eeprom_params = &iwl6000_eeprom_params,                \
349         .led_mode = IWL_LED_BLINK,                              \
350         .internal_wimax_coex = true
351
352 const struct iwl_cfg iwl6150_bgn_cfg = {
353         .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN",
354         IWL_DEVICE_6150,
355         .ht_params = &iwl6000_ht_params,
356 };
357
358 const struct iwl_cfg iwl6150_bg_cfg = {
359         .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG",
360         IWL_DEVICE_6150,
361 };
362
363 const struct iwl_cfg iwl6000_3agn_cfg = {
364         .name = "Intel(R) Centrino(R) Ultimate-N 6300 AGN",
365         .fw_name_pre = IWL6000_FW_PRE,
366         .ucode_api_max = IWL6000_UCODE_API_MAX,
367         .ucode_api_ok = IWL6000_UCODE_API_OK,
368         .ucode_api_min = IWL6000_UCODE_API_MIN,
369         .device_family = IWL_DEVICE_FAMILY_6000,
370         .max_inst_size = IWL60_RTC_INST_SIZE,
371         .max_data_size = IWL60_RTC_DATA_SIZE,
372         .nvm_ver = EEPROM_6000_EEPROM_VERSION,
373         .nvm_calib_ver = EEPROM_6000_TX_POWER_VERSION,
374         .base_params = &iwl6000_base_params,
375         .eeprom_params = &iwl6000_eeprom_params,
376         .ht_params = &iwl6000_ht_params,
377         .led_mode = IWL_LED_BLINK,
378 };
379
380 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_OK));
381 MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_OK));
382 MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_OK));
383 MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2B_UCODE_API_OK));