Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
0002 /*
0003  * Copyright (C) 2017 Intel Deutschland GmbH
0004  * Copyright (C) 2018-2022 Intel Corporation
0005  */
0006 #ifndef __iwl_fw_acpi__
0007 #define __iwl_fw_acpi__
0008 
0009 #include <linux/acpi.h>
0010 #include "fw/api/commands.h"
0011 #include "fw/api/power.h"
0012 #include "fw/api/phy.h"
0013 #include "fw/api/nvm-reg.h"
0014 #include "fw/img.h"
0015 #include "iwl-trans.h"
0016 
0017 
0018 #define ACPI_WRDS_METHOD    "WRDS"
0019 #define ACPI_EWRD_METHOD    "EWRD"
0020 #define ACPI_WGDS_METHOD    "WGDS"
0021 #define ACPI_WRDD_METHOD    "WRDD"
0022 #define ACPI_SPLC_METHOD    "SPLC"
0023 #define ACPI_ECKV_METHOD    "ECKV"
0024 #define ACPI_PPAG_METHOD    "PPAG"
0025 #define ACPI_WTAS_METHOD    "WTAS"
0026 
0027 #define ACPI_WIFI_DOMAIN    (0x07)
0028 
0029 #define ACPI_SAR_PROFILE_NUM        4
0030 
0031 #define ACPI_NUM_GEO_PROFILES       3
0032 #define ACPI_NUM_GEO_PROFILES_REV3  8
0033 #define ACPI_GEO_PER_CHAIN_SIZE     3
0034 
0035 #define ACPI_SAR_NUM_CHAINS_REV0    2
0036 #define ACPI_SAR_NUM_CHAINS_REV1    2
0037 #define ACPI_SAR_NUM_CHAINS_REV2    4
0038 #define ACPI_SAR_NUM_SUB_BANDS_REV0 5
0039 #define ACPI_SAR_NUM_SUB_BANDS_REV1 11
0040 #define ACPI_SAR_NUM_SUB_BANDS_REV2 11
0041 
0042 #define ACPI_WRDS_WIFI_DATA_SIZE_REV0   (ACPI_SAR_NUM_CHAINS_REV0 * \
0043                      ACPI_SAR_NUM_SUB_BANDS_REV0 + 2)
0044 #define ACPI_WRDS_WIFI_DATA_SIZE_REV1   (ACPI_SAR_NUM_CHAINS_REV1 * \
0045                      ACPI_SAR_NUM_SUB_BANDS_REV1 + 2)
0046 #define ACPI_WRDS_WIFI_DATA_SIZE_REV2   (ACPI_SAR_NUM_CHAINS_REV2 * \
0047                      ACPI_SAR_NUM_SUB_BANDS_REV2 + 2)
0048 #define ACPI_EWRD_WIFI_DATA_SIZE_REV0   ((ACPI_SAR_PROFILE_NUM - 1) * \
0049                      ACPI_SAR_NUM_CHAINS_REV0 * \
0050                      ACPI_SAR_NUM_SUB_BANDS_REV0 + 3)
0051 #define ACPI_EWRD_WIFI_DATA_SIZE_REV1   ((ACPI_SAR_PROFILE_NUM - 1) * \
0052                      ACPI_SAR_NUM_CHAINS_REV1 * \
0053                      ACPI_SAR_NUM_SUB_BANDS_REV1 + 3)
0054 #define ACPI_EWRD_WIFI_DATA_SIZE_REV2   ((ACPI_SAR_PROFILE_NUM - 1) * \
0055                      ACPI_SAR_NUM_CHAINS_REV2 * \
0056                      ACPI_SAR_NUM_SUB_BANDS_REV2 + 3)
0057 
0058 /* revision 0 and 1 are identical, except for the semantics in the FW */
0059 #define ACPI_GEO_NUM_BANDS_REV0     2
0060 #define ACPI_GEO_NUM_BANDS_REV2     3
0061 #define ACPI_GEO_NUM_CHAINS     2
0062 
0063 #define ACPI_WRDD_WIFI_DATA_SIZE    2
0064 #define ACPI_SPLC_WIFI_DATA_SIZE    2
0065 #define ACPI_ECKV_WIFI_DATA_SIZE    2
0066 
0067 /*
0068  * TAS size: 1 elelment for type,
0069  *       1 element for enabled field,
0070  *       1 element for block list size,
0071  *       16 elements for block list array
0072  */
0073 #define APCI_WTAS_BLACK_LIST_MAX    16
0074 #define ACPI_WTAS_WIFI_DATA_SIZE    (3 + APCI_WTAS_BLACK_LIST_MAX)
0075 #define ACPI_WTAS_ENABLED_MSK       0x1
0076 #define ACPI_WTAS_OVERRIDE_IEC_MSK  0x2
0077 #define ACPI_WTAS_ENABLE_IEC_MSK    0x4
0078 #define ACPI_WTAS_OVERRIDE_IEC_POS  0x1
0079 #define ACPI_WTAS_ENABLE_IEC_POS    0x2
0080 #define ACPI_WTAS_USA_UHB_MSK       BIT(16)
0081 #define ACPI_WTAS_USA_UHB_POS       16
0082 
0083 
0084 #define ACPI_PPAG_WIFI_DATA_SIZE_V1 ((IWL_NUM_CHAIN_LIMITS * \
0085                       IWL_NUM_SUB_BANDS_V1) + 2)
0086 #define ACPI_PPAG_WIFI_DATA_SIZE_V2 ((IWL_NUM_CHAIN_LIMITS * \
0087                       IWL_NUM_SUB_BANDS_V2) + 2)
0088 
0089 /* PPAG gain value bounds in 1/8 dBm */
0090 #define ACPI_PPAG_MIN_LB -16
0091 #define ACPI_PPAG_MAX_LB 24
0092 #define ACPI_PPAG_MIN_HB -16
0093 #define ACPI_PPAG_MAX_HB 40
0094 #define ACPI_PPAG_MASK 3
0095 #define IWL_PPAG_ETSI_MASK BIT(0)
0096 
0097 #define IWL_SAR_ENABLE_MSK      BIT(0)
0098 #define IWL_REDUCE_POWER_FLAGS_POS  1
0099 
0100 /*
0101  * The profile for revision 2 is a superset of revision 1, which is in
0102  * turn a superset of revision 0.  So we can store all revisions
0103  * inside revision 2, which is what we represent here.
0104  */
0105 struct iwl_sar_profile_chain {
0106     u8 subbands[ACPI_SAR_NUM_SUB_BANDS_REV2];
0107 };
0108 
0109 struct iwl_sar_profile {
0110     bool enabled;
0111     struct iwl_sar_profile_chain chains[ACPI_SAR_NUM_CHAINS_REV2];
0112 };
0113 
0114 /* Same thing as with SAR, all revisions fit in revision 2 */
0115 struct iwl_geo_profile_band {
0116     u8 max;
0117     u8 chains[ACPI_GEO_NUM_CHAINS];
0118 };
0119 
0120 struct iwl_geo_profile {
0121     struct iwl_geo_profile_band bands[ACPI_GEO_NUM_BANDS_REV2];
0122 };
0123 
0124 /* Same thing as with SAR, all revisions fit in revision 2 */
0125 struct iwl_ppag_chain {
0126     s8 subbands[ACPI_SAR_NUM_SUB_BANDS_REV2];
0127 };
0128 
0129 enum iwl_dsm_funcs_rev_0 {
0130     DSM_FUNC_QUERY = 0,
0131     DSM_FUNC_DISABLE_SRD = 1,
0132     DSM_FUNC_ENABLE_INDONESIA_5G2 = 2,
0133     DSM_FUNC_ENABLE_6E = 3,
0134     DSM_FUNC_11AX_ENABLEMENT = 6,
0135     DSM_FUNC_ENABLE_UNII4_CHAN = 7,
0136     DSM_FUNC_ACTIVATE_CHANNEL = 8,
0137     DSM_FUNC_FORCE_DISABLE_CHANNELS = 9
0138 };
0139 
0140 enum iwl_dsm_values_srd {
0141     DSM_VALUE_SRD_ACTIVE,
0142     DSM_VALUE_SRD_PASSIVE,
0143     DSM_VALUE_SRD_DISABLE,
0144     DSM_VALUE_SRD_MAX
0145 };
0146 
0147 enum iwl_dsm_values_indonesia {
0148     DSM_VALUE_INDONESIA_DISABLE,
0149     DSM_VALUE_INDONESIA_ENABLE,
0150     DSM_VALUE_INDONESIA_RESERVED,
0151     DSM_VALUE_INDONESIA_MAX
0152 };
0153 
0154 /* DSM RFI uses a different GUID, so need separate definitions */
0155 
0156 #define DSM_RFI_FUNC_ENABLE 3
0157 
0158 enum iwl_dsm_values_rfi {
0159     DSM_VALUE_RFI_ENABLE,
0160     DSM_VALUE_RFI_DISABLE,
0161     DSM_VALUE_RFI_MAX
0162 };
0163 
0164 #ifdef CONFIG_ACPI
0165 
0166 struct iwl_fw_runtime;
0167 
0168 extern const guid_t iwl_guid;
0169 extern const guid_t iwl_rfi_guid;
0170 
0171 void *iwl_acpi_get_object(struct device *dev, acpi_string method);
0172 
0173 int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func,
0174             const guid_t *guid, u8 *value);
0175 
0176 int iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func,
0177              const guid_t *guid, u32 *value);
0178 
0179 union acpi_object *iwl_acpi_get_wifi_pkg_range(struct device *dev,
0180                            union acpi_object *data,
0181                            int min_data_size,
0182                            int max_data_size,
0183                            int *tbl_rev);
0184 /**
0185  * iwl_acpi_get_mcc - read MCC from ACPI, if available
0186  *
0187  * @dev: the struct device
0188  * @mcc: output buffer (3 bytes) that will get the MCC
0189  *
0190  * This function tries to read the current MCC from ACPI if available.
0191  */
0192 int iwl_acpi_get_mcc(struct device *dev, char *mcc);
0193 
0194 u64 iwl_acpi_get_pwr_limit(struct device *dev);
0195 
0196 /*
0197  * iwl_acpi_get_eckv - read external clock validation from ACPI, if available
0198  *
0199  * @dev: the struct device
0200  * @extl_clk: output var (2 bytes) that will get the clk indication.
0201  *
0202  * This function tries to read the external clock indication
0203  * from ACPI if available.
0204  */
0205 int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk);
0206 
0207 int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt,
0208                __le16 *per_chain, u32 n_tables, u32 n_subbands,
0209                int prof_a, int prof_b);
0210 
0211 int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt);
0212 
0213 int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt);
0214 
0215 int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt);
0216 
0217 bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt);
0218 
0219 int iwl_sar_geo_init(struct iwl_fw_runtime *fwrt,
0220              struct iwl_per_chain_offset *table,
0221              u32 n_bands, u32 n_profiles);
0222 
0223 int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
0224              union iwl_tas_config_cmd *cmd, int fw_ver);
0225 
0226 __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt);
0227 
0228 int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt);
0229 
0230 int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *cmd,
0231             int *cmd_size);
0232 
0233 bool iwl_acpi_is_ppag_approved(struct iwl_fw_runtime *fwrt);
0234 
0235 #else /* CONFIG_ACPI */
0236 
0237 static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method)
0238 {
0239     return ERR_PTR(-ENOENT);
0240 }
0241 
0242 static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev,
0243                         int func, union acpi_object *args)
0244 {
0245     return ERR_PTR(-ENOENT);
0246 }
0247 
0248 static inline int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func,
0249                       const guid_t *guid, u8 *value)
0250 {
0251     return -ENOENT;
0252 }
0253 
0254 static inline int iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func,
0255                        const guid_t *guid, u32 *value)
0256 {
0257     return -ENOENT;
0258 }
0259 
0260 static inline union acpi_object *
0261 iwl_acpi_get_wifi_pkg_range(struct device *dev,
0262                 union acpi_object *data,
0263                 int min_data_size, int max_data_size,
0264                 int *tbl_rev)
0265 {
0266     return ERR_PTR(-ENOENT);
0267 }
0268 
0269 static inline int iwl_acpi_get_mcc(struct device *dev, char *mcc)
0270 {
0271     return -ENOENT;
0272 }
0273 
0274 static inline u64 iwl_acpi_get_pwr_limit(struct device *dev)
0275 {
0276     return 0;
0277 }
0278 
0279 static inline int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk)
0280 {
0281     return -ENOENT;
0282 }
0283 
0284 static inline int iwl_sar_select_profile(struct iwl_fw_runtime *fwrt,
0285                __le16 *per_chain, u32 n_tables, u32 n_subbands,
0286                int prof_a, int prof_b)
0287 {
0288     return -ENOENT;
0289 }
0290 
0291 static inline int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt)
0292 {
0293     return -ENOENT;
0294 }
0295 
0296 static inline int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt)
0297 {
0298     return -ENOENT;
0299 }
0300 
0301 static inline int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt)
0302 {
0303     return 1;
0304 }
0305 
0306 static inline bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt)
0307 {
0308     return false;
0309 }
0310 
0311 static inline int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
0312                    union iwl_tas_config_cmd *cmd, int fw_ver)
0313 {
0314     return -ENOENT;
0315 }
0316 
0317 static inline __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt)
0318 {
0319     return 0;
0320 }
0321 
0322 static inline int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
0323 {
0324     return -ENOENT;
0325 }
0326 
0327 static inline int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt,
0328                     union iwl_ppag_table_cmd *cmd, int *cmd_size)
0329 {
0330     return -ENOENT;
0331 }
0332 
0333 static inline bool iwl_acpi_is_ppag_approved(struct iwl_fw_runtime *fwrt)
0334 {
0335     return false;
0336 }
0337 
0338 #endif /* CONFIG_ACPI */
0339 
0340 static inline union acpi_object *
0341 iwl_acpi_get_wifi_pkg(struct device *dev,
0342               union acpi_object *data,
0343               int data_size, int *tbl_rev)
0344 {
0345     return iwl_acpi_get_wifi_pkg_range(dev, data, data_size, data_size,
0346                        tbl_rev);
0347 }
0348 
0349 #endif /* __iwl_fw_acpi__ */