Merge branch 'next' into for-linus
[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 };
89
90 static const struct iwl_base_params iwl6050_base_params = {
91         .eeprom_size = OTP_LOW_IMAGE_SIZE,
92         .num_of_queues = IWLAGN_NUM_QUEUES,
93         .pll_cfg_val = 0,
94         .max_ll_items = OTP_MAX_LL_ITEMS_6x50,
95         .shadow_ram_support = true,
96         .led_compensation = 51,
97         .wd_timeout = IWL_DEF_WD_TIMEOUT,
98         .max_event_log_size = 1024,
99         .shadow_reg_enable = false, /* TODO: fix bugs using this feature */
100 };
101
102 static const struct iwl_base_params iwl6000_g2_base_params = {
103         .eeprom_size = OTP_LOW_IMAGE_SIZE,
104         .num_of_queues = IWLAGN_NUM_QUEUES,
105         .pll_cfg_val = 0,
106         .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
107         .shadow_ram_support = true,
108         .led_compensation = 57,
109         .wd_timeout = IWL_LONG_WD_TIMEOUT,
110         .max_event_log_size = 512,
111         .shadow_reg_enable = false, /* TODO: fix bugs using this feature */
112 };
113
114 static const struct iwl_ht_params iwl6000_ht_params = {
115         .ht_greenfield_support = true,
116         .use_rts_for_aggregation = true, /* use rts/cts protection */
117         .ht40_bands = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ),
118 };
119
120 static const struct iwl_eeprom_params iwl6000_eeprom_params = {
121         .regulatory_bands = {
122                 EEPROM_REG_BAND_1_CHANNELS,
123                 EEPROM_REG_BAND_2_CHANNELS,
124                 EEPROM_REG_BAND_3_CHANNELS,
125                 EEPROM_REG_BAND_4_CHANNELS,
126                 EEPROM_REG_BAND_5_CHANNELS,
127                 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
128                 EEPROM_REG_BAND_52_HT40_CHANNELS
129         },
130         .enhanced_txpower = true,
131 };
132
133 #define IWL_DEVICE_6005                                         \
134         .fw_name_pre = IWL6005_FW_PRE,                          \
135         .ucode_api_max = IWL6000G2_UCODE_API_MAX,               \
136         .ucode_api_ok = IWL6000G2_UCODE_API_OK,                 \
137         .ucode_api_min = IWL6000G2_UCODE_API_MIN,               \
138         .device_family = IWL_DEVICE_FAMILY_6005,                \
139         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
140         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
141         .nvm_ver = EEPROM_6005_EEPROM_VERSION,          \
142         .nvm_calib_ver = EEPROM_6005_TX_POWER_VERSION,  \
143         .base_params = &iwl6000_g2_base_params,                 \
144         .eeprom_params = &iwl6000_eeprom_params,                \
145         .led_mode = IWL_LED_RF_STATE
146
147 const struct iwl_cfg iwl6005_2agn_cfg = {
148         .name = "Intel(R) Centrino(R) Advanced-N 6205 AGN",
149         IWL_DEVICE_6005,
150         .ht_params = &iwl6000_ht_params,
151 };
152
153 const struct iwl_cfg iwl6005_2abg_cfg = {
154         .name = "Intel(R) Centrino(R) Advanced-N 6205 ABG",
155         IWL_DEVICE_6005,
156 };
157
158 const struct iwl_cfg iwl6005_2bg_cfg = {
159         .name = "Intel(R) Centrino(R) Advanced-N 6205 BG",
160         IWL_DEVICE_6005,
161 };
162
163 const struct iwl_cfg iwl6005_2agn_sff_cfg = {
164         .name = "Intel(R) Centrino(R) Advanced-N 6205S AGN",
165         IWL_DEVICE_6005,
166         .ht_params = &iwl6000_ht_params,
167 };
168
169 const struct iwl_cfg iwl6005_2agn_d_cfg = {
170         .name = "Intel(R) Centrino(R) Advanced-N 6205D AGN",
171         IWL_DEVICE_6005,
172         .ht_params = &iwl6000_ht_params,
173 };
174
175 const struct iwl_cfg iwl6005_2agn_mow1_cfg = {
176         .name = "Intel(R) Centrino(R) Advanced-N 6206 AGN",
177         IWL_DEVICE_6005,
178         .ht_params = &iwl6000_ht_params,
179 };
180
181 const struct iwl_cfg iwl6005_2agn_mow2_cfg = {
182         .name = "Intel(R) Centrino(R) Advanced-N 6207 AGN",
183         IWL_DEVICE_6005,
184         .ht_params = &iwl6000_ht_params,
185 };
186
187 #define IWL_DEVICE_6030                                         \
188         .fw_name_pre = IWL6030_FW_PRE,                          \
189         .ucode_api_max = IWL6000G2_UCODE_API_MAX,               \
190         .ucode_api_ok = IWL6000G2B_UCODE_API_OK,                \
191         .ucode_api_min = IWL6000G2_UCODE_API_MIN,               \
192         .device_family = IWL_DEVICE_FAMILY_6030,                \
193         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
194         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
195         .nvm_ver = EEPROM_6030_EEPROM_VERSION,          \
196         .nvm_calib_ver = EEPROM_6030_TX_POWER_VERSION,  \
197         .base_params = &iwl6000_g2_base_params,                 \
198         .eeprom_params = &iwl6000_eeprom_params,                \
199         .led_mode = IWL_LED_RF_STATE
200
201 const struct iwl_cfg iwl6030_2agn_cfg = {
202         .name = "Intel(R) Centrino(R) Advanced-N 6230 AGN",
203         IWL_DEVICE_6030,
204         .ht_params = &iwl6000_ht_params,
205 };
206
207 const struct iwl_cfg iwl6030_2abg_cfg = {
208         .name = "Intel(R) Centrino(R) Advanced-N 6230 ABG",
209         IWL_DEVICE_6030,
210 };
211
212 const struct iwl_cfg iwl6030_2bgn_cfg = {
213         .name = "Intel(R) Centrino(R) Advanced-N 6230 BGN",
214         IWL_DEVICE_6030,
215         .ht_params = &iwl6000_ht_params,
216 };
217
218 const struct iwl_cfg iwl6030_2bg_cfg = {
219         .name = "Intel(R) Centrino(R) Advanced-N 6230 BG",
220         IWL_DEVICE_6030,
221 };
222
223 #define IWL_DEVICE_6035                                         \
224         .fw_name_pre = IWL6030_FW_PRE,                          \
225         .ucode_api_max = IWL6035_UCODE_API_MAX,                 \
226         .ucode_api_ok = IWL6035_UCODE_API_OK,                   \
227         .ucode_api_min = IWL6035_UCODE_API_MIN,                 \
228         .device_family = IWL_DEVICE_FAMILY_6030,                \
229         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
230         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
231         .nvm_ver = EEPROM_6030_EEPROM_VERSION,          \
232         .nvm_calib_ver = EEPROM_6030_TX_POWER_VERSION,  \
233         .base_params = &iwl6000_g2_base_params,                 \
234         .eeprom_params = &iwl6000_eeprom_params,                \
235         .led_mode = IWL_LED_RF_STATE
236
237 const struct iwl_cfg iwl6035_2agn_cfg = {
238         .name = "Intel(R) Centrino(R) Advanced-N 6235 AGN",
239         IWL_DEVICE_6035,
240         .ht_params = &iwl6000_ht_params,
241 };
242
243 const struct iwl_cfg iwl6035_2agn_sff_cfg = {
244         .name = "Intel(R) Centrino(R) Ultimate-N 6235 AGN",
245         IWL_DEVICE_6035,
246         .ht_params = &iwl6000_ht_params,
247 };
248
249 const struct iwl_cfg iwl1030_bgn_cfg = {
250         .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN",
251         IWL_DEVICE_6030,
252         .ht_params = &iwl6000_ht_params,
253 };
254
255 const struct iwl_cfg iwl1030_bg_cfg = {
256         .name = "Intel(R) Centrino(R) Wireless-N 1030 BG",
257         IWL_DEVICE_6030,
258 };
259
260 const struct iwl_cfg iwl130_bgn_cfg = {
261         .name = "Intel(R) Centrino(R) Wireless-N 130 BGN",
262         IWL_DEVICE_6030,
263         .ht_params = &iwl6000_ht_params,
264         .rx_with_siso_diversity = true,
265 };
266
267 const struct iwl_cfg iwl130_bg_cfg = {
268         .name = "Intel(R) Centrino(R) Wireless-N 130 BG",
269         IWL_DEVICE_6030,
270         .rx_with_siso_diversity = true,
271 };
272
273 /*
274  * "i": Internal configuration, use internal Power Amplifier
275  */
276 #define IWL_DEVICE_6000i                                        \
277         .fw_name_pre = IWL6000_FW_PRE,                          \
278         .ucode_api_max = IWL6000_UCODE_API_MAX,                 \
279         .ucode_api_ok = IWL6000_UCODE_API_OK,                   \
280         .ucode_api_min = IWL6000_UCODE_API_MIN,                 \
281         .device_family = IWL_DEVICE_FAMILY_6000i,               \
282         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
283         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
284         .valid_tx_ant = ANT_BC,         /* .cfg overwrite */    \
285         .valid_rx_ant = ANT_BC,         /* .cfg overwrite */    \
286         .nvm_ver = EEPROM_6000_EEPROM_VERSION,          \
287         .nvm_calib_ver = EEPROM_6000_TX_POWER_VERSION,  \
288         .base_params = &iwl6000_base_params,                    \
289         .eeprom_params = &iwl6000_eeprom_params,                \
290         .led_mode = IWL_LED_BLINK
291
292 const struct iwl_cfg iwl6000i_2agn_cfg = {
293         .name = "Intel(R) Centrino(R) Advanced-N 6200 AGN",
294         IWL_DEVICE_6000i,
295         .ht_params = &iwl6000_ht_params,
296 };
297
298 const struct iwl_cfg iwl6000i_2abg_cfg = {
299         .name = "Intel(R) Centrino(R) Advanced-N 6200 ABG",
300         IWL_DEVICE_6000i,
301 };
302
303 const struct iwl_cfg iwl6000i_2bg_cfg = {
304         .name = "Intel(R) Centrino(R) Advanced-N 6200 BG",
305         IWL_DEVICE_6000i,
306 };
307
308 #define IWL_DEVICE_6050                                         \
309         .fw_name_pre = IWL6050_FW_PRE,                          \
310         .ucode_api_max = IWL6050_UCODE_API_MAX,                 \
311         .ucode_api_min = IWL6050_UCODE_API_MIN,                 \
312         .device_family = IWL_DEVICE_FAMILY_6050,                \
313         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
314         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
315         .valid_tx_ant = ANT_AB,         /* .cfg overwrite */    \
316         .valid_rx_ant = ANT_AB,         /* .cfg overwrite */    \
317         .nvm_ver = EEPROM_6050_EEPROM_VERSION,          \
318         .nvm_calib_ver = EEPROM_6050_TX_POWER_VERSION,  \
319         .base_params = &iwl6050_base_params,                    \
320         .eeprom_params = &iwl6000_eeprom_params,                \
321         .led_mode = IWL_LED_BLINK,                              \
322         .internal_wimax_coex = true
323
324 const struct iwl_cfg iwl6050_2agn_cfg = {
325         .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN",
326         IWL_DEVICE_6050,
327         .ht_params = &iwl6000_ht_params,
328 };
329
330 const struct iwl_cfg iwl6050_2abg_cfg = {
331         .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 ABG",
332         IWL_DEVICE_6050,
333 };
334
335 #define IWL_DEVICE_6150                                         \
336         .fw_name_pre = IWL6050_FW_PRE,                          \
337         .ucode_api_max = IWL6050_UCODE_API_MAX,                 \
338         .ucode_api_min = IWL6050_UCODE_API_MIN,                 \
339         .device_family = IWL_DEVICE_FAMILY_6150,                \
340         .max_inst_size = IWL60_RTC_INST_SIZE,                   \
341         .max_data_size = IWL60_RTC_DATA_SIZE,                   \
342         .nvm_ver = EEPROM_6150_EEPROM_VERSION,          \
343         .nvm_calib_ver = EEPROM_6150_TX_POWER_VERSION,  \
344         .base_params = &iwl6050_base_params,                    \
345         .eeprom_params = &iwl6000_eeprom_params,                \
346         .led_mode = IWL_LED_BLINK,                              \
347         .internal_wimax_coex = true
348
349 const struct iwl_cfg iwl6150_bgn_cfg = {
350         .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN",
351         IWL_DEVICE_6150,
352         .ht_params = &iwl6000_ht_params,
353 };
354
355 const struct iwl_cfg iwl6150_bg_cfg = {
356         .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG",
357         IWL_DEVICE_6150,
358 };
359
360 const struct iwl_cfg iwl6000_3agn_cfg = {
361         .name = "Intel(R) Centrino(R) Ultimate-N 6300 AGN",
362         .fw_name_pre = IWL6000_FW_PRE,
363         .ucode_api_max = IWL6000_UCODE_API_MAX,
364         .ucode_api_ok = IWL6000_UCODE_API_OK,
365         .ucode_api_min = IWL6000_UCODE_API_MIN,
366         .device_family = IWL_DEVICE_FAMILY_6000,
367         .max_inst_size = IWL60_RTC_INST_SIZE,
368         .max_data_size = IWL60_RTC_DATA_SIZE,
369         .nvm_ver = EEPROM_6000_EEPROM_VERSION,
370         .nvm_calib_ver = EEPROM_6000_TX_POWER_VERSION,
371         .base_params = &iwl6000_base_params,
372         .eeprom_params = &iwl6000_eeprom_params,
373         .ht_params = &iwl6000_ht_params,
374         .led_mode = IWL_LED_BLINK,
375 };
376
377 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_OK));
378 MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_OK));
379 MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_OK));
380 MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2B_UCODE_API_OK));