1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2017 Intel Deutschland GmbH 4 * Copyright (C) 2018-2023 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/api/commands.h" 12 #include "fw/api/power.h" 13 #include "fw/api/phy.h" 14 #include "fw/api/nvm-reg.h" 15 #include "fw/api/config.h" 16 #include "fw/img.h" 17 #include "iwl-trans.h" 18 19 20 #define ACPI_WRDS_METHOD "WRDS" 21 #define ACPI_EWRD_METHOD "EWRD" 22 #define ACPI_WGDS_METHOD "WGDS" 23 #define ACPI_WRDD_METHOD "WRDD" 24 #define ACPI_SPLC_METHOD "SPLC" 25 #define ACPI_ECKV_METHOD "ECKV" 26 #define ACPI_PPAG_METHOD "PPAG" 27 #define ACPI_WTAS_METHOD "WTAS" 28 #define ACPI_WPFC_METHOD "WPFC" 29 #define ACPI_GLAI_METHOD "GLAI" 30 #define ACPI_WBEM_METHOD "WBEM" 31 32 #define ACPI_WIFI_DOMAIN (0x07) 33 34 #define ACPI_SAR_PROFILE_NUM 4 35 36 #define ACPI_NUM_GEO_PROFILES 3 37 #define ACPI_NUM_GEO_PROFILES_REV3 8 38 #define ACPI_GEO_PER_CHAIN_SIZE 3 39 40 #define ACPI_SAR_NUM_CHAINS_REV0 2 41 #define ACPI_SAR_NUM_CHAINS_REV1 2 42 #define ACPI_SAR_NUM_CHAINS_REV2 4 43 #define ACPI_SAR_NUM_SUB_BANDS_REV0 5 44 #define ACPI_SAR_NUM_SUB_BANDS_REV1 11 45 #define ACPI_SAR_NUM_SUB_BANDS_REV2 11 46 47 #define ACPI_WRDS_WIFI_DATA_SIZE_REV0 (ACPI_SAR_NUM_CHAINS_REV0 * \ 48 ACPI_SAR_NUM_SUB_BANDS_REV0 + 2) 49 #define ACPI_WRDS_WIFI_DATA_SIZE_REV1 (ACPI_SAR_NUM_CHAINS_REV1 * \ 50 ACPI_SAR_NUM_SUB_BANDS_REV1 + 2) 51 #define ACPI_WRDS_WIFI_DATA_SIZE_REV2 (ACPI_SAR_NUM_CHAINS_REV2 * \ 52 ACPI_SAR_NUM_SUB_BANDS_REV2 + 2) 53 #define ACPI_EWRD_WIFI_DATA_SIZE_REV0 ((ACPI_SAR_PROFILE_NUM - 1) * \ 54 ACPI_SAR_NUM_CHAINS_REV0 * \ 55 ACPI_SAR_NUM_SUB_BANDS_REV0 + 3) 56 #define ACPI_EWRD_WIFI_DATA_SIZE_REV1 ((ACPI_SAR_PROFILE_NUM - 1) * \ 57 ACPI_SAR_NUM_CHAINS_REV1 * \ 58 ACPI_SAR_NUM_SUB_BANDS_REV1 + 3) 59 #define ACPI_EWRD_WIFI_DATA_SIZE_REV2 ((ACPI_SAR_PROFILE_NUM - 1) * \ 60 ACPI_SAR_NUM_CHAINS_REV2 * \ 61 ACPI_SAR_NUM_SUB_BANDS_REV2 + 3) 62 #define ACPI_WPFC_WIFI_DATA_SIZE 5 /* domain and 4 filter config words */ 63 64 /* revision 0 and 1 are identical, except for the semantics in the FW */ 65 #define ACPI_GEO_NUM_BANDS_REV0 2 66 #define ACPI_GEO_NUM_BANDS_REV2 3 67 68 #define ACPI_WRDD_WIFI_DATA_SIZE 2 69 #define ACPI_SPLC_WIFI_DATA_SIZE 2 70 #define ACPI_ECKV_WIFI_DATA_SIZE 2 71 72 /* 73 * One element for domain type, 74 * and one for enablement of Wi-Fi 320MHz per MCC 75 */ 76 #define ACPI_WBEM_WIFI_DATA_SIZE 2 77 /* 78 * One element for domain type, 79 * and one for the status 80 */ 81 #define ACPI_GLAI_WIFI_DATA_SIZE 2 82 #define ACPI_GLAI_MAX_STATUS 2 83 /* 84 * TAS size: 1 elelment for type, 85 * 1 element for enabled field, 86 * 1 element for block list size, 87 * 16 elements for block list array 88 */ 89 #define ACPI_WTAS_WIFI_DATA_SIZE (3 + IWL_WTAS_BLACK_LIST_MAX) 90 91 #define ACPI_PPAG_WIFI_DATA_SIZE_V1 ((IWL_NUM_CHAIN_LIMITS * \ 92 IWL_NUM_SUB_BANDS_V1) + 2) 93 #define ACPI_PPAG_WIFI_DATA_SIZE_V2 ((IWL_NUM_CHAIN_LIMITS * \ 94 IWL_NUM_SUB_BANDS_V2) + 2) 95 96 #define IWL_SAR_ENABLE_MSK BIT(0) 97 #define IWL_REDUCE_POWER_FLAGS_POS 1 98 99 /* The Inidcator whether UEFI WIFI GUID tables are locked is read from ACPI */ 100 #define UEFI_WIFI_GUID_UNLOCKED 0 101 102 #define ACPI_DSM_REV 0 103 104 #define IWL_ACPI_WBEM_REV0_MASK (BIT(0) | BIT(1)) 105 #define IWL_ACPI_WBEM_REVISION 0 106 107 #ifdef CONFIG_ACPI 108 109 struct iwl_fw_runtime; 110 111 extern const guid_t iwl_guid; 112 113 /** 114 * iwl_acpi_get_mcc - read MCC from ACPI, if available 115 * 116 * @fwrt: the fw runtime struct 117 * @mcc: output buffer (3 bytes) that will get the MCC 118 * 119 * This function tries to read the current MCC from ACPI if available. 120 */ 121 int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc); 122 123 int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit); 124 125 /* 126 * iwl_acpi_get_eckv - read external clock validation from ACPI, if available 127 * 128 * @fwrt: the fw runtime struct 129 * @extl_clk: output var (2 bytes) that will get the clk indication. 130 * 131 * This function tries to read the external clock indication 132 * from ACPI if available. 133 */ 134 int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk); 135 136 int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt); 137 138 int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt); 139 140 int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt); 141 142 int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt, 143 struct iwl_tas_data *data); 144 145 int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt); 146 147 void iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt, 148 struct iwl_phy_specific_cfg *filters); 149 150 void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt); 151 152 int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt, 153 enum iwl_dsm_funcs func, u32 *value); 154 155 int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value); 156 #else /* CONFIG_ACPI */ 157 158 static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev, 159 int func, union acpi_object *args) 160 { 161 return ERR_PTR(-ENOENT); 162 } 163 164 static inline int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc) 165 { 166 return -ENOENT; 167 } 168 169 static inline int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, 170 u64 *dflt_pwr_limit) 171 { 172 *dflt_pwr_limit = 0; 173 return 0; 174 } 175 176 static inline int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk) 177 { 178 return -ENOENT; 179 } 180 181 static inline int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt) 182 { 183 return -ENOENT; 184 } 185 186 static inline int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt) 187 { 188 return -ENOENT; 189 } 190 191 static inline int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt) 192 { 193 return 1; 194 } 195 196 static inline int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt, 197 struct iwl_tas_data *data) 198 { 199 return -ENOENT; 200 } 201 202 static inline int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt) 203 { 204 return -ENOENT; 205 } 206 207 /* macro since the second argument doesn't always exist */ 208 #define iwl_acpi_get_phy_filters(fwrt, filters) do { } while (0) 209 210 static inline void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt) 211 { 212 } 213 214 static inline int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt, 215 enum iwl_dsm_funcs func, u32 *value) 216 { 217 return -ENOENT; 218 } 219 220 static inline int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value) 221 { 222 return -ENOENT; 223 } 224 #endif /* CONFIG_ACPI */ 225 226 #endif /* __iwl_fw_acpi__ */ 227