1*b4c3e9b5SBjoern A. Zeeb // SPDX-License-Identifier: ISC 2*b4c3e9b5SBjoern A. Zeeb /* 3*b4c3e9b5SBjoern A. Zeeb * Copyright (c) 2010 Broadcom Corporation 4*b4c3e9b5SBjoern A. Zeeb */ 5*b4c3e9b5SBjoern A. Zeeb 6*b4c3e9b5SBjoern A. Zeeb /* 7*b4c3e9b5SBjoern A. Zeeb * phy_hal.h: functionality exported from the phy to higher layers 8*b4c3e9b5SBjoern A. Zeeb */ 9*b4c3e9b5SBjoern A. Zeeb 10*b4c3e9b5SBjoern A. Zeeb #ifndef _BRCM_PHY_HAL_H_ 11*b4c3e9b5SBjoern A. Zeeb #define _BRCM_PHY_HAL_H_ 12*b4c3e9b5SBjoern A. Zeeb 13*b4c3e9b5SBjoern A. Zeeb #include <brcmu_utils.h> 14*b4c3e9b5SBjoern A. Zeeb #include <brcmu_wifi.h> 15*b4c3e9b5SBjoern A. Zeeb #include <phy_shim.h> 16*b4c3e9b5SBjoern A. Zeeb 17*b4c3e9b5SBjoern A. Zeeb #define IDCODE_VER_MASK 0x0000000f 18*b4c3e9b5SBjoern A. Zeeb #define IDCODE_VER_SHIFT 0 19*b4c3e9b5SBjoern A. Zeeb #define IDCODE_MFG_MASK 0x00000fff 20*b4c3e9b5SBjoern A. Zeeb #define IDCODE_MFG_SHIFT 0 21*b4c3e9b5SBjoern A. Zeeb #define IDCODE_ID_MASK 0x0ffff000 22*b4c3e9b5SBjoern A. Zeeb #define IDCODE_ID_SHIFT 12 23*b4c3e9b5SBjoern A. Zeeb #define IDCODE_REV_MASK 0xf0000000 24*b4c3e9b5SBjoern A. Zeeb #define IDCODE_REV_SHIFT 28 25*b4c3e9b5SBjoern A. Zeeb 26*b4c3e9b5SBjoern A. Zeeb #define NORADIO_ID 0xe4f5 27*b4c3e9b5SBjoern A. Zeeb #define NORADIO_IDCODE 0x4e4f5246 28*b4c3e9b5SBjoern A. Zeeb 29*b4c3e9b5SBjoern A. Zeeb #define BCM2055_ID 0x2055 30*b4c3e9b5SBjoern A. Zeeb #define BCM2055_IDCODE 0x02055000 31*b4c3e9b5SBjoern A. Zeeb #define BCM2055A0_IDCODE 0x1205517f 32*b4c3e9b5SBjoern A. Zeeb 33*b4c3e9b5SBjoern A. Zeeb #define BCM2056_ID 0x2056 34*b4c3e9b5SBjoern A. Zeeb #define BCM2056_IDCODE 0x02056000 35*b4c3e9b5SBjoern A. Zeeb #define BCM2056A0_IDCODE 0x1205617f 36*b4c3e9b5SBjoern A. Zeeb 37*b4c3e9b5SBjoern A. Zeeb #define BCM2057_ID 0x2057 38*b4c3e9b5SBjoern A. Zeeb #define BCM2057_IDCODE 0x02057000 39*b4c3e9b5SBjoern A. Zeeb #define BCM2057A0_IDCODE 0x1205717f 40*b4c3e9b5SBjoern A. Zeeb 41*b4c3e9b5SBjoern A. Zeeb #define BCM2064_ID 0x2064 42*b4c3e9b5SBjoern A. Zeeb #define BCM2064_IDCODE 0x02064000 43*b4c3e9b5SBjoern A. Zeeb #define BCM2064A0_IDCODE 0x0206417f 44*b4c3e9b5SBjoern A. Zeeb 45*b4c3e9b5SBjoern A. Zeeb #define PHY_TPC_HW_OFF false 46*b4c3e9b5SBjoern A. Zeeb #define PHY_TPC_HW_ON true 47*b4c3e9b5SBjoern A. Zeeb 48*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_DRIVERUP 1 49*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_WATCHDOG 2 50*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_PHYINIT 3 51*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_JOIN_BSS 4 52*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_START_IBSS 5 53*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_UP_BSS 6 54*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_CHAN 7 55*b4c3e9b5SBjoern A. Zeeb #define PHY_FULLCAL 8 56*b4c3e9b5SBjoern A. Zeeb 57*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_DISABLE 0 58*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_SPHASE 1 59*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_MPHASE 2 60*b4c3e9b5SBjoern A. Zeeb #define PHY_PERICAL_MANUAL 3 61*b4c3e9b5SBjoern A. Zeeb 62*b4c3e9b5SBjoern A. Zeeb #define PHY_HOLD_FOR_ASSOC 1 63*b4c3e9b5SBjoern A. Zeeb #define PHY_HOLD_FOR_SCAN 2 64*b4c3e9b5SBjoern A. Zeeb #define PHY_HOLD_FOR_RM 4 65*b4c3e9b5SBjoern A. Zeeb #define PHY_HOLD_FOR_PLT 8 66*b4c3e9b5SBjoern A. Zeeb #define PHY_HOLD_FOR_MUTE 16 67*b4c3e9b5SBjoern A. Zeeb #define PHY_HOLD_FOR_NOT_ASSOC 0x20 68*b4c3e9b5SBjoern A. Zeeb 69*b4c3e9b5SBjoern A. Zeeb #define PHY_MUTE_FOR_PREISM 1 70*b4c3e9b5SBjoern A. Zeeb #define PHY_MUTE_ALL 0xffffffff 71*b4c3e9b5SBjoern A. Zeeb 72*b4c3e9b5SBjoern A. Zeeb #define PHY_NOISE_FIXED_VAL (-95) 73*b4c3e9b5SBjoern A. Zeeb #define PHY_NOISE_FIXED_VAL_NPHY (-92) 74*b4c3e9b5SBjoern A. Zeeb #define PHY_NOISE_FIXED_VAL_LCNPHY (-92) 75*b4c3e9b5SBjoern A. Zeeb 76*b4c3e9b5SBjoern A. Zeeb #define PHY_MODE_CAL 0x0002 77*b4c3e9b5SBjoern A. Zeeb #define PHY_MODE_NOISEM 0x0004 78*b4c3e9b5SBjoern A. Zeeb 79*b4c3e9b5SBjoern A. Zeeb #define BRCMS_TXPWR_DB_FACTOR 4 80*b4c3e9b5SBjoern A. Zeeb 81*b4c3e9b5SBjoern A. Zeeb /* a large TX Power as an init value to factor out of min() calculations, 82*b4c3e9b5SBjoern A. Zeeb * keep low enough to fit in an s8, units are .25 dBm 83*b4c3e9b5SBjoern A. Zeeb */ 84*b4c3e9b5SBjoern A. Zeeb #define BRCMS_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */ 85*b4c3e9b5SBjoern A. Zeeb 86*b4c3e9b5SBjoern A. Zeeb #define BRCMS_NUM_RATES_CCK 4 87*b4c3e9b5SBjoern A. Zeeb #define BRCMS_NUM_RATES_OFDM 8 88*b4c3e9b5SBjoern A. Zeeb #define BRCMS_NUM_RATES_MCS_1_STREAM 8 89*b4c3e9b5SBjoern A. Zeeb #define BRCMS_NUM_RATES_MCS_2_STREAM 8 90*b4c3e9b5SBjoern A. Zeeb #define BRCMS_NUM_RATES_MCS_3_STREAM 8 91*b4c3e9b5SBjoern A. Zeeb #define BRCMS_NUM_RATES_MCS_4_STREAM 8 92*b4c3e9b5SBjoern A. Zeeb 93*b4c3e9b5SBjoern A. Zeeb #define BRCMS_RSSI_INVALID 0 /* invalid RSSI value */ 94*b4c3e9b5SBjoern A. Zeeb 95*b4c3e9b5SBjoern A. Zeeb struct d11regs; 96*b4c3e9b5SBjoern A. Zeeb struct phy_shim_info; 97*b4c3e9b5SBjoern A. Zeeb 98*b4c3e9b5SBjoern A. Zeeb struct txpwr_limits { 99*b4c3e9b5SBjoern A. Zeeb u8 cck[BRCMS_NUM_RATES_CCK]; 100*b4c3e9b5SBjoern A. Zeeb u8 ofdm[BRCMS_NUM_RATES_OFDM]; 101*b4c3e9b5SBjoern A. Zeeb 102*b4c3e9b5SBjoern A. Zeeb u8 ofdm_cdd[BRCMS_NUM_RATES_OFDM]; 103*b4c3e9b5SBjoern A. Zeeb 104*b4c3e9b5SBjoern A. Zeeb u8 ofdm_40_siso[BRCMS_NUM_RATES_OFDM]; 105*b4c3e9b5SBjoern A. Zeeb u8 ofdm_40_cdd[BRCMS_NUM_RATES_OFDM]; 106*b4c3e9b5SBjoern A. Zeeb 107*b4c3e9b5SBjoern A. Zeeb u8 mcs_20_siso[BRCMS_NUM_RATES_MCS_1_STREAM]; 108*b4c3e9b5SBjoern A. Zeeb u8 mcs_20_cdd[BRCMS_NUM_RATES_MCS_1_STREAM]; 109*b4c3e9b5SBjoern A. Zeeb u8 mcs_20_stbc[BRCMS_NUM_RATES_MCS_1_STREAM]; 110*b4c3e9b5SBjoern A. Zeeb u8 mcs_20_mimo[BRCMS_NUM_RATES_MCS_2_STREAM]; 111*b4c3e9b5SBjoern A. Zeeb 112*b4c3e9b5SBjoern A. Zeeb u8 mcs_40_siso[BRCMS_NUM_RATES_MCS_1_STREAM]; 113*b4c3e9b5SBjoern A. Zeeb u8 mcs_40_cdd[BRCMS_NUM_RATES_MCS_1_STREAM]; 114*b4c3e9b5SBjoern A. Zeeb u8 mcs_40_stbc[BRCMS_NUM_RATES_MCS_1_STREAM]; 115*b4c3e9b5SBjoern A. Zeeb u8 mcs_40_mimo[BRCMS_NUM_RATES_MCS_2_STREAM]; 116*b4c3e9b5SBjoern A. Zeeb u8 mcs32; 117*b4c3e9b5SBjoern A. Zeeb }; 118*b4c3e9b5SBjoern A. Zeeb 119*b4c3e9b5SBjoern A. Zeeb struct tx_power { 120*b4c3e9b5SBjoern A. Zeeb u32 flags; 121*b4c3e9b5SBjoern A. Zeeb u16 chanspec; /* txpwr report for this channel */ 122*b4c3e9b5SBjoern A. Zeeb u16 local_chanspec; /* channel on which we are associated */ 123*b4c3e9b5SBjoern A. Zeeb u8 local_max; /* local max according to the AP */ 124*b4c3e9b5SBjoern A. Zeeb u8 local_constraint; /* local constraint according to the AP */ 125*b4c3e9b5SBjoern A. Zeeb s8 antgain[2]; /* Ant gain for each band - from SROM */ 126*b4c3e9b5SBjoern A. Zeeb u8 rf_cores; /* count of RF Cores being reported */ 127*b4c3e9b5SBjoern A. Zeeb u8 est_Pout[4]; /* Latest tx power out estimate per RF chain */ 128*b4c3e9b5SBjoern A. Zeeb u8 est_Pout_act[4]; /* Latest tx power out estimate per RF chain 129*b4c3e9b5SBjoern A. Zeeb * without adjustment */ 130*b4c3e9b5SBjoern A. Zeeb u8 est_Pout_cck; /* Latest CCK tx power out estimate */ 131*b4c3e9b5SBjoern A. Zeeb u8 tx_power_max[4]; /* Maximum target power among all rates */ 132*b4c3e9b5SBjoern A. Zeeb /* Index of the rate with the max target power */ 133*b4c3e9b5SBjoern A. Zeeb u8 tx_power_max_rate_ind[4]; 134*b4c3e9b5SBjoern A. Zeeb /* User limit */ 135*b4c3e9b5SBjoern A. Zeeb u8 user_limit[WL_TX_POWER_RATES]; 136*b4c3e9b5SBjoern A. Zeeb /* Regulatory power limit */ 137*b4c3e9b5SBjoern A. Zeeb u8 reg_limit[WL_TX_POWER_RATES]; 138*b4c3e9b5SBjoern A. Zeeb /* Max power board can support (SROM) */ 139*b4c3e9b5SBjoern A. Zeeb u8 board_limit[WL_TX_POWER_RATES]; 140*b4c3e9b5SBjoern A. Zeeb /* Latest target power */ 141*b4c3e9b5SBjoern A. Zeeb u8 target[WL_TX_POWER_RATES]; 142*b4c3e9b5SBjoern A. Zeeb }; 143*b4c3e9b5SBjoern A. Zeeb 144*b4c3e9b5SBjoern A. Zeeb struct brcms_chanvec { 145*b4c3e9b5SBjoern A. Zeeb u8 vec[MAXCHANNEL / NBBY]; 146*b4c3e9b5SBjoern A. Zeeb }; 147*b4c3e9b5SBjoern A. Zeeb 148*b4c3e9b5SBjoern A. Zeeb struct shared_phy_params { 149*b4c3e9b5SBjoern A. Zeeb struct si_pub *sih; 150*b4c3e9b5SBjoern A. Zeeb struct phy_shim_info *physhim; 151*b4c3e9b5SBjoern A. Zeeb uint unit; 152*b4c3e9b5SBjoern A. Zeeb uint corerev; 153*b4c3e9b5SBjoern A. Zeeb u16 vid; 154*b4c3e9b5SBjoern A. Zeeb u16 did; 155*b4c3e9b5SBjoern A. Zeeb uint chip; 156*b4c3e9b5SBjoern A. Zeeb uint chiprev; 157*b4c3e9b5SBjoern A. Zeeb uint chippkg; 158*b4c3e9b5SBjoern A. Zeeb uint sromrev; 159*b4c3e9b5SBjoern A. Zeeb uint boardtype; 160*b4c3e9b5SBjoern A. Zeeb uint boardrev; 161*b4c3e9b5SBjoern A. Zeeb u32 boardflags; 162*b4c3e9b5SBjoern A. Zeeb u32 boardflags2; 163*b4c3e9b5SBjoern A. Zeeb }; 164*b4c3e9b5SBjoern A. Zeeb 165*b4c3e9b5SBjoern A. Zeeb 166*b4c3e9b5SBjoern A. Zeeb struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp); 167*b4c3e9b5SBjoern A. Zeeb struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, 168*b4c3e9b5SBjoern A. Zeeb struct bcma_device *d11core, int bandtype, 169*b4c3e9b5SBjoern A. Zeeb struct wiphy *wiphy); 170*b4c3e9b5SBjoern A. Zeeb void wlc_phy_detach(struct brcms_phy_pub *ppi); 171*b4c3e9b5SBjoern A. Zeeb 172*b4c3e9b5SBjoern A. Zeeb bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype, 173*b4c3e9b5SBjoern A. Zeeb u16 *phyrev, u16 *radioid, u16 *radiover); 174*b4c3e9b5SBjoern A. Zeeb bool wlc_phy_get_encore(struct brcms_phy_pub *pih); 175*b4c3e9b5SBjoern A. Zeeb u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih); 176*b4c3e9b5SBjoern A. Zeeb 177*b4c3e9b5SBjoern A. Zeeb void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate); 178*b4c3e9b5SBjoern A. Zeeb void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate); 179*b4c3e9b5SBjoern A. Zeeb void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec); 180*b4c3e9b5SBjoern A. Zeeb void wlc_phy_watchdog(struct brcms_phy_pub *ppi); 181*b4c3e9b5SBjoern A. Zeeb int wlc_phy_down(struct brcms_phy_pub *ppi); 182*b4c3e9b5SBjoern A. Zeeb u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih); 183*b4c3e9b5SBjoern A. Zeeb void wlc_phy_cal_init(struct brcms_phy_pub *ppi); 184*b4c3e9b5SBjoern A. Zeeb void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init); 185*b4c3e9b5SBjoern A. Zeeb 186*b4c3e9b5SBjoern A. Zeeb void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec); 187*b4c3e9b5SBjoern A. Zeeb u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi); 188*b4c3e9b5SBjoern A. Zeeb void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, u16 newch); 189*b4c3e9b5SBjoern A. Zeeb void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw); 190*b4c3e9b5SBjoern A. Zeeb 191*b4c3e9b5SBjoern A. Zeeb int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, struct d11rxhdr *rxh); 192*b4c3e9b5SBjoern A. Zeeb void wlc_phy_por_inform(struct brcms_phy_pub *ppi); 193*b4c3e9b5SBjoern A. Zeeb void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi); 194*b4c3e9b5SBjoern A. Zeeb bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi); 195*b4c3e9b5SBjoern A. Zeeb 196*b4c3e9b5SBjoern A. Zeeb void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on); 197*b4c3e9b5SBjoern A. Zeeb void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on); 198*b4c3e9b5SBjoern A. Zeeb 199*b4c3e9b5SBjoern A. Zeeb void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi, 200*b4c3e9b5SBjoern A. Zeeb bool wide_filter); 201*b4c3e9b5SBjoern A. Zeeb void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band, 202*b4c3e9b5SBjoern A. Zeeb struct brcms_chanvec *channels); 203*b4c3e9b5SBjoern A. Zeeb 204*b4c3e9b5SBjoern A. Zeeb void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan, u8 *_min_, 205*b4c3e9b5SBjoern A. Zeeb u8 *_max_, int rate); 206*b4c3e9b5SBjoern A. Zeeb void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *, 207*b4c3e9b5SBjoern A. Zeeb u16 chanspec); 208*b4c3e9b5SBjoern A. Zeeb int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override); 209*b4c3e9b5SBjoern A. Zeeb int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override); 210*b4c3e9b5SBjoern A. Zeeb void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi, 211*b4c3e9b5SBjoern A. Zeeb struct txpwr_limits *); 212*b4c3e9b5SBjoern A. Zeeb bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi); 213*b4c3e9b5SBjoern A. Zeeb 214*b4c3e9b5SBjoern A. Zeeb void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain); 215*b4c3e9b5SBjoern A. Zeeb void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain); 216*b4c3e9b5SBjoern A. Zeeb u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih); 217*b4c3e9b5SBjoern A. Zeeb void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val); 218*b4c3e9b5SBjoern A. Zeeb 219*b4c3e9b5SBjoern A. Zeeb void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason); 220*b4c3e9b5SBjoern A. Zeeb void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi); 221*b4c3e9b5SBjoern A. Zeeb 222*b4c3e9b5SBjoern A. Zeeb void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val); 223*b4c3e9b5SBjoern A. Zeeb void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val); 224*b4c3e9b5SBjoern A. Zeeb void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags); 225*b4c3e9b5SBjoern A. Zeeb 226*b4c3e9b5SBjoern A. Zeeb void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type); 227*b4c3e9b5SBjoern A. Zeeb 228*b4c3e9b5SBjoern A. Zeeb void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, 229*b4c3e9b5SBjoern A. Zeeb struct tx_power *power, uint channel); 230*b4c3e9b5SBjoern A. Zeeb 231*b4c3e9b5SBjoern A. Zeeb void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal); 232*b4c3e9b5SBjoern A. Zeeb void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war); 233*b4c3e9b5SBjoern A. Zeeb void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, bool bf_preempt); 234*b4c3e9b5SBjoern A. Zeeb void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap); 235*b4c3e9b5SBjoern A. Zeeb 236*b4c3e9b5SBjoern A. Zeeb const u8 *wlc_phy_get_ofdm_rate_lookup(void); 237*b4c3e9b5SBjoern A. Zeeb 238*b4c3e9b5SBjoern A. Zeeb s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi, 239*b4c3e9b5SBjoern A. Zeeb u8 mcs_offset); 240*b4c3e9b5SBjoern A. Zeeb s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset); 241*b4c3e9b5SBjoern A. Zeeb #endif /* _BRCM_PHY_HAL_H_ */ 242