Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmsmac/phy/phy_int.h
178701 views
// SPDX-License-Identifier: ISC1/*2* Copyright (c) 2010 Broadcom Corporation3*/45#ifndef _BRCM_PHY_INT_H_6#define _BRCM_PHY_INT_H_78#include <types.h>9#include <brcmu_utils.h>10#include <brcmu_wifi.h>1112#define PHY_VERSION { 1, 82, 8, 0 }1314#define LCNXN_BASEREV 161516struct phy_shim_info;1718struct brcms_phy_srom_fem {19/* TSSI positive slope, 1: positive, 0: negative */20u8 tssipos;21/* Ext PA gain-type: full-gain: 0, pa-lite: 1, no_pa: 2 */22u8 extpagain;23/* support 32 combinations of different Pdet dynamic ranges */24u8 pdetrange;25/* TR switch isolation */26u8 triso;27/* antswctrl lookup table configuration: 32 possible choices */28u8 antswctrllut;29};3031#define ISNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_N)32#define ISLCNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_LCN)3334#define PHY_GET_RFATTN(rfgain) ((rfgain) & 0x0f)35#define PHY_GET_PADMIX(rfgain) (((rfgain) & 0x10) >> 4)36#define PHY_GET_RFGAINID(rfattn, padmix, width) ((rfattn) + ((padmix)*(width)))37#define PHY_SAT(x, n) ((x) > ((1<<((n)-1))-1) ? ((1<<((n)-1))-1) : \38((x) < -(1<<((n)-1)) ? -(1<<((n)-1)) : (x)))39#define PHY_SHIFT_ROUND(x, n) ((x) >= 0 ? ((x)+(1<<((n)-1)))>>(n) : (x)>>(n))40#define PHY_HW_ROUND(x, s) ((x >> s) + ((x >> (s-1)) & (s != 0)))4142#define CH_5G_GROUP 343#define A_LOW_CHANS 044#define A_MID_CHANS 145#define A_HIGH_CHANS 246#define CH_2G_GROUP 147#define G_ALL_CHANS 04849#define FIRST_REF5_CHANNUM 14950#define LAST_REF5_CHANNUM 16551#define FIRST_5G_CHAN 1452#define LAST_5G_CHAN 5053#define FIRST_MID_5G_CHAN 1454#define LAST_MID_5G_CHAN 3555#define FIRST_HIGH_5G_CHAN 3656#define LAST_HIGH_5G_CHAN 4157#define FIRST_LOW_5G_CHAN 4258#define LAST_LOW_5G_CHAN 505960#define BASE_LOW_5G_CHAN 490061#define BASE_MID_5G_CHAN 510062#define BASE_HIGH_5G_CHAN 55006364#define CHAN5G_FREQ(chan) (5000 + chan*5)65#define CHAN2G_FREQ(chan) (2407 + chan*5)6667#define TXP_FIRST_CCK 068#define TXP_LAST_CCK 369#define TXP_FIRST_OFDM 470#define TXP_LAST_OFDM 1171#define TXP_FIRST_OFDM_20_CDD 1272#define TXP_LAST_OFDM_20_CDD 1973#define TXP_FIRST_MCS_20_SISO 2074#define TXP_LAST_MCS_20_SISO 2775#define TXP_FIRST_MCS_20_CDD 2876#define TXP_LAST_MCS_20_CDD 3577#define TXP_FIRST_MCS_20_STBC 3678#define TXP_LAST_MCS_20_STBC 4379#define TXP_FIRST_MCS_20_SDM 4480#define TXP_LAST_MCS_20_SDM 5181#define TXP_FIRST_OFDM_40_SISO 5282#define TXP_LAST_OFDM_40_SISO 5983#define TXP_FIRST_OFDM_40_CDD 6084#define TXP_LAST_OFDM_40_CDD 6785#define TXP_FIRST_MCS_40_SISO 6886#define TXP_LAST_MCS_40_SISO 7587#define TXP_FIRST_MCS_40_CDD 7688#define TXP_LAST_MCS_40_CDD 8389#define TXP_FIRST_MCS_40_STBC 8490#define TXP_LAST_MCS_40_STBC 9191#define TXP_FIRST_MCS_40_SDM 9292#define TXP_LAST_MCS_40_SDM 9993#define TXP_MCS_32 10094#define TXP_NUM_RATES 10195#define ADJ_PWR_TBL_LEN 849697#define TXP_FIRST_SISO_MCS_20 2098#define TXP_LAST_SISO_MCS_20 2799100#define PHY_CORE_NUM_1 1101#define PHY_CORE_NUM_2 2102#define PHY_CORE_NUM_3 3103#define PHY_CORE_NUM_4 4104#define PHY_CORE_MAX PHY_CORE_NUM_4105#define PHY_CORE_0 0106#define PHY_CORE_1 1107#define PHY_CORE_2 2108#define PHY_CORE_3 3109110#define MA_WINDOW_SZ 8111112#define PHY_NOISE_SAMPLE_MON 1113#define PHY_NOISE_SAMPLE_EXTERNAL 2114#define PHY_NOISE_WINDOW_SZ 16115#define PHY_NOISE_GLITCH_INIT_MA 10116#define PHY_NOISE_GLITCH_INIT_MA_BADPlCP 10117#define PHY_NOISE_STATE_MON 0x1118#define PHY_NOISE_STATE_EXTERNAL 0x2119#define PHY_NOISE_SAMPLE_LOG_NUM_NPHY 10120#define PHY_NOISE_SAMPLE_LOG_NUM_UCODE 9121122#define PHY_NOISE_OFFSETFACT_4322 (-103)123#define PHY_NOISE_MA_WINDOW_SZ 2124125#define PHY_RSSI_TABLE_SIZE 64126#define RSSI_ANT_MERGE_MAX 0127#define RSSI_ANT_MERGE_MIN 1128#define RSSI_ANT_MERGE_AVG 2129130#define PHY_TSSI_TABLE_SIZE 64131#define APHY_TSSI_TABLE_SIZE 256132#define TX_GAIN_TABLE_LENGTH 64133#define DEFAULT_11A_TXP_IDX 24134#define NUM_TSSI_FRAMES 4135#define NULL_TSSI 0x7f136#define NULL_TSSI_W 0x7f7f137138#define PHY_PAPD_EPS_TBL_SIZE_LCNPHY 64139140#define LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL 9141142#define PHY_TXPWR_MIN 10143#define PHY_TXPWR_MIN_NPHY 8144#define RADIOPWR_OVERRIDE_DEF (-1)145146#define PWRTBL_NUM_COEFF 3147148#define SPURAVOID_DISABLE 0149#define SPURAVOID_AUTO 1150#define SPURAVOID_FORCEON 2151#define SPURAVOID_FORCEON2 3152153#define PHY_SW_TIMER_FAST 15154#define PHY_SW_TIMER_SLOW 60155#define PHY_SW_TIMER_GLACIAL 120156157#define PHY_PERICAL_AUTO 0158#define PHY_PERICAL_FULL 1159#define PHY_PERICAL_PARTIAL 2160161#define PHY_PERICAL_NODELAY 0162#define PHY_PERICAL_INIT_DELAY 5163#define PHY_PERICAL_ASSOC_DELAY 5164#define PHY_PERICAL_WDOG_DELAY 5165166#define MPHASE_TXCAL_NUMCMDS 2167168#define PHY_PERICAL_MPHASE_PENDING(pi) \169(pi->mphase_cal_phase_id > MPHASE_CAL_STATE_IDLE)170171enum {172MPHASE_CAL_STATE_IDLE = 0,173MPHASE_CAL_STATE_INIT = 1,174MPHASE_CAL_STATE_TXPHASE0,175MPHASE_CAL_STATE_TXPHASE1,176MPHASE_CAL_STATE_TXPHASE2,177MPHASE_CAL_STATE_TXPHASE3,178MPHASE_CAL_STATE_TXPHASE4,179MPHASE_CAL_STATE_TXPHASE5,180MPHASE_CAL_STATE_PAPDCAL,181MPHASE_CAL_STATE_RXCAL,182MPHASE_CAL_STATE_RSSICAL,183MPHASE_CAL_STATE_IDLETSSI184};185186enum phy_cal_mode {187CAL_FULL,188CAL_RECAL,189CAL_CURRECAL,190CAL_DIGCAL,191CAL_GCTRL,192CAL_SOFT,193CAL_DIGLO194};195196#define RDR_NTIERS 1197#define RDR_TIER_SIZE 64198#define RDR_LIST_SIZE (512/3)199#define RDR_EPOCH_SIZE 40200#define RDR_NANTENNAS 2201#define RDR_NTIER_SIZE RDR_LIST_SIZE202#define RDR_LP_BUFFER_SIZE 64203#define LP_LEN_HIS_SIZE 10204205#define STATIC_NUM_RF 32206#define STATIC_NUM_BB 9207208#define BB_MULT_MASK 0x0000ffff209#define BB_MULT_VALID_MASK 0x80000000210211#define PHY_CHAIN_TX_DISABLE_TEMP 115212#define PHY_HYSTERESIS_DELTATEMP 5213214#define SCAN_INPROG_PHY(pi) \215(mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN))216217#define PLT_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_PLT))218219#define ASSOC_INPROG_PHY(pi) \220(mboolisset(pi->measure_hold, PHY_HOLD_FOR_ASSOC))221222#define SCAN_RM_IN_PROGRESS(pi) \223(mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN | PHY_HOLD_FOR_RM))224225#define PHY_MUTED(pi) \226(mboolisset(pi->measure_hold, PHY_HOLD_FOR_MUTE))227228#define PUB_NOT_ASSOC(pi) \229(mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC))230231struct phy_table_info {232uint table;233int q;234uint max;235};236237struct phytbl_info {238const void *tbl_ptr;239u32 tbl_len;240u32 tbl_id;241u32 tbl_offset;242u32 tbl_width;243};244245struct interference_info {246u8 curr_home_channel;247u16 crsminpwrthld_40_stored;248u16 crsminpwrthld_20L_stored;249u16 crsminpwrthld_20U_stored;250u16 init_gain_code_core1_stored;251u16 init_gain_code_core2_stored;252u16 init_gain_codeb_core1_stored;253u16 init_gain_codeb_core2_stored;254u16 init_gain_table_stored[4];255256u16 clip1_hi_gain_code_core1_stored;257u16 clip1_hi_gain_code_core2_stored;258u16 clip1_hi_gain_codeb_core1_stored;259u16 clip1_hi_gain_codeb_core2_stored;260u16 nb_clip_thresh_core1_stored;261u16 nb_clip_thresh_core2_stored;262u16 init_ofdmlna2gainchange_stored[4];263u16 init_ccklna2gainchange_stored[4];264u16 clip1_lo_gain_code_core1_stored;265u16 clip1_lo_gain_code_core2_stored;266u16 clip1_lo_gain_codeb_core1_stored;267u16 clip1_lo_gain_codeb_core2_stored;268u16 w1_clip_thresh_core1_stored;269u16 w1_clip_thresh_core2_stored;270u16 radio_2056_core1_rssi_gain_stored;271u16 radio_2056_core2_rssi_gain_stored;272u16 energy_drop_timeout_len_stored;273274u16 ed_crs40_assertthld0_stored;275u16 ed_crs40_assertthld1_stored;276u16 ed_crs40_deassertthld0_stored;277u16 ed_crs40_deassertthld1_stored;278u16 ed_crs20L_assertthld0_stored;279u16 ed_crs20L_assertthld1_stored;280u16 ed_crs20L_deassertthld0_stored;281u16 ed_crs20L_deassertthld1_stored;282u16 ed_crs20U_assertthld0_stored;283u16 ed_crs20U_assertthld1_stored;284u16 ed_crs20U_deassertthld0_stored;285u16 ed_crs20U_deassertthld1_stored;286287u16 badplcp_ma;288u16 badplcp_ma_previous;289u16 badplcp_ma_total;290u16 badplcp_ma_list[MA_WINDOW_SZ];291int badplcp_ma_index;292s16 pre_badplcp_cnt;293s16 bphy_pre_badplcp_cnt;294295u16 init_gain_core1;296u16 init_gain_core2;297u16 init_gainb_core1;298u16 init_gainb_core2;299u16 init_gain_rfseq[4];300301u16 crsminpwr0;302u16 crsminpwrl0;303u16 crsminpwru0;304305s16 crsminpwr_index;306307u16 radio_2057_core1_rssi_wb1a_gc_stored;308u16 radio_2057_core2_rssi_wb1a_gc_stored;309u16 radio_2057_core1_rssi_wb1g_gc_stored;310u16 radio_2057_core2_rssi_wb1g_gc_stored;311u16 radio_2057_core1_rssi_wb2_gc_stored;312u16 radio_2057_core2_rssi_wb2_gc_stored;313u16 radio_2057_core1_rssi_nb_gc_stored;314u16 radio_2057_core2_rssi_nb_gc_stored;315};316317struct aci_save_gphy {318u16 rc_cal_ovr;319u16 phycrsth1;320u16 phycrsth2;321u16 init_n1p1_gain;322u16 p1_p2_gain;323u16 n1_n2_gain;324u16 n1_p1_gain;325u16 div_search_gain;326u16 div_p1_p2_gain;327u16 div_search_gn_change;328u16 table_7_2;329u16 table_7_3;330u16 cckshbits_gnref;331u16 clip_thresh;332u16 clip2_thresh;333u16 clip3_thresh;334u16 clip_p2_thresh;335u16 clip_pwdn_thresh;336u16 clip_n1p1_thresh;337u16 clip_n1_pwdn_thresh;338u16 bbconfig;339u16 cthr_sthr_shdin;340u16 energy;341u16 clip_p1_p2_thresh;342u16 threshold;343u16 reg15;344u16 reg16;345u16 reg17;346u16 div_srch_idx;347u16 div_srch_p1_p2;348u16 div_srch_gn_back;349u16 ant_dwell;350u16 ant_wr_settle;351};352353struct lo_complex_abgphy_info {354s8 i;355s8 q;356};357358struct nphy_iq_comp {359s16 a0;360s16 b0;361s16 a1;362s16 b1;363};364365struct nphy_txpwrindex {366s8 index;367s8 index_internal;368s8 index_internal_save;369u16 AfectrlOverride;370u16 AfeCtrlDacGain;371u16 rad_gain;372u8 bbmult;373u16 iqcomp_a;374u16 iqcomp_b;375u16 locomp;376};377378struct txiqcal_cache {379380u16 txcal_coeffs_2G[8];381u16 txcal_radio_regs_2G[8];382struct nphy_iq_comp rxcal_coeffs_2G;383384u16 txcal_coeffs_5G[8];385u16 txcal_radio_regs_5G[8];386struct nphy_iq_comp rxcal_coeffs_5G;387};388389struct nphy_pwrctrl {390s8 max_pwr_2g;391s8 idle_targ_2g;392s16 pwrdet_2g_a1;393s16 pwrdet_2g_b0;394s16 pwrdet_2g_b1;395s8 max_pwr_5gm;396s8 idle_targ_5gm;397s8 max_pwr_5gh;398s8 max_pwr_5gl;399s16 pwrdet_5gm_a1;400s16 pwrdet_5gm_b0;401s16 pwrdet_5gm_b1;402s16 pwrdet_5gl_a1;403s16 pwrdet_5gl_b0;404s16 pwrdet_5gl_b1;405s16 pwrdet_5gh_a1;406s16 pwrdet_5gh_b0;407s16 pwrdet_5gh_b1;408s8 idle_targ_5gl;409s8 idle_targ_5gh;410s8 idle_tssi_2g;411s8 idle_tssi_5g;412s8 idle_tssi;413s16 a1;414s16 b0;415s16 b1;416};417418struct nphy_txgains {419u16 txlpf[2];420u16 txgm[2];421u16 pga[2];422u16 pad[2];423u16 ipa[2];424};425426#define PHY_NOISEVAR_BUFSIZE 10427428struct nphy_noisevar_buf {429int bufcount;430int tone_id[PHY_NOISEVAR_BUFSIZE];431u32 noise_vars[PHY_NOISEVAR_BUFSIZE];432u32 min_noise_vars[PHY_NOISEVAR_BUFSIZE];433};434435struct rssical_cache {436u16 rssical_radio_regs_2G[2];437u16 rssical_phyregs_2G[12];438439u16 rssical_radio_regs_5G[2];440u16 rssical_phyregs_5G[12];441};442443struct lcnphy_cal_results {444445u16 txiqlocal_a;446u16 txiqlocal_b;447u16 txiqlocal_didq;448u8 txiqlocal_ei0;449u8 txiqlocal_eq0;450u8 txiqlocal_fi0;451u8 txiqlocal_fq0;452453u16 txiqlocal_bestcoeffs[11];454u16 txiqlocal_bestcoeffs_valid;455456u32 papd_eps_tbl[PHY_PAPD_EPS_TBL_SIZE_LCNPHY];457u16 analog_gain_ref;458u16 lut_begin;459u16 lut_end;460u16 lut_step;461u16 rxcompdbm;462u16 papdctrl;463u16 sslpnCalibClkEnCtrl;464465u16 rxiqcal_coeff_a0;466u16 rxiqcal_coeff_b0;467};468469struct shared_phy {470struct brcms_phy *phy_head;471uint unit;472struct phy_shim_info *physhim;473uint corerev;474u32 machwcap;475bool up;476bool clk;477uint now;478u16 vid;479u16 did;480uint chip;481uint chiprev;482uint chippkg;483uint sromrev;484uint boardtype;485uint boardrev;486u32 boardflags;487u32 boardflags2;488uint fast_timer;489uint slow_timer;490uint glacial_timer;491u8 rx_antdiv;492s8 phy_noise_window[MA_WINDOW_SZ];493uint phy_noise_index;494u8 hw_phytxchain;495u8 hw_phyrxchain;496u8 phytxchain;497u8 phyrxchain;498u8 rssi_mode;499bool _rifs_phy;500};501502struct brcms_phy_pub {503uint phy_type;504uint phy_rev;505u8 phy_corenum;506u16 radioid;507u8 radiorev;508u8 radiover;509510uint coreflags;511uint ana_rev;512bool abgphy_encore;513};514515struct phy_func_ptr {516void (*init)(struct brcms_phy *);517void (*calinit)(struct brcms_phy *);518void (*chanset)(struct brcms_phy *, u16 chanspec);519void (*txpwrrecalc)(struct brcms_phy *);520int (*longtrn)(struct brcms_phy *, int);521void (*txiqccget)(struct brcms_phy *, u16 *, u16 *);522void (*txiqccset)(struct brcms_phy *, u16, u16);523u16 (*txloccget)(struct brcms_phy *);524void (*radioloftget)(struct brcms_phy *, u8 *, u8 *, u8 *, u8 *);525void (*carrsuppr)(struct brcms_phy *);526s32 (*rxsigpwr)(struct brcms_phy *, s32);527void (*detach)(struct brcms_phy *);528};529530struct brcms_phy {531struct brcms_phy_pub pubpi_ro;532struct shared_phy *sh;533struct phy_func_ptr pi_fptr;534535union {536struct brcms_phy_lcnphy *pi_lcnphy;537} u;538bool user_txpwr_at_rfport;539540struct bcma_device *d11core;541struct brcms_phy *next;542struct brcms_phy_pub pubpi;543544bool do_initcal;545bool phytest_on;546bool ofdm_rateset_war;547bool bf_preempt_4306;548u16 radio_chanspec;549u8 antsel_type;550u16 bw;551u8 txpwr_percent;552bool phy_init_por;553554bool init_in_progress;555bool initialized;556bool sbtml_gm;557uint refcnt;558bool watchdog_override;559u8 phynoise_state;560uint phynoise_now;561int phynoise_chan_watchdog;562bool phynoise_polling;563bool disable_percal;564u32 measure_hold;565566s16 txpa_2g[PWRTBL_NUM_COEFF];567s16 txpa_2g_low_temp[PWRTBL_NUM_COEFF];568s16 txpa_2g_high_temp[PWRTBL_NUM_COEFF];569s16 txpa_5g_low[PWRTBL_NUM_COEFF];570s16 txpa_5g_mid[PWRTBL_NUM_COEFF];571s16 txpa_5g_hi[PWRTBL_NUM_COEFF];572573u8 tx_srom_max_2g;574u8 tx_srom_max_5g_low;575u8 tx_srom_max_5g_mid;576u8 tx_srom_max_5g_hi;577u8 tx_srom_max_rate_2g[TXP_NUM_RATES];578u8 tx_srom_max_rate_5g_low[TXP_NUM_RATES];579u8 tx_srom_max_rate_5g_mid[TXP_NUM_RATES];580u8 tx_srom_max_rate_5g_hi[TXP_NUM_RATES];581u8 tx_user_target[TXP_NUM_RATES];582s8 tx_power_offset[TXP_NUM_RATES];583u8 tx_power_target[TXP_NUM_RATES];584585struct brcms_phy_srom_fem srom_fem2g;586struct brcms_phy_srom_fem srom_fem5g;587588u8 tx_power_max;589u8 tx_power_max_rate_ind;590bool hwpwrctrl;591u8 nphy_txpwrctrl;592s8 nphy_txrx_chain;593bool phy_5g_pwrgain;594595u16 phy_wreg;596u16 phy_wreg_limit;597598s8 n_preamble_override;599u8 antswitch;600u8 aa2g, aa5g;601602s8 idle_tssi[CH_5G_GROUP];603s8 target_idle_tssi;604s8 txpwr_est_Pout;605u8 tx_power_min;606u8 txpwr_limit[TXP_NUM_RATES];607u8 txpwr_env_limit[TXP_NUM_RATES];608u8 adj_pwr_tbl_nphy[ADJ_PWR_TBL_LEN];609610bool channel_14_wide_filter;611612bool txpwroverride;613bool txpwridx_override_aphy;614s16 radiopwr_override;615u16 hwpwr_txcur;616u8 saved_txpwr_idx;617618bool edcrs_threshold_lock;619620u32 tr_R_gain_val;621u32 tr_T_gain_val;622623s16 ofdm_analog_filt_bw_override;624s16 cck_analog_filt_bw_override;625s16 ofdm_rccal_override;626s16 cck_rccal_override;627u16 extlna_type;628629uint interference_mode_crs_time;630u16 crsglitch_prev;631bool interference_mode_crs;632633u32 phy_tx_tone_freq;634uint phy_lastcal;635bool phy_forcecal;636bool phy_fixed_noise;637u32 xtalfreq;638u8 pdiv;639s8 carrier_suppr_disable;640641bool phy_bphy_evm;642bool phy_bphy_rfcs;643s8 phy_scraminit;644u8 phy_gpiosel;645646s16 phy_txcore_disable_temp;647s16 phy_txcore_enable_temp;648s8 phy_tempsense_offset;649bool phy_txcore_heatedup;650651u16 radiopwr;652u16 bb_atten;653u16 txctl1;654655u16 mintxbias;656u16 mintxmag;657struct lo_complex_abgphy_info gphy_locomp_iq658[STATIC_NUM_RF][STATIC_NUM_BB];659s8 stats_11b_txpower[STATIC_NUM_RF][STATIC_NUM_BB];660u16 gain_table[TX_GAIN_TABLE_LENGTH];661bool loopback_gain;662s16 max_lpback_gain_hdB;663s16 trsw_rx_gain_hdB;664u8 power_vec[8];665666u16 rc_cal;667int nrssi_table_delta;668int nrssi_slope_scale;669int nrssi_slope_offset;670int min_rssi;671int max_rssi;672673s8 txpwridx;674u8 min_txpower;675676u8 a_band_high_disable;677678u16 tx_vos;679u16 global_tx_bb_dc_bias_loft;680681int rf_max;682int bb_max;683int rf_list_size;684int bb_list_size;685u16 *rf_attn_list;686u16 *bb_attn_list;687u16 padmix_mask;688u16 padmix_reg;689u16 *txmag_list;690uint txmag_len;691bool txmag_enable;692693s8 *a_tssi_to_dbm;694s8 *m_tssi_to_dbm;695s8 *l_tssi_to_dbm;696s8 *h_tssi_to_dbm;697u8 *hwtxpwr;698699u16 freqtrack_saved_regs[2];700int cur_interference_mode;701bool hwpwrctrl_capable;702bool temppwrctrl_capable;703704uint phycal_nslope;705uint phycal_noffset;706uint phycal_mlo;707uint phycal_txpower;708709u8 phy_aa2g;710711bool nphy_tableloaded;712s8 nphy_rssisel;713u32 nphy_bb_mult_save;714u16 nphy_txiqlocal_bestc[11];715bool nphy_txiqlocal_coeffsvalid;716struct nphy_txpwrindex nphy_txpwrindex[PHY_CORE_NUM_2];717struct nphy_pwrctrl nphy_pwrctrl_info[PHY_CORE_NUM_2];718u16 cck2gpo;719u32 ofdm2gpo;720u32 ofdm5gpo;721u32 ofdm5glpo;722u32 ofdm5ghpo;723u8 bw402gpo;724u8 bw405gpo;725u8 bw405glpo;726u8 bw405ghpo;727u8 cdd2gpo;728u8 cdd5gpo;729u8 cdd5glpo;730u8 cdd5ghpo;731u8 stbc2gpo;732u8 stbc5gpo;733u8 stbc5glpo;734u8 stbc5ghpo;735u8 bwdup2gpo;736u8 bwdup5gpo;737u8 bwdup5glpo;738u8 bwdup5ghpo;739u16 mcs2gpo[8];740u16 mcs5gpo[8];741u16 mcs5glpo[8];742u16 mcs5ghpo[8];743u32 nphy_rxcalparams;744745u8 phy_spuravoid;746bool phy_isspuravoid;747748u8 phy_pabias;749u8 nphy_papd_skip;750u8 nphy_tssi_slope;751752s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ];753u8 nphy_noise_index;754755bool nphy_gain_boost;756bool nphy_elna_gain_config;757u16 old_bphy_test;758u16 old_bphy_testcontrol;759760bool phyhang_avoid;761762bool rssical_nphy;763u8 nphy_perical;764uint nphy_perical_last;765u8 cal_type_override;766u8 mphase_cal_phase_id;767u8 mphase_txcal_cmdidx;768u8 mphase_txcal_numcmds;769u16 mphase_txcal_bestcoeffs[11];770u16 nphy_txiqlocal_chanspec;771u16 nphy_iqcal_chanspec_2G;772u16 nphy_iqcal_chanspec_5G;773u16 nphy_rssical_chanspec_2G;774u16 nphy_rssical_chanspec_5G;775struct wlapi_timer *phycal_timer;776bool use_int_tx_iqlo_cal_nphy;777bool internal_tx_iqlo_cal_tapoff_intpa_nphy;778s16 nphy_lastcal_temp;779780struct txiqcal_cache calibration_cache;781struct rssical_cache rssical_cache;782783u8 nphy_txpwr_idx[2];784u8 nphy_papd_cal_type;785uint nphy_papd_last_cal;786u16 nphy_papd_tx_gain_at_last_cal[2];787u8 nphy_papd_cal_gain_index[2];788s16 nphy_papd_epsilon_offset[2];789bool nphy_papd_recal_enable;790u32 nphy_papd_recal_counter;791bool nphy_force_papd_cal;792bool nphy_papdcomp;793bool ipa2g_on;794bool ipa5g_on;795796u16 classifier_state;797u16 clip_state[2];798uint nphy_deaf_count;799u8 rxiq_samps;800u8 rxiq_antsel;801802u16 rfctrlIntc1_save;803u16 rfctrlIntc2_save;804bool first_cal_after_assoc;805u16 tx_rx_cal_radio_saveregs[22];806u16 tx_rx_cal_phy_saveregs[15];807808u8 nphy_cal_orig_pwr_idx[2];809u8 nphy_txcal_pwr_idx[2];810u8 nphy_rxcal_pwr_idx[2];811u16 nphy_cal_orig_tx_gain[2];812struct nphy_txgains nphy_cal_target_gain;813u16 nphy_txcal_bbmult;814u16 nphy_gmval;815816u16 nphy_saved_bbconf;817818bool nphy_gband_spurwar_en;819bool nphy_gband_spurwar2_en;820bool nphy_aband_spurwar_en;821u16 nphy_rccal_value;822u16 nphy_crsminpwr[3];823struct nphy_noisevar_buf nphy_saved_noisevars;824bool nphy_anarxlpf_adjusted;825bool nphy_crsminpwr_adjusted;826bool nphy_noisevars_adjusted;827828bool nphy_rxcal_active;829u16 radar_percal_mask;830bool dfs_lp_buffer_nphy;831832u16 nphy_fineclockgatecontrol;833834s8 rx2tx_biasentry;835836u16 crsminpwr0;837u16 crsminpwrl0;838u16 crsminpwru0;839s16 noise_crsminpwr_index;840u16 init_gain_core1;841u16 init_gain_core2;842u16 init_gainb_core1;843u16 init_gainb_core2;844u8 aci_noise_curr_channel;845u16 init_gain_rfseq[4];846847bool radio_is_on;848849bool nphy_sample_play_lpf_bw_ctl_ovr;850851u16 tbl_data_hi;852u16 tbl_data_lo;853u16 tbl_addr;854855uint tbl_save_id;856uint tbl_save_offset;857858u8 txpwrctrl;859s8 txpwrindex[PHY_CORE_MAX];860861u8 phycal_tempdelta;862u32 mcs20_po;863u32 mcs40_po;864struct wiphy *wiphy;865};866867struct cs32 {868s32 q;869s32 i;870};871872struct radio_regs {873u16 address;874u32 init_a;875u32 init_g;876u8 do_init_a;877u8 do_init_g;878};879880struct radio_20xx_regs {881u16 address;882u8 init;883u8 do_init;884};885886struct lcnphy_radio_regs {887u16 address;888u8 init_a;889u8 init_g;890u8 do_init_a;891u8 do_init_g;892};893894u16 read_phy_reg(struct brcms_phy *pi, u16 addr);895void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);896void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);897void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);898void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);899900u16 read_radio_reg(struct brcms_phy *pi, u16 addr);901void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);902void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);903void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);904void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask);905906void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);907908void wlc_phyreg_enter(struct brcms_phy_pub *pih);909void wlc_phyreg_exit(struct brcms_phy_pub *pih);910911void wlc_phy_read_table(struct brcms_phy *pi,912const struct phytbl_info *ptbl_info,913u16 tblAddr, u16 tblDataHi, u16 tblDatalo);914void wlc_phy_write_table(struct brcms_phy *pi,915const struct phytbl_info *ptbl_info,916u16 tblAddr, u16 tblDataHi, u16 tblDatalo);917void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset,918u16 tblAddr, u16 tblDataHi, u16 tblDataLo);919void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);920921void wlc_phy_txpower_update_shm(struct brcms_phy *pi);922923u8 wlc_phy_nbits(s32 value);924void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);925926uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi,927struct radio_20xx_regs *radioregs);928uint wlc_phy_init_radio_regs(struct brcms_phy *pi,929const struct radio_regs *radioregs,930u16 core_offset);931932void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi);933934void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on);935void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, s32 *eps_imag);936937void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi);938void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi);939940void wlc_phy_attach_nphy(struct brcms_phy *pi);941bool wlc_phy_attach_lcnphy(struct brcms_phy *pi);942943void wlc_phy_detach_lcnphy(struct brcms_phy *pi);944945void wlc_phy_init_nphy(struct brcms_phy *pi);946void wlc_phy_init_lcnphy(struct brcms_phy *pi);947948void wlc_phy_cal_init_nphy(struct brcms_phy *pi);949void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi);950951void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec);952void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec);953void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi, u16 chanspec);954int wlc_phy_channel2freq(uint channel);955int wlc_phy_chanspec_freq2bandrange_lpssn(uint);956int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec);957958void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode);959s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi);960961void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi);962void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi);963void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi);964965void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index);966void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable);967void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi);968void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val,969bool iqcalmode);970971void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan,972u8 *max_pwr, u8 rate_id);973void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start,974u8 rate_mcs_end, u8 rate_ofdm_start);975void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power, u8 rate_ofdm_start,976u8 rate_ofdm_end, u8 rate_mcs_start);977978u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode);979s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode);980s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode);981s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode);982void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi);983void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel);984void wlc_2064_vco_cal(struct brcms_phy *pi);985986void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);987988#define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18989#define LCNPHY_TX_POWER_TABLE_SIZE 128990#define LCNPHY_MAX_TX_POWER_INDEX (LCNPHY_TX_POWER_TABLE_SIZE - 1)991#define LCNPHY_TBL_ID_TXPWRCTL 0x07992#define LCNPHY_TX_PWR_CTRL_OFF 0993#define LCNPHY_TX_PWR_CTRL_SW (0x1 << 15)994#define LCNPHY_TX_PWR_CTRL_HW ((0x1 << 15) | \995(0x1 << 14) | \996(0x1 << 13))997998#define LCNPHY_TX_PWR_CTRL_TEMPBASED 0xE0019991000void wlc_lcnphy_write_table(struct brcms_phy *pi,1001const struct phytbl_info *pti);1002void wlc_lcnphy_read_table(struct brcms_phy *pi, struct phytbl_info *pti);1003void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b);1004void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq);1005void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b);1006u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi);1007void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0, u8 *eq0, u8 *fi0,1008u8 *fq0);1009void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode);1010void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode);1011bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi);1012void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi);1013s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1);1014void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr, s8 *cck_pwr);1015void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi);10161017s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index);10181019#define NPHY_MAX_HPVGA1_INDEX 101020#define NPHY_DEF_HPVGA1_INDEXLIMIT 710211022struct phy_iq_est {1023s32 iq_prod;1024u32 i_pwr;1025u32 q_pwr;1026};10271028void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, bool enable);10291030#define wlc_phy_write_table_nphy(pi, pti) \1031wlc_phy_write_table(pi, pti, 0x72, 0x74, 0x73)10321033#define wlc_phy_read_table_nphy(pi, pti) \1034wlc_phy_read_table(pi, pti, 0x72, 0x74, 0x73)10351036#define wlc_nphy_table_addr(pi, id, off) \1037wlc_phy_table_addr((pi), (id), (off), 0x72, 0x74, 0x73)10381039#define wlc_nphy_table_data_write(pi, w, v) \1040wlc_phy_table_data_write((pi), (w), (v))10411042void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o, u32 w,1043void *d);1044void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32, u32,1045const void *);10461047#define PHY_IPA(pi) \1048((pi->ipa2g_on && CHSPEC_IS2G(pi->radio_chanspec)) || \1049(pi->ipa5g_on && CHSPEC_IS5G(pi->radio_chanspec)))10501051#define BRCMS_PHY_WAR_PR51571(pi) \1052if (NREV_LT((pi)->pubpi.phy_rev, 3)) \1053(void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol))10541055void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype);1056void wlc_phy_aci_reset_nphy(struct brcms_phy *pi);1057void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en);10581059u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan);1060void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on);10611062void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi);10631064void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd);1065s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi);10661067u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val);10681069void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est,1070u16 num_samps, u8 wait_time, u8 wait_for_crs);10711072void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write,1073struct nphy_iq_comp *comp);1074void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi);10751076void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask);1077u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih);10781079void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type);1080void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi);1081void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi);1082void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi);1083u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi);10841085struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi);1086int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi,1087struct nphy_txgains target_gain, bool full, bool m);1088int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain,1089u8 type, bool d);1090void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask,1091s8 txpwrindex, bool res);1092void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type);1093int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type,1094s32 *rssi_buf, u8 nsamps);1095void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi);1096int wlc_phy_aci_scan_nphy(struct brcms_phy *pi);1097void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower,1098bool debug);1099int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u8 mode,1100u8, bool);1101void wlc_phy_stopplayback_nphy(struct brcms_phy *pi);1102void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf,1103u8 num_samps);1104void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi);11051106int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh);11071108#define NPHY_TESTPATTERN_BPHY_EVM 01109#define NPHY_TESTPATTERN_BPHY_RFCS 111101111void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs);1112#endif /* _BRCM_PHY_INT_H_ */111311141115