1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright(c) 2021-2024 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"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" 27 28 29 #define IWL_SGOM_MAP_SIZE 339 30 #define IWL_UATS_MAP_SIZE 339 31 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 46 47 struct pnvm_sku_package { 48 u8 rev; 49 u32 total_size; 50 u8 n_skus; 51 u32 reserved[2]; 52 u8 data[]; 53 } __packed; 54 55 struct uefi_cnv_wlan_sgom_data { 56 u8 revision; 57 u8 offset_map[IWL_SGOM_MAP_SIZE - 1]; 58 } __packed; 59 60 struct uefi_cnv_wlan_uats_data { 61 u8 revision; 62 u8 offset_map[IWL_UATS_MAP_SIZE - 1]; 63 } __packed; 64 65 struct uefi_cnv_common_step_data { 66 u8 revision; 67 u8 step_mode; 68 u8 cnvi_eq_channel; 69 u8 cnvr_eq_channel; 70 u8 radio1; 71 u8 radio2; 72 } __packed; 73 74 /* 75 * struct uefi_sar_profile - a SAR profile as defined in UEFI 76 * 77 * @chains: a per-chain table of SAR values 78 */ 79 struct uefi_sar_profile { 80 struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE]; 81 } __packed; 82 83 /* 84 * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI 85 * 86 * @revision: the revision of the table 87 * @mode: is WRDS enbaled/disabled 88 * @sar_profile: sar profile #1 89 */ 90 struct uefi_cnv_var_wrds { 91 u8 revision; 92 u32 mode; 93 struct uefi_sar_profile sar_profile; 94 } __packed; 95 96 /* 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) 102 */ 103 struct uefi_cnv_var_ewrd { 104 u8 revision; 105 u32 mode; 106 u32 num_profiles; 107 struct uefi_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM - 1]; 108 } __packed; 109 110 /* 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. 116 */ 117 struct uefi_cnv_var_wgds { 118 u8 revision; 119 u8 num_profiles; 120 struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM]; 121 } __packed; 122 123 /* 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 128 */ 129 struct uefi_cnv_var_ppag { 130 u8 revision; 131 u32 ppag_modes; 132 struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS]; 133 } __packed; 134 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 140 */ 141 struct uefi_cnv_var_wtas { 142 u8 revision; 143 u32 tas_selection; 144 u8 black_list_size; 145 u16 black_list[IWL_WTAS_BLACK_LIST_MAX]; 146 } __packed; 147 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 151 */ 152 struct uefi_cnv_var_splc { 153 u8 revision; 154 u32 default_pwr_limit; 155 } __packed; 156 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 160 */ 161 struct uefi_cnv_var_wrdd { 162 u8 revision; 163 u32 mcc; 164 } __packed; 165 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 169 */ 170 struct uefi_cnv_var_eckv { 171 u8 revision; 172 u32 ext_clock_valid; 173 } __packed; 174 175 #define UEFI_MAX_DSM_FUNCS 32 176 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 180 */ 181 struct uefi_cnv_var_general_cfg { 182 u8 revision; 183 u32 functions[UEFI_MAX_DSM_FUNCS]; 184 } __packed; 185 186 #define IWL_UEFI_WBEM_REV0_MASK (BIT(0) | BIT(1)) 187 /* struct uefi_cnv_wlan_wbem_data - Bandwidth enablement per MCC as defined 188 * in UEFI 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 194 */ 195 struct uefi_cnv_wlan_wbem_data { 196 u8 revision; 197 u32 wbem_320mhz_per_mcc; 198 } __packed; 199 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), 203 }; 204 205 #define IWL_UEFI_PUNCTURING_REV0_MASK (IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK | \ 206 IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK) 207 /** 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. 213 */ 214 struct uefi_cnv_var_puncturing_data { 215 u8 revision; 216 u32 puncturing; 217 } __packed; 218 219 /** 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 225 * 226 * Platform information for STEP configuration/workarounds. 227 */ 228 struct uefi_cnv_wlan_dsbr_data { 229 u8 revision; 230 u32 config; 231 } __packed; 232 233 /* 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. 237 */ 238 #ifdef CONFIG_EFI 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, 259 u32 *value); 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) 267 { 268 return ERR_PTR(-EOPNOTSUPP); 269 } 270 271 static inline int 272 iwl_uefi_reduce_power_parse(struct iwl_trans *trans, 273 const u8 *data, size_t len, 274 struct iwl_pnvm_image *pnvm_data) 275 { 276 return -EOPNOTSUPP; 277 } 278 279 static inline u8 * 280 iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len) 281 { 282 return ERR_PTR(-EOPNOTSUPP); 283 } 284 285 static inline void iwl_uefi_get_step_table(struct iwl_trans *trans) 286 { 287 } 288 289 static inline int 290 iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data, 291 u32 tlv_len, struct iwl_pnvm_image *pnvm_data) 292 { 293 return 0; 294 } 295 296 static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt) 297 { 298 return -ENOENT; 299 } 300 301 static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt) 302 { 303 return -ENOENT; 304 } 305 306 static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt) 307 { 308 return -ENOENT; 309 } 310 311 static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt) 312 { 313 return -ENOENT; 314 } 315 316 static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt, 317 struct iwl_tas_data *data) 318 { 319 return -ENOENT; 320 } 321 322 static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt, 323 u64 *dflt_pwr_limit) 324 { 325 *dflt_pwr_limit = 0; 326 return 0; 327 } 328 329 static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc) 330 { 331 return -ENOENT; 332 } 333 334 static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk) 335 { 336 return -ENOENT; 337 } 338 339 static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value) 340 { 341 return -ENOENT; 342 } 343 344 static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, 345 enum iwl_dsm_funcs func, u32 *value) 346 { 347 return -ENOENT; 348 } 349 350 static inline 351 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt) 352 { 353 } 354 355 static inline 356 int iwl_uefi_get_uats_table(struct iwl_trans *trans, 357 struct iwl_fw_runtime *fwrt) 358 { 359 return 0; 360 } 361 362 static inline 363 int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt) 364 { 365 return 0; 366 } 367 368 static inline 369 int iwl_uefi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value) 370 { 371 return -ENOENT; 372 } 373 #endif /* CONFIG_EFI */ 374 #endif /* __iwl_fw_uefi__ */ 375