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"
28 #define IWL_SGOM_MAP_SIZE 339
29 #define IWL_UATS_MAP_SIZE 339
31 #define IWL_UEFI_WRDS_REVISION 2
32 #define IWL_UEFI_EWRD_REVISION 2
33 #define IWL_UEFI_WGDS_REVISION 3
34 #define IWL_UEFI_MIN_PPAG_REV 1
35 #define IWL_UEFI_MAX_PPAG_REV 3
36 #define IWL_UEFI_WTAS_REVISION 1
37 #define IWL_UEFI_SPLC_REVISION 0
38 #define IWL_UEFI_WRDD_REVISION 0
39 #define IWL_UEFI_ECKV_REVISION 0
40 #define IWL_UEFI_WBEM_REVISION 0
41 #define IWL_UEFI_DSM_REVISION 4
42 #define IWL_UEFI_PUNCTURING_REVISION 0
44 struct pnvm_sku_package {
52 struct uefi_cnv_wlan_sgom_data {
54 u8 offset_map[IWL_SGOM_MAP_SIZE - 1];
57 struct uefi_cnv_wlan_uats_data {
59 u8 offset_map[IWL_UATS_MAP_SIZE - 1];
62 struct uefi_cnv_common_step_data {
72 * struct uefi_sar_profile - a SAR profile as defined in UEFI
74 * @chains: a per-chain table of SAR values
76 struct uefi_sar_profile {
77 struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE];
81 * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI
83 * @revision: the revision of the table
84 * @mode: is WRDS enbaled/disabled
85 * @sar_profile: sar profile #1
87 struct uefi_cnv_var_wrds {
90 struct uefi_sar_profile sar_profile;
94 * struct uefi_cnv_var_ewrd - EWRD table as defined in UEFI
95 * @revision: the revision of the table
96 * @mode: is WRDS enbaled/disabled
97 * @num_profiles: how many additional profiles we have in this table (0-3)
98 * @sar_profiles: the additional SAR profiles (#2-#4)
100 struct uefi_cnv_var_ewrd {
104 struct uefi_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM - 1];
108 * struct uefi_cnv_var_wgds - WGDS table as defined in UEFI
109 * @revision: the revision of the table
110 * @num_profiles: the number of geo profiles we have in the table.
111 * The first 3 are mandatory, and can have up to 8.
112 * @geo_profiles: a per-profile table of the offsets to add to SAR values.
114 struct uefi_cnv_var_wgds {
117 struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM];
121 * struct uefi_cnv_var_ppag - PPAG table as defined in UEFI
122 * @revision: the revision of the table
123 * @ppag_modes: values from &enum iwl_ppag_flags
124 * @ppag_chains: the PPAG values per chain and band
126 struct uefi_cnv_var_ppag {
129 struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];
132 /* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI
133 * @revision: the revision of the table
134 * @tas_selection: different options of TAS enablement.
135 * @black_list_size: the number of defined entried in the black list
136 * @black_list: a list of countries that are not allowed to use the TAS feature
138 struct uefi_cnv_var_wtas {
142 u16 black_list[IWL_WTAS_BLACK_LIST_MAX];
145 /* struct uefi_cnv_var_splc - SPLC tabled as defined in UEFI
146 * @revision: the revision of the table
147 * @default_pwr_limit: The default maximum power per device
149 struct uefi_cnv_var_splc {
151 u32 default_pwr_limit;
154 /* struct uefi_cnv_var_wrdd - WRDD table as defined in UEFI
155 * @revision: the revision of the table
156 * @mcc: country identifier as defined in ISO/IEC 3166-1 Alpha 2 code
158 struct uefi_cnv_var_wrdd {
163 /* struct uefi_cnv_var_eckv - ECKV table as defined in UEFI
164 * @revision: the revision of the table
165 * @ext_clock_valid: indicates if external 32KHz clock is valid
167 struct uefi_cnv_var_eckv {
172 #define UEFI_MAX_DSM_FUNCS 32
174 /* struct uefi_cnv_var_general_cfg - DSM-like table as defined in UEFI
175 * @revision: the revision of the table
176 * @functions: payload of the different DSM functions
178 struct uefi_cnv_var_general_cfg {
180 u32 functions[UEFI_MAX_DSM_FUNCS];
183 #define IWL_UEFI_WBEM_REV0_MASK (BIT(0) | BIT(1))
184 /* struct uefi_cnv_wlan_wbem_data - Bandwidth enablement per MCC as defined
186 * @revision: the revision of the table
187 * @wbem_320mhz_per_mcc: enablement of 320MHz bandwidth per MCC
188 * bit 0 - if set, 320MHz is enabled for Japan
189 * bit 1 - if set, 320MHz is enabled for South Korea
190 * bit 2- 31, Reserved
192 struct uefi_cnv_wlan_wbem_data {
194 u32 wbem_320mhz_per_mcc;
197 enum iwl_uefi_cnv_puncturing_flags {
198 IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK = BIT(0),
199 IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK = BIT(1),
202 #define IWL_UEFI_PUNCTURING_REV0_MASK (IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK | \
203 IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK)
205 * struct uefi_cnv_var_puncturing_data - controlling channel
206 * puncturing for few countries.
207 * @revision: the revision of the table
208 * @puncturing: enablement of channel puncturing per mcc
209 * see &enum iwl_uefi_cnv_puncturing_flags.
211 struct uefi_cnv_var_puncturing_data {
217 * This is known to be broken on v4.19 and to work on v5.4. Until we
218 * figure out why this is the case and how to make it work, simply
219 * disable the feature in old kernels.
222 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len);
223 u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);
224 int iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
225 const u8 *data, size_t len,
226 struct iwl_pnvm_image *pnvm_data);
227 void iwl_uefi_get_step_table(struct iwl_trans *trans);
228 int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
229 u32 tlv_len, struct iwl_pnvm_image *pnvm_data);
230 int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt);
231 int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt);
232 int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt);
233 int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt);
234 int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
235 struct iwl_tas_data *data);
236 int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
237 u64 *dflt_pwr_limit);
238 int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);
239 int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk);
240 int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);
241 int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
243 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
244 int iwl_uefi_get_uats_table(struct iwl_trans *trans,
245 struct iwl_fw_runtime *fwrt);
246 int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt);
247 #else /* CONFIG_EFI */
248 static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
250 return ERR_PTR(-EOPNOTSUPP);
254 iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
255 const u8 *data, size_t len,
256 struct iwl_pnvm_image *pnvm_data)
262 iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
264 return ERR_PTR(-EOPNOTSUPP);
267 static inline void iwl_uefi_get_step_table(struct iwl_trans *trans)
272 iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
273 u32 tlv_len, struct iwl_pnvm_image *pnvm_data)
278 static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt)
283 static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt)
288 static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt)
293 static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
298 static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
299 struct iwl_tas_data *data)
304 static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
311 static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
316 static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
321 static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
326 static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt,
327 enum iwl_dsm_funcs func, u32 *value)
333 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
338 int iwl_uefi_get_uats_table(struct iwl_trans *trans,
339 struct iwl_fw_runtime *fwrt)
345 int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt)
349 #endif /* CONFIG_EFI */
350 #endif /* __iwl_fw_uefi__ */