1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright(c) 2021-2024 Intel Corporation
5 #ifndef __iwl_fw_uefi__
6 #define __iwl_fw_uefi__
8 #include "fw/regulatory.h"
10 #define IWL_UEFI_OEM_PNVM_NAME L"UefiCnvWlanOemSignedPnvm"
11 #define IWL_UEFI_REDUCED_POWER_NAME L"UefiCnvWlanReducedPower"
12 #define IWL_UEFI_SGOM_NAME L"UefiCnvWlanSarGeoOffsetMapping"
13 #define IWL_UEFI_STEP_NAME L"UefiCnvCommonSTEP"
14 #define IWL_UEFI_UATS_NAME L"CnvUefiWlanUATS"
15 #define IWL_UEFI_WRDS_NAME L"UefiCnvWlanWRDS"
16 #define IWL_UEFI_EWRD_NAME L"UefiCnvWlanEWRD"
17 #define IWL_UEFI_WGDS_NAME L"UefiCnvWlanWGDS"
18 #define IWL_UEFI_PPAG_NAME L"UefiCnvWlanPPAG"
19 #define IWL_UEFI_WTAS_NAME L"UefiCnvWlanWTAS"
20 #define IWL_UEFI_SPLC_NAME L"UefiCnvWlanSPLC"
21 #define IWL_UEFI_WRDD_NAME L"UefiCnvWlanWRDD"
22 #define IWL_UEFI_ECKV_NAME L"UefiCnvWlanECKV"
23 #define IWL_UEFI_DSM_NAME L"UefiCnvWlanGeneralCfg"
24 #define IWL_UEFI_WBEM_NAME L"UefiCnvWlanWBEM"
25 #define IWL_UEFI_PUNCTURING_NAME L"UefiCnvWlanPuncturing"
26 #define IWL_UEFI_DSBR_NAME L"UefiCnvCommonDSBR"
29 #define IWL_SGOM_MAP_SIZE 339
30 #define IWL_UATS_MAP_SIZE 339
32 #define IWL_UEFI_WRDS_REVISION 2
33 #define IWL_UEFI_EWRD_REVISION 2
34 #define IWL_UEFI_WGDS_REVISION 3
35 #define IWL_UEFI_MIN_PPAG_REV 1
36 #define IWL_UEFI_MAX_PPAG_REV 3
37 #define IWL_UEFI_MIN_WTAS_REVISION 1
38 #define IWL_UEFI_MAX_WTAS_REVISION 2
39 #define IWL_UEFI_SPLC_REVISION 0
40 #define IWL_UEFI_WRDD_REVISION 0
41 #define IWL_UEFI_ECKV_REVISION 0
42 #define IWL_UEFI_WBEM_REVISION 0
43 #define IWL_UEFI_DSM_REVISION 4
44 #define IWL_UEFI_PUNCTURING_REVISION 0
45 #define IWL_UEFI_DSBR_REVISION 1
47 struct pnvm_sku_package
{
55 struct uefi_cnv_wlan_sgom_data
{
57 u8 offset_map
[IWL_SGOM_MAP_SIZE
- 1];
60 struct uefi_cnv_wlan_uats_data
{
62 u8 offset_map
[IWL_UATS_MAP_SIZE
- 1];
65 struct uefi_cnv_common_step_data
{
75 * struct uefi_sar_profile - a SAR profile as defined in UEFI
77 * @chains: a per-chain table of SAR values
79 struct uefi_sar_profile
{
80 struct iwl_sar_profile_chain chains
[BIOS_SAR_MAX_CHAINS_PER_PROFILE
];
84 * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI
86 * @revision: the revision of the table
87 * @mode: is WRDS enbaled/disabled
88 * @sar_profile: sar profile #1
90 struct uefi_cnv_var_wrds
{
93 struct uefi_sar_profile sar_profile
;
97 * struct uefi_cnv_var_ewrd - EWRD table as defined in UEFI
98 * @revision: the revision of the table
99 * @mode: is WRDS enbaled/disabled
100 * @num_profiles: how many additional profiles we have in this table (0-3)
101 * @sar_profiles: the additional SAR profiles (#2-#4)
103 struct uefi_cnv_var_ewrd
{
107 struct uefi_sar_profile sar_profiles
[BIOS_SAR_MAX_PROFILE_NUM
- 1];
111 * struct uefi_cnv_var_wgds - WGDS table as defined in UEFI
112 * @revision: the revision of the table
113 * @num_profiles: the number of geo profiles we have in the table.
114 * The first 3 are mandatory, and can have up to 8.
115 * @geo_profiles: a per-profile table of the offsets to add to SAR values.
117 struct uefi_cnv_var_wgds
{
120 struct iwl_geo_profile geo_profiles
[BIOS_GEO_MAX_PROFILE_NUM
];
124 * struct uefi_cnv_var_ppag - PPAG table as defined in UEFI
125 * @revision: the revision of the table
126 * @ppag_modes: values from &enum iwl_ppag_flags
127 * @ppag_chains: the PPAG values per chain and band
129 struct uefi_cnv_var_ppag
{
132 struct iwl_ppag_chain ppag_chains
[IWL_NUM_CHAIN_LIMITS
];
135 /* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI
136 * @revision: the revision of the table
137 * @tas_selection: different options of TAS enablement.
138 * @black_list_size: the number of defined entried in the black list
139 * @black_list: a list of countries that are not allowed to use the TAS feature
141 struct uefi_cnv_var_wtas
{
145 u16 black_list
[IWL_WTAS_BLACK_LIST_MAX
];
148 /* struct uefi_cnv_var_splc - SPLC tabled as defined in UEFI
149 * @revision: the revision of the table
150 * @default_pwr_limit: The default maximum power per device
152 struct uefi_cnv_var_splc
{
154 u32 default_pwr_limit
;
157 /* struct uefi_cnv_var_wrdd - WRDD table as defined in UEFI
158 * @revision: the revision of the table
159 * @mcc: country identifier as defined in ISO/IEC 3166-1 Alpha 2 code
161 struct uefi_cnv_var_wrdd
{
166 /* struct uefi_cnv_var_eckv - ECKV table as defined in UEFI
167 * @revision: the revision of the table
168 * @ext_clock_valid: indicates if external 32KHz clock is valid
170 struct uefi_cnv_var_eckv
{
175 #define UEFI_MAX_DSM_FUNCS 32
177 /* struct uefi_cnv_var_general_cfg - DSM-like table as defined in UEFI
178 * @revision: the revision of the table
179 * @functions: payload of the different DSM functions
181 struct uefi_cnv_var_general_cfg
{
183 u32 functions
[UEFI_MAX_DSM_FUNCS
];
186 #define IWL_UEFI_WBEM_REV0_MASK (BIT(0) | BIT(1))
187 /* struct uefi_cnv_wlan_wbem_data - Bandwidth enablement per MCC as defined
189 * @revision: the revision of the table
190 * @wbem_320mhz_per_mcc: enablement of 320MHz bandwidth per MCC
191 * bit 0 - if set, 320MHz is enabled for Japan
192 * bit 1 - if set, 320MHz is enabled for South Korea
193 * bit 2- 31, Reserved
195 struct uefi_cnv_wlan_wbem_data
{
197 u32 wbem_320mhz_per_mcc
;
200 enum iwl_uefi_cnv_puncturing_flags
{
201 IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK
= BIT(0),
202 IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK
= BIT(1),
205 #define IWL_UEFI_PUNCTURING_REV0_MASK (IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK | \
206 IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK)
208 * struct uefi_cnv_var_puncturing_data - controlling channel
209 * puncturing for few countries.
210 * @revision: the revision of the table
211 * @puncturing: enablement of channel puncturing per mcc
212 * see &enum iwl_uefi_cnv_puncturing_flags.
214 struct uefi_cnv_var_puncturing_data
{
220 * struct uefi_cnv_wlan_dsbr_data - BIOS STEP configuration information
221 * @revision: the revision of the table
222 * @config: STEP configuration flags:
223 * bit 8, switch to URM depending on FW setting
224 * bit 9, switch to URM
226 * Platform information for STEP configuration/workarounds.
228 struct uefi_cnv_wlan_dsbr_data
{
234 * This is known to be broken on v4.19 and to work on v5.4. Until we
235 * figure out why this is the case and how to make it work, simply
236 * disable the feature in old kernels.
239 void *iwl_uefi_get_pnvm(struct iwl_trans
*trans
, size_t *len
);
240 u8
*iwl_uefi_get_reduced_power(struct iwl_trans
*trans
, size_t *len
);
241 int iwl_uefi_reduce_power_parse(struct iwl_trans
*trans
,
242 const u8
*data
, size_t len
,
243 struct iwl_pnvm_image
*pnvm_data
);
244 void iwl_uefi_get_step_table(struct iwl_trans
*trans
);
245 int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans
*trans
, const u8
*data
,
246 u32 tlv_len
, struct iwl_pnvm_image
*pnvm_data
);
247 int iwl_uefi_get_wrds_table(struct iwl_fw_runtime
*fwrt
);
248 int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime
*fwrt
);
249 int iwl_uefi_get_wgds_table(struct iwl_fw_runtime
*fwrt
);
250 int iwl_uefi_get_ppag_table(struct iwl_fw_runtime
*fwrt
);
251 int iwl_uefi_get_tas_table(struct iwl_fw_runtime
*fwrt
,
252 struct iwl_tas_data
*data
);
253 int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime
*fwrt
,
254 u64
*dflt_pwr_limit
);
255 int iwl_uefi_get_mcc(struct iwl_fw_runtime
*fwrt
, char *mcc
);
256 int iwl_uefi_get_eckv(struct iwl_fw_runtime
*fwrt
, u32
*extl_clk
);
257 int iwl_uefi_get_wbem(struct iwl_fw_runtime
*fwrt
, u32
*value
);
258 int iwl_uefi_get_dsm(struct iwl_fw_runtime
*fwrt
, enum iwl_dsm_funcs func
,
260 void iwl_uefi_get_sgom_table(struct iwl_trans
*trans
, struct iwl_fw_runtime
*fwrt
);
261 int iwl_uefi_get_uats_table(struct iwl_trans
*trans
,
262 struct iwl_fw_runtime
*fwrt
);
263 int iwl_uefi_get_puncturing(struct iwl_fw_runtime
*fwrt
);
264 int iwl_uefi_get_dsbr(struct iwl_fw_runtime
*fwrt
, u32
*value
);
265 #else /* CONFIG_EFI */
266 static inline void *iwl_uefi_get_pnvm(struct iwl_trans
*trans
, size_t *len
)
268 return ERR_PTR(-EOPNOTSUPP
);
272 iwl_uefi_reduce_power_parse(struct iwl_trans
*trans
,
273 const u8
*data
, size_t len
,
274 struct iwl_pnvm_image
*pnvm_data
)
280 iwl_uefi_get_reduced_power(struct iwl_trans
*trans
, size_t *len
)
282 return ERR_PTR(-EOPNOTSUPP
);
285 static inline void iwl_uefi_get_step_table(struct iwl_trans
*trans
)
290 iwl_uefi_handle_tlv_mem_desc(struct iwl_trans
*trans
, const u8
*data
,
291 u32 tlv_len
, struct iwl_pnvm_image
*pnvm_data
)
296 static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime
*fwrt
)
301 static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime
*fwrt
)
306 static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime
*fwrt
)
311 static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime
*fwrt
)
316 static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime
*fwrt
,
317 struct iwl_tas_data
*data
)
322 static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime
*fwrt
,
329 static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime
*fwrt
, char *mcc
)
334 static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime
*fwrt
, u32
*extl_clk
)
339 static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime
*fwrt
, u32
*value
)
344 static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime
*fwrt
,
345 enum iwl_dsm_funcs func
, u32
*value
)
351 void iwl_uefi_get_sgom_table(struct iwl_trans
*trans
, struct iwl_fw_runtime
*fwrt
)
356 int iwl_uefi_get_uats_table(struct iwl_trans
*trans
,
357 struct iwl_fw_runtime
*fwrt
)
363 int iwl_uefi_get_puncturing(struct iwl_fw_runtime
*fwrt
)
369 int iwl_uefi_get_dsbr(struct iwl_fw_runtime
*fwrt
, u32
*value
)
373 #endif /* CONFIG_EFI */
374 #endif /* __iwl_fw_uefi__ */