xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h (revision 05ee19c18c2bb3dea69e29219017367c4a77e65a)
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 - 2015 Intel Mobile Communications GmbH
10  * Copyright(c) 2016 - 2017 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 - 2015 Intel Mobile Communications GmbH
33  * Copyright(c) 2016 - 2017 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 #ifndef __iwl_fw_api_nvm_reg_h__
66 #define __iwl_fw_api_nvm_reg_h__
67 
68 /**
69  * enum iwl_regulatory_and_nvm_subcmd_ids - regulatory/NVM commands
70  */
71 enum iwl_regulatory_and_nvm_subcmd_ids {
72 	/**
73 	 * @NVM_ACCESS_COMPLETE: &struct iwl_nvm_access_complete_cmd
74 	 */
75 	NVM_ACCESS_COMPLETE = 0x0,
76 
77 	/**
78 	 * @NVM_GET_INFO:
79 	 * Command is &struct iwl_nvm_get_info,
80 	 * response is &struct iwl_nvm_get_info_rsp
81 	 */
82 	NVM_GET_INFO = 0x2,
83 
84 	/**
85 	 * @TAS_CONFIG: &struct iwl_tas_config_cmd
86 	 */
87 	TAS_CONFIG = 0x3,
88 };
89 
90 /**
91  * enum iwl_nvm_access_op - NVM access opcode
92  * @IWL_NVM_READ: read NVM
93  * @IWL_NVM_WRITE: write NVM
94  */
95 enum iwl_nvm_access_op {
96 	IWL_NVM_READ	= 0,
97 	IWL_NVM_WRITE	= 1,
98 };
99 
100 /**
101  * enum iwl_nvm_access_target - target of the NVM_ACCESS_CMD
102  * @NVM_ACCESS_TARGET_CACHE: access the cache
103  * @NVM_ACCESS_TARGET_OTP: access the OTP
104  * @NVM_ACCESS_TARGET_EEPROM: access the EEPROM
105  */
106 enum iwl_nvm_access_target {
107 	NVM_ACCESS_TARGET_CACHE = 0,
108 	NVM_ACCESS_TARGET_OTP = 1,
109 	NVM_ACCESS_TARGET_EEPROM = 2,
110 };
111 
112 /**
113  * enum iwl_nvm_section_type - section types for NVM_ACCESS_CMD
114  * @NVM_SECTION_TYPE_SW: software section
115  * @NVM_SECTION_TYPE_REGULATORY: regulatory section
116  * @NVM_SECTION_TYPE_CALIBRATION: calibration section
117  * @NVM_SECTION_TYPE_PRODUCTION: production section
118  * @NVM_SECTION_TYPE_REGULATORY_SDP: regulatory section used by 3168 series
119  * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section
120  * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section
121  * @NVM_MAX_NUM_SECTIONS: number of sections
122  */
123 enum iwl_nvm_section_type {
124 	NVM_SECTION_TYPE_SW = 1,
125 	NVM_SECTION_TYPE_REGULATORY = 3,
126 	NVM_SECTION_TYPE_CALIBRATION = 4,
127 	NVM_SECTION_TYPE_PRODUCTION = 5,
128 	NVM_SECTION_TYPE_REGULATORY_SDP = 8,
129 	NVM_SECTION_TYPE_MAC_OVERRIDE = 11,
130 	NVM_SECTION_TYPE_PHY_SKU = 12,
131 	NVM_MAX_NUM_SECTIONS = 13,
132 };
133 
134 /**
135  * struct iwl_nvm_access_cmd - Request the device to send an NVM section
136  * @op_code: &enum iwl_nvm_access_op
137  * @target: &enum iwl_nvm_access_target
138  * @type: &enum iwl_nvm_section_type
139  * @offset: offset in bytes into the section
140  * @length: in bytes, to read/write
141  * @data: if write operation, the data to write. On read its empty
142  */
143 struct iwl_nvm_access_cmd {
144 	u8 op_code;
145 	u8 target;
146 	__le16 type;
147 	__le16 offset;
148 	__le16 length;
149 	u8 data[];
150 } __packed; /* NVM_ACCESS_CMD_API_S_VER_2 */
151 
152 /**
153  * struct iwl_nvm_access_resp_ver2 - response to NVM_ACCESS_CMD
154  * @offset: offset in bytes into the section
155  * @length: in bytes, either how much was written or read
156  * @type: NVM_SECTION_TYPE_*
157  * @status: 0 for success, fail otherwise
158  * @data: if read operation, the data returned. Empty on write.
159  */
160 struct iwl_nvm_access_resp {
161 	__le16 offset;
162 	__le16 length;
163 	__le16 type;
164 	__le16 status;
165 	u8 data[];
166 } __packed; /* NVM_ACCESS_CMD_RESP_API_S_VER_2 */
167 
168 /*
169  * struct iwl_nvm_get_info - request to get NVM data
170  */
171 struct iwl_nvm_get_info {
172 	__le32 reserved;
173 } __packed; /* REGULATORY_NVM_GET_INFO_CMD_API_S_VER_1 */
174 
175 /**
176  * enum iwl_nvm_info_general_flags - flags in NVM_GET_INFO resp
177  * @NVM_GENERAL_FLAGS_EMPTY_OTP: 1 if OTP is empty
178  */
179 enum iwl_nvm_info_general_flags {
180 	NVM_GENERAL_FLAGS_EMPTY_OTP	= BIT(0),
181 };
182 
183 /**
184  * struct iwl_nvm_get_info_general - general NVM data
185  * @flags: bit 0: 1 - empty, 0 - non-empty
186  * @nvm_version: nvm version
187  * @board_type: board type
188  * @n_hw_addrs: number of reserved MAC addresses
189  */
190 struct iwl_nvm_get_info_general {
191 	__le32 flags;
192 	__le16 nvm_version;
193 	u8 board_type;
194 	u8 n_hw_addrs;
195 } __packed; /* REGULATORY_NVM_GET_INFO_GENERAL_S_VER_2 */
196 
197 /**
198  * enum iwl_nvm_mac_sku_flags - flags in &iwl_nvm_get_info_sku
199  * @NVM_MAC_SKU_FLAGS_BAND_2_4_ENABLED: true if 2.4 band enabled
200  * @NVM_MAC_SKU_FLAGS_BAND_5_2_ENABLED: true if 5.2 band enabled
201  * @NVM_MAC_SKU_FLAGS_802_11N_ENABLED: true if 11n enabled
202  * @NVM_MAC_SKU_FLAGS_802_11AC_ENABLED: true if 11ac enabled
203  * @NVM_MAC_SKU_FLAGS_MIMO_DISABLED: true if MIMO disabled
204  * @NVM_MAC_SKU_FLAGS_WAPI_ENABLED: true if WAPI enabled
205  * @NVM_MAC_SKU_FLAGS_REG_CHECK_ENABLED: true if regulatory checker enabled
206  * @NVM_MAC_SKU_FLAGS_API_LOCK_ENABLED: true if API lock enabled
207  */
208 enum iwl_nvm_mac_sku_flags {
209 	NVM_MAC_SKU_FLAGS_BAND_2_4_ENABLED	= BIT(0),
210 	NVM_MAC_SKU_FLAGS_BAND_5_2_ENABLED	= BIT(1),
211 	NVM_MAC_SKU_FLAGS_802_11N_ENABLED	= BIT(2),
212 	NVM_MAC_SKU_FLAGS_802_11AC_ENABLED	= BIT(3),
213 	/**
214 	 * @NVM_MAC_SKU_FLAGS_802_11AX_ENABLED: true if 11ax enabled
215 	 */
216 	NVM_MAC_SKU_FLAGS_802_11AX_ENABLED	= BIT(4),
217 	NVM_MAC_SKU_FLAGS_MIMO_DISABLED		= BIT(5),
218 	NVM_MAC_SKU_FLAGS_WAPI_ENABLED		= BIT(8),
219 	NVM_MAC_SKU_FLAGS_REG_CHECK_ENABLED	= BIT(14),
220 	NVM_MAC_SKU_FLAGS_API_LOCK_ENABLED	= BIT(15),
221 };
222 
223 /**
224  * struct iwl_nvm_get_info_sku - mac information
225  * @mac_sku_flags: flags for SKU, see &enum iwl_nvm_mac_sku_flags
226  */
227 struct iwl_nvm_get_info_sku {
228 	__le32 mac_sku_flags;
229 } __packed; /* REGULATORY_NVM_GET_INFO_MAC_SKU_SECTION_S_VER_2 */
230 
231 /**
232  * struct iwl_nvm_get_info_phy - phy information
233  * @tx_chains: BIT 0 chain A, BIT 1 chain B
234  * @rx_chains: BIT 0 chain A, BIT 1 chain B
235  */
236 struct iwl_nvm_get_info_phy {
237 	__le32 tx_chains;
238 	__le32 rx_chains;
239 } __packed; /* REGULATORY_NVM_GET_INFO_PHY_SKU_SECTION_S_VER_1 */
240 
241 #define IWL_NUM_CHANNELS_V1	51
242 #define IWL_NUM_CHANNELS	110
243 
244 /**
245  * struct iwl_nvm_get_info_regulatory - regulatory information
246  * @lar_enabled: is LAR enabled
247  * @channel_profile: regulatory data of this channel
248  * @reserved: reserved
249  */
250 struct iwl_nvm_get_info_regulatory_v1 {
251 	__le32 lar_enabled;
252 	__le16 channel_profile[IWL_NUM_CHANNELS_V1];
253 	__le16 reserved;
254 } __packed; /* REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_1 */
255 
256 /**
257  * struct iwl_nvm_get_info_regulatory - regulatory information
258  * @lar_enabled: is LAR enabled
259  * @n_channels: number of valid channels in the array
260  * @channel_profile: regulatory data of this channel
261  */
262 struct iwl_nvm_get_info_regulatory {
263 	__le32 lar_enabled;
264 	__le32 n_channels;
265 	__le32 channel_profile[IWL_NUM_CHANNELS];
266 } __packed; /* REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_2 */
267 
268 /**
269  * struct iwl_nvm_get_info_rsp_v3 - response to get NVM data
270  * @general: general NVM data
271  * @mac_sku: data relating to MAC sku
272  * @phy_sku: data relating to PHY sku
273  * @regulatory: regulatory data
274  */
275 struct iwl_nvm_get_info_rsp_v3 {
276 	struct iwl_nvm_get_info_general general;
277 	struct iwl_nvm_get_info_sku mac_sku;
278 	struct iwl_nvm_get_info_phy phy_sku;
279 	struct iwl_nvm_get_info_regulatory_v1 regulatory;
280 } __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_3 */
281 
282 /**
283  * struct iwl_nvm_get_info_rsp - response to get NVM data
284  * @general: general NVM data
285  * @mac_sku: data relating to MAC sku
286  * @phy_sku: data relating to PHY sku
287  * @regulatory: regulatory data
288  */
289 struct iwl_nvm_get_info_rsp {
290 	struct iwl_nvm_get_info_general general;
291 	struct iwl_nvm_get_info_sku mac_sku;
292 	struct iwl_nvm_get_info_phy phy_sku;
293 	struct iwl_nvm_get_info_regulatory regulatory;
294 } __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_4 */
295 
296 /**
297  * struct iwl_nvm_access_complete_cmd - NVM_ACCESS commands are completed
298  * @reserved: reserved
299  */
300 struct iwl_nvm_access_complete_cmd {
301 	__le32 reserved;
302 } __packed; /* NVM_ACCESS_COMPLETE_CMD_API_S_VER_1 */
303 
304 /**
305  * struct iwl_mcc_update_cmd - Request the device to update geographic
306  * regulatory profile according to the given MCC (Mobile Country Code).
307  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
308  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
309  * MCC in the cmd response will be the relevant MCC in the NVM.
310  * @mcc: given mobile country code
311  * @source_id: the source from where we got the MCC, see iwl_mcc_source
312  * @reserved: reserved for alignment
313  * @key: integrity key for MCC API OEM testing
314  * @reserved2: reserved
315  */
316 struct iwl_mcc_update_cmd {
317 	__le16 mcc;
318 	u8 source_id;
319 	u8 reserved;
320 	__le32 key;
321 	u8 reserved2[20];
322 } __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_2 */
323 
324 /**
325  * enum iwl_geo_information - geographic information.
326  * @GEO_NO_INFO: no special info for this geo profile.
327  * @GEO_WMM_ETSI_5GHZ_INFO: this geo profile limits the WMM params
328  *	for the 5 GHz band.
329  */
330 enum iwl_geo_information {
331 	GEO_NO_INFO =			0,
332 	GEO_WMM_ETSI_5GHZ_INFO =	BIT(0),
333 };
334 
335 /**
336  * struct iwl_mcc_update_resp_v3 - response to MCC_UPDATE_CMD.
337  * Contains the new channel control profile map, if changed, and the new MCC
338  * (mobile country code).
339  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
340  * @status: see &enum iwl_mcc_update_status
341  * @mcc: the new applied MCC
342  * @cap: capabilities for all channels which matches the MCC
343  * @source_id: the MCC source, see iwl_mcc_source
344  * @time: time elapsed from the MCC test start (in units of 30 seconds)
345  * @geo_info: geographic specific profile information
346  *	see &enum iwl_geo_information.
347  * @n_channels: number of channels in @channels_data.
348  * @channels: channel control data map, DWORD for each channel. Only the first
349  *	16bits are used.
350  */
351 struct iwl_mcc_update_resp_v3 {
352 	__le32 status;
353 	__le16 mcc;
354 	u8 cap;
355 	u8 source_id;
356 	__le16 time;
357 	__le16 geo_info;
358 	__le32 n_channels;
359 	__le32 channels[0];
360 } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_3 */
361 
362 /**
363  * struct iwl_mcc_update_resp - response to MCC_UPDATE_CMD.
364  * Contains the new channel control profile map, if changed, and the new MCC
365  * (mobile country code).
366  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
367  * @status: see &enum iwl_mcc_update_status
368  * @mcc: the new applied MCC
369  * @cap: capabilities for all channels which matches the MCC
370  * @time: time elapsed from the MCC test start (in units of 30 seconds)
371  * @geo_info: geographic specific profile information
372  *	see &enum iwl_geo_information.
373  * @source_id: the MCC source, see iwl_mcc_source
374  * @reserved: for four bytes alignment.
375  * @n_channels: number of channels in @channels_data.
376  * @channels: channel control data map, DWORD for each channel. Only the first
377  *	16bits are used.
378  */
379 struct iwl_mcc_update_resp {
380 	__le32 status;
381 	__le16 mcc;
382 	__le16 cap;
383 	__le16 time;
384 	__le16 geo_info;
385 	u8 source_id;
386 	u8 reserved[3];
387 	__le32 n_channels;
388 	__le32 channels[0];
389 } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_4 */
390 
391 /**
392  * struct iwl_mcc_chub_notif - chub notifies of mcc change
393  * (MCC_CHUB_UPDATE_CMD = 0xc9)
394  * The Chub (Communication Hub, CommsHUB) is a HW component that connects to
395  * the cellular and connectivity cores that gets updates of the mcc, and
396  * notifies the ucode directly of any mcc change.
397  * The ucode requests the driver to request the device to update geographic
398  * regulatory  profile according to the given MCC (Mobile Country Code).
399  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
400  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
401  * MCC in the cmd response will be the relevant MCC in the NVM.
402  * @mcc: given mobile country code
403  * @source_id: identity of the change originator, see iwl_mcc_source
404  * @reserved1: reserved for alignment
405  */
406 struct iwl_mcc_chub_notif {
407 	__le16 mcc;
408 	u8 source_id;
409 	u8 reserved1;
410 } __packed; /* LAR_MCC_NOTIFY_S */
411 
412 enum iwl_mcc_update_status {
413 	MCC_RESP_NEW_CHAN_PROFILE,
414 	MCC_RESP_SAME_CHAN_PROFILE,
415 	MCC_RESP_INVALID,
416 	MCC_RESP_NVM_DISABLED,
417 	MCC_RESP_ILLEGAL,
418 	MCC_RESP_LOW_PRIORITY,
419 	MCC_RESP_TEST_MODE_ACTIVE,
420 	MCC_RESP_TEST_MODE_NOT_ACTIVE,
421 	MCC_RESP_TEST_MODE_DENIAL_OF_SERVICE,
422 };
423 
424 enum iwl_mcc_source {
425 	MCC_SOURCE_OLD_FW = 0,
426 	MCC_SOURCE_ME = 1,
427 	MCC_SOURCE_BIOS = 2,
428 	MCC_SOURCE_3G_LTE_HOST = 3,
429 	MCC_SOURCE_3G_LTE_DEVICE = 4,
430 	MCC_SOURCE_WIFI = 5,
431 	MCC_SOURCE_RESERVED = 6,
432 	MCC_SOURCE_DEFAULT = 7,
433 	MCC_SOURCE_UNINITIALIZED = 8,
434 	MCC_SOURCE_MCC_API = 9,
435 	MCC_SOURCE_GET_CURRENT = 0x10,
436 	MCC_SOURCE_GETTING_MCC_TEST_MODE = 0x11,
437 };
438 
439 #define IWL_TAS_BLACK_LIST_MAX 16
440 /**
441  * struct iwl_tas_config_cmd - configures the TAS
442  * @black_list_size: size of relevant field in black_list_array
443  * @black_list_array: black list countries (without TAS)
444  */
445 struct iwl_tas_config_cmd {
446 	__le32 black_list_size;
447 	__le32 black_list_array[IWL_TAS_BLACK_LIST_MAX];
448 } __packed; /* TAS_CONFIG_CMD_API_S_VER_2 */
449 #endif /* __iwl_fw_api_nvm_reg_h__ */
450