linux/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_int.h

// SPDX-License-Identifier: ISC
/*
 * Copyright (c) 2010 Broadcom Corporation
 */

#ifndef _BRCM_PHY_INT_H_
#define _BRCM_PHY_INT_H_

#include <types.h>
#include <brcmu_utils.h>
#include <brcmu_wifi.h>

#define PHY_VERSION

#define LCNXN_BASEREV

struct phy_shim_info;

struct brcms_phy_srom_fem {};

#define ISNPHY(pi)
#define ISLCNPHY(pi)

#define PHY_GET_RFATTN(rfgain)
#define PHY_GET_PADMIX(rfgain)
#define PHY_GET_RFGAINID(rfattn, padmix, width)
#define PHY_SAT(x, n)
#define PHY_SHIFT_ROUND(x, n)
#define PHY_HW_ROUND(x, s)

#define CH_5G_GROUP
#define A_LOW_CHANS
#define A_MID_CHANS
#define A_HIGH_CHANS
#define CH_2G_GROUP
#define G_ALL_CHANS

#define FIRST_REF5_CHANNUM
#define LAST_REF5_CHANNUM
#define FIRST_5G_CHAN
#define LAST_5G_CHAN
#define FIRST_MID_5G_CHAN
#define LAST_MID_5G_CHAN
#define FIRST_HIGH_5G_CHAN
#define LAST_HIGH_5G_CHAN
#define FIRST_LOW_5G_CHAN
#define LAST_LOW_5G_CHAN

#define BASE_LOW_5G_CHAN
#define BASE_MID_5G_CHAN
#define BASE_HIGH_5G_CHAN

#define CHAN5G_FREQ(chan)
#define CHAN2G_FREQ(chan)

#define TXP_FIRST_CCK
#define TXP_LAST_CCK
#define TXP_FIRST_OFDM
#define TXP_LAST_OFDM
#define TXP_FIRST_OFDM_20_CDD
#define TXP_LAST_OFDM_20_CDD
#define TXP_FIRST_MCS_20_SISO
#define TXP_LAST_MCS_20_SISO
#define TXP_FIRST_MCS_20_CDD
#define TXP_LAST_MCS_20_CDD
#define TXP_FIRST_MCS_20_STBC
#define TXP_LAST_MCS_20_STBC
#define TXP_FIRST_MCS_20_SDM
#define TXP_LAST_MCS_20_SDM
#define TXP_FIRST_OFDM_40_SISO
#define TXP_LAST_OFDM_40_SISO
#define TXP_FIRST_OFDM_40_CDD
#define TXP_LAST_OFDM_40_CDD
#define TXP_FIRST_MCS_40_SISO
#define TXP_LAST_MCS_40_SISO
#define TXP_FIRST_MCS_40_CDD
#define TXP_LAST_MCS_40_CDD
#define TXP_FIRST_MCS_40_STBC
#define TXP_LAST_MCS_40_STBC
#define TXP_FIRST_MCS_40_SDM
#define TXP_LAST_MCS_40_SDM
#define TXP_MCS_32
#define TXP_NUM_RATES
#define ADJ_PWR_TBL_LEN

#define TXP_FIRST_SISO_MCS_20
#define TXP_LAST_SISO_MCS_20

#define PHY_CORE_NUM_1
#define PHY_CORE_NUM_2
#define PHY_CORE_NUM_3
#define PHY_CORE_NUM_4
#define PHY_CORE_MAX
#define PHY_CORE_0
#define PHY_CORE_1
#define PHY_CORE_2
#define PHY_CORE_3

#define MA_WINDOW_SZ

#define PHY_NOISE_SAMPLE_MON
#define PHY_NOISE_SAMPLE_EXTERNAL
#define PHY_NOISE_WINDOW_SZ
#define PHY_NOISE_GLITCH_INIT_MA
#define PHY_NOISE_GLITCH_INIT_MA_BADPlCP
#define PHY_NOISE_STATE_MON
#define PHY_NOISE_STATE_EXTERNAL
#define PHY_NOISE_SAMPLE_LOG_NUM_NPHY
#define PHY_NOISE_SAMPLE_LOG_NUM_UCODE

#define PHY_NOISE_OFFSETFACT_4322
#define PHY_NOISE_MA_WINDOW_SZ

