xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/acpi.h (revision 91ec2035134982b98fab0609a9fd8480e8217dc1)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2017 Intel Deutschland GmbH
4  * Copyright (C) 2018-2023, 2025-2026 Intel Corporation
5  */
6 #ifndef __iwl_fw_acpi__
7 #define __iwl_fw_acpi__
8 
9 #include <linux/acpi.h>
10 #include "fw/regulatory.h"
11 #include "fw/img.h"
12 #include "iwl-trans.h"
13 
14 
15 #define ACPI_WRDS_METHOD	"WRDS"
16 #define ACPI_EWRD_METHOD	"EWRD"
17 #define ACPI_WGDS_METHOD	"WGDS"
18 #define ACPI_WRDD_METHOD	"WRDD"
19 #define ACPI_SPLC_METHOD	"SPLC"
20 #define ACPI_ECKV_METHOD	"ECKV"
21 #define ACPI_PPAG_METHOD	"PPAG"
22 #define ACPI_WTAS_METHOD	"WTAS"
23 #define ACPI_WPFC_METHOD	"WPFC"
24 #define ACPI_GLAI_METHOD	"GLAI"
25 #define ACPI_WBEM_METHOD	"WBEM"
26 #define ACPI_DSBR_METHOD	"DSBR"
27 
28 #define ACPI_WIFI_DOMAIN	(0x07)
29 
30 #define ACPI_SAR_PROFILE_NUM		4
31 
32 #define ACPI_NUM_GEO_PROFILES		3
33 #define ACPI_NUM_GEO_PROFILES_REV3	8
34 #define ACPI_GEO_PER_CHAIN_SIZE		3
35 
36 #define ACPI_SAR_NUM_CHAINS_REV0	2
37 #define ACPI_SAR_NUM_CHAINS_REV1	2
38 #define ACPI_SAR_NUM_CHAINS_REV2	4
39 #define ACPI_SAR_NUM_SUB_BANDS_REV0	5
40 #define ACPI_SAR_NUM_SUB_BANDS_REV1	11
41 #define ACPI_SAR_NUM_SUB_BANDS_REV2	11
42 #define ACPI_SAR_NUM_SUB_BANDS_REV3	12
43 
44 #define ACPI_WRDS_WIFI_DATA_SIZE_REV0	(ACPI_SAR_NUM_CHAINS_REV0 * \
45 					 ACPI_SAR_NUM_SUB_BANDS_REV0 + 2)
46 #define ACPI_WRDS_WIFI_DATA_SIZE_REV1	(ACPI_SAR_NUM_CHAINS_REV1 * \
47 					 ACPI_SAR_NUM_SUB_BANDS_REV1 + 2)
48 #define ACPI_WRDS_WIFI_DATA_SIZE_REV2	(ACPI_SAR_NUM_CHAINS_REV2 * \
49 					 ACPI_SAR_NUM_SUB_BANDS_REV2 + 2)
50 #define ACPI_WRDS_WIFI_DATA_SIZE_REV3	(ACPI_SAR_NUM_CHAINS_REV2 * \
51 					 ACPI_SAR_NUM_SUB_BANDS_REV3 + 2)
52 #define ACPI_EWRD_WIFI_DATA_SIZE_REV0	((ACPI_SAR_PROFILE_NUM - 1) * \
53 					 ACPI_SAR_NUM_CHAINS_REV0 * \
54 					 ACPI_SAR_NUM_SUB_BANDS_REV0 + 3)
55 #define ACPI_EWRD_WIFI_DATA_SIZE_REV1	((ACPI_SAR_PROFILE_NUM - 1) * \
56 					 ACPI_SAR_NUM_CHAINS_REV1 * \
57 					 ACPI_SAR_NUM_SUB_BANDS_REV1 + 3)
58 #define ACPI_EWRD_WIFI_DATA_SIZE_REV2	((ACPI_SAR_PROFILE_NUM - 1) * \
59 					 ACPI_SAR_NUM_CHAINS_REV2 * \
60 					 ACPI_SAR_NUM_SUB_BANDS_REV2 + 3)
61 #define ACPI_EWRD_WIFI_DATA_SIZE_REV3	((ACPI_SAR_PROFILE_NUM - 1) * \
62 					 ACPI_SAR_NUM_CHAINS_REV2 * \
63 					 ACPI_SAR_NUM_SUB_BANDS_REV3 + 3)
64 #define ACPI_WPFC_WIFI_DATA_SIZE	5 /* domain and 4 filter config words */
65 
66 /* revision 0 and 1 are identical, except for the semantics in the FW */
67 #define ACPI_GEO_NUM_BANDS_REV0		2
68 #define ACPI_GEO_NUM_BANDS_REV2		3
69 #define ACPI_GEO_NUM_BANDS_REV4		4
70 
71 #define ACPI_WRDD_WIFI_DATA_SIZE	2
72 #define ACPI_SPLC_WIFI_DATA_SIZE	2
73 #define ACPI_ECKV_WIFI_DATA_SIZE	2
74 
75 /*
76  * One element for domain type,
77  * and one for enablement of Wi-Fi 320MHz per MCC
78  */
79 #define ACPI_WBEM_WIFI_DATA_SIZE	2
80 /*
81  * One element for domain type,
82  * and one for DSBR response data
83  */
84 #define ACPI_DSBR_WIFI_DATA_SIZE	2
85 #define ACPI_DSBR_WIFI_DATA_REV		1
86 
87 /*
88  * One element for domain type,
89  * and one for the status
90  */
91 #define ACPI_GLAI_WIFI_DATA_SIZE	2
92 #define ACPI_GLAI_MAX_STATUS		2
93 /*
94  * TAS size: 1 elelment for type,
95  *	     1 element for enabled field,
96  *	     1 element for block list size,
97  *	     16 elements for block list array
98  */
99 #define ACPI_WTAS_WIFI_DATA_SIZE	(3 + IWL_WTAS_BLACK_LIST_MAX)
100 
101 #define ACPI_PPAG_NUM_CHAINS		2
102 #define ACPI_PPAG_NUM_BANDS_V1		5
103 #define ACPI_PPAG_NUM_BANDS_V2		11
104 #define ACPI_PPAG_NUM_BANDS_V3		12
105 #define ACPI_PPAG_WIFI_DATA_SIZE_V1	((ACPI_PPAG_NUM_CHAINS * \
106 					  ACPI_PPAG_NUM_BANDS_V1) + 2)
107 #define ACPI_PPAG_WIFI_DATA_SIZE_V2	((ACPI_PPAG_NUM_CHAINS * \
108 					  ACPI_PPAG_NUM_BANDS_V2) + 2)
109 
110 /* used for ACPI PPAG table rev 5 */
111 #define ACPI_PPAG_WIFI_DATA_SIZE_V3	((ACPI_PPAG_NUM_CHAINS * \
112 					  ACPI_PPAG_NUM_BANDS_V3) + 2)
113 
114 /* The Inidcator whether UEFI WIFI GUID tables are locked is read from ACPI */
115 #define UEFI_WIFI_GUID_UNLOCKED		0
116 
117 #define ACPI_DSM_REV 0
118 
119 #define DSM_INTERNAL_FUNC_GET_PLAT_INFO	1
120 /* TBD: VPRO is BIT(0) in the result, but what's the result? */
121 
122 #define DSM_INTERNAL_FUNC_PRODUCT_RESET	2
123 
124 /* DSM_INTERNAL_FUNC_PRODUCT_RESET - product reset (aka "PLDR") */
125 enum iwl_dsm_internal_product_reset_cmds {
126 	DSM_INTERNAL_PLDR_CMD_GET_MODE = 1,
127 	DSM_INTERNAL_PLDR_CMD_SET_MODE = 2,
128 	DSM_INTERNAL_PLDR_CMD_GET_STATUS = 3,
129 };
130 
131 enum iwl_dsm_internal_product_reset_mode {
132 	DSM_INTERNAL_PLDR_MODE_EN_PROD_RESET	= BIT(0),
133 	DSM_INTERNAL_PLDR_MODE_EN_WIFI_FLR	= BIT(1),
134 	DSM_INTERNAL_PLDR_MODE_EN_BT_OFF_ON	= BIT(2),
135 };
136 
137 struct iwl_dsm_internal_product_reset_cmd {
138 	/* cmd is from enum iwl_dsm_internal_product_reset_cmds */
139 	u16 cmd;
140 	u16 value;
141 } __packed;
142 
143 #define IWL_ACPI_WBEM_REV0_MASK (BIT(0) | BIT(1))
144 #define IWL_ACPI_WBEM_REVISION 0
145 
146 #ifdef CONFIG_ACPI
147 
148 struct iwl_fw_runtime;
149 
150 union acpi_object *iwl_acpi_get_dsm_object(struct device *dev, int rev,
151 					   int func, union acpi_object *args,
152 					   const guid_t *guid);
153 
154 /**
155  * iwl_acpi_get_mcc - read MCC from ACPI, if available
156  *
157  * @fwrt: the fw runtime struct
158  * @mcc: output buffer (3 bytes) that will get the MCC
159  *
160  * This function tries to read the current MCC from ACPI if available.
161  * Return: 0 on success, or a negative error code
162  */
163 int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);
164 
165 int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit);
166 
167 /*
168  * iwl_acpi_get_eckv - read external clock validation from ACPI, if available
169  *
170  * @fwrt: the fw runtime struct
171  * @extl_clk: output var (2 bytes) that will get the clk indication.
172  *
173  * This function tries to read the external clock indication
174  * from ACPI if available.
175  */
176 int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk);
177 
178 int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt);
179 
180 int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt);
181 
182 int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt);
183 
184 int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
185 			   struct iwl_tas_data *data);
186 
187 int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt);
188 
189 int iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt);
190 
191 void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt);
192 
193 int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt,
194 		     enum iwl_dsm_funcs func, u32 *value);
195 
196 int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);
197 
198 int iwl_acpi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value);
199 
200 #else /* CONFIG_ACPI */
201 
202 static inline union acpi_object *
iwl_acpi_get_dsm_object(struct device * dev,int rev,int func,union acpi_object * args,const guid_t * guid)203 iwl_acpi_get_dsm_object(struct device *dev, int rev, int func,
204 			union acpi_object *args, const guid_t *guid)
205 {
206 	return ERR_PTR(-ENOENT);
207 }
208 
iwl_acpi_get_mcc(struct iwl_fw_runtime * fwrt,char * mcc)209 static inline int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
210 {
211 	return -ENOENT;
212 }
213 
iwl_acpi_get_pwr_limit(struct iwl_fw_runtime * fwrt,u64 * dflt_pwr_limit)214 static inline int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
215 					 u64 *dflt_pwr_limit)
216 {
217 	*dflt_pwr_limit = 0;
218 	return 0;
219 }
220 
iwl_acpi_get_eckv(struct iwl_fw_runtime * fwrt,u32 * extl_clk)221 static inline int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
222 {
223 	return -ENOENT;
224 }
225 
iwl_acpi_get_wrds_table(struct iwl_fw_runtime * fwrt)226 static inline int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt)
227 {
228 	return -ENOENT;
229 }
230 
iwl_acpi_get_ewrd_table(struct iwl_fw_runtime * fwrt)231 static inline int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt)
232 {
233 	return -ENOENT;
234 }
235 
iwl_acpi_get_wgds_table(struct iwl_fw_runtime * fwrt)236 static inline int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt)
237 {
238 	return 1;
239 }
240 
iwl_acpi_get_tas_table(struct iwl_fw_runtime * fwrt,struct iwl_tas_data * data)241 static inline int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
242 					 struct iwl_tas_data *data)
243 {
244 	return -ENOENT;
245 }
246 
iwl_acpi_get_ppag_table(struct iwl_fw_runtime * fwrt)247 static inline int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
248 {
249 	return -ENOENT;
250 }
251 
iwl_acpi_get_phy_filters(struct iwl_fw_runtime * fwrt)252 static inline int iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt)
253 {
254 	return -ENOENT;
255 }
256 
iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime * fwrt)257 static inline void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt)
258 {
259 }
260 
iwl_acpi_get_dsm(struct iwl_fw_runtime * fwrt,enum iwl_dsm_funcs func,u32 * value)261 static inline int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt,
262 				   enum iwl_dsm_funcs func, u32 *value)
263 {
264 	return -ENOENT;
265 }
266 
iwl_acpi_get_wbem(struct iwl_fw_runtime * fwrt,u32 * value)267 static inline int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
268 {
269 	return -ENOENT;
270 }
271 
iwl_acpi_get_dsbr(struct iwl_fw_runtime * fwrt,u32 * value)272 static inline int iwl_acpi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value)
273 {
274 	return -ENOENT;
275 }
276 #endif /* CONFIG_ACPI */
277 
278 #endif /* __iwl_fw_acpi__ */
279