162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright(c) 2021-2023 Intel Corporation
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci#ifndef __iwl_fw_uefi__
662306a36Sopenharmony_ci#define __iwl_fw_uefi__
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#define IWL_UEFI_OEM_PNVM_NAME		L"UefiCnvWlanOemSignedPnvm"
962306a36Sopenharmony_ci#define IWL_UEFI_REDUCED_POWER_NAME	L"UefiCnvWlanReducedPower"
1062306a36Sopenharmony_ci#define IWL_UEFI_SGOM_NAME		L"UefiCnvWlanSarGeoOffsetMapping"
1162306a36Sopenharmony_ci#define IWL_UEFI_STEP_NAME		L"UefiCnvCommonSTEP"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define IWL_SGOM_MAP_SIZE		339
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cistruct pnvm_sku_package {
1662306a36Sopenharmony_ci	u8 rev;
1762306a36Sopenharmony_ci	u32 total_size;
1862306a36Sopenharmony_ci	u8 n_skus;
1962306a36Sopenharmony_ci	u32 reserved[2];
2062306a36Sopenharmony_ci	u8 data[];
2162306a36Sopenharmony_ci} __packed;
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_cistruct uefi_cnv_wlan_sgom_data {
2462306a36Sopenharmony_ci	u8 revision;
2562306a36Sopenharmony_ci	u8 offset_map[IWL_SGOM_MAP_SIZE - 1];
2662306a36Sopenharmony_ci} __packed;
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistruct uefi_cnv_common_step_data {
2962306a36Sopenharmony_ci	u8 revision;
3062306a36Sopenharmony_ci	u8 step_mode;
3162306a36Sopenharmony_ci	u8 cnvi_eq_channel;
3262306a36Sopenharmony_ci	u8 cnvr_eq_channel;
3362306a36Sopenharmony_ci	u8 radio1;
3462306a36Sopenharmony_ci	u8 radio2;
3562306a36Sopenharmony_ci} __packed;
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/*
3862306a36Sopenharmony_ci * This is known to be broken on v4.19 and to work on v5.4.  Until we
3962306a36Sopenharmony_ci * figure out why this is the case and how to make it work, simply
4062306a36Sopenharmony_ci * disable the feature in old kernels.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_ci#ifdef CONFIG_EFI
4362306a36Sopenharmony_civoid *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len);
4462306a36Sopenharmony_ciu8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);
4562306a36Sopenharmony_ciint iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
4662306a36Sopenharmony_ci				const u8 *data, size_t len,
4762306a36Sopenharmony_ci				struct iwl_pnvm_image *pnvm_data);
4862306a36Sopenharmony_civoid iwl_uefi_get_step_table(struct iwl_trans *trans);
4962306a36Sopenharmony_ciint iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
5062306a36Sopenharmony_ci				 u32 tlv_len, struct iwl_pnvm_image *pnvm_data);
5162306a36Sopenharmony_ci#else /* CONFIG_EFI */
5262306a36Sopenharmony_cistatic inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
5362306a36Sopenharmony_ci{
5462306a36Sopenharmony_ci	return ERR_PTR(-EOPNOTSUPP);
5562306a36Sopenharmony_ci}
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cistatic inline int
5862306a36Sopenharmony_ciiwl_uefi_reduce_power_parse(struct iwl_trans *trans,
5962306a36Sopenharmony_ci			    const u8 *data, size_t len,
6062306a36Sopenharmony_ci			    struct iwl_pnvm_image *pnvm_data)
6162306a36Sopenharmony_ci{
6262306a36Sopenharmony_ci	return -EOPNOTSUPP;
6362306a36Sopenharmony_ci}
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_cistatic inline u8 *
6662306a36Sopenharmony_ciiwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
6762306a36Sopenharmony_ci{
6862306a36Sopenharmony_ci	return ERR_PTR(-EOPNOTSUPP);
6962306a36Sopenharmony_ci}
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_cistatic inline void iwl_uefi_get_step_table(struct iwl_trans *trans)
7262306a36Sopenharmony_ci{
7362306a36Sopenharmony_ci}
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_cistatic inline int
7662306a36Sopenharmony_ciiwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
7762306a36Sopenharmony_ci			     u32 tlv_len, struct iwl_pnvm_image *pnvm_data)
7862306a36Sopenharmony_ci{
7962306a36Sopenharmony_ci	return 0;
8062306a36Sopenharmony_ci}
8162306a36Sopenharmony_ci#endif /* CONFIG_EFI */
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#if defined(CONFIG_EFI) && defined(CONFIG_ACPI)
8462306a36Sopenharmony_civoid iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
8562306a36Sopenharmony_ci#else
8662306a36Sopenharmony_cistatic inline
8762306a36Sopenharmony_civoid iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
8862306a36Sopenharmony_ci{
8962306a36Sopenharmony_ci}
9062306a36Sopenharmony_ci#endif
9162306a36Sopenharmony_ci#endif /* __iwl_fw_uefi__ */
92