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