1 /******************************************************************************
2  *
3  * This file is provided under a dual BSD/GPLv2 license.  When using or
4  * redistributing this file, you may do so under either license.
5  *
6  * GPL LICENSE SUMMARY
7  *
8  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
10  * Copyright(c) 2015        Intel Deutschland GmbH
11  * Copyright(c) 2018 - 2019 Intel Corporation
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of version 2 of the GNU General Public License as
15  * published by the Free Software Foundation.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * The full GNU General Public License is included in this distribution
23  * in the file called COPYING.
24  *
25  * Contact Information:
26  *  Intel Linux Wireless <linuxwifi@intel.com>
27  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28  *
29  * BSD LICENSE
30  *
31  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
33  * Copyright(c) 2015        Intel Deutschland GmbH
34  * Copyright(c) 2018 - 2019 Intel Corporation
35  * All rights reserved.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  *
41  *  * Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  *  * Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in
45  *    the documentation and/or other materials provided with the
46  *    distribution.
47  *  * Neither the name Intel Corporation nor the names of its
48  *    contributors may be used to endorse or promote products derived
49  *    from this software without specific prior written permission.
50  *
51  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62  *
63  *****************************************************************************/
64 
65 #include <linux/module.h>
66 #include <linux/stringify.h>
67 #include "iwl-config.h"
68 
69 /* Highest firmware API version supported */
70 #define IWL7260_UCODE_API_MAX	17
71 #define IWL7265_UCODE_API_MAX	17
72 #define IWL7265D_UCODE_API_MAX	29
73 #define IWL3168_UCODE_API_MAX	29
74 
75 /* Lowest firmware API version supported */
76 #define IWL7260_UCODE_API_MIN	17
77 #define IWL7265_UCODE_API_MIN	17
78 #define IWL7265D_UCODE_API_MIN	22
79 #define IWL3168_UCODE_API_MIN	22
80 
81 /* NVM versions */
82 #define IWL7260_NVM_VERSION		0x0a1d
83 #define IWL3160_NVM_VERSION		0x709
84 #define IWL3165_NVM_VERSION		0x709
85 #define IWL3168_NVM_VERSION		0xd01
86 #define IWL7265_NVM_VERSION		0x0a1d
87 #define IWL7265D_NVM_VERSION		0x0c11
88 
89 /* DCCM offsets and lengths */
90 #define IWL7000_DCCM_OFFSET		0x800000
91 #define IWL7260_DCCM_LEN		0x14000
92 #define IWL3160_DCCM_LEN		0x10000
93 #define IWL7265_DCCM_LEN		0x17A00
94 
95 #define IWL7260_FW_PRE "iwlwifi-7260-"
96 #define IWL7260_MODULE_FIRMWARE(api) IWL7260_FW_PRE __stringify(api) ".ucode"
97 
98 #define IWL3160_FW_PRE "iwlwifi-3160-"
99 #define IWL3160_MODULE_FIRMWARE(api) IWL3160_FW_PRE __stringify(api) ".ucode"
100 
101 #define IWL3168_FW_PRE "iwlwifi-3168-"
102 #define IWL3168_MODULE_FIRMWARE(api) IWL3168_FW_PRE __stringify(api) ".ucode"
103 
104 #define IWL7265_FW_PRE "iwlwifi-7265-"
105 #define IWL7265_MODULE_FIRMWARE(api) IWL7265_FW_PRE __stringify(api) ".ucode"
106 
107 #define IWL7265D_FW_PRE "iwlwifi-7265D-"
108 #define IWL7265D_MODULE_FIRMWARE(api) IWL7265D_FW_PRE __stringify(api) ".ucode"
109 
110 static const struct iwl_base_params iwl7000_base_params = {
111 	.eeprom_size = OTP_LOW_IMAGE_SIZE_16K,
112 	.num_of_queues = 31,
113 	.max_tfd_queue_size = 256,
114 	.shadow_ram_support = true,
115 	.led_compensation = 57,
116 	.wd_timeout = IWL_LONG_WD_TIMEOUT,
117 	.max_event_log_size = 512,
118 	.shadow_reg_enable = true,
119 	.pcie_l1_allowed = true,
120 	.apmg_wake_up_wa = true,
121 };
122 
123 static const struct iwl_tt_params iwl7000_high_temp_tt_params = {
124 	.ct_kill_entry = 118,
125 	.ct_kill_exit = 96,
126 	.ct_kill_duration = 5,
127 	.dynamic_smps_entry = 114,
128 	.dynamic_smps_exit = 110,
129 	.tx_protection_entry = 114,
130 	.tx_protection_exit = 108,
131 	.tx_backoff = {
132 		{.temperature = 112, .backoff = 300},
133 		{.temperature = 113, .backoff = 800},
134 		{.temperature = 114, .backoff = 1500},
135 		{.temperature = 115, .backoff = 3000},
136 		{.temperature = 116, .backoff = 5000},
137 		{.temperature = 117, .backoff = 10000},
138 	},
139 	.support_ct_kill = true,
140 	.support_dynamic_smps = true,
141 	.support_tx_protection = true,
142 	.support_tx_backoff = true,
143 };
144 
145 static const struct iwl_ht_params iwl7000_ht_params = {
146 	.stbc = true,
147 	.ht40_bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ),
148 };
149 
150 #define IWL_DEVICE_7000_COMMON					\
151 	.trans.device_family = IWL_DEVICE_FAMILY_7000,		\
152 	.trans.base_params = &iwl7000_base_params,		\
153 	.led_mode = IWL_LED_RF_STATE,				\
154 	.nvm_hw_section_num = 0,				\
155 	.non_shared_ant = ANT_A,				\
156 	.max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,	\
157 	.dccm_offset = IWL7000_DCCM_OFFSET
158 
159 #define IWL_DEVICE_7000						\
160 	IWL_DEVICE_7000_COMMON,					\
161 	.ucode_api_max = IWL7260_UCODE_API_MAX,			\
162 	.ucode_api_min = IWL7260_UCODE_API_MIN
163 
164 #define IWL_DEVICE_7005						\
165 	IWL_DEVICE_7000_COMMON,					\
166 	.ucode_api_max = IWL7265_UCODE_API_MAX,			\
167 	.ucode_api_min = IWL7265_UCODE_API_MIN
168 
169 #define IWL_DEVICE_3008						\
170 	IWL_DEVICE_7000_COMMON,					\
171 	.ucode_api_max = IWL3168_UCODE_API_MAX,			\
172 	.ucode_api_min = IWL3168_UCODE_API_MIN
173 
174 #define IWL_DEVICE_7005D					\
175 	IWL_DEVICE_7000_COMMON,					\
176 	.ucode_api_max = IWL7265D_UCODE_API_MAX,		\
177 	.ucode_api_min = IWL7265D_UCODE_API_MIN
178 
179 const struct iwl_cfg iwl7260_2ac_cfg = {
180 	.name = "Intel(R) Dual Band Wireless AC 7260",
181 	.fw_name_pre = IWL7260_FW_PRE,
182 	IWL_DEVICE_7000,
183 	.ht_params = &iwl7000_ht_params,
184 	.nvm_ver = IWL7260_NVM_VERSION,
185 	.host_interrupt_operation_mode = true,
186 	.lp_xtal_workaround = true,
187 	.dccm_len = IWL7260_DCCM_LEN,
188 };
189 
190 const struct iwl_cfg iwl7260_2ac_cfg_high_temp = {
191 	.name = "Intel(R) Dual Band Wireless AC 7260",
192 	.fw_name_pre = IWL7260_FW_PRE,
193 	IWL_DEVICE_7000,
194 	.ht_params = &iwl7000_ht_params,
195 	.nvm_ver = IWL7260_NVM_VERSION,
196 	.high_temp = true,
197 	.host_interrupt_operation_mode = true,
198 	.lp_xtal_workaround = true,
199 	.dccm_len = IWL7260_DCCM_LEN,
200 	.thermal_params = &iwl7000_high_temp_tt_params,
201 };
202 
203 const struct iwl_cfg iwl7260_2n_cfg = {
204 	.name = "Intel(R) Dual Band Wireless N 7260",
205 	.fw_name_pre = IWL7260_FW_PRE,
206 	IWL_DEVICE_7000,
207 	.ht_params = &iwl7000_ht_params,
208 	.nvm_ver = IWL7260_NVM_VERSION,
209 	.host_interrupt_operation_mode = true,
210 	.lp_xtal_workaround = true,
211 	.dccm_len = IWL7260_DCCM_LEN,
212 };
213 
214 const struct iwl_cfg iwl7260_n_cfg = {
215 	.name = "Intel(R) Wireless N 7260",
216 	.fw_name_pre = IWL7260_FW_PRE,
217 	IWL_DEVICE_7000,
218 	.ht_params = &iwl7000_ht_params,
219 	.nvm_ver = IWL7260_NVM_VERSION,
220 	.host_interrupt_operation_mode = true,
221 	.lp_xtal_workaround = true,
222 	.dccm_len = IWL7260_DCCM_LEN,
223 };
224 
225 const struct iwl_cfg iwl3160_2ac_cfg = {
226 	.name = "Intel(R) Dual Band Wireless AC 3160",
227 	.fw_name_pre = IWL3160_FW_PRE,
228 	IWL_DEVICE_7000,
229 	.ht_params = &iwl7000_ht_params,
230 	.nvm_ver = IWL3160_NVM_VERSION,
231 	.host_interrupt_operation_mode = true,
232 	.dccm_len = IWL3160_DCCM_LEN,
233 };
234 
235 const struct iwl_cfg iwl3160_2n_cfg = {
236 	.name = "Intel(R) Dual Band Wireless N 3160",
237 	.fw_name_pre = IWL3160_FW_PRE,
238 	IWL_DEVICE_7000,
239 	.ht_params = &iwl7000_ht_params,
240 	.nvm_ver = IWL3160_NVM_VERSION,
241 	.host_interrupt_operation_mode = true,
242 	.dccm_len = IWL3160_DCCM_LEN,
243 };
244 
245 const struct iwl_cfg iwl3160_n_cfg = {
246 	.name = "Intel(R) Wireless N 3160",
247 	.fw_name_pre = IWL3160_FW_PRE,
248 	IWL_DEVICE_7000,
249 	.ht_params = &iwl7000_ht_params,
250 	.nvm_ver = IWL3160_NVM_VERSION,
251 	.host_interrupt_operation_mode = true,
252 	.dccm_len = IWL3160_DCCM_LEN,
253 };
254 
255 static const struct iwl_pwr_tx_backoff iwl7265_pwr_tx_backoffs[] = {
256 	{.pwr = 1600, .backoff = 0},
257 	{.pwr = 1300, .backoff = 467},
258 	{.pwr = 900,  .backoff = 1900},
259 	{.pwr = 800, .backoff = 2630},
260 	{.pwr = 700, .backoff = 3720},
261 	{.pwr = 600, .backoff = 5550},
262 	{.pwr = 500, .backoff = 9350},
263 	{0},
264 };
265 
266 static const struct iwl_ht_params iwl7265_ht_params = {
267 	.stbc = true,
268 	.ldpc = true,
269 	.ht40_bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ),
270 };
271 
272 const struct iwl_cfg iwl3165_2ac_cfg = {
273 	.name = "Intel(R) Dual Band Wireless AC 3165",
274 	.fw_name_pre = IWL7265D_FW_PRE,
275 	IWL_DEVICE_7005D,
276 	.ht_params = &iwl7000_ht_params,
277 	.nvm_ver = IWL3165_NVM_VERSION,
278 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
279 	.dccm_len = IWL7265_DCCM_LEN,
280 };
281 
282 const struct iwl_cfg iwl3168_2ac_cfg = {
283 	.name = "Intel(R) Dual Band Wireless AC 3168",
284 	.fw_name_pre = IWL3168_FW_PRE,
285 	IWL_DEVICE_3008,
286 	.ht_params = &iwl7000_ht_params,
287 	.nvm_ver = IWL3168_NVM_VERSION,
288 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
289 	.dccm_len = IWL7265_DCCM_LEN,
290 	.nvm_type = IWL_NVM_SDP,
291 };
292 
293 const struct iwl_cfg iwl7265_2ac_cfg = {
294 	.name = "Intel(R) Dual Band Wireless AC 7265",
295 	.fw_name_pre = IWL7265_FW_PRE,
296 	IWL_DEVICE_7005,
297 	.ht_params = &iwl7265_ht_params,
298 	.nvm_ver = IWL7265_NVM_VERSION,
299 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
300 	.dccm_len = IWL7265_DCCM_LEN,
301 };
302 
303 const struct iwl_cfg iwl7265_2n_cfg = {
304 	.name = "Intel(R) Dual Band Wireless N 7265",
305 	.fw_name_pre = IWL7265_FW_PRE,
306 	IWL_DEVICE_7005,
307 	.ht_params = &iwl7265_ht_params,
308 	.nvm_ver = IWL7265_NVM_VERSION,
309 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
310 	.dccm_len = IWL7265_DCCM_LEN,
311 };
312 
313 const struct iwl_cfg iwl7265_n_cfg = {
314 	.name = "Intel(R) Wireless N 7265",
315 	.fw_name_pre = IWL7265_FW_PRE,
316 	IWL_DEVICE_7005,
317 	.ht_params = &iwl7265_ht_params,
318 	.nvm_ver = IWL7265_NVM_VERSION,
319 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
320 	.dccm_len = IWL7265_DCCM_LEN,
321 };
322 
323 const struct iwl_cfg iwl7265d_2ac_cfg = {
324 	.name = "Intel(R) Dual Band Wireless AC 7265",
325 	.fw_name_pre = IWL7265D_FW_PRE,
326 	IWL_DEVICE_7005D,
327 	.ht_params = &iwl7265_ht_params,
328 	.nvm_ver = IWL7265D_NVM_VERSION,
329 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
330 	.dccm_len = IWL7265_DCCM_LEN,
331 };
332 
333 const struct iwl_cfg iwl7265d_2n_cfg = {
334 	.name = "Intel(R) Dual Band Wireless N 7265",
335 	.fw_name_pre = IWL7265D_FW_PRE,
336 	IWL_DEVICE_7005D,
337 	.ht_params = &iwl7265_ht_params,
338 	.nvm_ver = IWL7265D_NVM_VERSION,
339 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
340 	.dccm_len = IWL7265_DCCM_LEN,
341 };
342 
343 const struct iwl_cfg iwl7265d_n_cfg = {
344 	.name = "Intel(R) Wireless N 7265",
345 	.fw_name_pre = IWL7265D_FW_PRE,
346 	IWL_DEVICE_7005D,
347 	.ht_params = &iwl7265_ht_params,
348 	.nvm_ver = IWL7265D_NVM_VERSION,
349 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
350 	.dccm_len = IWL7265_DCCM_LEN,
351 };
352 
353 MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_MAX));
354 MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL7260_UCODE_API_MAX));
355 MODULE_FIRMWARE(IWL3168_MODULE_FIRMWARE(IWL3168_UCODE_API_MAX));
356 MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7265_UCODE_API_MAX));
357 MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7265D_UCODE_API_MAX));
358