Loading...
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
17struct pnvm_sku_package {
18 u8 rev;
19 u32 total_size;
20 u8 n_skus;
21 u32 reserved[2];
22 u8 data[];
23} __packed;
24
25struct uefi_cnv_wlan_sgom_data {
26 u8 revision;
27 u8 offset_map[IWL_SGOM_MAP_SIZE - 1];
28} __packed;
29
30struct uefi_cnv_wlan_uats_data {
31 u8 revision;
32 u8 offset_map[IWL_UATS_MAP_SIZE - 1];
33} __packed;
34
35struct 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
50void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len);
51u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len);
52int iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
53 const u8 *data, size_t len,
54 struct iwl_pnvm_image *pnvm_data);
55void iwl_uefi_get_step_table(struct iwl_trans *trans);
56int 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 */
59static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
60{
61 return ERR_PTR(-EOPNOTSUPP);
62}
63
64static inline int
65iwl_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
72static inline u8 *
73iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
74{
75 return ERR_PTR(-EOPNOTSUPP);
76}
77
78static inline void iwl_uefi_get_step_table(struct iwl_trans *trans)
79{
80}
81
82static inline int
83iwl_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)
91void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
92int iwl_uefi_get_uats_table(struct iwl_trans *trans,
93 struct iwl_fw_runtime *fwrt);
94#else
95static inline
96void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
97{
98}
99
100static inline
101int 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__ */
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2/*
3 * Copyright(c) 2021-2024 Intel Corporation
4 */
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 339
29#define IWL_UATS_MAP_SIZE 339
30
31#define IWL_UEFI_WRDS_REVISION 2
32#define IWL_UEFI_EWRD_REVISION 2
33#define IWL_UEFI_WGDS_REVISION 3
34#define IWL_UEFI_MIN_PPAG_REV 1
35#define IWL_UEFI_MAX_PPAG_REV 3
36#define IWL_UEFI_WTAS_REVISION 1
37#define IWL_UEFI_SPLC_REVISION 0
38#define IWL_UEFI_WRDD_REVISION 0
39#define IWL_UEFI_ECKV_REVISION 0
40#define IWL_UEFI_WBEM_REVISION 0
41#define IWL_UEFI_DSM_REVISION 4
42#define IWL_UEFI_PUNCTURING_REVISION 0
43
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 UEFI
73 *
74 * @chains: a per-chain table of SAR values
75 */
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 UEFI
82 *
83 * @revision: the revision of the table
84 * @mode: is WRDS enbaled/disabled
85 * @sar_profile: sar profile #1
86 */
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 UEFI
95 * @revision: the revision of the table
96 * @mode: is WRDS enbaled/disabled
97 * @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 UEFI
109 * @revision: the revision of the table
110 * @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 UEFI
122 * @revision: the revision of the table
123 * @ppag_modes: values from &enum iwl_ppag_flags
124 * @ppag_chains: the PPAG values per chain and band
125 */
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 UEFI
133 * @revision: the revision of the table
134 * @tas_selection: different options of TAS enablement.
135 * @black_list_size: the number of defined entried in the black list
136 * @black_list: a list of countries that are not allowed to use the TAS feature
137 */
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 UEFI
146 * @revision: the revision of the table
147 * @default_pwr_limit: The default maximum power per device
148 */
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 UEFI
155 * @revision: the revision of the table
156 * @mcc: country identifier as defined in ISO/IEC 3166-1 Alpha 2 code
157 */
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 UEFI
164 * @revision: the revision of the table
165 * @ext_clock_valid: indicates if external 32KHz clock is valid
166 */
167struct uefi_cnv_var_eckv {
168 u8 revision;
169 u32 ext_clock_valid;
170} __packed;
171
172#define UEFI_MAX_DSM_FUNCS 32
173
174/* struct uefi_cnv_var_general_cfg - DSM-like table as defined in UEFI
175 * @revision: the revision of the table
176 * @functions: payload of the different DSM functions
177 */
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 defined
185 * in UEFI
186 * @revision: the revision of the table
187 * @wbem_320mhz_per_mcc: enablement of 320MHz bandwidth per MCC
188 * bit 0 - if set, 320MHz is enabled for Japan
189 * bit 1 - if set, 320MHz is enabled for South Korea
190 * bit 2- 31, Reserved
191 */
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 channel
206 * puncturing for few countries.
207 * @revision: the revision of the table
208 * @puncturing: enablement of channel puncturing per mcc
209 * 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 we
218 * figure out why this is the case and how to make it work, simply
219 * disable the feature in old kernels.
220 */
221#ifdef CONFIG_EFI
222void *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 int
254iwl_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 int
272iwl_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 inline
333void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt)
334{
335}
336
337static inline
338int iwl_uefi_get_uats_table(struct iwl_trans *trans,
339 struct iwl_fw_runtime *fwrt)
340{
341 return 0;
342}
343
344static inline
345int iwl_uefi_get_puncturing(struct iwl_fw_runtime *fwrt)
346{
347 return 0;
348}
349#endif /* CONFIG_EFI */
350#endif /* __iwl_fw_uefi__ */