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