#define PHY_RSSI_TABLE_SIZE
#define RSSI_ANT_MERGE_MAX
#define RSSI_ANT_MERGE_MIN
#define RSSI_ANT_MERGE_AVG

#define PHY_TSSI_TABLE_SIZE
#define APHY_TSSI_TABLE_SIZE
#define TX_GAIN_TABLE_LENGTH
#define DEFAULT_11A_TXP_IDX
#define NUM_TSSI_FRAMES
#define NULL_TSSI
#define NULL_TSSI_W

#define PHY_PAPD_EPS_TBL_SIZE_LCNPHY

#define LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL

#define PHY_TXPWR_MIN
#define PHY_TXPWR_MIN_NPHY
#define RADIOPWR_OVERRIDE_DEF

#define PWRTBL_NUM_COEFF

#define SPURAVOID_DISABLE
#define SPURAVOID_AUTO
#define SPURAVOID_FORCEON
#define SPURAVOID_FORCEON2

#define PHY_SW_TIMER_FAST
#define PHY_SW_TIMER_SLOW
#define PHY_SW_TIMER_GLACIAL

#define PHY_PERICAL_AUTO
#define PHY_PERICAL_FULL
#define PHY_PERICAL_PARTIAL

#define PHY_PERICAL_NODELAY
#define PHY_PERICAL_INIT_DELAY
#define PHY_PERICAL_ASSOC_DELAY
#define PHY_PERICAL_WDOG_DELAY

#define MPHASE_TXCAL_NUMCMDS

#define PHY_PERICAL_MPHASE_PENDING(pi)

enum {};

enum phy_cal_mode {};

#define RDR_NTIERS
#define RDR_TIER_SIZE
#define RDR_LIST_SIZE
#define RDR_EPOCH_SIZE
#define RDR_NANTENNAS
#define RDR_NTIER_SIZE
#define RDR_LP_BUFFER_SIZE
#define LP_LEN_HIS_SIZE

#define STATIC_NUM_RF
#define STATIC_NUM_BB

#define BB_MULT_MASK
#define BB_MULT_VALID_MASK

#define PHY_CHAIN_TX_DISABLE_TEMP
#define PHY_HYSTERESIS_DELTATEMP

#define SCAN_INPROG_PHY(pi)

#define PLT_INPROG_PHY(pi)

#define ASSOC_INPROG_PHY(pi)

#define SCAN_RM_IN_PROGRESS(pi)

#define PHY_MUTED(pi)

#define PUB_NOT_ASSOC(pi)

struct phy_table_info {};

struct phytbl_info {};

struct interference_info {};

struct aci_save_gphy {};

struct lo_complex_abgphy_info {};

struct nphy_iq_comp {};

struct nphy_txpwrindex {};

struct txiqcal_cache {};

struct nphy_pwrctrl {};

struct nphy_txgains {};

#define PHY_NOISEVAR_BUFSIZE

struct nphy_noisevar_buf {};

struct rssical_cache {};

struct lcnphy_cal_results {};

struct shared_phy {};

struct brcms_phy_pub {};

struct phy_func_ptr {};

struct brcms_phy {};

struct cs32 {};

struct radio_regs {};

struct radio_20xx_regs {};

struct lcnphy_radio_regs {};

u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);

u16 read_radio_reg(struct brcms_phy *pi, u16 addr);
void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask);

void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);

void wlc_phyreg_enter(struct brcms_phy_pub *pih);
void wlc_phyreg_exit(struct brcms_phy_pub *pih);
void wlc_radioreg_enter(struct brcms_phy_pub *pih);
void wlc_radioreg_exit(struct brcms_phy_pub *pih);

void wlc_phy_read_table(struct brcms_phy *pi,
			const struct phytbl_info *ptbl_info,
			u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
void wlc_phy_write_table(struct brcms_phy *pi,
			 const struct phytbl_info *ptbl_info,
			 u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset,
			u16 tblAddr, u16 tblDataHi, u16 tblDataLo);
void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);

void write_phy_channel_reg(struct brcms_phy *pi, uint val);
void wlc_phy_txpower_update_shm(struct brcms_phy *pi);

u8 wlc_phy_nbits(s32 value);
void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);

uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi,
				      struct radio_20xx_regs *radioregs);
uint wlc_phy_init_radio_regs(struct brcms_phy *pi,
			     const struct radio_regs *radioregs,
			     u16 core_offset);

