225 lines · c
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */2/*3 * Copyright (C) 2023-2024 Intel Corporation4 */5 6#ifndef __fw_regulatory_h__7#define __fw_regulatory_h__8 9#include "fw/img.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"14#include "fw/api/nvm-reg.h"15#include "fw/img.h"16#include "iwl-trans.h"17 18#define BIOS_SAR_MAX_PROFILE_NUM 419/*20 * Each SAR profile has (up to, depends on the table revision) 4 chains:21 * chain A, chain B, chain A when in CDB, chain B when in CDB22 */23#define BIOS_SAR_MAX_CHAINS_PER_PROFILE 424#define BIOS_SAR_NUM_CHAINS 225#define BIOS_SAR_MAX_SUB_BANDS_NUM 1126 27#define BIOS_GEO_NUM_CHAINS 228#define BIOS_GEO_MAX_NUM_BANDS 329#define BIOS_GEO_MAX_PROFILE_NUM 830#define BIOS_GEO_MIN_PROFILE_NUM 331 32#define IWL_SAR_ENABLE_MSK BIT(0)33 34/* PPAG gain value bounds in 1/8 dBm */35#define IWL_PPAG_MIN_LB -1636#define IWL_PPAG_MAX_LB 2437#define IWL_PPAG_MIN_HB -1638#define IWL_PPAG_MAX_HB 4039 40#define IWL_PPAG_ETSI_CHINA_MASK 341#define IWL_PPAG_REV3_MASK 0x7FF42 43#define IWL_WTAS_ENABLED_MSK 0x144#define IWL_WTAS_OVERRIDE_IEC_MSK 0x245#define IWL_WTAS_ENABLE_IEC_MSK 0x446#define IWL_WTAS_USA_UHB_MSK BIT(16)47 48#define BIOS_MCC_CHINA 0x434e49 50/*51 * The profile for revision 2 is a superset of revision 1, which is in52 * turn a superset of revision 0. So we can store all revisions53 * inside revision 2, which is what we represent here.54 */55 56/*57 * struct iwl_sar_profile_chain - per-chain values of a SAR profile58 * @subbands: the SAR value for each subband59 */60struct iwl_sar_profile_chain {61 u8 subbands[BIOS_SAR_MAX_SUB_BANDS_NUM];62};63 64/*65 * struct iwl_sar_profile - SAR profile from SAR tables66 * @enabled: whether the profile is enabled or not67 * @chains: per-chain SAR values68 */69struct iwl_sar_profile {70 bool enabled;71 struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE];72};73 74/* Same thing as with SAR, all revisions fit in revision 2 */75 76/*77 * struct iwl_geo_profile_band - per-band geo SAR offsets78 * @max: the max tx power allowed for the band79 * @chains: SAR offsets values for each chain80 */81struct iwl_geo_profile_band {82 u8 max;83 u8 chains[BIOS_GEO_NUM_CHAINS];84};85 86/*87 * struct iwl_geo_profile - geo profile88 * @bands: per-band table of the SAR offsets89 */90struct iwl_geo_profile {91 struct iwl_geo_profile_band bands[BIOS_GEO_MAX_NUM_BANDS];92};93 94/* Same thing as with SAR, all revisions fit in revision 2 */95struct iwl_ppag_chain {96 s8 subbands[BIOS_SAR_MAX_SUB_BANDS_NUM];97};98 99struct iwl_tas_data {100 __le32 block_list_size;101 __le32 block_list_array[IWL_WTAS_BLACK_LIST_MAX];102 u8 override_tas_iec;103 u8 enable_tas_iec;104 u8 usa_tas_uhb_allowed;105};106 107/* For DSM revision 0 and 4 */108enum iwl_dsm_funcs {109 DSM_FUNC_QUERY = 0,110 DSM_FUNC_DISABLE_SRD = 1,111 DSM_FUNC_ENABLE_INDONESIA_5G2 = 2,112 DSM_FUNC_ENABLE_6E = 3,113 DSM_FUNC_REGULATORY_CONFIG = 4,114 DSM_FUNC_11AX_ENABLEMENT = 6,115 DSM_FUNC_ENABLE_UNII4_CHAN = 7,116 DSM_FUNC_ACTIVATE_CHANNEL = 8,117 DSM_FUNC_FORCE_DISABLE_CHANNELS = 9,118 DSM_FUNC_ENERGY_DETECTION_THRESHOLD = 10,119 DSM_FUNC_RFI_CONFIG = 11,120 DSM_FUNC_ENABLE_11BE = 12,121 DSM_FUNC_NUM_FUNCS = 13,122};123 124enum iwl_dsm_values_srd {125 DSM_VALUE_SRD_ACTIVE,126 DSM_VALUE_SRD_PASSIVE,127 DSM_VALUE_SRD_DISABLE,128 DSM_VALUE_SRD_MAX129};130 131enum iwl_dsm_values_indonesia {132 DSM_VALUE_INDONESIA_DISABLE,133 DSM_VALUE_INDONESIA_ENABLE,134 DSM_VALUE_INDONESIA_RESERVED,135 DSM_VALUE_INDONESIA_MAX136};137 138enum iwl_dsm_unii4_bitmap {139 DSM_VALUE_UNII4_US_OVERRIDE_MSK = BIT(0),140 DSM_VALUE_UNII4_US_EN_MSK = BIT(1),141 DSM_VALUE_UNII4_ETSI_OVERRIDE_MSK = BIT(2),142 DSM_VALUE_UNII4_ETSI_EN_MSK = BIT(3),143 DSM_VALUE_UNII4_CANADA_OVERRIDE_MSK = BIT(4),144 DSM_VALUE_UNII4_CANADA_EN_MSK = BIT(5),145};146 147#define DSM_UNII4_ALLOW_BITMAP_CMD_V8 (DSM_VALUE_UNII4_US_OVERRIDE_MSK | \148 DSM_VALUE_UNII4_US_EN_MSK | \149 DSM_VALUE_UNII4_ETSI_OVERRIDE_MSK | \150 DSM_VALUE_UNII4_ETSI_EN_MSK)151#define DSM_UNII4_ALLOW_BITMAP (DSM_UNII4_ALLOW_BITMAP_CMD_V8 | \152 DSM_VALUE_UNII4_CANADA_OVERRIDE_MSK | \153 DSM_VALUE_UNII4_CANADA_EN_MSK)154 155enum iwl_dsm_values_rfi {156 DSM_VALUE_RFI_DLVR_DISABLE = BIT(0),157 DSM_VALUE_RFI_DDR_DISABLE = BIT(1),158};159 160#define DSM_VALUE_RFI_DISABLE (DSM_VALUE_RFI_DLVR_DISABLE |\161 DSM_VALUE_RFI_DDR_DISABLE)162 163enum iwl_dsm_masks_reg {164 DSM_MASK_CHINA_22_REG = BIT(2)165};166 167struct iwl_fw_runtime;168 169bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt);170 171int iwl_sar_geo_fill_table(struct iwl_fw_runtime *fwrt,172 struct iwl_per_chain_offset *table,173 u32 n_bands, u32 n_profiles);174 175int iwl_sar_fill_profile(struct iwl_fw_runtime *fwrt,176 __le16 *per_chain, u32 n_tables, u32 n_subbands,177 int prof_a, int prof_b);178 179int iwl_fill_ppag_table(struct iwl_fw_runtime *fwrt,180 union iwl_ppag_table_cmd *cmd,181 int *cmd_size);182 183bool iwl_is_ppag_approved(struct iwl_fw_runtime *fwrt);184 185bool iwl_is_tas_approved(void);186 187int iwl_parse_tas_selection(struct iwl_fw_runtime *fwrt,188 struct iwl_tas_data *tas_data,189 const u32 tas_selection);190 191int iwl_bios_get_wrds_table(struct iwl_fw_runtime *fwrt);192 193int iwl_bios_get_ewrd_table(struct iwl_fw_runtime *fwrt);194 195int iwl_bios_get_wgds_table(struct iwl_fw_runtime *fwrt);196 197int iwl_bios_get_ppag_table(struct iwl_fw_runtime *fwrt);198 199int iwl_bios_get_tas_table(struct iwl_fw_runtime *fwrt,200 struct iwl_tas_data *data);201 202int iwl_bios_get_pwr_limit(struct iwl_fw_runtime *fwrt,203 u64 *dflt_pwr_limit);204 205int iwl_bios_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);206int iwl_bios_get_eckv(struct iwl_fw_runtime *fwrt, u32 *ext_clk);207int iwl_bios_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);208 209int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,210 struct iwl_lari_config_change_cmd *cmd,211 size_t *cmd_size);212 213int iwl_bios_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,214 u32 *value);215 216static inline u32 iwl_bios_get_ppag_flags(const u32 ppag_modes,217 const u8 ppag_ver)218{219 return ppag_modes & (ppag_ver < 3 ? IWL_PPAG_ETSI_CHINA_MASK :220 IWL_PPAG_REV3_MASK);221}222 223bool iwl_puncturing_is_allowed_in_bios(u32 puncturing, u16 mcc);224#endif /* __fw_regulatory_h__ */225