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 26 27 #define IWL_SGOM_MAP_SIZE 339 28 #define IWL_UATS_MAP_SIZE 339 29 30 #define IWL_UEFI_WRDS_REVISION 2 31 #define IWL_UEFI_EWRD_REVISION 2 32 #define IWL_UEFI_WGDS_REVISION 3 33 #define IWL_UEFI_MIN_PPAG_REV 1 34 #define IWL_UEFI_MAX_PPAG_REV 3 35 #define IWL_UEFI_WTAS_REVISION 1 36 #define IWL_UEFI_SPLC_REVISION 0 37 #define IWL_UEFI_WRDD_REVISION 0 38 #define IWL_UEFI_ECKV_REVISION 0 39 #define IWL_UEFI_WBEM_REVISION 0 40 #define IWL_UEFI_DSM_REVISION 4 41 42 struct pnvm_sku_package { 43 u8 rev; 44 u32 total_size; 45 u8 n_skus; 46 u32 reserved[2]; 47 u8 data[]; 48 } __packed; 49 50 struct uefi_cnv_wlan_sgom_data { 51 u8 revision; 52 u8 offset_map[IWL_SGOM_MAP_SIZE - 1]; 53 } __packed; 54 55 struct uefi_cnv_wlan_uats_data { 56 u8 revision; 57 u8 offset_map[IWL_UATS_MAP_SIZE - 1]; 58 } __packed; 59 60 struct uefi_cnv_common_step_data { 61 u8 revision; 62 u8 step_mode; 63 u8 cnvi_eq_channel; 64 u8 cnvr_eq_channel; 65 u8 radio1; 66 u8 radio2; 67 } __packed; 68 69 /* 70 * struct uefi_sar_profile - a SAR profile as defined in UEFI 71 * 72 * @chains: a per-chain table of SAR values 73 */ 74 struct uefi_sar_profile { 75 struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE]; 76 } __packed; 77 78 /* 79 * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI 80 * 81 * @revision: the revision of the table 82 * @mode: is WRDS enbaled/disabled 83 * @sar_profile: sar profile #1 84 */ 85 struct uefi_cnv_var_wrds { 86 u8 revision; 87 u32 mode; 88 struct uefi_sar_profile sar_profile; 89 } __packed; 90 91 /* 92 * struct uefi_cnv_var_ewrd - EWRD table as defined in UEFI 93 * @revision: the revision of the table 94 * @mode: is WRDS enbaled/disabled 95 * @num_profiles: how many additional profiles we have in this table (0-3) 96 * @sar_profiles: the additional SAR profiles (#2-#4) 97 */ 98 struct uefi_cnv_var_ewrd { 99 u8 revision; 100 u32 mode; 101 u32 num_profiles; 102 struct uefi_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM - 1]; 103 } __packed; 104 105 /* 106 * struct uefi_cnv_var_wgds - WGDS table as defined in UEFI 107 * @revision: the revision of the table 108 * @num_profiles: the number of geo profiles we have in the table. 109 * The first 3 are mandatory, and can have up to 8. 110 * @geo_profiles: a per-profile table of the offsets to add to SAR values. 111 */ 112 struct uefi_cnv_var_wgds { 113 u8 revision; 114 u8 num_profiles; 115 struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM]; 116 } __packed; 117 118 /* 119 * struct uefi_cnv_var_ppag - PPAG table as defined in UEFI 120 * @revision: the revision of the table 121 * @ppag_modes: values from &enum iwl_ppag_flags 122 * @ppag_chains: the PPAG values per chain and band 123 */ 124 struct uefi_cnv_var_ppag { 125 u8 revision; 126 u32 ppag_modes; 127 struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS]; 128 } __packed; 129 130 /* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI 131 * @revision: the revision of the table 132 * @tas_selection: different options of TAS enablement. 133 * @black_list_size: the number of defined entried in the black list 134 * @black_list: a list of countries that are not allowed to use the TAS feature 135 */ 136 struct uefi_cnv_var_wtas { 137 u8 revision; 138 u32 tas_selection; 139 u8 black_list_size; 140 u16 black_list[IWL_WTAS_BLACK_LIST_MAX]; 141 } __packed; 142 143 /* struct uefi_cnv_var_splc - SPLC tabled as defined in UEFI 144 * @revision: the revision of the table 145 * @default_pwr_limit: The default maximum power per device 146 */ 147 struct uefi_cnv_var_splc { 148 u8 revision; 149 u32 default_pwr_limit; 150 } __packed; 151 152 #define UEFI_MCC_CHINA 0x434e 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 /* 198 * This is known to be broken on v4.19 and to work on v5.4. Until we 199 * figure out why this is the case and how to make it work, simply 200 * disable the feature in old kernels. 201 */ 202 #ifdef CONFIG_EFI 203 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len); 204 u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len); 205 int iwl_uefi_reduce_power_parse(struct iwl_trans *trans, 206 const u8 *data, size_t len, 207 struct iwl_pnvm_image *pnvm_data); 208 void iwl_uefi_get_step_table(struct iwl_trans *trans); 209 int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data, 210 u32 tlv_len, struct iwl_pnvm_image *pnvm_data); 211 int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt); 212 int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt); 213 int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt); 214 int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt); 215 int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt, 216 struct iwl_tas_data *data); 217 int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt, 218 u64 *dflt_pwr_limit); 219 int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc); 220 int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk); 221 int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value); 222 int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func, 223 u32 *value); 224 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt); 225 int iwl_uefi_get_uats_table(struct iwl_trans *trans, 226 struct iwl_fw_runtime *fwrt); 227 #else /* CONFIG_EFI */ 228 static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len) 229 { 230 return ERR_PTR(-EOPNOTSUPP); 231 } 232 233 static inline int 234 iwl_uefi_reduce_power_parse(struct iwl_trans *trans, 235 const u8 *data, size_t len, 236 struct iwl_pnvm_image *pnvm_data) 237 { 238 return -EOPNOTSUPP; 239 } 240 241 static inline u8 * 242 iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len) 243 { 244 return ERR_PTR(-EOPNOTSUPP); 245 } 246 247 static inline void iwl_uefi_get_step_table(struct iwl_trans *trans) 248 { 249 } 250 251 static inline int 252 iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data, 253 u32 tlv_len, struct iwl_pnvm_image *pnvm_data) 254 { 255 return 0; 256 } 257 258 static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt) 259 { 260 return -ENOENT; 261 } 262 263 static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt) 264 { 265 return -ENOENT; 266 } 267 268 static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt) 269 { 270 return -ENOENT; 271 } 272 273 static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt) 274 { 275 return -ENOENT; 276 } 277 278 static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt, 279 struct iwl_tas_data *data) 280 { 281 return -ENOENT; 282 } 283 284 static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt, 285 u64 *dflt_pwr_limit) 286 { 287 *dflt_pwr_limit = 0; 288 return 0; 289 } 290 291 static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc) 292 { 293 return -ENOENT; 294 } 295 296 static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk) 297 { 298 return -ENOENT; 299 } 300 301 static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value) 302 { 303 return -ENOENT; 304 } 305 306 static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, 307 enum iwl_dsm_funcs func, u32 *value) 308 { 309 return -ENOENT; 310 } 311 312 static inline 313 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt) 314 { 315 } 316 317 static inline 318 int iwl_uefi_get_uats_table(struct iwl_trans *trans, 319 struct iwl_fw_runtime *fwrt) 320 { 321 return 0; 322 } 323 #endif /* CONFIG_EFI */ 324 #endif /* __iwl_fw_uefi__ */ 325