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