| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 |
/* |
| 3 |
* Copyright(c) 2021-2025 Intel Corporation |
| 4 |
*/ |
| 5 |
#ifndef __iwl_fw_uefi__ |
| 6 |
#define __iwl_fw_uefi__ |
| 7 |
|
| 8 |
#include "fw/regulatory.h" |
| 9 |
|
| 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"UefiCnvCommonECKV" |
| 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" |
| 27 |
#define IWL_UEFI_WPFC_NAME L"WPFC" |
| 28 |
|
| 29 |
|
| 30 |
#define IWL_SGOM_MAP_SIZE 339 |
| 31 |
#define IWL_UATS_MAP_SIZE 339 |
| 32 |
|
| 33 |
#define IWL_UEFI_WRDS_REVISION 2 |
| 34 |
#define IWL_UEFI_EWRD_REVISION 2 |
| 35 |
#define IWL_UEFI_WGDS_REVISION 3 |
| 36 |
#define IWL_UEFI_MIN_PPAG_REV 1 |
| 37 |
#define IWL_UEFI_MAX_PPAG_REV 4 |
| 38 |
#define IWL_UEFI_MIN_WTAS_REVISION 1 |
| 39 |
#define IWL_UEFI_MAX_WTAS_REVISION 2 |
| 40 |
#define IWL_UEFI_SPLC_REVISION 0 |
| 41 |
#define IWL_UEFI_WRDD_REVISION 0 |
| 42 |
#define IWL_UEFI_ECKV_REVISION 0 |
| 43 |
#define IWL_UEFI_WBEM_REVISION 0 |
| 44 |
#define IWL_UEFI_DSM_REVISION 4 |
| 45 |
#define IWL_UEFI_PUNCTURING_REVISION 0 |
| 46 |
#define IWL_UEFI_DSBR_REVISION 1 |
| 47 |
|
| 48 |
struct pnvm_sku_package { |
| 49 |
u8 rev; |
| 50 |
u32 total_size; |
| 51 |
u8 n_skus; |
| 52 |
u32 reserved[2]; |
| 53 |
u8 data[]; |
| 54 |
} __packed; |
| 55 |
|
| 56 |
struct uefi_cnv_wlan_sgom_data { |
| 57 |
u8 revision; |
| 58 |
u8 offset_map[IWL_SGOM_MAP_SIZE - 1]; |
| 59 |
} __packed; |
| 60 |
|
| 61 |
struct uefi_cnv_wlan_uats_data { |
| 62 |
u8 revision; |
| 63 |
u8 mcc_to_ap_type_map[IWL_UATS_MAP_SIZE - 1]; |
| 64 |
} __packed; |
| 65 |
|
| 66 |
struct uefi_cnv_common_step_data { |
| 67 |
u8 revision; |
| 68 |
u8 step_mode; |
| 69 |
u8 cnvi_eq_channel; |
| 70 |
u8 cnvr_eq_channel; |
| 71 |
u8 radio1; |
| 72 |
u8 radio2; |
| 73 |
} __packed; |
| 74 |
|
| 75 |
/* |
| 76 |
* struct uefi_sar_profile - a SAR profile as defined in UEFI |
| 77 |
* |
| 78 |
* @chains: a per-chain table of SAR values |
| 79 |
*/ |
| 80 |
struct uefi_sar_profile { |
| 81 |
struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE]; |
| 82 |
} __packed; |
| 83 |
|
| 84 |
/* |
| 85 |
* struct uefi_cnv_var_wrds - WRDS table as defined in UEFI |
| 86 |
* |
| 87 |
* @revision: the revision of the table |
| 88 |
* @mode: is WRDS enbaled/disabled |
| 89 |
* @sar_profile: sar profile #1 |
| 90 |
*/ |
| 91 |
struct uefi_cnv_var_wrds { |
| 92 |
u8 revision; |
| 93 |
u32 mode; |
| 94 |
struct uefi_sar_profile sar_profile; |
| 95 |
} __packed; |
| 96 |
|
| 97 |
/* |
| 98 |
* struct uefi_cnv_var_ewrd - EWRD table as defined in UEFI |
| 99 |
* @revision: the revision of the table |
| 100 |
* @mode: is WRDS enbaled/disabled |
| 101 |
* @num_profiles: how many additional profiles we have in this table (0-3) |
| 102 |
* @sar_profiles: the additional SAR profiles (#2-#4) |
| 103 |
*/ |
| 104 |
struct uefi_cnv_var_ewrd { |
| 105 |
u8 revision; |
| 106 |
u32 mode; |
| 107 |
u32 num_profiles; |
| 108 |
struct uefi_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM - 1]; |
| 109 |
} __packed; |
| 110 |
|
| 111 |
/* |
| 112 |
* struct uefi_cnv_var_wgds - WGDS table as defined in UEFI |
| 113 |
* @revision: the revision of the table |
| 114 |
* @num_profiles: the number of geo profiles we have in the table. |
| 115 |
* The first 3 are mandatory, and can have up to 8. |
| 116 |
* @geo_profiles: a per-profile table of the offsets to add to SAR values. |
| 117 |
*/ |
| 118 |
struct uefi_cnv_var_wgds { |
| 119 |
u8 revision; |
| 120 |
u8 num_profiles; |
| 121 |
struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM]; |
| 122 |
} __packed; |
| 123 |
|
| 124 |
/* |
| 125 |
* struct uefi_cnv_var_ppag - PPAG table as defined in UEFI |
| 126 |
* @revision: the revision of the table |
| 127 |
* @ppag_modes: values from &enum iwl_ppag_flags |
| 128 |
* @ppag_chains: the PPAG values per chain and band |
| 129 |
*/ |
| 130 |
struct uefi_cnv_var_ppag { |
| 131 |
u8 revision; |
| 132 |
u32 ppag_modes; |
| 133 |
struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS]; |
| 134 |
} __packed; |
| 135 |
|
| 136 |
/* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI |
| 137 |
* @revision: the revision of the table |
| 138 |
* @tas_selection: different options of TAS enablement. |
| 139 |
* @black_list_size: the number of defined entried in the black list |
| 140 |
* @black_list: a list of countries that are not allowed to use the TAS feature |
| 141 |
*/ |
| 142 |
struct uefi_cnv_var_wtas { |
| 143 |
u8 revision; |
| 144 |
u32 tas_selection; |
| 145 |
u8 black_list_size; |
| 146 |
u16 black_list[IWL_WTAS_BLACK_LIST_MAX]; |
| 147 |
} __packed; |
| 148 |
|
| 149 |
/* struct uefi_cnv_var_splc - SPLC tabled as defined in UEFI |
| 150 |
* @revision: the revision of the table |
| 151 |
* @default_pwr_limit: The default maximum power per device |
| 152 |
*/ |
| 153 |
struct uefi_cnv_var_splc { |
| 154 |
u8 revision; |
| 155 |
u32 default_pwr_limit; |
| 156 |
} __packed; |
| 157 |
|
| 158 |
/* struct uefi_cnv_var_wrdd - WRDD table as defined in UEFI |
| 159 |
* @revision: the revision of the table |
| 160 |
* @mcc: country identifier as defined in ISO/IEC 3166-1 Alpha 2 code |
| 161 |
*/ |
| 162 |
struct uefi_cnv_var_wrdd { |
| 163 |
u8 revision; |
| 164 |
u32 mcc; |
| 165 |
} __packed; |
| 166 |
|
| 167 |
/* struct uefi_cnv_var_eckv - ECKV table as defined in UEFI |
| 168 |
* @revision: the revision of the table |
| 169 |
* @ext_clock_valid: indicates if external 32KHz clock is valid |
| 170 |
*/ |
| 171 |
struct uefi_cnv_var_eckv { |
| 172 |
u8 revision; |
| 173 |
u32 ext_clock_valid; |
| 174 |
} __packed; |
| 175 |
|
| 176 |
#define UEFI_MAX_DSM_FUNCS 32 |
| 177 |
|
| 178 |
/* struct uefi_cnv_var_general_cfg - DSM-like table as defined in UEFI |
| 179 |
* @revision: the revision of the table |
| 180 |
* @functions: payload of the different DSM functions |
| 181 |
*/ |
| 182 |
struct uefi_cnv_var_general_cfg { |
| 183 |
u8 revision; |
| 184 |
u32 functions[UEFI_MAX_DSM_FUNCS]; |
| 185 |
} __packed; |
| 186 |
|
| 187 |
#define IWL_UEFI_WBEM_REV0_MASK (BIT(0) | BIT(1)) |
| 188 |
/* struct uefi_cnv_wlan_wbem_data - Bandwidth enablement per MCC as defined |
| 189 |
* in UEFI |
| 190 |
* @revision: the revision of the table |
| 191 |
* @wbem_320mhz_per_mcc: enablement of 320MHz bandwidth per MCC |
| 192 |
* bit 0 - if set, 320MHz is enabled for Japan |
| 193 |
* bit 1 - if set, 320MHz is enabled for South Korea |
| 194 |
* bit 2- 31, Reserved |
| 195 |
*/ |
| 196 |
struct uefi_cnv_wlan_wbem_data { |
| 197 |
u8 revision; |
| 198 |
u32 wbem_320mhz_per_mcc; |
| 199 |
} __packed; |
| 200 |
|
| 201 |
enum iwl_uefi_cnv_puncturing_flags { |
| 202 |
IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK = BIT(0), |
| 203 |
IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK = BIT(1), |
| 204 |
}; |
| 205 |
|
| 206 |
#define IWL_UEFI_PUNCTURING_REV0_MASK (IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK | \ |
| 207 |
IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK) |
| 208 |
/** |
| 209 |
* struct uefi_cnv_var_puncturing_data - controlling channel |
| 210 |
* puncturing for few countries. |
| 211 |
* @revision: the revision of the table |
| 212 |
* @puncturing: enablement of channel puncturing per mcc |
| 213 |
* see &enum iwl_uefi_cnv_puncturing_flags. |
| 214 |
*/ |
| 215 |
struct uefi_cnv_var_puncturing_data { |
| 216 |
u8 revision; |
| 217 |
u32 puncturing; |
| 218 |
} __packed; |
| 219 |
|
| 220 |
/** |
| 221 |
* struct uefi_cnv_wlan_dsbr_data - BIOS STEP configuration information |
| 222 |
* @revision: the revision of the table |
| 223 |
* @config: STEP configuration flags: |
| 224 |
* bit 8, switch to URM depending on FW setting |
| 225 |
* bit 9, switch to URM |
| 226 |
* |
| 227 |
* Platform information for STEP configuration/workarounds. |
| 228 |
*/ |
| 229 |
struct uefi_cnv_wlan_dsbr_data { |
| 230 |
u8 revision; |
| 231 |
u32 config; |
| 232 |
} __packed; |
| 233 |
|
| 234 |
/** |
| 235 |
* struct uefi_cnv_wpfc_data - BIOS Wi-Fi PHY filter Configuration |
| 236 |
* @revision: the revision of the table |
| 237 |
* @chains: configuration of each of the chains (a-d) |
| 238 |
* |
| 239 |
* specific PHY filter configuration |
| 240 |
*/ |
| 241 |
struct uefi_cnv_wpfc_data { |
| 242 |
u8 revision; |
| 243 |
u32 chains[4]; |
| 244 |
} __packed; |
| 245 |
|
| 246 |
/* |
| 247 |
* This is known to be broken on v4.19 and to work on v5.4. Until we |
| 248 |
* figure out why this is the case and how to make it work, simply |
| 249 |
* disable the feature in old kernels. |
| 250 |
*/ |
| 251 |
#ifdef CONFIG_EFI |
| 252 |
void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len); |
| 253 |
u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len); |
| 254 |
int iwl_uefi_reduce_power_parse(struct iwl_trans *trans, |
| 255 |
const u8 *data, size_t len, |
| 256 |
struct iwl_pnvm_image *pnvm_data, |
| 257 |
__le32 sku_id[3]); |
| 258 |
void iwl_uefi_get_step_table(struct iwl_trans *trans); |
| 259 |
int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data, |
| 260 |
u32 tlv_len, struct iwl_pnvm_image *pnvm_data); |
| 261 |
int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt); |
| 262 |
int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt); |
| 263 |
int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt); |
| 264 |
int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt); |
| 265 |
int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt, |
| 266 |
struct iwl_tas_data *data); |
| 267 |
int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt, |
| 268 |
u64 *dflt_pwr_limit); |
| 269 |
int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc); |
| 270 |
int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk); |
| 271 |
int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value); |
| 272 |
int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func, |
| 273 |
u32 *value); |
| 274 |
void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt); |
| 275 |
void iwl_uefi_get_uats_table(struct iwl_trans *trans, |
| 276 |
struct iwl_fw_runtime *fwrt); |
| 277 |
int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt); |
| 278 |
int iwl_uefi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value); |
| 279 |
int iwl_uefi_get_phy_filters(struct iwl_fw_runtime *fwrt); |
| 280 |
#else /* CONFIG_EFI */ |
| 281 |
static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len) |
| 282 |
{ |
| 283 |
return ERR_PTR(-EOPNOTSUPP); |
| 284 |
} |
| 285 |
|
| 286 |
static inline int |
| 287 |
iwl_uefi_reduce_power_parse(struct iwl_trans *trans, |
| 288 |
const u8 *data, size_t len, |
| 289 |
struct iwl_pnvm_image *pnvm_data, |
| 290 |
__le32 sku_id[3]) |
| 291 |
{ |
| 292 |
return -EOPNOTSUPP; |
| 293 |
} |
| 294 |
|
| 295 |
static inline u8 * |
| 296 |
iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len) |
| 297 |
{ |
| 298 |
return ERR_PTR(-EOPNOTSUPP); |
| 299 |
} |
| 300 |
|
| 301 |
static inline void iwl_uefi_get_step_table(struct iwl_trans *trans) |
| 302 |
{ |
| 303 |
} |
| 304 |
|
| 305 |
static inline int |
| 306 |
iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data, |
| 307 |
u32 tlv_len, struct iwl_pnvm_image *pnvm_data) |
| 308 |
{ |
| 309 |
return 0; |
| 310 |
} |
| 311 |
|
| 312 |
static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt) |
| 313 |
{ |
| 314 |
return -ENOENT; |
| 315 |
} |
| 316 |
|
| 317 |
static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt) |
| 318 |
{ |
| 319 |
return -ENOENT; |
| 320 |
} |
| 321 |
|
| 322 |
static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt) |
| 323 |
{ |
| 324 |
return -ENOENT; |
| 325 |
} |
| 326 |
|
| 327 |
static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt) |
| 328 |
{ |
| 329 |
return -ENOENT; |
| 330 |
} |
| 331 |
|
| 332 |
static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt, |
| 333 |
struct iwl_tas_data *data) |
| 334 |
{ |
| 335 |
return -ENOENT; |
| 336 |
} |
| 337 |
|
| 338 |
static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt, |
| 339 |
u64 *dflt_pwr_limit) |
| 340 |
{ |
| 341 |
*dflt_pwr_limit = 0; |
| 342 |
return 0; |
| 343 |
} |
| 344 |
|
| 345 |
static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc) |
| 346 |
{ |
| 347 |
return -ENOENT; |
| 348 |
} |
| 349 |
|
| 350 |
static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk) |
| 351 |
{ |
| 352 |
return -ENOENT; |
| 353 |
} |
| 354 |
|
| 355 |
static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value) |
| 356 |
{ |
| 357 |
return -ENOENT; |
| 358 |
} |
| 359 |
|
| 360 |
static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, |
| 361 |
enum iwl_dsm_funcs func, u32 *value) |
| 362 |
{ |
| 363 |
return -ENOENT; |
| 364 |
} |
| 365 |
|
| 366 |
static inline |
| 367 |
void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt) |
| 368 |
{ |
| 369 |
} |
| 370 |
|
| 371 |
static inline void |
| 372 |
iwl_uefi_get_uats_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt) |
| 373 |
{ |
| 374 |
} |
| 375 |
|
| 376 |
static inline |
| 377 |
int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt) |
| 378 |
{ |
| 379 |
return 0; |
| 380 |
} |
| 381 |
|
| 382 |
static inline |
| 383 |
int iwl_uefi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value) |
| 384 |
{ |
| 385 |
return -ENOENT; |
| 386 |
} |
| 387 |
|
| 388 |
static inline int iwl_uefi_get_phy_filters(struct iwl_fw_runtime *fwrt) |
| 389 |
{ |
| 390 |
return -ENOENT; |
| 391 |
} |
| 392 |
#endif /* CONFIG_EFI */ |
| 393 |
#endif /* __iwl_fw_uefi__ */ |