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 27 28 #define IWL_SGOM_MAP_SIZE 339 29 #define IWL_UATS_MAP_SIZE 339 30 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 43 44 struct pnvm_sku_package { 45 u8 rev; 46 u32 total_size; 47 u8 n_skus; 48 u32 reserved[2]; 49 u8 data[]; 50 } __packed; 51 52 struct uefi_cnv_wlan_sgom_data { 53 u8 revision; 54 u8 offset_map[IWL_SGOM_MAP_SIZE - 1]; 55 } __packed; 56 57 struct uefi_cnv_wlan_uats_data { 58 u8 revision; 59 u8 offset_map[IWL_UATS_MAP_SIZE - 1]; 60 } __packed; 61 62 struct uefi_cnv_common_step_data { 63 u8 revision; 64 u8 step_mode; 65 u8 cnvi_eq_channel; 66 u8 cnvr_eq_channel; 67 u8 radio1; 68 u8 radio2; 69 } __packed; 70 71 /* 72 * struct uefi_sar_profile - a SAR profile as defined in UEFI 73 * 74 * @chains: a per-chain table of SAR values 75 */ 76 struct uefi_sar_profile { 77 struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE]; 78 } __packed; 79 80 /* 81 * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI 82 * 83 * @revision: the revision of the table 84 * @mode: is WRDS enbaled/disabled 85 * @sar_profile: sar profile #1 86 */ 87 struct uefi_cnv_var_wrds { 88 u8 revision; 89 u32 mode; 90 struct uefi_sar_profile sar_profile; 91 } __packed; 92 93 /* 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) 99 */ 100 struct uefi_cnv_var_ewrd { 101 u8 revision; 102 u32 mode; 103 u32 num_profiles; 104 struct uefi_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM - 1]; 105 } __packed; 106 107 /* 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. 113 */ 114 struct uefi_cnv_var_wgds { 115 u8 revision; 116 u8 num_profiles; 117 struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM]; 118 } __packed; 119 120 /* 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 125 */ 126 struct uefi_cnv_var_ppag { 127 u8 revision; 128 u32 ppag_modes; 129 struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS]; 130 } __packed; 131 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 137 */ 138 struct uefi_cnv_var_wtas { 139 u8 revision; 140 u32 tas_selection; 141 u8 black_list_size; 142 u16 black_list[IWL_WTAS_BLACK_LIST_MAX]; 143 } __packed; 144 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 148 */ 149 struct uefi_cnv_var_splc { 150 u8 revision; 151 u32 default_pwr_limit; 152 } __packed; 153 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 157 */ 158 struct uefi_cnv_var_wrdd { 159 u8 revision; 160 u32 mcc; 161 } __packed; 162 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 166 */ 167 struct uefi_cnv_var_eckv { 168 u8 revision; 169 u32 ext_clock_valid; 170 } __packed; 171 172 #define UEFI_MAX_DSM_FUNCS 32 173 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 177 */ 178 struct uefi_cnv_var_general_cfg { 179 u8 revision; 180 u32 functions[UEFI_MAX_DSM_FUNCS]; 181 } __packed; 182 183 #define IWL_UEFI_WBEM_REV0_MASK (BIT(0) | BIT(1)) 184 /* struct uefi_cnv_wlan_wbem_data - Bandwidth enablement per MCC as defined 185 * in UEFI 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 191 */ 192 struct uefi_cnv_wlan_wbem_data { 193 u8 revision; 194 u32 wbem_320mhz_per_mcc; 195 } __packed; 196 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), 200 }; 201 202 #define IWL_UEFI_PUNCTURING_REV0_MASK (IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK | \ 203 IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK) 204 /** 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. 210 */ 211 struct uefi_cnv_var_puncturing_data { 212 u8 revision; 213 u32 puncturing; 214 } __packed; 215 216 /* 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. 220 */ 221 #ifdef CONFIG_EFI 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, 242 u32 *value); 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) 249 { 250 return ERR_PTR(-EOPNOTSUPP); 251 } 252 253 static inline int 254 iwl_uefi_reduce_power_parse(struct iwl_trans *trans, 255 const u8 *data, size_t len, 256 struct iwl_pnvm_image *pnvm_data) 257 { 258 return -EOPNOTSUPP; 259 } 260 261 static inline u8 * 262 iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len) 263 { 264 return ERR_PTR(-EOPNOTSUPP); 265 } 266 267 static inline void iwl_uefi_get_step_table(struct iwl_trans *trans) 268 { 269 } 270 271 static inline int 272 iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data, 273 u32 tlv_len, struct iwl_pnvm_image *pnvm_data) 274 { 275 return 0; 276 } 277 278 static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt) 279 { 280 return -ENOENT; 281 } 282 283 static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt) 284 { 285 return -ENOENT; 286 } 287 288 static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt) 289 { 290 return -ENOENT; 291 } 292 293 static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt) 294 { 295 return -ENOENT; 296 } 297 298 static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt, 299 struct iwl_tas_data *data) 300 { 301 return -ENOENT; 302 } 303 304 static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt, 305 u64 *dflt_pwr_limit) 306 { 307 *dflt_pwr_limit = 0; 308 return 0; 309 } 310 311 static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc) 312 { 313 return -ENOENT; 314 } 315 316 static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk) 317 { 318 return -ENOENT; 319 } 320 321 static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value) 322 { 323 return -ENOENT; 324 } 325 326 static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, 327 enum iwl_dsm_funcs func, u32 *value) 328 { 329 return -ENOENT; 330 } 331 332 static inline 333 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt) 334 { 335 } 336 337 static inline 338 int iwl_uefi_get_uats_table(struct iwl_trans *trans, 339 struct iwl_fw_runtime *fwrt) 340 { 341 return 0; 342 } 343 344 static inline 345 int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt) 346 { 347 return 0; 348 } 349 #endif /* CONFIG_EFI */ 350 #endif /* __iwl_fw_uefi__ */ 351