1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright(c) 2021-2023 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"
26 #define IWL_SGOM_MAP_SIZE 339
27 #define IWL_UATS_MAP_SIZE 339
29 #define IWL_UEFI_WRDS_REVISION 2
30 #define IWL_UEFI_EWRD_REVISION 2
31 #define IWL_UEFI_WGDS_REVISION 3
32 #define IWL_UEFI_MIN_PPAG_REV 1
33 #define IWL_UEFI_MAX_PPAG_REV 3
34 #define IWL_UEFI_WTAS_REVISION 1
35 #define IWL_UEFI_SPLC_REVISION 0
36 #define IWL_UEFI_WRDD_REVISION 0
37 #define IWL_UEFI_ECKV_REVISION 0
38 #define IWL_UEFI_DSM_REVISION 4
40 struct pnvm_sku_package {
48 struct uefi_cnv_wlan_sgom_data {
50 u8 offset_map[IWL_SGOM_MAP_SIZE - 1];
53 struct uefi_cnv_wlan_uats_data {
55 u8 offset_map[IWL_UATS_MAP_SIZE - 1];
58 struct uefi_cnv_common_step_data {
68 * struct uefi_sar_profile - a SAR profile as defined in UEFI
70 * @chains: a per-chain table of SAR values
72 struct uefi_sar_profile {
73 struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE];
77 * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI
79 * @revision: the revision of the table
80 * @mode: is WRDS enbaled/disabled
81 * @sar_profile: sar profile #1
83 struct uefi_cnv_var_wrds {
86 struct uefi_sar_profile sar_profile;
90 * struct uefi_cnv_var_ewrd - EWRD table as defined in UEFI
91 * @revision: the revision of the table
92 * @mode: is WRDS enbaled/disabled
93 * @num_profiles: how many additional profiles we have in this table (0-3)
94 * @sar_profiles: the additional SAR profiles (#2-#4)
96 struct uefi_cnv_var_ewrd {
100 struct uefi_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM - 1];
104 * struct uefi_cnv_var_wgds - WGDS table as defined in UEFI
105 * @revision: the revision of the table
106 * @num_profiles: the number of geo profiles we have in the table.
107 * The first 3 are mandatory, and can have up to 8.
108 * @geo_profiles: a per-profile table of the offsets to add to SAR values.
110 struct uefi_cnv_var_wgds {
113 struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM];
117 * struct uefi_cnv_var_ppag - PPAG table as defined in UEFI
118 * @revision: the revision of the table
119 * @ppag_modes: values from &enum iwl_ppag_flags
120 * @ppag_chains: the PPAG values per chain and band
122 struct uefi_cnv_var_ppag {
125 struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];
128 /* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI
129 * @revision: the revision of the table
130 * @tas_selection: different options of TAS enablement.
131 * @black_list_size: the number of defined entried in the black list
132 * @black_list: a list of countries that are not allowed to use the TAS feature
134 struct uefi_cnv_var_wtas {
138 u16 black_list[IWL_WTAS_BLACK_LIST_MAX];
141 /* struct uefi_cnv_var_splc - SPLC tabled as defined in UEFI
142 * @revision: the revision of the table
143 * @default_pwr_limit: The default maximum power per device
145 struct uefi_cnv_var_splc {
147 u32 default_pwr_limit;
150 #define UEFI_MCC_CHINA 0x434e
152 /* struct uefi_cnv_var_wrdd - WRDD table as defined in UEFI
153 * @revision: the revision of the table
154 * @mcc: country identifier as defined in ISO/IEC 3166-1 Alpha 2 code
156 struct uefi_cnv_var_wrdd {
161 /* struct uefi_cnv_var_eckv - ECKV table as defined in UEFI
162 * @revision: the revision of the table
163 * @ext_clock_valid: indicates if external 32KHz clock is valid
165 struct uefi_cnv_var_eckv {
170 #define UEFI_MAX_DSM_FUNCS 32
172 /* struct uefi_cnv_var_general_cfg - DSM-like table as defined in UEFI
173 * @revision: the revision of the table
174 * @functions: payload of the different DSM functions
176 struct uefi_cnv_var_general_cfg {
178 u32 functions[UEFI_MAX_DSM_FUNCS];
182 * This is known to be broken on v4.19 and to work on v5.4. Until we
183 * figure out why this is the case and how to make it work, simply
184 * disable the feature in old kernels.
187 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len);
188 u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);
189 int iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
190 const u8 *data, size_t len,
191 struct iwl_pnvm_image *pnvm_data);
192 void iwl_uefi_get_step_table(struct iwl_trans *trans);
193 int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
194 u32 tlv_len, struct iwl_pnvm_image *pnvm_data);
195 int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt);
196 int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt);
197 int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt);
198 int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt);
199 int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
200 struct iwl_tas_data *data);
201 int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
202 u64 *dflt_pwr_limit);
203 int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);
204 int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk);
205 int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
207 #else /* CONFIG_EFI */
208 static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
210 return ERR_PTR(-EOPNOTSUPP);
214 iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
215 const u8 *data, size_t len,
216 struct iwl_pnvm_image *pnvm_data)
222 iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
224 return ERR_PTR(-EOPNOTSUPP);
227 static inline void iwl_uefi_get_step_table(struct iwl_trans *trans)
232 iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
233 u32 tlv_len, struct iwl_pnvm_image *pnvm_data)
238 static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt)
243 static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt)
248 static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt)
253 static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
258 static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
259 struct iwl_tas_data *data)
264 static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
271 static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
276 static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
281 static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt,
282 enum iwl_dsm_funcs func, u32 *value)
286 #endif /* CONFIG_EFI */
288 #if defined(CONFIG_EFI) && defined(CONFIG_ACPI)
289 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
290 int iwl_uefi_get_uats_table(struct iwl_trans *trans,
291 struct iwl_fw_runtime *fwrt);
294 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
299 int iwl_uefi_get_uats_table(struct iwl_trans *trans,
300 struct iwl_fw_runtime *fwrt)
305 #endif /* __iwl_fw_uefi__ */