1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2017 Intel Deutschland GmbH 4 * Copyright (C) 2018-2021 Intel Corporation 5 */ 6 #ifndef __iwl_fw_acpi__ 7 #define __iwl_fw_acpi__ 8 9 #include <linux/acpi.h> 10 #include "fw/api/commands.h" 11 #include "fw/api/power.h" 12 #include "fw/api/phy.h" 13 #include "fw/api/nvm-reg.h" 14 #include "fw/img.h" 15 #include "iwl-trans.h" 16 17 18 #define ACPI_WRDS_METHOD "WRDS" 19 #define ACPI_EWRD_METHOD "EWRD" 20 #define ACPI_WGDS_METHOD "WGDS" 21 #define ACPI_WRDD_METHOD "WRDD" 22 #define ACPI_SPLC_METHOD "SPLC" 23 #define ACPI_ECKV_METHOD "ECKV" 24 #define ACPI_PPAG_METHOD "PPAG" 25 #define ACPI_WTAS_METHOD "WTAS" 26 27 #define ACPI_WIFI_DOMAIN (0x07) 28 29 #define ACPI_SAR_TABLE_SIZE 10 30 #define ACPI_SAR_PROFILE_NUM 4 31 32 #define ACPI_GEO_TABLE_SIZE 6 33 #define ACPI_NUM_GEO_PROFILES 3 34 #define ACPI_GEO_PER_CHAIN_SIZE 3 35 36 #define ACPI_SAR_NUM_CHAIN_LIMITS 2 37 #define ACPI_SAR_NUM_SUB_BANDS 5 38 #define ACPI_SAR_NUM_TABLES 1 39 40 #define ACPI_WRDS_WIFI_DATA_SIZE (ACPI_SAR_TABLE_SIZE + 2) 41 #define ACPI_EWRD_WIFI_DATA_SIZE ((ACPI_SAR_PROFILE_NUM - 1) * \ 42 ACPI_SAR_TABLE_SIZE + 3) 43 #define ACPI_WGDS_WIFI_DATA_SIZE 19 44 #define ACPI_WRDD_WIFI_DATA_SIZE 2 45 #define ACPI_SPLC_WIFI_DATA_SIZE 2 46 #define ACPI_ECKV_WIFI_DATA_SIZE 2 47 48 /* 49 * 1 type, 1 enabled, 1 block list size, 16 block list array 50 */ 51 #define APCI_WTAS_BLACK_LIST_MAX 16 52 #define ACPI_WTAS_WIFI_DATA_SIZE (3 + APCI_WTAS_BLACK_LIST_MAX) 53 54 #define ACPI_WGDS_TABLE_SIZE 3 55 56 #define ACPI_PPAG_WIFI_DATA_SIZE_V1 ((IWL_NUM_CHAIN_LIMITS * \ 57 IWL_NUM_SUB_BANDS_V1) + 2) 58 #define ACPI_PPAG_WIFI_DATA_SIZE_V2 ((IWL_NUM_CHAIN_LIMITS * \ 59 IWL_NUM_SUB_BANDS_V2) + 2) 60 61 /* PPAG gain value bounds in 1/8 dBm */ 62 #define ACPI_PPAG_MIN_LB -16 63 #define ACPI_PPAG_MAX_LB 24 64 #define ACPI_PPAG_MIN_HB -16 65 #define ACPI_PPAG_MAX_HB 40 66 67 struct iwl_sar_profile { 68 bool enabled; 69 u8 table[ACPI_SAR_TABLE_SIZE]; 70 }; 71 72 struct iwl_geo_profile { 73 u8 values[ACPI_GEO_TABLE_SIZE]; 74 }; 75 76 enum iwl_dsm_funcs_rev_0 { 77 DSM_FUNC_QUERY = 0, 78 DSM_FUNC_DISABLE_SRD = 1, 79 DSM_FUNC_ENABLE_INDONESIA_5G2 = 2, 80 DSM_FUNC_11AX_ENABLEMENT = 6, 81 DSM_FUNC_ENABLE_UNII4_CHAN = 7 82 }; 83 84 enum iwl_dsm_values_srd { 85 DSM_VALUE_SRD_ACTIVE, 86 DSM_VALUE_SRD_PASSIVE, 87 DSM_VALUE_SRD_DISABLE, 88 DSM_VALUE_SRD_MAX 89 }; 90 91 enum iwl_dsm_values_indonesia { 92 DSM_VALUE_INDONESIA_DISABLE, 93 DSM_VALUE_INDONESIA_ENABLE, 94 DSM_VALUE_INDONESIA_RESERVED, 95 DSM_VALUE_INDONESIA_MAX 96 }; 97 98 /* DSM RFI uses a different GUID, so need separate definitions */ 99 100 #define DSM_RFI_FUNC_ENABLE 3 101 102 enum iwl_dsm_values_rfi { 103 DSM_VALUE_RFI_ENABLE, 104 DSM_VALUE_RFI_DISABLE, 105 DSM_VALUE_RFI_MAX 106 }; 107 108 #ifdef CONFIG_ACPI 109 110 struct iwl_fw_runtime; 111 112 extern const guid_t iwl_guid; 113 extern const guid_t iwl_rfi_guid; 114 115 void *iwl_acpi_get_object(struct device *dev, acpi_string method); 116 117 int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, 118 const guid_t *guid, u8 *value); 119 120 int iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func, 121 const guid_t *guid, u32 *value); 122 123 union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev, 124 union acpi_object *data, 125 int data_size, int *tbl_rev); 126 127 /** 128 * iwl_acpi_get_mcc - read MCC from ACPI, if available 129 * 130 * @dev: the struct device 131 * @mcc: output buffer (3 bytes) that will get the MCC 132 * 133 * This function tries to read the current MCC from ACPI if available. 134 */ 135 int iwl_acpi_get_mcc(struct device *dev, char *mcc); 136 137 u64 iwl_acpi_get_pwr_limit(struct device *dev); 138 139 /* 140 * iwl_acpi_get_eckv - read external clock validation from ACPI, if available 141 * 142 * @dev: the struct device 143 * @extl_clk: output var (2 bytes) that will get the clk indication. 144 * 145 * This function tries to read the external clock indication 146 * from ACPI if available. 147 */ 148 int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk); 149 150 int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, 151 __le16 *per_chain, u32 n_tables, u32 n_subbands, 152 int prof_a, int prof_b); 153 154 int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt); 155 156 int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt); 157 158 int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt); 159 160 bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt); 161 162 int iwl_sar_geo_init(struct iwl_fw_runtime *fwrt, 163 struct iwl_per_chain_offset *table, u32 n_bands); 164 165 int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt, __le32 *block_list_array, 166 int *block_list_size); 167 168 __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt); 169 170 #else /* CONFIG_ACPI */ 171 172 static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method) 173 { 174 return ERR_PTR(-ENOENT); 175 } 176 177 static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev, 178 int func, union acpi_object *args) 179 { 180 return ERR_PTR(-ENOENT); 181 } 182 183 static inline int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, 184 const guid_t *guid, u8 *value) 185 { 186 return -ENOENT; 187 } 188 189 static inline int iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func, 190 const guid_t *guid, u32 *value) 191 { 192 return -ENOENT; 193 } 194 195 static inline union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev, 196 union acpi_object *data, 197 int data_size, 198 int *tbl_rev) 199 { 200 return ERR_PTR(-ENOENT); 201 } 202 203 static inline int iwl_acpi_get_mcc(struct device *dev, char *mcc) 204 { 205 return -ENOENT; 206 } 207 208 static inline u64 iwl_acpi_get_pwr_limit(struct device *dev) 209 { 210 return 0; 211 } 212 213 static inline int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk) 214 { 215 return -ENOENT; 216 } 217 218 static inline int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, 219 __le16 *per_chain, u32 n_tables, u32 n_subbands, 220 int prof_a, int prof_b) 221 { 222 return -ENOENT; 223 } 224 225 static inline int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt) 226 { 227 return -ENOENT; 228 } 229 230 static inline int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt) 231 { 232 return -ENOENT; 233 } 234 235 static inline int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt) 236 { 237 return -ENOENT; 238 } 239 240 static inline bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt) 241 { 242 return false; 243 } 244 245 static inline int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt, 246 __le32 *block_list_array, 247 int *block_list_size) 248 { 249 return -ENOENT; 250 } 251 252 static inline __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt) 253 { 254 return 0; 255 } 256 257 #endif /* CONFIG_ACPI */ 258 #endif /* __iwl_fw_acpi__ */ 259