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