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 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 #define IWL_SAR_ENABLE_MSK BIT(0) 115 #define IWL_REDUCE_POWER_FLAGS_POS 1 116 117 /* The Inidcator whether UEFI WIFI GUID tables are locked is read from ACPI */ 118 #define UEFI_WIFI_GUID_UNLOCKED 0 119 120 #define ACPI_DSM_REV 0 121 122 #define DSM_INTERNAL_FUNC_GET_PLAT_INFO 1 123 /* TBD: VPRO is BIT(0) in the result, but what's the result? */ 124 125 #define DSM_INTERNAL_FUNC_PRODUCT_RESET 2 126 127 /* DSM_INTERNAL_FUNC_PRODUCT_RESET - product reset (aka "PLDR") */ 128 enum iwl_dsm_internal_product_reset_cmds { 129 DSM_INTERNAL_PLDR_CMD_GET_MODE = 1, 130 DSM_INTERNAL_PLDR_CMD_SET_MODE = 2, 131 DSM_INTERNAL_PLDR_CMD_GET_STATUS = 3, 132 }; 133 134 enum iwl_dsm_internal_product_reset_mode { 135 DSM_INTERNAL_PLDR_MODE_EN_PROD_RESET = BIT(0), 136 DSM_INTERNAL_PLDR_MODE_EN_WIFI_FLR = BIT(1), 137 DSM_INTERNAL_PLDR_MODE_EN_BT_OFF_ON = BIT(2), 138 }; 139 140 struct iwl_dsm_internal_product_reset_cmd { 141 /* cmd is from enum iwl_dsm_internal_product_reset_cmds */ 142 u16 cmd; 143 u16 value; 144 } __packed; 145 146 #define IWL_ACPI_WBEM_REV0_MASK (BIT(0) | BIT(1)) 147 #define IWL_ACPI_WBEM_REVISION 0 148 149 #ifdef CONFIG_ACPI 150 151 struct iwl_fw_runtime; 152 153 union acpi_object *iwl_acpi_get_dsm_object(struct device *dev, int rev, 154 int func, union acpi_object *args, 155 const guid_t *guid); 156 157 /** 158 * iwl_acpi_get_mcc - read MCC from ACPI, if available 159 * 160 * @fwrt: the fw runtime struct 161 * @mcc: output buffer (3 bytes) that will get the MCC 162 * 163 * This function tries to read the current MCC from ACPI if available. 164 * Return: 0 on success, or a negative error code 165 */ 166 int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc); 167 168 int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit); 169 170 /* 171 * iwl_acpi_get_eckv - read external clock validation from ACPI, if available 172 * 173 * @fwrt: the fw runtime struct 174 * @extl_clk: output var (2 bytes) that will get the clk indication. 175 * 176 * This function tries to read the external clock indication 177 * from ACPI if available. 178 */ 179 int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk); 180 181 int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt); 182 183 int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt); 184 185 int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt); 186 187 int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt, 188 struct iwl_tas_data *data); 189 190 int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt); 191 192 int iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt); 193 194 void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt); 195 196 int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt, 197 enum iwl_dsm_funcs func, u32 *value); 198 199 int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value); 200 201 int iwl_acpi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value); 202 203 #else /* CONFIG_ACPI */ 204 205 static inline union acpi_object * 206 iwl_acpi_get_dsm_object(struct device *dev, int rev, int func, 207 union acpi_object *args, const guid_t *guid) 208 { 209 return ERR_PTR(-ENOENT); 210 } 211 212 static inline int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc) 213 { 214 return -ENOENT; 215 } 216 217 static inline int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, 218 u64 *dflt_pwr_limit) 219 { 220 *dflt_pwr_limit = 0; 221 return 0; 222 } 223 224 static inline int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk) 225 { 226 return -ENOENT; 227 } 228 229 static inline int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt) 230 { 231 return -ENOENT; 232 } 233 234 static inline int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt) 235 { 236 return -ENOENT; 237 } 238 239 static inline int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt) 240 { 241 return 1; 242 } 243 244 static inline int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt, 245 struct iwl_tas_data *data) 246 { 247 return -ENOENT; 248 } 249 250 static inline int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt) 251 { 252 return -ENOENT; 253 } 254 255 static inline int iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt) 256 { 257 return -ENOENT; 258 } 259 260 static inline void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt) 261 { 262 } 263 264 static inline int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt, 265 enum iwl_dsm_funcs func, u32 *value) 266 { 267 return -ENOENT; 268 } 269 270 static inline int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value) 271 { 272 return -ENOENT; 273 } 274 275 static inline int iwl_acpi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value) 276 { 277 return -ENOENT; 278 } 279 #endif /* CONFIG_ACPI */ 280 281 #endif /* __iwl_fw_acpi__ */ 282