1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2010 Broadcom Corporation
6 #ifndef _BRCM_PHY_INT_H_
7 #define _BRCM_PHY_INT_H_
10 #include <brcmu_utils.h>
11 #include <brcmu_wifi.h>
13 #define PHY_VERSION { 1, 82, 8, 0 }
15 #define LCNXN_BASEREV 16
19 struct brcms_phy_srom_fem {
20 /* TSSI positive slope, 1: positive, 0: negative */
22 /* Ext PA gain-type: full-gain: 0, pa-lite: 1, no_pa: 2 */
24 /* support 32 combinations of different Pdet dynamic ranges */
26 /* TR switch isolation */
28 /* antswctrl lookup table configuration: 32 possible choices */
32 #define ISNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_N)
33 #define ISLCNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_LCN)
35 #define PHY_GET_RFATTN(rfgain) ((rfgain) & 0x0f)
36 #define PHY_GET_PADMIX(rfgain) (((rfgain) & 0x10) >> 4)
37 #define PHY_GET_RFGAINID(rfattn, padmix, width) ((rfattn) + ((padmix)*(width)))
38 #define PHY_SAT(x, n) ((x) > ((1<<((n)-1))-1) ? ((1<<((n)-1))-1) : \
39 ((x) < -(1<<((n)-1)) ? -(1<<((n)-1)) : (x)))
40 #define PHY_SHIFT_ROUND(x, n) ((x) >= 0 ? ((x)+(1<<((n)-1)))>>(n) : (x)>>(n))
41 #define PHY_HW_ROUND(x, s) ((x >> s) + ((x >> (s-1)) & (s != 0)))
46 #define A_HIGH_CHANS 2
50 #define FIRST_REF5_CHANNUM 149
51 #define LAST_REF5_CHANNUM 165
52 #define FIRST_5G_CHAN 14
53 #define LAST_5G_CHAN 50
54 #define FIRST_MID_5G_CHAN 14
55 #define LAST_MID_5G_CHAN 35
56 #define FIRST_HIGH_5G_CHAN 36
57 #define LAST_HIGH_5G_CHAN 41
58 #define FIRST_LOW_5G_CHAN 42
59 #define LAST_LOW_5G_CHAN 50
61 #define BASE_LOW_5G_CHAN 4900
62 #define BASE_MID_5G_CHAN 5100
63 #define BASE_HIGH_5G_CHAN 5500
65 #define CHAN5G_FREQ(chan) (5000 + chan*5)
66 #define CHAN2G_FREQ(chan) (2407 + chan*5)
68 #define TXP_FIRST_CCK 0
69 #define TXP_LAST_CCK 3
70 #define TXP_FIRST_OFDM 4
71 #define TXP_LAST_OFDM 11
72 #define TXP_FIRST_OFDM_20_CDD 12
73 #define TXP_LAST_OFDM_20_CDD 19
74 #define TXP_FIRST_MCS_20_SISO 20
75 #define TXP_LAST_MCS_20_SISO 27
76 #define TXP_FIRST_MCS_20_CDD 28
77 #define TXP_LAST_MCS_20_CDD 35
78 #define TXP_FIRST_MCS_20_STBC 36
79 #define TXP_LAST_MCS_20_STBC 43
80 #define TXP_FIRST_MCS_20_SDM 44
81 #define TXP_LAST_MCS_20_SDM 51
82 #define TXP_FIRST_OFDM_40_SISO 52
83 #define TXP_LAST_OFDM_40_SISO 59
84 #define TXP_FIRST_OFDM_40_CDD 60
85 #define TXP_LAST_OFDM_40_CDD 67
86 #define TXP_FIRST_MCS_40_SISO 68
87 #define TXP_LAST_MCS_40_SISO 75
88 #define TXP_FIRST_MCS_40_CDD 76
89 #define TXP_LAST_MCS_40_CDD 83
90 #define TXP_FIRST_MCS_40_STBC 84
91 #define TXP_LAST_MCS_40_STBC 91
92 #define TXP_FIRST_MCS_40_SDM 92
93 #define TXP_LAST_MCS_40_SDM 99
94 #define TXP_MCS_32 100
95 #define TXP_NUM_RATES 101
96 #define ADJ_PWR_TBL_LEN 84
98 #define TXP_FIRST_SISO_MCS_20 20
99 #define TXP_LAST_SISO_MCS_20 27
101 #define PHY_CORE_NUM_1 1
102 #define PHY_CORE_NUM_2 2
103 #define PHY_CORE_NUM_3 3
104 #define PHY_CORE_NUM_4 4
105 #define PHY_CORE_MAX PHY_CORE_NUM_4
111 #define MA_WINDOW_SZ 8
113 #define PHY_NOISE_SAMPLE_MON 1
114 #define PHY_NOISE_SAMPLE_EXTERNAL 2
115 #define PHY_NOISE_WINDOW_SZ 16
116 #define PHY_NOISE_GLITCH_INIT_MA 10
117 #define PHY_NOISE_GLITCH_INIT_MA_BADPlCP 10
118 #define PHY_NOISE_STATE_MON 0x1
119 #define PHY_NOISE_STATE_EXTERNAL 0x2
120 #define PHY_NOISE_SAMPLE_LOG_NUM_NPHY 10
121 #define PHY_NOISE_SAMPLE_LOG_NUM_UCODE 9
123 #define PHY_NOISE_OFFSETFACT_4322 (-103)
124 #define PHY_NOISE_MA_WINDOW_SZ 2
126 #define PHY_RSSI_TABLE_SIZE 64
127 #define RSSI_ANT_MERGE_MAX 0
128 #define RSSI_ANT_MERGE_MIN 1
129 #define RSSI_ANT_MERGE_AVG 2
131 #define PHY_TSSI_TABLE_SIZE 64
132 #define APHY_TSSI_TABLE_SIZE 256
133 #define TX_GAIN_TABLE_LENGTH 64
134 #define DEFAULT_11A_TXP_IDX 24
135 #define NUM_TSSI_FRAMES 4
136 #define NULL_TSSI 0x7f
137 #define NULL_TSSI_W 0x7f7f
139 #define PHY_PAPD_EPS_TBL_SIZE_LCNPHY 64
141 #define LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL 9
143 #define PHY_TXPWR_MIN 10
144 #define PHY_TXPWR_MIN_NPHY 8
145 #define RADIOPWR_OVERRIDE_DEF (-1)
147 #define PWRTBL_NUM_COEFF 3
149 #define SPURAVOID_DISABLE 0
150 #define SPURAVOID_AUTO 1
151 #define SPURAVOID_FORCEON 2
152 #define SPURAVOID_FORCEON2 3
154 #define PHY_SW_TIMER_FAST 15
155 #define PHY_SW_TIMER_SLOW 60
156 #define PHY_SW_TIMER_GLACIAL 120
158 #define PHY_PERICAL_AUTO 0
159 #define PHY_PERICAL_FULL 1
160 #define PHY_PERICAL_PARTIAL 2
162 #define PHY_PERICAL_NODELAY 0
163 #define PHY_PERICAL_INIT_DELAY 5
164 #define PHY_PERICAL_ASSOC_DELAY 5
165 #define PHY_PERICAL_WDOG_DELAY 5
167 #define MPHASE_TXCAL_NUMCMDS 2
169 #define PHY_PERICAL_MPHASE_PENDING(pi) \
170 (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_IDLE)
173 MPHASE_CAL_STATE_IDLE = 0,
174 MPHASE_CAL_STATE_INIT = 1,
175 MPHASE_CAL_STATE_TXPHASE0,
176 MPHASE_CAL_STATE_TXPHASE1,
177 MPHASE_CAL_STATE_TXPHASE2,
178 MPHASE_CAL_STATE_TXPHASE3,
179 MPHASE_CAL_STATE_TXPHASE4,
180 MPHASE_CAL_STATE_TXPHASE5,
181 MPHASE_CAL_STATE_PAPDCAL,
182 MPHASE_CAL_STATE_RXCAL,
183 MPHASE_CAL_STATE_RSSICAL,
184 MPHASE_CAL_STATE_IDLETSSI
198 #define RDR_TIER_SIZE 64
199 #define RDR_LIST_SIZE (512/3)
200 #define RDR_EPOCH_SIZE 40
201 #define RDR_NANTENNAS 2
202 #define RDR_NTIER_SIZE RDR_LIST_SIZE
203 #define RDR_LP_BUFFER_SIZE 64
204 #define LP_LEN_HIS_SIZE 10
206 #define STATIC_NUM_RF 32
207 #define STATIC_NUM_BB 9
209 #define BB_MULT_MASK 0x0000ffff
210 #define BB_MULT_VALID_MASK 0x80000000
212 #define PHY_CHAIN_TX_DISABLE_TEMP 115
213 #define PHY_HYSTERESIS_DELTATEMP 5
215 #define SCAN_INPROG_PHY(pi) \
216 (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN))
218 #define PLT_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_PLT))
220 #define ASSOC_INPROG_PHY(pi) \
221 (mboolisset(pi->measure_hold, PHY_HOLD_FOR_ASSOC))
223 #define SCAN_RM_IN_PROGRESS(pi) \
224 (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN | PHY_HOLD_FOR_RM))
226 #define PHY_MUTED(pi) \
227 (mboolisset(pi->measure_hold, PHY_HOLD_FOR_MUTE))
229 #define PUB_NOT_ASSOC(pi) \
230 (mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC))
232 struct phy_table_info {
246 struct interference_info {
247 u8 curr_home_channel;
248 u16 crsminpwrthld_40_stored;
249 u16 crsminpwrthld_20L_stored;
250 u16 crsminpwrthld_20U_stored;
251 u16 init_gain_code_core1_stored;
252 u16 init_gain_code_core2_stored;
253 u16 init_gain_codeb_core1_stored;
254 u16 init_gain_codeb_core2_stored;
255 u16 init_gain_table_stored[4];
257 u16 clip1_hi_gain_code_core1_stored;
258 u16 clip1_hi_gain_code_core2_stored;
259 u16 clip1_hi_gain_codeb_core1_stored;
260 u16 clip1_hi_gain_codeb_core2_stored;
261 u16 nb_clip_thresh_core1_stored;
262 u16 nb_clip_thresh_core2_stored;
263 u16 init_ofdmlna2gainchange_stored[4];
264 u16 init_ccklna2gainchange_stored[4];
265 u16 clip1_lo_gain_code_core1_stored;
266 u16 clip1_lo_gain_code_core2_stored;
267 u16 clip1_lo_gain_codeb_core1_stored;
268 u16 clip1_lo_gain_codeb_core2_stored;
269 u16 w1_clip_thresh_core1_stored;
270 u16 w1_clip_thresh_core2_stored;
271 u16 radio_2056_core1_rssi_gain_stored;
272 u16 radio_2056_core2_rssi_gain_stored;
273 u16 energy_drop_timeout_len_stored;
275 u16 ed_crs40_assertthld0_stored;
276 u16 ed_crs40_assertthld1_stored;
277 u16 ed_crs40_deassertthld0_stored;
278 u16 ed_crs40_deassertthld1_stored;
279 u16 ed_crs20L_assertthld0_stored;
280 u16 ed_crs20L_assertthld1_stored;
281 u16 ed_crs20L_deassertthld0_stored;
282 u16 ed_crs20L_deassertthld1_stored;
283 u16 ed_crs20U_assertthld0_stored;
284 u16 ed_crs20U_assertthld1_stored;
285 u16 ed_crs20U_deassertthld0_stored;
286 u16 ed_crs20U_deassertthld1_stored;
289 u16 badplcp_ma_previous;
290 u16 badplcp_ma_total;
291 u16 badplcp_ma_list[MA_WINDOW_SZ];
292 int badplcp_ma_index;
294 s16 bphy_pre_badplcp_cnt;
298 u16 init_gainb_core1;
299 u16 init_gainb_core2;
300 u16 init_gain_rfseq[4];
308 u16 radio_2057_core1_rssi_wb1a_gc_stored;
309 u16 radio_2057_core2_rssi_wb1a_gc_stored;
310 u16 radio_2057_core1_rssi_wb1g_gc_stored;
311 u16 radio_2057_core2_rssi_wb1g_gc_stored;
312 u16 radio_2057_core1_rssi_wb2_gc_stored;
313 u16 radio_2057_core2_rssi_wb2_gc_stored;
314 u16 radio_2057_core1_rssi_nb_gc_stored;
315 u16 radio_2057_core2_rssi_nb_gc_stored;
318 struct aci_save_gphy {
328 u16 div_search_gn_change;
336 u16 clip_pwdn_thresh;
337 u16 clip_n1p1_thresh;
338 u16 clip_n1_pwdn_thresh;
342 u16 clip_p1_p2_thresh;
349 u16 div_srch_gn_back;
354 struct lo_complex_abgphy_info {
359 struct nphy_iq_comp {
366 struct nphy_txpwrindex {
369 s8 index_internal_save;
379 struct txiqcal_cache {
381 u16 txcal_coeffs_2G[8];
382 u16 txcal_radio_regs_2G[8];
383 struct nphy_iq_comp rxcal_coeffs_2G;
385 u16 txcal_coeffs_5G[8];
386 u16 txcal_radio_regs_5G[8];
387 struct nphy_iq_comp rxcal_coeffs_5G;
390 struct nphy_pwrctrl {
419 struct nphy_txgains {
427 #define PHY_NOISEVAR_BUFSIZE 10
429 struct nphy_noisevar_buf {
431 int tone_id[PHY_NOISEVAR_BUFSIZE];
432 u32 noise_vars[PHY_NOISEVAR_BUFSIZE];
433 u32 min_noise_vars[PHY_NOISEVAR_BUFSIZE];
436 struct rssical_cache {
437 u16 rssical_radio_regs_2G[2];
438 u16 rssical_phyregs_2G[12];
440 u16 rssical_radio_regs_5G[2];
441 u16 rssical_phyregs_5G[12];
444 struct lcnphy_cal_results {
454 u16 txiqlocal_bestcoeffs[11];
455 u16 txiqlocal_bestcoeffs_valid;
457 u32 papd_eps_tbl[PHY_PAPD_EPS_TBL_SIZE_LCNPHY];
464 u16 sslpnCalibClkEnCtrl;
466 u16 rxiqcal_coeff_a0;
467 u16 rxiqcal_coeff_b0;
471 struct brcms_phy *phy_head;
473 struct phy_shim_info *physhim;
493 s8 phy_noise_window[MA_WINDOW_SZ];
494 uint phy_noise_index;
503 struct brcms_phy_pub {
516 struct phy_func_ptr {
517 void (*init)(struct brcms_phy *);
518 void (*calinit)(struct brcms_phy *);
519 void (*chanset)(struct brcms_phy *, u16 chanspec);
520 void (*txpwrrecalc)(struct brcms_phy *);
521 int (*longtrn)(struct brcms_phy *, int);
522 void (*txiqccget)(struct brcms_phy *, u16 *, u16 *);
523 void (*txiqccset)(struct brcms_phy *, u16, u16);
524 u16 (*txloccget)(struct brcms_phy *);
525 void (*radioloftget)(struct brcms_phy *, u8 *, u8 *, u8 *, u8 *);
526 void (*carrsuppr)(struct brcms_phy *);
527 s32 (*rxsigpwr)(struct brcms_phy *, s32);
528 void (*detach)(struct brcms_phy *);
532 struct brcms_phy_pub pubpi_ro;
533 struct shared_phy *sh;
534 struct phy_func_ptr pi_fptr;
537 struct brcms_phy_lcnphy *pi_lcnphy;
539 bool user_txpwr_at_rfport;
541 struct bcma_device *d11core;
542 struct brcms_phy *next;
543 struct brcms_phy_pub pubpi;
547 bool ofdm_rateset_war;
548 bool bf_preempt_4306;
555 bool init_in_progress;
559 bool watchdog_override;
562 int phynoise_chan_watchdog;
563 bool phynoise_polling;
567 s16 txpa_2g[PWRTBL_NUM_COEFF];
568 s16 txpa_2g_low_temp[PWRTBL_NUM_COEFF];
569 s16 txpa_2g_high_temp[PWRTBL_NUM_COEFF];
570 s16 txpa_5g_low[PWRTBL_NUM_COEFF];
571 s16 txpa_5g_mid[PWRTBL_NUM_COEFF];
572 s16 txpa_5g_hi[PWRTBL_NUM_COEFF];
575 u8 tx_srom_max_5g_low;
576 u8 tx_srom_max_5g_mid;
577 u8 tx_srom_max_5g_hi;
578 u8 tx_srom_max_rate_2g[TXP_NUM_RATES];
579 u8 tx_srom_max_rate_5g_low[TXP_NUM_RATES];
580 u8 tx_srom_max_rate_5g_mid[TXP_NUM_RATES];
581 u8 tx_srom_max_rate_5g_hi[TXP_NUM_RATES];
582 u8 tx_user_target[TXP_NUM_RATES];
583 s8 tx_power_offset[TXP_NUM_RATES];
584 u8 tx_power_target[TXP_NUM_RATES];
586 struct brcms_phy_srom_fem srom_fem2g;
587 struct brcms_phy_srom_fem srom_fem5g;
590 u8 tx_power_max_rate_ind;
599 s8 n_preamble_override;
603 s8 idle_tssi[CH_5G_GROUP];
607 u8 txpwr_limit[TXP_NUM_RATES];
608 u8 txpwr_env_limit[TXP_NUM_RATES];
609 u8 adj_pwr_tbl_nphy[ADJ_PWR_TBL_LEN];
611 bool channel_14_wide_filter;
614 bool txpwridx_override_aphy;
615 s16 radiopwr_override;
619 bool edcrs_threshold_lock;
624 s16 ofdm_analog_filt_bw_override;
625 s16 cck_analog_filt_bw_override;
626 s16 ofdm_rccal_override;
627 s16 cck_rccal_override;
630 uint interference_mode_crs_time;
632 bool interference_mode_crs;
634 u32 phy_tx_tone_freq;
637 bool phy_fixed_noise;
640 s8 carrier_suppr_disable;
647 s16 phy_txcore_disable_temp;
648 s16 phy_txcore_enable_temp;
649 s8 phy_tempsense_offset;
650 bool phy_txcore_heatedup;
658 struct lo_complex_abgphy_info gphy_locomp_iq
659 [STATIC_NUM_RF][STATIC_NUM_BB];
660 s8 stats_11b_txpower[STATIC_NUM_RF][STATIC_NUM_BB];
661 u16 gain_table[TX_GAIN_TABLE_LENGTH];
663 s16 max_lpback_gain_hdB;
664 s16 trsw_rx_gain_hdB;
668 int nrssi_table_delta;
669 int nrssi_slope_scale;
670 int nrssi_slope_offset;
677 u8 a_band_high_disable;
680 u16 global_tx_bb_dc_bias_loft;
700 u16 freqtrack_saved_regs[2];
701 int cur_interference_mode;
702 bool hwpwrctrl_capable;
703 bool temppwrctrl_capable;
712 bool nphy_tableloaded;
714 u32 nphy_bb_mult_save;
715 u16 nphy_txiqlocal_bestc[11];
716 bool nphy_txiqlocal_coeffsvalid;
717 struct nphy_txpwrindex nphy_txpwrindex[PHY_CORE_NUM_2];
718 struct nphy_pwrctrl nphy_pwrctrl_info[PHY_CORE_NUM_2];
744 u32 nphy_rxcalparams;
747 bool phy_isspuravoid;
753 s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ];
756 bool nphy_gain_boost;
757 bool nphy_elna_gain_config;
759 u16 old_bphy_testcontrol;
765 uint nphy_perical_last;
766 u8 cal_type_override;
767 u8 mphase_cal_phase_id;
768 u8 mphase_txcal_cmdidx;
769 u8 mphase_txcal_numcmds;
770 u16 mphase_txcal_bestcoeffs[11];
771 u16 nphy_txiqlocal_chanspec;
772 u16 nphy_iqcal_chanspec_2G;
773 u16 nphy_iqcal_chanspec_5G;
774 u16 nphy_rssical_chanspec_2G;
775 u16 nphy_rssical_chanspec_5G;
776 struct wlapi_timer *phycal_timer;
777 bool use_int_tx_iqlo_cal_nphy;
778 bool internal_tx_iqlo_cal_tapoff_intpa_nphy;
779 s16 nphy_lastcal_temp;
781 struct txiqcal_cache calibration_cache;
782 struct rssical_cache rssical_cache;
784 u8 nphy_txpwr_idx[2];
785 u8 nphy_papd_cal_type;
786 uint nphy_papd_last_cal;
787 u16 nphy_papd_tx_gain_at_last_cal[2];
788 u8 nphy_papd_cal_gain_index[2];
789 s16 nphy_papd_epsilon_offset[2];
790 bool nphy_papd_recal_enable;
791 u32 nphy_papd_recal_counter;
792 bool nphy_force_papd_cal;
797 u16 classifier_state;
799 uint nphy_deaf_count;
803 u16 rfctrlIntc1_save;
804 u16 rfctrlIntc2_save;
805 bool first_cal_after_assoc;
806 u16 tx_rx_cal_radio_saveregs[22];
807 u16 tx_rx_cal_phy_saveregs[15];
809 u8 nphy_cal_orig_pwr_idx[2];
810 u8 nphy_txcal_pwr_idx[2];
811 u8 nphy_rxcal_pwr_idx[2];
812 u16 nphy_cal_orig_tx_gain[2];
813 struct nphy_txgains nphy_cal_target_gain;
814 u16 nphy_txcal_bbmult;
817 u16 nphy_saved_bbconf;
819 bool nphy_gband_spurwar_en;
820 bool nphy_gband_spurwar2_en;
821 bool nphy_aband_spurwar_en;
822 u16 nphy_rccal_value;
823 u16 nphy_crsminpwr[3];
824 struct nphy_noisevar_buf nphy_saved_noisevars;
825 bool nphy_anarxlpf_adjusted;
826 bool nphy_crsminpwr_adjusted;
827 bool nphy_noisevars_adjusted;
829 bool nphy_rxcal_active;
830 u16 radar_percal_mask;
831 bool dfs_lp_buffer_nphy;
833 u16 nphy_fineclockgatecontrol;
840 s16 noise_crsminpwr_index;
843 u16 init_gainb_core1;
844 u16 init_gainb_core2;
845 u8 aci_noise_curr_channel;
846 u16 init_gain_rfseq[4];
850 bool nphy_sample_play_lpf_bw_ctl_ovr;
857 uint tbl_save_offset;
860 s8 txpwrindex[PHY_CORE_MAX];
881 struct radio_20xx_regs {
887 struct lcnphy_radio_regs {
895 u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
896 void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
897 void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
898 void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
899 void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
901 u16 read_radio_reg(struct brcms_phy *pi, u16 addr);
902 void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
903 void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
904 void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
905 void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask);
907 void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
909 void wlc_phyreg_enter(struct brcms_phy_pub *pih);
910 void wlc_phyreg_exit(struct brcms_phy_pub *pih);
911 void wlc_radioreg_enter(struct brcms_phy_pub *pih);
912 void wlc_radioreg_exit(struct brcms_phy_pub *pih);
914 void wlc_phy_read_table(struct brcms_phy *pi,
915 const struct phytbl_info *ptbl_info,
916 u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
917 void wlc_phy_write_table(struct brcms_phy *pi,
918 const struct phytbl_info *ptbl_info,
919 u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
920 void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset,
921 u16 tblAddr, u16 tblDataHi, u16 tblDataLo);
922 void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);
924 void write_phy_channel_reg(struct brcms_phy *pi, uint val);
925 void wlc_phy_txpower_update_shm(struct brcms_phy *pi);
927 u8 wlc_phy_nbits(s32 value);
928 void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);
930 uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi,
931 struct radio_20xx_regs *radioregs);
932 uint wlc_phy_init_radio_regs(struct brcms_phy *pi,
933 const struct radio_regs *radioregs,
936 void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi);
938 void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on);
939 void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, s32 *eps_imag);
941 void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi);
942 void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi);
944 bool wlc_phy_attach_nphy(struct brcms_phy *pi);
945 bool wlc_phy_attach_lcnphy(struct brcms_phy *pi);
947 void wlc_phy_detach_lcnphy(struct brcms_phy *pi);
949 void wlc_phy_init_nphy(struct brcms_phy *pi);
950 void wlc_phy_init_lcnphy(struct brcms_phy *pi);
952 void wlc_phy_cal_init_nphy(struct brcms_phy *pi);
953 void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi);
955 void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec);
956 void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec);
957 void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi, u16 chanspec);
958 int wlc_phy_channel2freq(uint channel);
959 int wlc_phy_chanspec_freq2bandrange_lpssn(uint);
960 int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec);
962 void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode);
963 s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi);
965 void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi);
966 void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi);
967 void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi);
969 void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index);
970 void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable);
971 void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi);
972 void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val,
975 void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan,
976 u8 *max_pwr, u8 rate_id);
977 void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start,
978 u8 rate_mcs_end, u8 rate_ofdm_start);
979 void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power, u8 rate_ofdm_start,
980 u8 rate_ofdm_end, u8 rate_mcs_start);
982 u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode);
983 s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode);
984 s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode);
985 s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode);
986 void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi);
987 void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel);
988 void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode);
989 void wlc_2064_vco_cal(struct brcms_phy *pi);
991 void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);
993 #define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18
994 #define LCNPHY_TX_POWER_TABLE_SIZE 128
995 #define LCNPHY_MAX_TX_POWER_INDEX (LCNPHY_TX_POWER_TABLE_SIZE - 1)
996 #define LCNPHY_TBL_ID_TXPWRCTL 0x07
997 #define LCNPHY_TX_PWR_CTRL_OFF 0
998 #define LCNPHY_TX_PWR_CTRL_SW (0x1 << 15)
999 #define LCNPHY_TX_PWR_CTRL_HW ((0x1 << 15) | \
1003 #define LCNPHY_TX_PWR_CTRL_TEMPBASED 0xE001
1005 void wlc_lcnphy_write_table(struct brcms_phy *pi,
1006 const struct phytbl_info *pti);
1007 void wlc_lcnphy_read_table(struct brcms_phy *pi, struct phytbl_info *pti);
1008 void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b);
1009 void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq);
1010 void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b);
1011 u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi);
1012 void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0, u8 *eq0, u8 *fi0,
1014 void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode);
1015 void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode);
1016 bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi);
1017 void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi);
1018 s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1);
1019 void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr, s8 *cck_pwr);
1020 void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi);
1022 s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index);
1024 #define NPHY_MAX_HPVGA1_INDEX 10
1025 #define NPHY_DEF_HPVGA1_INDEXLIMIT 7
1033 void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, bool enable);
1034 void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode);
1036 #define wlc_phy_write_table_nphy(pi, pti) \
1037 wlc_phy_write_table(pi, pti, 0x72, 0x74, 0x73)
1039 #define wlc_phy_read_table_nphy(pi, pti) \
1040 wlc_phy_read_table(pi, pti, 0x72, 0x74, 0x73)
1042 #define wlc_nphy_table_addr(pi, id, off) \
1043 wlc_phy_table_addr((pi), (id), (off), 0x72, 0x74, 0x73)
1045 #define wlc_nphy_table_data_write(pi, w, v) \
1046 wlc_phy_table_data_write((pi), (w), (v))
1048 void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o, u32 w,
1050 void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32, u32,
1053 #define PHY_IPA(pi) \
1054 ((pi->ipa2g_on && CHSPEC_IS2G(pi->radio_chanspec)) || \
1055 (pi->ipa5g_on && CHSPEC_IS5G(pi->radio_chanspec)))
1057 #define BRCMS_PHY_WAR_PR51571(pi) \
1058 if (NREV_LT((pi)->pubpi.phy_rev, 3)) \
1059 (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol))
1061 void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype);
1062 void wlc_phy_aci_reset_nphy(struct brcms_phy *pi);
1063 void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en);
1065 u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan);
1066 void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on);
1068 void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi);
1070 void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd);
1071 s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi);
1073 u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val);
1075 void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est,
1076 u16 num_samps, u8 wait_time, u8 wait_for_crs);
1078 void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write,
1079 struct nphy_iq_comp *comp);
1080 void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi);
1082 void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask);
1083 u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih);
1085 void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type);
1086 void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi);
1087 void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi);
1088 void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi);
1089 u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi);
1091 struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi);
1092 int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi,
1093 struct nphy_txgains target_gain, bool full, bool m);
1094 int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain,
1096 void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask,
1097 s8 txpwrindex, bool res);
1098 void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type);
1099 int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type,
1100 s32 *rssi_buf, u8 nsamps);
1101 void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi);
1102 int wlc_phy_aci_scan_nphy(struct brcms_phy *pi);
1103 void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower,
1105 int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u8 mode,
1107 void wlc_phy_stopplayback_nphy(struct brcms_phy *pi);
1108 void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf,
1110 void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi);
1112 int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh);
1114 #define NPHY_TESTPATTERN_BPHY_EVM 0
1115 #define NPHY_TESTPATTERN_BPHY_RFCS 1
1117 void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs);
1119 void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset,
1121 s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, u16 chanspec);
1123 bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih);
1124 #endif /* _BRCM_PHY_INT_H_ */