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