1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright (C) 2023 Intel Corporation
6 #ifndef __fw_regulatory_h__
7 #define __fw_regulatory_h__
10 #include "fw/api/commands.h"
11 #include "fw/api/power.h"
12 #include "fw/api/phy.h"
13 #include "fw/api/config.h"
15 #include "iwl-trans.h"
17 #define BIOS_SAR_MAX_PROFILE_NUM 4
19 * Each SAR profile has (up to, depends on the table revision) 4 chains:
20 * chain A, chain B, chain A when in CDB, chain B when in CDB
22 #define BIOS_SAR_MAX_CHAINS_PER_PROFILE 4
23 #define BIOS_SAR_NUM_CHAINS 2
24 #define BIOS_SAR_MAX_SUB_BANDS_NUM 11
26 #define BIOS_GEO_NUM_CHAINS 2
27 #define BIOS_GEO_MAX_NUM_BANDS 3
28 #define BIOS_GEO_MAX_PROFILE_NUM 8
29 #define BIOS_GEO_MIN_PROFILE_NUM 3
31 #define IWL_SAR_ENABLE_MSK BIT(0)
33 /* PPAG gain value bounds in 1/8 dBm */
34 #define IWL_PPAG_MIN_LB -16
35 #define IWL_PPAG_MAX_LB 24
36 #define IWL_PPAG_MIN_HB -16
37 #define IWL_PPAG_MAX_HB 40
39 #define IWL_PPAG_ETSI_CHINA_MASK 3
40 #define IWL_PPAG_ETSI_MASK BIT(0)
42 #define IWL_WTAS_BLACK_LIST_MAX 16
43 #define IWL_WTAS_ENABLED_MSK 0x1
44 #define IWL_WTAS_OVERRIDE_IEC_MSK 0x2
45 #define IWL_WTAS_ENABLE_IEC_MSK 0x4
46 #define IWL_WTAS_USA_UHB_MSK BIT(16)
49 * The profile for revision 2 is a superset of revision 1, which is in
50 * turn a superset of revision 0. So we can store all revisions
51 * inside revision 2, which is what we represent here.
55 * struct iwl_sar_profile_chain - per-chain values of a SAR profile
56 * @subbands: the SAR value for each subband
58 struct iwl_sar_profile_chain {
59 u8 subbands[BIOS_SAR_MAX_SUB_BANDS_NUM];
63 * struct iwl_sar_profile - SAR profile from SAR tables
64 * @enabled: whether the profile is enabled or not
65 * @chains: per-chain SAR values
67 struct iwl_sar_profile {
69 struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE];
72 /* Same thing as with SAR, all revisions fit in revision 2 */
75 * struct iwl_geo_profile_band - per-band geo SAR offsets
76 * @max: the max tx power allowed for the band
77 * @chains: SAR offsets values for each chain
79 struct iwl_geo_profile_band {
81 u8 chains[BIOS_GEO_NUM_CHAINS];
85 * struct iwl_geo_profile - geo profile
86 * @bands: per-band table of the SAR offsets
88 struct iwl_geo_profile {
89 struct iwl_geo_profile_band bands[BIOS_GEO_MAX_NUM_BANDS];
92 /* Same thing as with SAR, all revisions fit in revision 2 */
93 struct iwl_ppag_chain {
94 s8 subbands[BIOS_SAR_MAX_SUB_BANDS_NUM];
98 __le32 block_list_size;
99 __le32 block_list_array[IWL_WTAS_BLACK_LIST_MAX];
102 u8 usa_tas_uhb_allowed;
105 /* For DSM revision 0 and 4 */
108 DSM_FUNC_DISABLE_SRD = 1,
109 DSM_FUNC_ENABLE_INDONESIA_5G2 = 2,
110 DSM_FUNC_ENABLE_6E = 3,
111 DSM_FUNC_REGULATORY_CONFIG = 4,
112 DSM_FUNC_11AX_ENABLEMENT = 6,
113 DSM_FUNC_ENABLE_UNII4_CHAN = 7,
114 DSM_FUNC_ACTIVATE_CHANNEL = 8,
115 DSM_FUNC_FORCE_DISABLE_CHANNELS = 9,
116 DSM_FUNC_ENERGY_DETECTION_THRESHOLD = 10,
117 DSM_FUNC_RFI_CONFIG = 11,
118 DSM_FUNC_NUM_FUNCS = 12,
121 enum iwl_dsm_values_srd {
122 DSM_VALUE_SRD_ACTIVE,
123 DSM_VALUE_SRD_PASSIVE,
124 DSM_VALUE_SRD_DISABLE,
128 enum iwl_dsm_values_indonesia {
129 DSM_VALUE_INDONESIA_DISABLE,
130 DSM_VALUE_INDONESIA_ENABLE,
131 DSM_VALUE_INDONESIA_RESERVED,
132 DSM_VALUE_INDONESIA_MAX
135 enum iwl_dsm_values_rfi {
136 DSM_VALUE_RFI_DLVR_DISABLE = BIT(0),
137 DSM_VALUE_RFI_DDR_DISABLE = BIT(1),
140 #define DSM_VALUE_RFI_DISABLE (DSM_VALUE_RFI_DLVR_DISABLE |\
141 DSM_VALUE_RFI_DDR_DISABLE)
143 enum iwl_dsm_masks_reg {
144 DSM_MASK_CHINA_22_REG = BIT(2)
147 struct iwl_fw_runtime;
149 bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt);
151 int iwl_sar_geo_fill_table(struct iwl_fw_runtime *fwrt,
152 struct iwl_per_chain_offset *table,
153 u32 n_bands, u32 n_profiles);
155 int iwl_sar_fill_profile(struct iwl_fw_runtime *fwrt,
156 __le16 *per_chain, u32 n_tables, u32 n_subbands,
157 int prof_a, int prof_b);
159 int iwl_fill_ppag_table(struct iwl_fw_runtime *fwrt,
160 union iwl_ppag_table_cmd *cmd,
163 bool iwl_is_ppag_approved(struct iwl_fw_runtime *fwrt);
165 bool iwl_is_tas_approved(void);
167 int iwl_parse_tas_selection(struct iwl_fw_runtime *fwrt,
168 struct iwl_tas_data *tas_data,
169 const u32 tas_selection);
171 int iwl_bios_get_wrds_table(struct iwl_fw_runtime *fwrt);
173 int iwl_bios_get_ewrd_table(struct iwl_fw_runtime *fwrt);
175 int iwl_bios_get_wgds_table(struct iwl_fw_runtime *fwrt);
177 int iwl_bios_get_ppag_table(struct iwl_fw_runtime *fwrt);
179 int iwl_bios_get_tas_table(struct iwl_fw_runtime *fwrt,
180 struct iwl_tas_data *data);
182 int iwl_bios_get_pwr_limit(struct iwl_fw_runtime *fwrt,
183 u64 *dflt_pwr_limit);
185 int iwl_bios_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);
186 int iwl_bios_get_eckv(struct iwl_fw_runtime *fwrt, u32 *ext_clk);
188 __le32 iwl_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt);
190 int iwl_bios_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
192 #endif /* __fw_regulatory_h__ */