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