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 }; 82 83 enum iwl_dsm_values_srd { 84 DSM_VALUE_SRD_ACTIVE, 85 DSM_VALUE_SRD_PASSIVE, 86 DSM_VALUE_SRD_DISABLE, 87 DSM_VALUE_SRD_MAX 88 }; 89 90 enum iwl_dsm_values_indonesia { 91 DSM_VALUE_INDONESIA_DISABLE, 92 DSM_VALUE_INDONESIA_ENABLE, 93 DSM_VALUE_INDONESIA_RESERVED, 94 DSM_VALUE_INDONESIA_MAX 95 }; 96 97 /* DSM RFI uses a different GUID, so need separate definitions */ 98 99 #define DSM_RFI_FUNC_ENABLE 3 100 101 enum iwl_dsm_values_rfi { 102 DSM_VALUE_RFI_ENABLE, 103 DSM_VALUE_RFI_DISABLE, 104 DSM_VALUE_RFI_MAX 105 }; 106 107 #ifdef CONFIG_ACPI 108 109 struct iwl_fw_runtime; 110 111 extern const guid_t iwl_guid; 112 extern const guid_t iwl_rfi_guid; 113 114 void *iwl_acpi_get_object(struct device *dev, acpi_string method); 115 116 int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, 117 const guid_t *guid, u8 *value); 118 119 union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev, 120 union acpi_object *data, 121 int data_size, int *tbl_rev); 122 123 /** 124 * iwl_acpi_get_mcc - read MCC from ACPI, if available 125 * 126 * @dev: the struct device 127 * @mcc: output buffer (3 bytes) that will get the MCC 128 * 129 * This function tries to read the current MCC from ACPI if available. 130 */ 131 int iwl_acpi_get_mcc(struct device *dev, char *mcc); 132 133 u64 iwl_acpi_get_pwr_limit(struct device *dev); 134 135 /* 136 * iwl_acpi_get_eckv - read external clock validation from ACPI, if available 137 * 138 * @dev: the struct device 139 * @extl_clk: output var (2 bytes) that will get the clk indication. 140 * 141 * This function tries to read the external clock indication 142 * from ACPI if available. 143 */ 144 int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk); 145 146 int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, 147 __le16 *per_chain, u32 n_tables, u32 n_subbands, 148 int prof_a, int prof_b); 149 150 int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt); 151 152 int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt); 153 154 int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt); 155 156 bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt); 157 158 int iwl_sar_geo_init(struct iwl_fw_runtime *fwrt, 159 struct iwl_per_chain_offset *table, u32 n_bands); 160 161 int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt, __le32 *block_list_array, 162 int *block_list_size); 163 164 __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt); 165 166 #else /* CONFIG_ACPI */ 167 168 static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method) 169 { 170 return ERR_PTR(-ENOENT); 171 } 172 173 static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev, 174 int func, union acpi_object *args) 175 { 176 return ERR_PTR(-ENOENT); 177 } 178 179 static inline int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, 180 const guid_t *guid, u8 *value) 181 { 182 return -ENOENT; 183 } 184 185 static inline union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev, 186 union acpi_object *data, 187 int data_size, 188 int *tbl_rev) 189 { 190 return ERR_PTR(-ENOENT); 191 } 192 193 static inline int iwl_acpi_get_mcc(struct device *dev, char *mcc) 194 { 195 return -ENOENT; 196 } 197 198 static inline u64 iwl_acpi_get_pwr_limit(struct device *dev) 199 { 200 return 0; 201 } 202 203 static inline int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk) 204 { 205 return -ENOENT; 206 } 207 208 static inline int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt, 209 __le16 *per_chain, u32 n_tables, u32 n_subbands, 210 int prof_a, int prof_b) 211 { 212 return -ENOENT; 213 } 214 215 static inline int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt) 216 { 217 return -ENOENT; 218 } 219 220 static inline int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt) 221 { 222 return -ENOENT; 223 } 224 225 static inline int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt) 226 { 227 return -ENOENT; 228 } 229 230 static inline bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt) 231 { 232 return false; 233 } 234 235 static inline int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt, 236 __le32 *block_list_array, 237 int *block_list_size) 238 { 239 return -ENOENT; 240 } 241 242 static inline __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt) 243 { 244 return 0; 245 } 246 247 #endif /* CONFIG_ACPI */ 248 #endif /* __iwl_fw_acpi__ */ 249