xref: /freebsd/sys/contrib/dev/iwlwifi/fw/uefi.h (revision faf25f48d601ae39f5752602f3020e2e92605625)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright(c) 2021 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 
12 /*
13  * TODO: we have these hardcoded values that the caller must pass,
14  * because reading from the UEFI is not working.  To implement this
15  * properly, we have to change iwl_pnvm_get_from_uefi() to call
16  * efivar_entry_size() and return the value to the caller instead.
17  */
18 #define IWL_HARDCODED_PNVM_SIZE		4096
19 #define IWL_HARDCODED_REDUCE_POWER_SIZE	32768
20 #define IWL_HARDCODED_SGOM_SIZE		339
21 
22 struct pnvm_sku_package {
23 	u8 rev;
24 	u32 total_size;
25 	u8 n_skus;
26 	u32 reserved[2];
27 	u8 data[];
28 } __packed;
29 
30 struct uefi_cnv_wlan_sgom_data {
31 	u8 revision;
32 	u8 offset_map[IWL_HARDCODED_SGOM_SIZE - 1];
33 } __packed;
34 
35 /*
36  * This is known to be broken on v4.19 and to work on v5.4.  Until we
37  * figure out why this is the case and how to make it work, simply
38  * disable the feature in old kernels.
39  */
40 #ifdef CONFIG_EFI
41 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len);
42 void *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);
43 #else /* CONFIG_EFI */
44 static inline
45 void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
46 {
47 	return ERR_PTR(-EOPNOTSUPP);
48 }
49 
50 static inline
51 void *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
52 {
53 	return ERR_PTR(-EOPNOTSUPP);
54 }
55 #endif /* CONFIG_EFI */
56 
57 #if defined(CONFIG_EFI) && defined(CONFIG_ACPI)
58 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
59 #else
60 static inline
61 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
62 {
63 }
64 #endif
65 #endif /* __iwl_fw_uefi__ */
66