void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi);

void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on);
void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, s32 *eps_imag);

void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi);
void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi);

void wlc_phy_attach_nphy(struct brcms_phy *pi);
bool wlc_phy_attach_lcnphy(struct brcms_phy *pi);

void wlc_phy_detach_lcnphy(struct brcms_phy *pi);

void wlc_phy_init_nphy(struct brcms_phy *pi);
void wlc_phy_init_lcnphy(struct brcms_phy *pi);

void wlc_phy_cal_init_nphy(struct brcms_phy *pi);
void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi);

void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec);
void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec);
void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi, u16 chanspec);
int wlc_phy_channel2freq(uint channel);
int wlc_phy_chanspec_freq2bandrange_lpssn(uint);
int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec);

void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode);
s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi);

void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi);
void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi);
void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi);

void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index);
void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable);
void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi);
void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val,
			      bool iqcalmode);

void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan,
					u8 *max_pwr, u8 rate_id);
void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start,
				     u8 rate_mcs_end, u8 rate_ofdm_start);
void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power, u8 rate_ofdm_start,
				     u8 rate_ofdm_end, u8 rate_mcs_start);

u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode);
s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode);
s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode);
s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode);
void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi);
void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel);
void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode);
void wlc_2064_vco_cal(struct brcms_phy *pi);

void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);

#define LCNPHY_TBL_ID_PAPDCOMPDELTATBL
#define LCNPHY_TX_POWER_TABLE_SIZE
#define LCNPHY_MAX_TX_POWER_INDEX
#define LCNPHY_TBL_ID_TXPWRCTL
#define LCNPHY_TX_PWR_CTRL_OFF
#define LCNPHY_TX_PWR_CTRL_SW
#define LCNPHY_TX_PWR_CTRL_HW

#define LCNPHY_TX_PWR_CTRL_TEMPBASED

void wlc_lcnphy_write_table(struct brcms_phy *pi,
			    const struct phytbl_info *pti);
void wlc_lcnphy_read_table(struct brcms_phy *pi, struct phytbl_info *pti);
void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b);
void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq);
void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b);
u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi);
void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0, u8 *eq0, u8 *fi0,
			       u8 *fq0);
void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode);
void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode);
bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi);
void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi);
s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1);
void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr, s8 *cck_pwr);
void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi);

s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index);

#define NPHY_MAX_HPVGA1_INDEX
#define NPHY_DEF_HPVGA1_INDEXLIMIT

struct phy_iq_est {};

void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, bool enable);
void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode);

#define wlc_phy_write_table_nphy(pi, pti)

#define wlc_phy_read_table_nphy(pi, pti)

#define wlc_nphy_table_addr(pi, id, off)

#define wlc_nphy_table_data_write(pi, w, v)

void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o, u32 w,
			     void *d);
void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32, u32,
			      const void *);

#define PHY_IPA(pi)

#define BRCMS_PHY_WAR_PR51571(pi)

void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype);
void wlc_phy_aci_reset_nphy(struct brcms_phy *pi);
void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en);

u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan);
void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on);

void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi);

void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd);
s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi);

u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val);

void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est,
			    u16 num_samps, u8 wait_time, u8 wait_for_crs);

void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write,
			       struct nphy_iq_comp *comp);
void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi);

void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask);
u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih);

void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type);
void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi);
void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi);
void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi);
u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi);

struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi);
int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi,
			    struct nphy_txgains target_gain, bool full, bool m);
int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain,
			  u8 type, bool d);
void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask,
			      s8 txpwrindex, bool res);
void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type);
int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type,
			   s32 *rssi_buf, u8 nsamps);
void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi);
int wlc_phy_aci_scan_nphy(struct brcms_phy *pi);
void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower,
				 bool debug);
int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u8 mode,
			 u8, bool);
void wlc_phy_stopplayback_nphy(struct brcms_phy *pi);
void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf,
			      u8 num_samps);
void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi);

int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh);

#define NPHY_TESTPATTERN_BPHY_EVM
#define NPHY_TESTPATTERN_BPHY_RFCS

void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs);

void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset,
				s8 *ofdmoffset);
s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, u16 chanspec);

bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih);
#endif				/* _BRCM_PHY_INT_H_ */