1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright(c) 2021-2022 Intel Corporation 4 */ 5 #ifndef __iwl_fw_uefi__ 6 #define __iwl_fw_uefi__ 7 8 #define IWL_UEFI_OEM_PNVM_NAME L"UefiCnvWlanOemSignedPnvm" 9 #define IWL_UEFI_REDUCED_POWER_NAME L"UefiCnvWlanReducedPower" 10 #define IWL_UEFI_SGOM_NAME L"UefiCnvWlanSarGeoOffsetMapping" 11 #define IWL_UEFI_STEP_NAME L"UefiCnvCommonSTEP" 12 13 /* 14 * TODO: we have these hardcoded values that the caller must pass, 15 * because reading from the UEFI is not working. To implement this 16 * properly, we have to change iwl_pnvm_get_from_uefi() to call 17 * efivar_entry_size() and return the value to the caller instead. 18 */ 19 #define IWL_HARDCODED_PNVM_SIZE 4096 20 #define IWL_HARDCODED_REDUCE_POWER_SIZE 32768 21 #define IWL_HARDCODED_SGOM_SIZE 339 22 #define IWL_HARDCODED_STEP_SIZE 6 23 24 struct pnvm_sku_package { 25 u8 rev; 26 u32 total_size; 27 u8 n_skus; 28 u32 reserved[2]; 29 u8 data[]; 30 } __packed; 31 32 struct uefi_cnv_wlan_sgom_data { 33 u8 revision; 34 u8 offset_map[IWL_HARDCODED_SGOM_SIZE - 1]; 35 } __packed; 36 37 struct uefi_cnv_common_step_data { 38 u8 revision; 39 u8 step_mode; 40 u8 cnvi_eq_channel; 41 u8 cnvr_eq_channel; 42 u8 radio1; 43 u8 radio2; 44 } __packed; 45 46 /* 47 * This is known to be broken on v4.19 and to work on v5.4. Until we 48 * figure out why this is the case and how to make it work, simply 49 * disable the feature in old kernels. 50 */ 51 #ifdef CONFIG_EFI 52 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len); 53 int iwl_uefi_get_reduced_power(struct iwl_trans *trans, 54 struct iwl_pnvm_image *pnvm_data); 55 void iwl_uefi_get_step_table(struct iwl_trans *trans); 56 #else /* CONFIG_EFI */ 57 static inline 58 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len) 59 { 60 return ERR_PTR(-EOPNOTSUPP); 61 } 62 63 static inline 64 int iwl_uefi_get_reduced_power(struct iwl_trans *trans, 65 struct iwl_pnvm_image *pnvm_data) 66 { 67 return -EOPNOTSUPP; 68 } 69 70 static inline 71 void iwl_uefi_get_step_table(struct iwl_trans *trans) 72 { 73 } 74 #endif /* CONFIG_EFI */ 75 76 #if defined(CONFIG_EFI) && defined(CONFIG_ACPI) 77 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt); 78 #else 79 static inline 80 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt) 81 { 82 } 83 #endif 84 #endif /* __iwl_fw_uefi__ */ 85