xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/uefi.h (revision 3d0fe49454652117522f60bfbefb978ba0e5300b)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright(c) 2021-2023 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 #define IWL_UEFI_UATS_NAME		L"CnvUefiWlanUATS"
13 
14 #define IWL_SGOM_MAP_SIZE		339
15 #define IWL_UATS_MAP_SIZE		339
16 
17 struct pnvm_sku_package {
18 	u8 rev;
19 	u32 total_size;
20 	u8 n_skus;
21 	u32 reserved[2];
22 	u8 data[];
23 } __packed;
24 
25 struct uefi_cnv_wlan_sgom_data {
26 	u8 revision;
27 	u8 offset_map[IWL_SGOM_MAP_SIZE - 1];
28 } __packed;
29 
30 struct uefi_cnv_wlan_uats_data {
31 	u8 revision;
32 	u8 offset_map[IWL_UATS_MAP_SIZE - 1];
33 } __packed;
34 
35 struct uefi_cnv_common_step_data {
36 	u8 revision;
37 	u8 step_mode;
38 	u8 cnvi_eq_channel;
39 	u8 cnvr_eq_channel;
40 	u8 radio1;
41 	u8 radio2;
42 } __packed;
43 
44 /*
45  * This is known to be broken on v4.19 and to work on v5.4.  Until we
46  * figure out why this is the case and how to make it work, simply
47  * disable the feature in old kernels.
48  */
49 #ifdef CONFIG_EFI
50 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len);
51 u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);
52 int iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
53 				const u8 *data, size_t len,
54 				struct iwl_pnvm_image *pnvm_data);
55 void iwl_uefi_get_step_table(struct iwl_trans *trans);
56 int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
57 				 u32 tlv_len, struct iwl_pnvm_image *pnvm_data);
58 #else /* CONFIG_EFI */
59 static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
60 {
61 	return ERR_PTR(-EOPNOTSUPP);
62 }
63 
64 static inline int
65 iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
66 			    const u8 *data, size_t len,
67 			    struct iwl_pnvm_image *pnvm_data)
68 {
69 	return -EOPNOTSUPP;
70 }
71 
72 static inline u8 *
73 iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
74 {
75 	return ERR_PTR(-EOPNOTSUPP);
76 }
77 
78 static inline void iwl_uefi_get_step_table(struct iwl_trans *trans)
79 {
80 }
81 
82 static inline int
83 iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
84 			     u32 tlv_len, struct iwl_pnvm_image *pnvm_data)
85 {
86 	return 0;
87 }
88 #endif /* CONFIG_EFI */
89 
90 #if defined(CONFIG_EFI) && defined(CONFIG_ACPI)
91 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
92 int iwl_uefi_get_uats_table(struct iwl_trans *trans,
93 			    struct iwl_fw_runtime *fwrt);
94 #else
95 static inline
96 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
97 {
98 }
99 
100 static inline
101 int iwl_uefi_get_uats_table(struct iwl_trans *trans,
102 			    struct iwl_fw_runtime *fwrt)
103 {
104 	return 0;
105 }
106 
107 #endif
108 #endif /* __iwl_fw_uefi__ */
109