1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /*
3  * Copyright (C) 2012-2014, 2018-2019 Intel Corporation
4  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5  * Copyright (C) 2015 Intel Deutschland GmbH
6  */
7 #include <linux/module.h>
8 #include <linux/stringify.h>
9 #include "iwl-config.h"
10 
11 /* Highest firmware API version supported */
12 #define IWL7260_UCODE_API_MAX	17
13 #define IWL7265_UCODE_API_MAX	17
14 #define IWL7265D_UCODE_API_MAX	29
15 #define IWL3168_UCODE_API_MAX	29
16 
17 /* Lowest firmware API version supported */
18 #define IWL7260_UCODE_API_MIN	17
19 #define IWL7265_UCODE_API_MIN	17
20 #define IWL7265D_UCODE_API_MIN	22
21 #define IWL3168_UCODE_API_MIN	22
22 
23 /* NVM versions */
24 #define IWL7260_NVM_VERSION		0x0a1d
25 #define IWL3160_NVM_VERSION		0x709
26 #define IWL3165_NVM_VERSION		0x709
27 #define IWL3168_NVM_VERSION		0xd01
28 #define IWL7265_NVM_VERSION		0x0a1d
29 #define IWL7265D_NVM_VERSION		0x0c11
30 
31 /* DCCM offsets and lengths */
32 #define IWL7000_DCCM_OFFSET		0x800000
33 #define IWL7260_DCCM_LEN		0x14000
34 #define IWL3160_DCCM_LEN		0x10000
35 #define IWL7265_DCCM_LEN		0x17A00
36 
37 #define IWL7260_FW_PRE "iwlwifi-7260-"
38 #define IWL7260_MODULE_FIRMWARE(api) IWL7260_FW_PRE __stringify(api) ".ucode"
39 
40 #define IWL3160_FW_PRE "iwlwifi-3160-"
41 #define IWL3160_MODULE_FIRMWARE(api) IWL3160_FW_PRE __stringify(api) ".ucode"
42 
43 #define IWL3168_FW_PRE "iwlwifi-3168-"
44 #define IWL3168_MODULE_FIRMWARE(api) IWL3168_FW_PRE __stringify(api) ".ucode"
45 
46 #define IWL7265_FW_PRE "iwlwifi-7265-"
47 #define IWL7265_MODULE_FIRMWARE(api) IWL7265_FW_PRE __stringify(api) ".ucode"
48 
49 #define IWL7265D_FW_PRE "iwlwifi-7265D-"
50 #define IWL7265D_MODULE_FIRMWARE(api) IWL7265D_FW_PRE __stringify(api) ".ucode"
51 
52 static const struct iwl_base_params iwl7000_base_params = {
53 	.eeprom_size = OTP_LOW_IMAGE_SIZE_16K,
54 	.num_of_queues = 31,
55 	.max_tfd_queue_size = 256,
56 	.shadow_ram_support = true,
57 	.led_compensation = 57,
58 	.wd_timeout = IWL_LONG_WD_TIMEOUT,
59 	.max_event_log_size = 512,
60 	.shadow_reg_enable = true,
61 	.pcie_l1_allowed = true,
62 	.apmg_wake_up_wa = true,
63 };
64 
65 static const struct iwl_tt_params iwl7000_high_temp_tt_params = {
66 	.ct_kill_entry = 118,
67 	.ct_kill_exit = 96,
68 	.ct_kill_duration = 5,
69 	.dynamic_smps_entry = 114,
70 	.dynamic_smps_exit = 110,
71 	.tx_protection_entry = 114,
72 	.tx_protection_exit = 108,
73 	.tx_backoff = {
74 		{.temperature = 112, .backoff = 300},
75 		{.temperature = 113, .backoff = 800},
76 		{.temperature = 114, .backoff = 1500},
77 		{.temperature = 115, .backoff = 3000},
78 		{.temperature = 116, .backoff = 5000},
79 		{.temperature = 117, .backoff = 10000},
80 	},
81 	.support_ct_kill = true,
82 	.support_dynamic_smps = true,
83 	.support_tx_protection = true,
84 	.support_tx_backoff = true,
85 };
86 
87 static const struct iwl_ht_params iwl7000_ht_params = {
88 	.stbc = true,
89 	.ht40_bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ),
90 };
91 
92 #define IWL_DEVICE_7000_COMMON					\
93 	.trans.device_family = IWL_DEVICE_FAMILY_7000,		\
94 	.trans.base_params = &iwl7000_base_params,		\
95 	.led_mode = IWL_LED_RF_STATE,				\
96 	.nvm_hw_section_num = 0,				\
97 	.non_shared_ant = ANT_A,				\
98 	.max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,	\
99 	.dccm_offset = IWL7000_DCCM_OFFSET
100 
101 #define IWL_DEVICE_7000						\
102 	IWL_DEVICE_7000_COMMON,					\
103 	.ucode_api_max = IWL7260_UCODE_API_MAX,			\
104 	.ucode_api_min = IWL7260_UCODE_API_MIN
105 
106 #define IWL_DEVICE_7005						\
107 	IWL_DEVICE_7000_COMMON,					\
108 	.ucode_api_max = IWL7265_UCODE_API_MAX,			\
109 	.ucode_api_min = IWL7265_UCODE_API_MIN
110 
111 #define IWL_DEVICE_3008						\
112 	IWL_DEVICE_7000_COMMON,					\
113 	.ucode_api_max = IWL3168_UCODE_API_MAX,			\
114 	.ucode_api_min = IWL3168_UCODE_API_MIN
115 
116 #define IWL_DEVICE_7005D					\
117 	IWL_DEVICE_7000_COMMON,					\
118 	.ucode_api_max = IWL7265D_UCODE_API_MAX,		\
119 	.ucode_api_min = IWL7265D_UCODE_API_MIN
120 
121 const struct iwl_cfg iwl7260_2ac_cfg = {
122 	.name = "Intel(R) Dual Band Wireless AC 7260",
123 	.fw_name_pre = IWL7260_FW_PRE,
124 	IWL_DEVICE_7000,
125 	.ht_params = &iwl7000_ht_params,
126 	.nvm_ver = IWL7260_NVM_VERSION,
127 	.host_interrupt_operation_mode = true,
128 	.lp_xtal_workaround = true,
129 	.dccm_len = IWL7260_DCCM_LEN,
130 };
131 
132 const struct iwl_cfg iwl7260_2ac_cfg_high_temp = {
133 	.name = "Intel(R) Dual Band Wireless AC 7260",
134 	.fw_name_pre = IWL7260_FW_PRE,
135 	IWL_DEVICE_7000,
136 	.ht_params = &iwl7000_ht_params,
137 	.nvm_ver = IWL7260_NVM_VERSION,
138 	.high_temp = true,
139 	.host_interrupt_operation_mode = true,
140 	.lp_xtal_workaround = true,
141 	.dccm_len = IWL7260_DCCM_LEN,
142 	.thermal_params = &iwl7000_high_temp_tt_params,
143 };
144 
145 const struct iwl_cfg iwl7260_2n_cfg = {
146 	.name = "Intel(R) Dual Band Wireless N 7260",
147 	.fw_name_pre = IWL7260_FW_PRE,
148 	IWL_DEVICE_7000,
149 	.ht_params = &iwl7000_ht_params,
150 	.nvm_ver = IWL7260_NVM_VERSION,
151 	.host_interrupt_operation_mode = true,
152 	.lp_xtal_workaround = true,
153 	.dccm_len = IWL7260_DCCM_LEN,
154 };
155 
156 const struct iwl_cfg iwl7260_n_cfg = {
157 	.name = "Intel(R) Wireless N 7260",
158 	.fw_name_pre = IWL7260_FW_PRE,
159 	IWL_DEVICE_7000,
160 	.ht_params = &iwl7000_ht_params,
161 	.nvm_ver = IWL7260_NVM_VERSION,
162 	.host_interrupt_operation_mode = true,
163 	.lp_xtal_workaround = true,
164 	.dccm_len = IWL7260_DCCM_LEN,
165 };
166 
167 const struct iwl_cfg iwl3160_2ac_cfg = {
168 	.name = "Intel(R) Dual Band Wireless AC 3160",
169 	.fw_name_pre = IWL3160_FW_PRE,
170 	IWL_DEVICE_7000,
171 	.ht_params = &iwl7000_ht_params,
172 	.nvm_ver = IWL3160_NVM_VERSION,
173 	.host_interrupt_operation_mode = true,
174 	.dccm_len = IWL3160_DCCM_LEN,
175 };
176 
177 const struct iwl_cfg iwl3160_2n_cfg = {
178 	.name = "Intel(R) Dual Band Wireless N 3160",
179 	.fw_name_pre = IWL3160_FW_PRE,
180 	IWL_DEVICE_7000,
181 	.ht_params = &iwl7000_ht_params,
182 	.nvm_ver = IWL3160_NVM_VERSION,
183 	.host_interrupt_operation_mode = true,
184 	.dccm_len = IWL3160_DCCM_LEN,
185 };
186 
187 const struct iwl_cfg iwl3160_n_cfg = {
188 	.name = "Intel(R) Wireless N 3160",
189 	.fw_name_pre = IWL3160_FW_PRE,
190 	IWL_DEVICE_7000,
191 	.ht_params = &iwl7000_ht_params,
192 	.nvm_ver = IWL3160_NVM_VERSION,
193 	.host_interrupt_operation_mode = true,
194 	.dccm_len = IWL3160_DCCM_LEN,
195 };
196 
197 static const struct iwl_pwr_tx_backoff iwl7265_pwr_tx_backoffs[] = {
198 	{.pwr = 1600, .backoff = 0},
199 	{.pwr = 1300, .backoff = 467},
200 	{.pwr = 900,  .backoff = 1900},
201 	{.pwr = 800, .backoff = 2630},
202 	{.pwr = 700, .backoff = 3720},
203 	{.pwr = 600, .backoff = 5550},
204 	{.pwr = 500, .backoff = 9350},
205 	{0},
206 };
207 
208 static const struct iwl_ht_params iwl7265_ht_params = {
209 	.stbc = true,
210 	.ldpc = true,
211 	.ht40_bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ),
212 };
213 
214 const struct iwl_cfg iwl3165_2ac_cfg = {
215 	.name = "Intel(R) Dual Band Wireless AC 3165",
216 	.fw_name_pre = IWL7265D_FW_PRE,
217 	IWL_DEVICE_7005D,
218 	.ht_params = &iwl7000_ht_params,
219 	.nvm_ver = IWL3165_NVM_VERSION,
220 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
221 	.dccm_len = IWL7265_DCCM_LEN,
222 };
223 
224 const struct iwl_cfg iwl3168_2ac_cfg = {
225 	.name = "Intel(R) Dual Band Wireless AC 3168",
226 	.fw_name_pre = IWL3168_FW_PRE,
227 	IWL_DEVICE_3008,
228 	.ht_params = &iwl7000_ht_params,
229 	.nvm_ver = IWL3168_NVM_VERSION,
230 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
231 	.dccm_len = IWL7265_DCCM_LEN,
232 	.nvm_type = IWL_NVM_SDP,
233 };
234 
235 const struct iwl_cfg iwl7265_2ac_cfg = {
236 	.name = "Intel(R) Dual Band Wireless AC 7265",
237 	.fw_name_pre = IWL7265_FW_PRE,
238 	IWL_DEVICE_7005,
239 	.ht_params = &iwl7265_ht_params,
240 	.nvm_ver = IWL7265_NVM_VERSION,
241 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
242 	.dccm_len = IWL7265_DCCM_LEN,
243 };
244 
245 const struct iwl_cfg iwl7265_2n_cfg = {
246 	.name = "Intel(R) Dual Band Wireless N 7265",
247 	.fw_name_pre = IWL7265_FW_PRE,
248 	IWL_DEVICE_7005,
249 	.ht_params = &iwl7265_ht_params,
250 	.nvm_ver = IWL7265_NVM_VERSION,
251 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
252 	.dccm_len = IWL7265_DCCM_LEN,
253 };
254 
255 const struct iwl_cfg iwl7265_n_cfg = {
256 	.name = "Intel(R) Wireless N 7265",
257 	.fw_name_pre = IWL7265_FW_PRE,
258 	IWL_DEVICE_7005,
259 	.ht_params = &iwl7265_ht_params,
260 	.nvm_ver = IWL7265_NVM_VERSION,
261 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
262 	.dccm_len = IWL7265_DCCM_LEN,
263 };
264 
265 const struct iwl_cfg iwl7265d_2ac_cfg = {
266 	.name = "Intel(R) Dual Band Wireless AC 7265",
267 	.fw_name_pre = IWL7265D_FW_PRE,
268 	IWL_DEVICE_7005D,
269 	.ht_params = &iwl7265_ht_params,
270 	.nvm_ver = IWL7265D_NVM_VERSION,
271 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
272 	.dccm_len = IWL7265_DCCM_LEN,
273 };
274 
275 const struct iwl_cfg iwl7265d_2n_cfg = {
276 	.name = "Intel(R) Dual Band Wireless N 7265",
277 	.fw_name_pre = IWL7265D_FW_PRE,
278 	IWL_DEVICE_7005D,
279 	.ht_params = &iwl7265_ht_params,
280 	.nvm_ver = IWL7265D_NVM_VERSION,
281 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
282 	.dccm_len = IWL7265_DCCM_LEN,
283 };
284 
285 const struct iwl_cfg iwl7265d_n_cfg = {
286 	.name = "Intel(R) Wireless N 7265",
287 	.fw_name_pre = IWL7265D_FW_PRE,
288 	IWL_DEVICE_7005D,
289 	.ht_params = &iwl7265_ht_params,
290 	.nvm_ver = IWL7265D_NVM_VERSION,
291 	.pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
292 	.dccm_len = IWL7265_DCCM_LEN,
293 };
294 
295 MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_MAX));
296 MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL7260_UCODE_API_MAX));
297 MODULE_FIRMWARE(IWL3168_MODULE_FIRMWARE(IWL3168_UCODE_API_MAX));
298 MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7265_UCODE_API_MAX));
299 MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7265D_UCODE_API_MAX));
300