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 void *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);
54 void iwl_uefi_get_step_table(struct iwl_trans *trans);
55 #else /* CONFIG_EFI */
56 static inline
57 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
58 {
59 	return ERR_PTR(-EOPNOTSUPP);
60 }
61 
62 static inline
63 void *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
64 {
65 	return ERR_PTR(-EOPNOTSUPP);
66 }
67 
68 static inline
69 void iwl_uefi_get_step_table(struct iwl_trans *trans)
70 {
71 }
72 #endif /* CONFIG_EFI */
73 
74 #if defined(CONFIG_EFI) && defined(CONFIG_ACPI)
75 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
76 #else
77 static inline
78 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
79 {
80 }
81 #endif
82 #endif /* __iwl_fw_uefi__ */
83