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