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 31 #define ACPI_WIFI_DOMAIN (0x07) 32 33 #define ACPI_SAR_PROFILE_NUM 4 34 35 #define ACPI_NUM_GEO_PROFILES 3 36 #define ACPI_NUM_GEO_PROFILES_REV3 8 37 #define ACPI_GEO_PER_CHAIN_SIZE 3 38 39 #define ACPI_SAR_NUM_CHAINS_REV0 2 40 #define ACPI_SAR_NUM_CHAINS_REV1 2 41 #define ACPI_SAR_NUM_CHAINS_REV2 4 42 #define ACPI_SAR_NUM_SUB_BANDS_REV0 5 43 #define ACPI_SAR_NUM_SUB_BANDS_REV1 11 44 #define ACPI_SAR_NUM_SUB_BANDS_REV2 11 45 46 #define ACPI_WRDS_WIFI_DATA_SIZE_REV0 (ACPI_SAR_NUM_CHAINS_REV0 * \ 47 ACPI_SAR_NUM_SUB_BANDS_REV0 + 2) 48 #define ACPI_WRDS_WIFI_DATA_SIZE_REV1 (ACPI_SAR_NUM_CHAINS_REV1 * \ 49 ACPI_SAR_NUM_SUB_BANDS_REV1 + 2) 50 #define ACPI_WRDS_WIFI_DATA_SIZE_REV2 (ACPI_SAR_NUM_CHAINS_REV2 * \ 51 ACPI_SAR_NUM_SUB_BANDS_REV2 + 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_WPFC_WIFI_DATA_SIZE 5 /* domain and 4 filter config words */ 62 63 /* revision 0 and 1 are identical, except for the semantics in the FW */ 64 #define ACPI_GEO_NUM_BANDS_REV0 2 65 #define ACPI_GEO_NUM_BANDS_REV2 3 66 67 #define ACPI_WRDD_WIFI_DATA_SIZE 2 68 #define ACPI_SPLC_WIFI_DATA_SIZE 2 69 #define ACPI_ECKV_WIFI_DATA_SIZE 2 70 /* 71 * One element for domain type, 72 * and one for the status 73 */ 74 #define ACPI_GLAI_WIFI_DATA_SIZE 2 75 #define ACPI_GLAI_MAX_STATUS 2 76 /* 77 * TAS size: 1 elelment for type, 78 * 1 element for enabled field, 79 * 1 element for block list size, 80 * 16 elements for block list array 81 */ 82 #define ACPI_WTAS_WIFI_DATA_SIZE (3 + IWL_WTAS_BLACK_LIST_MAX) 83 84 #define ACPI_PPAG_WIFI_DATA_SIZE_V1 ((IWL_NUM_CHAIN_LIMITS * \ 85 IWL_NUM_SUB_BANDS_V1) + 2) 86 #define ACPI_PPAG_WIFI_DATA_SIZE_V2 ((IWL_NUM_CHAIN_LIMITS * \ 87 IWL_NUM_SUB_BANDS_V2) + 2) 88 89 #define IWL_SAR_ENABLE_MSK BIT(0) 90 #define IWL_REDUCE_POWER_FLAGS_POS 1 91 92 /* The Inidcator whether UEFI WIFI GUID tables are locked is read from ACPI */ 93 #define UEFI_WIFI_GUID_UNLOCKED 0 94 95 #define ACPI_DSM_REV 0 96 97 #ifdef CONFIG_ACPI 98 99 struct iwl_fw_runtime; 100 101 extern const guid_t iwl_guid; 102 103 /** 104 * iwl_acpi_get_mcc - read MCC from ACPI, if available 105 * 106 * @fwrt: the fw runtime struct 107 * @mcc: output buffer (3 bytes) that will get the MCC 108 * 109 * This function tries to read the current MCC from ACPI if available. 110 */ 111 int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc); 112 113 int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit); 114 115 /* 116 * iwl_acpi_get_eckv - read external clock validation from ACPI, if available 117 * 118 * @fwrt: the fw runtime struct 119 * @extl_clk: output var (2 bytes) that will get the clk indication. 120 * 121 * This function tries to read the external clock indication 122 * from ACPI if available. 123 */ 124 int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk); 125 126 int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt); 127 128 int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt); 129 130 int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt); 131 132 int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt, 133 struct iwl_tas_data *data); 134 135 int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt); 136 137 void iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt, 138 struct iwl_phy_specific_cfg *filters); 139 140 void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt); 141 142 int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt, 143 enum iwl_dsm_funcs func, u32 *value); 144 145 #else /* CONFIG_ACPI */ 146 147 static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev, 148 int func, union acpi_object *args) 149 { 150 return ERR_PTR(-ENOENT); 151 } 152 153 static inline int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc) 154 { 155 return -ENOENT; 156 } 157 158 static inline int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, 159 u64 *dflt_pwr_limit) 160 { 161 *dflt_pwr_limit = 0; 162 return 0; 163 } 164 165 static inline int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk) 166 { 167 return -ENOENT; 168 } 169 170 static inline int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt) 171 { 172 return -ENOENT; 173 } 174 175 static inline int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt) 176 { 177 return -ENOENT; 178 } 179 180 static inline int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt) 181 { 182 return 1; 183 } 184 185 static inline int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt, 186 struct iwl_tas_data *data) 187 { 188 return -ENOENT; 189 } 190 191 static inline int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt) 192 { 193 return -ENOENT; 194 } 195 196 /* macro since the second argument doesn't always exist */ 197 #define iwl_acpi_get_phy_filters(fwrt, filters) do { } while (0) 198 199 static inline void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt) 200 { 201 } 202 203 static inline int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt, 204 enum iwl_dsm_funcs func, u32 *value) 205 { 206 return -ENOENT; 207 } 208 #endif /* CONFIG_ACPI */ 209 210 #endif /* __iwl_fw_acpi__ */ 211