Path: blob/main/sys/contrib/dev/iwlwifi/fw/regulatory.h
48287 views
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */1/*2* Copyright (C) 2023-2025 Intel Corporation3*/45#ifndef __fw_regulatory_h__6#define __fw_regulatory_h__78#include "fw/img.h"9#include "fw/api/commands.h"10#include "fw/api/power.h"11#include "fw/api/phy.h"12#include "fw/api/config.h"13#include "fw/api/nvm-reg.h"14#include "fw/img.h"15#include "iwl-trans.h"1617#define BIOS_SAR_MAX_PROFILE_NUM 418/*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 CDB21*/22#define BIOS_SAR_MAX_CHAINS_PER_PROFILE 423#define BIOS_SAR_NUM_CHAINS 224#define BIOS_SAR_MAX_SUB_BANDS_NUM 112526#define BIOS_GEO_NUM_CHAINS 227#define BIOS_GEO_MAX_NUM_BANDS 328#define BIOS_GEO_MAX_PROFILE_NUM 829#define BIOS_GEO_MIN_PROFILE_NUM 33031#define IWL_SAR_ENABLE_MSK BIT(0)3233/* PPAG gain value bounds in 1/8 dBm */34#define IWL_PPAG_MIN_LB -1635#define IWL_PPAG_MAX_LB 2436#define IWL_PPAG_MIN_HB -1637#define IWL_PPAG_MAX_HB 403839#define IWL_PPAG_ETSI_CHINA_MASK 340#define IWL_PPAG_REV3_MASK 0x7FF4142#define IWL_WTAS_ENABLED_MSK BIT(0)43#define IWL_WTAS_OVERRIDE_IEC_MSK BIT(1)44#define IWL_WTAS_ENABLE_IEC_MSK BIT(2)45#define IWL_WTAS_CANADA_UHB_MSK BIT(15)46#define IWL_WTAS_USA_UHB_MSK BIT(16)4748struct iwl_tas_selection_data {49u8 override_tas_iec:1,50enable_tas_iec:1,51usa_tas_uhb_allowed:1,52canada_tas_uhb_allowed:1;53};5455#define BIOS_MCC_CHINA 0x434e5657/*58* The profile for revision 2 is a superset of revision 1, which is in59* turn a superset of revision 0. So we can store all revisions60* inside revision 2, which is what we represent here.61*/6263/*64* struct iwl_sar_profile_chain - per-chain values of a SAR profile65* @subbands: the SAR value for each subband66*/67struct iwl_sar_profile_chain {68u8 subbands[BIOS_SAR_MAX_SUB_BANDS_NUM];69};7071/*72* struct iwl_sar_profile - SAR profile from SAR tables73* @enabled: whether the profile is enabled or not74* @chains: per-chain SAR values75*/76struct iwl_sar_profile {77bool enabled;78struct iwl_sar_profile_chain chains[BIOS_SAR_MAX_CHAINS_PER_PROFILE];79};8081/* Same thing as with SAR, all revisions fit in revision 2 */8283/*84* struct iwl_geo_profile_band - per-band geo SAR offsets85* @max: the max tx power allowed for the band86* @chains: SAR offsets values for each chain87*/88struct iwl_geo_profile_band {89u8 max;90u8 chains[BIOS_GEO_NUM_CHAINS];91};9293/*94* struct iwl_geo_profile - geo profile95* @bands: per-band table of the SAR offsets96*/97struct iwl_geo_profile {98struct iwl_geo_profile_band bands[BIOS_GEO_MAX_NUM_BANDS];99};100101/* Same thing as with SAR, all revisions fit in revision 2 */102struct iwl_ppag_chain {103s8 subbands[BIOS_SAR_MAX_SUB_BANDS_NUM];104};105106struct iwl_tas_data {107u8 block_list_size;108u16 block_list_array[IWL_WTAS_BLACK_LIST_MAX];109u8 table_source;110u8 table_revision;111u32 tas_selection;112};113114/* For DSM revision 0 and 4 */115enum iwl_dsm_funcs {116DSM_FUNC_QUERY = 0,117DSM_FUNC_DISABLE_SRD = 1,118DSM_FUNC_ENABLE_INDONESIA_5G2 = 2,119DSM_FUNC_ENABLE_6E = 3,120DSM_FUNC_REGULATORY_CONFIG = 4,121DSM_FUNC_11AX_ENABLEMENT = 6,122DSM_FUNC_ENABLE_UNII4_CHAN = 7,123DSM_FUNC_ACTIVATE_CHANNEL = 8,124DSM_FUNC_FORCE_DISABLE_CHANNELS = 9,125DSM_FUNC_ENERGY_DETECTION_THRESHOLD = 10,126DSM_FUNC_RFI_CONFIG = 11,127DSM_FUNC_ENABLE_11BE = 12,128DSM_FUNC_NUM_FUNCS = 13,129};130131enum iwl_dsm_values_srd {132DSM_VALUE_SRD_ACTIVE,133DSM_VALUE_SRD_PASSIVE,134DSM_VALUE_SRD_DISABLE,135DSM_VALUE_SRD_MAX136};137138enum iwl_dsm_values_indonesia {139DSM_VALUE_INDONESIA_DISABLE,140DSM_VALUE_INDONESIA_ENABLE,141DSM_VALUE_INDONESIA_RESERVED,142DSM_VALUE_INDONESIA_MAX143};144145enum iwl_dsm_unii4_bitmap {146DSM_VALUE_UNII4_US_OVERRIDE_MSK = BIT(0),147DSM_VALUE_UNII4_US_EN_MSK = BIT(1),148DSM_VALUE_UNII4_ETSI_OVERRIDE_MSK = BIT(2),149DSM_VALUE_UNII4_ETSI_EN_MSK = BIT(3),150DSM_VALUE_UNII4_CANADA_OVERRIDE_MSK = BIT(4),151DSM_VALUE_UNII4_CANADA_EN_MSK = BIT(5),152};153154#define DSM_UNII4_ALLOW_BITMAP (DSM_VALUE_UNII4_US_OVERRIDE_MSK |\155DSM_VALUE_UNII4_US_EN_MSK |\156DSM_VALUE_UNII4_ETSI_OVERRIDE_MSK |\157DSM_VALUE_UNII4_ETSI_EN_MSK |\158DSM_VALUE_UNII4_CANADA_OVERRIDE_MSK |\159DSM_VALUE_UNII4_CANADA_EN_MSK)160161#define DSM_11AX_ALLOW_BITMAP 0xF162#define DSM_EDT_ALLOWED_BITMAP 0x7ffff0163#define DSM_FORCE_DISABLE_CHANNELS_ALLOWED_BITMAP 0x7FF164165enum iwl_dsm_values_rfi {166DSM_VALUE_RFI_DLVR_DISABLE = BIT(0),167DSM_VALUE_RFI_DDR_DISABLE = BIT(1),168};169170#define DSM_VALUE_RFI_DISABLE (DSM_VALUE_RFI_DLVR_DISABLE |\171DSM_VALUE_RFI_DDR_DISABLE)172173bool iwl_rfi_is_enabled_in_bios(struct iwl_fw_runtime *fwrt);174175enum iwl_dsm_masks_reg {176DSM_MASK_CHINA_22_REG = BIT(2)177};178179struct iwl_fw_runtime;180181bool iwl_sar_geo_support(struct iwl_fw_runtime *fwrt);182183int iwl_sar_geo_fill_table(struct iwl_fw_runtime *fwrt,184struct iwl_per_chain_offset *table,185u32 n_bands, u32 n_profiles);186187int iwl_sar_fill_profile(struct iwl_fw_runtime *fwrt,188__le16 *per_chain, u32 n_tables, u32 n_subbands,189int prof_a, int prof_b);190191int iwl_fill_ppag_table(struct iwl_fw_runtime *fwrt,192union iwl_ppag_table_cmd *cmd,193int *cmd_size);194195bool iwl_is_ppag_approved(struct iwl_fw_runtime *fwrt);196197bool iwl_is_tas_approved(void);198bool iwl_add_mcc_to_tas_block_list(u16 *list, u8 *size, u16 mcc);199200struct iwl_tas_selection_data201iwl_parse_tas_selection(const u32 tas_selection, const u8 tbl_rev);202203int iwl_bios_get_wrds_table(struct iwl_fw_runtime *fwrt);204205int iwl_bios_get_ewrd_table(struct iwl_fw_runtime *fwrt);206207int iwl_bios_get_wgds_table(struct iwl_fw_runtime *fwrt);208209int iwl_bios_get_ppag_table(struct iwl_fw_runtime *fwrt);210211int iwl_bios_get_tas_table(struct iwl_fw_runtime *fwrt,212struct iwl_tas_data *data);213214int iwl_bios_get_pwr_limit(struct iwl_fw_runtime *fwrt,215u64 *dflt_pwr_limit);216217int iwl_bios_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);218int iwl_bios_get_eckv(struct iwl_fw_runtime *fwrt, u32 *ext_clk);219int iwl_bios_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);220221__le32 iwl_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt);222int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,223struct iwl_lari_config_change_cmd *cmd,224size_t *cmd_size);225226int iwl_bios_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,227u32 *value);228229static inline u32 iwl_bios_get_ppag_flags(const u32 ppag_modes,230const u8 ppag_bios_rev)231{232/* For revision 4 and above driver is pipe */233if (ppag_bios_rev >= 4)234return ppag_modes;235236return ppag_modes & (ppag_bios_rev < 3 ? IWL_PPAG_ETSI_CHINA_MASK :237IWL_PPAG_REV3_MASK);238}239240bool iwl_puncturing_is_allowed_in_bios(u32 puncturing, u16 mcc);241242#define IWL_DSBR_FW_MODIFIED_URM_MASK BIT(8)243#define IWL_DSBR_PERMANENT_URM_MASK BIT(9)244245int iwl_bios_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value);246int iwl_bios_get_phy_filters(struct iwl_fw_runtime *fwrt);247248static inline void iwl_bios_setup_step(struct iwl_trans *trans,249struct iwl_fw_runtime *fwrt)250{251u32 dsbr;252253if (!trans->mac_cfg->integrated)254return;255256if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_BZ)257return;258259if (iwl_bios_get_dsbr(fwrt, &dsbr))260dsbr = 0;261262trans->conf.dsbr_urm_fw_dependent =263!!(dsbr & IWL_DSBR_FW_MODIFIED_URM_MASK);264trans->conf.dsbr_urm_permanent =265!!(dsbr & IWL_DSBR_PERMANENT_URM_MASK);266}267#endif /* __fw_regulatory_h__ */268269270