brintos

brintos / linux-shallow public Read only

0
0
Text · 9.6 KiB · e525d44 Raw
351 lines · c
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */2/*3 * Copyright(c) 2021-2024 Intel Corporation4 */5#ifndef __iwl_fw_uefi__6#define __iwl_fw_uefi__7 8#include "fw/regulatory.h"9 10#define IWL_UEFI_OEM_PNVM_NAME		L"UefiCnvWlanOemSignedPnvm"11#define IWL_UEFI_REDUCED_POWER_NAME	L"UefiCnvWlanReducedPower"12#define IWL_UEFI_SGOM_NAME		L"UefiCnvWlanSarGeoOffsetMapping"13#define IWL_UEFI_STEP_NAME		L"UefiCnvCommonSTEP"14#define IWL_UEFI_UATS_NAME		L"CnvUefiWlanUATS"15#define IWL_UEFI_WRDS_NAME		L"UefiCnvWlanWRDS"16#define IWL_UEFI_EWRD_NAME		L"UefiCnvWlanEWRD"17#define IWL_UEFI_WGDS_NAME		L"UefiCnvWlanWGDS"18#define IWL_UEFI_PPAG_NAME		L"UefiCnvWlanPPAG"19#define IWL_UEFI_WTAS_NAME		L"UefiCnvWlanWTAS"20#define IWL_UEFI_SPLC_NAME		L"UefiCnvWlanSPLC"21#define IWL_UEFI_WRDD_NAME		L"UefiCnvWlanWRDD"22#define IWL_UEFI_ECKV_NAME		L"UefiCnvWlanECKV"23#define IWL_UEFI_DSM_NAME		L"UefiCnvWlanGeneralCfg"24#define IWL_UEFI_WBEM_NAME		L"UefiCnvWlanWBEM"25#define IWL_UEFI_PUNCTURING_NAME	L"UefiCnvWlanPuncturing"26 27 28#define IWL_SGOM_MAP_SIZE		33929#define IWL_UATS_MAP_SIZE		33930 31#define IWL_UEFI_WRDS_REVISION		232#define IWL_UEFI_EWRD_REVISION		233#define IWL_UEFI_WGDS_REVISION		334#define IWL_UEFI_MIN_PPAG_REV		135#define IWL_UEFI_MAX_PPAG_REV		336#define IWL_UEFI_WTAS_REVISION		137#define IWL_UEFI_SPLC_REVISION		038#define IWL_UEFI_WRDD_REVISION		039#define IWL_UEFI_ECKV_REVISION		040#define IWL_UEFI_WBEM_REVISION		041#define IWL_UEFI_DSM_REVISION		442#define IWL_UEFI_PUNCTURING_REVISION	043 44struct pnvm_sku_package {45	u8 rev;46	u32 total_size;47	u8 n_skus;48	u32 reserved[2];49	u8 data[];50} __packed;51 52struct uefi_cnv_wlan_sgom_data {53	u8 revision;54	u8 offset_map[IWL_SGOM_MAP_SIZE - 1];55} __packed;56 57struct uefi_cnv_wlan_uats_data {58	u8 revision;59	u8 offset_map[IWL_UATS_MAP_SIZE - 1];60} __packed;61 62struct uefi_cnv_common_step_data {63	u8 revision;64	u8 step_mode;65	u8 cnvi_eq_channel;66	u8 cnvr_eq_channel;67	u8 radio1;68	u8 radio2;69} __packed;70 71/*72 * struct uefi_sar_profile - a SAR profile as defined in UEFI73 *74 * @chains: a per-chain table of SAR values75 */76struct uefi_sar_profile {77	struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE];78} __packed;79 80/*81 * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI82 *83 * @revision: the revision of the table84 * @mode: is WRDS enbaled/disabled85 * @sar_profile: sar profile #186 */87struct uefi_cnv_var_wrds {88	u8 revision;89	u32 mode;90	struct uefi_sar_profile sar_profile;91} __packed;92 93/*94 * struct uefi_cnv_var_ewrd - EWRD table as defined in UEFI95 * @revision: the revision of the table96 * @mode: is WRDS enbaled/disabled97 * @num_profiles: how many additional profiles we have in this table (0-3)98 * @sar_profiles: the additional SAR profiles (#2-#4)99 */100struct uefi_cnv_var_ewrd {101	u8 revision;102	u32 mode;103	u32 num_profiles;104	struct uefi_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM - 1];105} __packed;106 107/*108 * struct uefi_cnv_var_wgds - WGDS table as defined in UEFI109 * @revision: the revision of the table110 * @num_profiles: the number of geo profiles we have in the table.111 *	The first 3 are mandatory, and can have up to 8.112 * @geo_profiles: a per-profile table of the offsets to add to SAR values.113 */114struct uefi_cnv_var_wgds {115	u8 revision;116	u8 num_profiles;117	struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM];118} __packed;119 120/*121 * struct uefi_cnv_var_ppag - PPAG table as defined in UEFI122 * @revision: the revision of the table123 * @ppag_modes: values from &enum iwl_ppag_flags124 * @ppag_chains: the PPAG values per chain and band125 */126struct uefi_cnv_var_ppag {127	u8 revision;128	u32 ppag_modes;129	struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];130} __packed;131 132/* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI133 * @revision: the revision of the table134 * @tas_selection: different options of TAS enablement.135 * @black_list_size: the number of defined entried in the black list136 * @black_list: a list of countries that are not allowed to use the TAS feature137 */138struct uefi_cnv_var_wtas {139	u8 revision;140	u32 tas_selection;141	u8 black_list_size;142	u16 black_list[IWL_WTAS_BLACK_LIST_MAX];143} __packed;144 145/* struct uefi_cnv_var_splc - SPLC tabled as defined in UEFI146 * @revision: the revision of the table147 * @default_pwr_limit: The default maximum power per device148 */149struct uefi_cnv_var_splc {150	u8 revision;151	u32 default_pwr_limit;152} __packed;153 154/* struct uefi_cnv_var_wrdd - WRDD table as defined in UEFI155 * @revision: the revision of the table156 * @mcc: country identifier as defined in ISO/IEC 3166-1 Alpha 2 code157 */158struct uefi_cnv_var_wrdd {159	u8 revision;160	u32 mcc;161} __packed;162 163/* struct uefi_cnv_var_eckv - ECKV table as defined in UEFI164 * @revision: the revision of the table165 * @ext_clock_valid: indicates if external 32KHz clock is valid166 */167struct uefi_cnv_var_eckv {168	u8 revision;169	u32 ext_clock_valid;170} __packed;171 172#define UEFI_MAX_DSM_FUNCS 32173 174/* struct uefi_cnv_var_general_cfg - DSM-like table as defined in UEFI175 * @revision: the revision of the table176 * @functions: payload of the different DSM functions177 */178struct uefi_cnv_var_general_cfg {179	u8 revision;180	u32 functions[UEFI_MAX_DSM_FUNCS];181} __packed;182 183#define IWL_UEFI_WBEM_REV0_MASK (BIT(0) | BIT(1))184/* struct uefi_cnv_wlan_wbem_data - Bandwidth enablement per MCC as defined185 *	in UEFI186 * @revision: the revision of the table187 * @wbem_320mhz_per_mcc: enablement of 320MHz bandwidth per MCC188 *	bit 0 - if set, 320MHz is enabled for Japan189 *	bit 1 - if set, 320MHz is enabled for South Korea190 *	bit 2- 31, Reserved191 */192struct uefi_cnv_wlan_wbem_data {193	u8 revision;194	u32 wbem_320mhz_per_mcc;195} __packed;196 197enum iwl_uefi_cnv_puncturing_flags {198	IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK	= BIT(0),199	IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK	= BIT(1),200};201 202#define IWL_UEFI_PUNCTURING_REV0_MASK (IWL_UEFI_CNV_PUNCTURING_USA_EN_MSK | \203				       IWL_UEFI_CNV_PUNCTURING_CANADA_EN_MSK)204/**205 * struct uefi_cnv_var_puncturing_data - controlling channel206 *	puncturing for few countries.207 * @revision: the revision of the table208 * @puncturing: enablement of channel puncturing per mcc209 *	see &enum iwl_uefi_cnv_puncturing_flags.210 */211struct uefi_cnv_var_puncturing_data {212	u8 revision;213	u32 puncturing;214} __packed;215 216/*217 * This is known to be broken on v4.19 and to work on v5.4.  Until we218 * figure out why this is the case and how to make it work, simply219 * disable the feature in old kernels.220 */221#ifdef CONFIG_EFI222void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len);223u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);224int iwl_uefi_reduce_power_parse(struct iwl_trans *trans,225				const u8 *data, size_t len,226				struct iwl_pnvm_image *pnvm_data);227void iwl_uefi_get_step_table(struct iwl_trans *trans);228int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,229				 u32 tlv_len, struct iwl_pnvm_image *pnvm_data);230int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt);231int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt);232int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt);233int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt);234int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,235			   struct iwl_tas_data *data);236int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,237			   u64 *dflt_pwr_limit);238int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);239int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk);240int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);241int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,242		     u32 *value);243void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);244int iwl_uefi_get_uats_table(struct iwl_trans *trans,245			    struct iwl_fw_runtime *fwrt);246int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt);247#else /* CONFIG_EFI */248static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)249{250	return ERR_PTR(-EOPNOTSUPP);251}252 253static inline int254iwl_uefi_reduce_power_parse(struct iwl_trans *trans,255			    const u8 *data, size_t len,256			    struct iwl_pnvm_image *pnvm_data)257{258	return -EOPNOTSUPP;259}260 261static inline u8 *262iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)263{264	return ERR_PTR(-EOPNOTSUPP);265}266 267static inline void iwl_uefi_get_step_table(struct iwl_trans *trans)268{269}270 271static inline int272iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,273			     u32 tlv_len, struct iwl_pnvm_image *pnvm_data)274{275	return 0;276}277 278static inline int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt)279{280	return -ENOENT;281}282 283static inline int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt)284{285	return -ENOENT;286}287 288static inline int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt)289{290	return -ENOENT;291}292 293static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)294{295	return -ENOENT;296}297 298static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,299					 struct iwl_tas_data *data)300{301	return -ENOENT;302}303 304static inline int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,305					 u64 *dflt_pwr_limit)306{307	*dflt_pwr_limit = 0;308	return 0;309}310 311static inline int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)312{313	return -ENOENT;314}315 316static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)317{318	return -ENOENT;319}320 321static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)322{323	return -ENOENT;324}325 326static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt,327				   enum iwl_dsm_funcs func, u32 *value)328{329	return -ENOENT;330}331 332static inline333void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)334{335}336 337static inline338int iwl_uefi_get_uats_table(struct iwl_trans *trans,339			    struct iwl_fw_runtime *fwrt)340{341	return 0;342}343 344static inline345int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt)346{347	return 0;348}349#endif /* CONFIG_EFI */350#endif /* __iwl_fw_uefi__ */351