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  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of version 2 of the GNU General Public License as
14  * published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * The full GNU General Public License is included in this distribution
22  * in the file called COPYING.
23  *
24  * Contact Information:
25  *  Intel Linux Wireless <linuxwifi@intel.com>
26  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27  *
28  * BSD LICENSE
29  *
30  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
33  * All rights reserved.
34  *
35  * Redistribution and use in source and binary forms, with or without
36  * modification, are permitted provided that the following conditions
37  * are met:
38  *
39  *  * Redistributions of source code must retain the above copyright
40  *    notice, this list of conditions and the following disclaimer.
41  *  * Redistributions in binary form must reproduce the above copyright
42  *    notice, this list of conditions and the following disclaimer in
43  *    the documentation and/or other materials provided with the
44  *    distribution.
45  *  * Neither the name Intel Corporation nor the names of its
46  *    contributors may be used to endorse or promote products derived
47  *    from this software without specific prior written permission.
48  *
49  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
52  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
53  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
57  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  *****************************************************************************/
62 
63 #ifndef __iwl_fw_api_nvm_reg_h__
64 #define __iwl_fw_api_nvm_reg_h__
65 
66 /**
67  * enum iwl_regulatory_and_nvm_subcmd_ids - regulatory/NVM commands
68  */
69 enum iwl_regulatory_and_nvm_subcmd_ids {
70 	/**
71 	 * @NVM_ACCESS_COMPLETE: &struct iwl_nvm_access_complete_cmd
72 	 */
73 	NVM_ACCESS_COMPLETE = 0x0,
74 
75 	/**
76 	 * @NVM_GET_INFO:
77 	 * Command is &struct iwl_nvm_get_info,
78 	 * response is &struct iwl_nvm_get_info_rsp
79 	 */
80 	NVM_GET_INFO = 0x2,
81 };
82 
83 /**
84  * enum iwl_nvm_access_op - NVM access opcode
85  * @IWL_NVM_READ: read NVM
86  * @IWL_NVM_WRITE: write NVM
87  */
88 enum iwl_nvm_access_op {
89 	IWL_NVM_READ	= 0,
90 	IWL_NVM_WRITE	= 1,
91 };
92 
93 /**
94  * enum iwl_nvm_access_target - target of the NVM_ACCESS_CMD
95  * @NVM_ACCESS_TARGET_CACHE: access the cache
96  * @NVM_ACCESS_TARGET_OTP: access the OTP
97  * @NVM_ACCESS_TARGET_EEPROM: access the EEPROM
98  */
99 enum iwl_nvm_access_target {
100 	NVM_ACCESS_TARGET_CACHE = 0,
101 	NVM_ACCESS_TARGET_OTP = 1,
102 	NVM_ACCESS_TARGET_EEPROM = 2,
103 };
104 
105 /**
106  * enum iwl_nvm_section_type - section types for NVM_ACCESS_CMD
107  * @NVM_SECTION_TYPE_SW: software section
108  * @NVM_SECTION_TYPE_REGULATORY: regulatory section
109  * @NVM_SECTION_TYPE_CALIBRATION: calibration section
110  * @NVM_SECTION_TYPE_PRODUCTION: production section
111  * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section
112  * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section
113  * @NVM_MAX_NUM_SECTIONS: number of sections
114  */
115 enum iwl_nvm_section_type {
116 	NVM_SECTION_TYPE_SW = 1,
117 	NVM_SECTION_TYPE_REGULATORY = 3,
118 	NVM_SECTION_TYPE_CALIBRATION = 4,
119 	NVM_SECTION_TYPE_PRODUCTION = 5,
120 	NVM_SECTION_TYPE_MAC_OVERRIDE = 11,
121 	NVM_SECTION_TYPE_PHY_SKU = 12,
122 	NVM_MAX_NUM_SECTIONS = 13,
123 };
124 
125 /**
126  * struct iwl_nvm_access_cmd - Request the device to send an NVM section
127  * @op_code: &enum iwl_nvm_access_op
128  * @target: &enum iwl_nvm_access_target
129  * @type: &enum iwl_nvm_section_type
130  * @offset: offset in bytes into the section
131  * @length: in bytes, to read/write
132  * @data: if write operation, the data to write. On read its empty
133  */
134 struct iwl_nvm_access_cmd {
135 	u8 op_code;
136 	u8 target;
137 	__le16 type;
138 	__le16 offset;
139 	__le16 length;
140 	u8 data[];
141 } __packed; /* NVM_ACCESS_CMD_API_S_VER_2 */
142 
143 /**
144  * struct iwl_nvm_access_resp_ver2 - response to NVM_ACCESS_CMD
145  * @offset: offset in bytes into the section
146  * @length: in bytes, either how much was written or read
147  * @type: NVM_SECTION_TYPE_*
148  * @status: 0 for success, fail otherwise
149  * @data: if read operation, the data returned. Empty on write.
150  */
151 struct iwl_nvm_access_resp {
152 	__le16 offset;
153 	__le16 length;
154 	__le16 type;
155 	__le16 status;
156 	u8 data[];
157 } __packed; /* NVM_ACCESS_CMD_RESP_API_S_VER_2 */
158 
159 /*
160  * struct iwl_nvm_get_info - request to get NVM data
161  */
162 struct iwl_nvm_get_info {
163 	__le32 reserved;
164 } __packed; /* GRP_REGULATORY_NVM_GET_INFO_CMD_S_VER_1 */
165 
166 /**
167  * enum iwl_nvm_info_general_flags - flags in NVM_GET_INFO resp
168  * @NVM_GENERAL_FLAGS_EMPTY_OTP: 1 if OTP is empty
169  */
170 enum iwl_nvm_info_general_flags {
171 	NVM_GENERAL_FLAGS_EMPTY_OTP	= BIT(0),
172 };
173 
174 /**
175  * struct iwl_nvm_get_info_general - general NVM data
176  * @flags: bit 0: 1 - empty, 0 - non-empty
177  * @nvm_version: nvm version
178  * @board_type: board type
179  * @reserved: reserved
180  */
181 struct iwl_nvm_get_info_general {
182 	__le32 flags;
183 	__le16 nvm_version;
184 	u8 board_type;
185 	u8 reserved;
186 } __packed; /* GRP_REGULATORY_NVM_GET_INFO_GENERAL_S_VER_1 */
187 
188 /**
189  * struct iwl_nvm_get_info_sku - mac information
190  * @enable_24g: band 2.4G enabled
191  * @enable_5g: band 5G enabled
192  * @enable_11n: 11n enabled
193  * @enable_11ac: 11ac enabled
194  * @mimo_disable: MIMO enabled
195  * @ext_crypto: Extended crypto enabled
196  */
197 struct iwl_nvm_get_info_sku {
198 	__le32 enable_24g;
199 	__le32 enable_5g;
200 	__le32 enable_11n;
201 	__le32 enable_11ac;
202 	__le32 mimo_disable;
203 	__le32 ext_crypto;
204 } __packed; /* GRP_REGULATORY_NVM_GET_INFO_MAC_SKU_SECTION_S_VER_1 */
205 
206 /**
207  * struct iwl_nvm_get_info_phy - phy information
208  * @tx_chains: BIT 0 chain A, BIT 1 chain B
209  * @rx_chains: BIT 0 chain A, BIT 1 chain B
210  */
211 struct iwl_nvm_get_info_phy {
212 	__le32 tx_chains;
213 	__le32 rx_chains;
214 } __packed; /* GRP_REGULATORY_NVM_GET_INFO_PHY_SKU_SECTION_S_VER_1 */
215 
216 #define IWL_NUM_CHANNELS (51)
217 
218 /**
219  * struct iwl_nvm_get_info_regulatory - regulatory information
220  * @lar_enabled: is LAR enabled
221  * @channel_profile: regulatory data of this channel
222  * @reserved: reserved
223  */
224 struct iwl_nvm_get_info_regulatory {
225 	__le32 lar_enabled;
226 	__le16 channel_profile[IWL_NUM_CHANNELS];
227 	__le16 reserved;
228 } __packed; /* GRP_REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_1 */
229 
230 /**
231  * struct iwl_nvm_get_info_rsp - response to get NVM data
232  * @general: general NVM data
233  * @mac_sku: data relating to MAC sku
234  * @phy_sku: data relating to PHY sku
235  * @regulatory: regulatory data
236  */
237 struct iwl_nvm_get_info_rsp {
238 	struct iwl_nvm_get_info_general general;
239 	struct iwl_nvm_get_info_sku mac_sku;
240 	struct iwl_nvm_get_info_phy phy_sku;
241 	struct iwl_nvm_get_info_regulatory regulatory;
242 } __packed; /* GRP_REGULATORY_NVM_GET_INFO_CMD_RSP_S_VER_1 */
243 
244 /**
245  * struct iwl_nvm_access_complete_cmd - NVM_ACCESS commands are completed
246  * @reserved: reserved
247  */
248 struct iwl_nvm_access_complete_cmd {
249 	__le32 reserved;
250 } __packed; /* NVM_ACCESS_COMPLETE_CMD_API_S_VER_1 */
251 
252 /**
253  * struct iwl_mcc_update_cmd_v1 - Request the device to update geographic
254  * regulatory profile according to the given MCC (Mobile Country Code).
255  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
256  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
257  * MCC in the cmd response will be the relevant MCC in the NVM.
258  * @mcc: given mobile country code
259  * @source_id: the source from where we got the MCC, see iwl_mcc_source
260  * @reserved: reserved for alignment
261  */
262 struct iwl_mcc_update_cmd_v1 {
263 	__le16 mcc;
264 	u8 source_id;
265 	u8 reserved;
266 } __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_1 */
267 
268 /**
269  * struct iwl_mcc_update_cmd - Request the device to update geographic
270  * regulatory profile according to the given MCC (Mobile Country Code).
271  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
272  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
273  * MCC in the cmd response will be the relevant MCC in the NVM.
274  * @mcc: given mobile country code
275  * @source_id: the source from where we got the MCC, see iwl_mcc_source
276  * @reserved: reserved for alignment
277  * @key: integrity key for MCC API OEM testing
278  * @reserved2: reserved
279  */
280 struct iwl_mcc_update_cmd {
281 	__le16 mcc;
282 	u8 source_id;
283 	u8 reserved;
284 	__le32 key;
285 	u8 reserved2[20];
286 } __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_2 */
287 
288 /**
289  * struct iwl_mcc_update_resp_v1  - response to MCC_UPDATE_CMD.
290  * Contains the new channel control profile map, if changed, and the new MCC
291  * (mobile country code).
292  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
293  * @status: see &enum iwl_mcc_update_status
294  * @mcc: the new applied MCC
295  * @cap: capabilities for all channels which matches the MCC
296  * @source_id: the MCC source, see iwl_mcc_source
297  * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
298  *		channels, depending on platform)
299  * @channels: channel control data map, DWORD for each channel. Only the first
300  *	16bits are used.
301  */
302 struct iwl_mcc_update_resp_v1  {
303 	__le32 status;
304 	__le16 mcc;
305 	u8 cap;
306 	u8 source_id;
307 	__le32 n_channels;
308 	__le32 channels[0];
309 } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_1 */
310 
311 /**
312  * struct iwl_mcc_update_resp - response to MCC_UPDATE_CMD.
313  * Contains the new channel control profile map, if changed, and the new MCC
314  * (mobile country code).
315  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
316  * @status: see &enum iwl_mcc_update_status
317  * @mcc: the new applied MCC
318  * @cap: capabilities for all channels which matches the MCC
319  * @source_id: the MCC source, see iwl_mcc_source
320  * @time: time elapsed from the MCC test start (in 30 seconds TU)
321  * @reserved: reserved.
322  * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
323  *		channels, depending on platform)
324  * @channels: channel control data map, DWORD for each channel. Only the first
325  *	16bits are used.
326  */
327 struct iwl_mcc_update_resp {
328 	__le32 status;
329 	__le16 mcc;
330 	u8 cap;
331 	u8 source_id;
332 	__le16 time;
333 	__le16 reserved;
334 	__le32 n_channels;
335 	__le32 channels[0];
336 } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_2 */
337 
338 /**
339  * struct iwl_mcc_chub_notif - chub notifies of mcc change
340  * (MCC_CHUB_UPDATE_CMD = 0xc9)
341  * The Chub (Communication Hub, CommsHUB) is a HW component that connects to
342  * the cellular and connectivity cores that gets updates of the mcc, and
343  * notifies the ucode directly of any mcc change.
344  * The ucode requests the driver to request the device to update geographic
345  * regulatory  profile according to the given MCC (Mobile Country Code).
346  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
347  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
348  * MCC in the cmd response will be the relevant MCC in the NVM.
349  * @mcc: given mobile country code
350  * @source_id: identity of the change originator, see iwl_mcc_source
351  * @reserved1: reserved for alignment
352  */
353 struct iwl_mcc_chub_notif {
354 	__le16 mcc;
355 	u8 source_id;
356 	u8 reserved1;
357 } __packed; /* LAR_MCC_NOTIFY_S */
358 
359 enum iwl_mcc_update_status {
360 	MCC_RESP_NEW_CHAN_PROFILE,
361 	MCC_RESP_SAME_CHAN_PROFILE,
362 	MCC_RESP_INVALID,
363 	MCC_RESP_NVM_DISABLED,
364 	MCC_RESP_ILLEGAL,
365 	MCC_RESP_LOW_PRIORITY,
366 	MCC_RESP_TEST_MODE_ACTIVE,
367 	MCC_RESP_TEST_MODE_NOT_ACTIVE,
368 	MCC_RESP_TEST_MODE_DENIAL_OF_SERVICE,
369 };
370 
371 enum iwl_mcc_source {
372 	MCC_SOURCE_OLD_FW = 0,
373 	MCC_SOURCE_ME = 1,
374 	MCC_SOURCE_BIOS = 2,
375 	MCC_SOURCE_3G_LTE_HOST = 3,
376 	MCC_SOURCE_3G_LTE_DEVICE = 4,
377 	MCC_SOURCE_WIFI = 5,
378 	MCC_SOURCE_RESERVED = 6,
379 	MCC_SOURCE_DEFAULT = 7,
380 	MCC_SOURCE_UNINITIALIZED = 8,
381 	MCC_SOURCE_MCC_API = 9,
382 	MCC_SOURCE_GET_CURRENT = 0x10,
383 	MCC_SOURCE_GETTING_MCC_TEST_MODE = 0x11,
384 };
385 
386 #endif /* __iwl_fw_api_nvm_reg_h__ */
387