1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef _BRCM_PHY_HAL_H_
22#define _BRCM_PHY_HAL_H_
23
24#include <brcmu_utils.h>
25#include <brcmu_wifi.h>
26#include <phy_shim.h>
27
28#define IDCODE_VER_MASK 0x0000000f
29#define IDCODE_VER_SHIFT 0
30#define IDCODE_MFG_MASK 0x00000fff
31#define IDCODE_MFG_SHIFT 0
32#define IDCODE_ID_MASK 0x0ffff000
33#define IDCODE_ID_SHIFT 12
34#define IDCODE_REV_MASK 0xf0000000
35#define IDCODE_REV_SHIFT 28
36
37#define NORADIO_ID 0xe4f5
38#define NORADIO_IDCODE 0x4e4f5246
39
40#define BCM2055_ID 0x2055
41#define BCM2055_IDCODE 0x02055000
42#define BCM2055A0_IDCODE 0x1205517f
43
44#define BCM2056_ID 0x2056
45#define BCM2056_IDCODE 0x02056000
46#define BCM2056A0_IDCODE 0x1205617f
47
48#define BCM2057_ID 0x2057
49#define BCM2057_IDCODE 0x02057000
50#define BCM2057A0_IDCODE 0x1205717f
51
52#define BCM2064_ID 0x2064
53#define BCM2064_IDCODE 0x02064000
54#define BCM2064A0_IDCODE 0x0206417f
55
56#define PHY_TPC_HW_OFF false
57#define PHY_TPC_HW_ON true
58
59#define PHY_PERICAL_DRIVERUP 1
60#define PHY_PERICAL_WATCHDOG 2
61#define PHY_PERICAL_PHYINIT 3
62#define PHY_PERICAL_JOIN_BSS 4
63#define PHY_PERICAL_START_IBSS 5
64#define PHY_PERICAL_UP_BSS 6
65#define PHY_PERICAL_CHAN 7
66#define PHY_FULLCAL 8
67
68#define PHY_PERICAL_DISABLE 0
69#define PHY_PERICAL_SPHASE 1
70#define PHY_PERICAL_MPHASE 2
71#define PHY_PERICAL_MANUAL 3
72
73#define PHY_HOLD_FOR_ASSOC 1
74#define PHY_HOLD_FOR_SCAN 2
75#define PHY_HOLD_FOR_RM 4
76#define PHY_HOLD_FOR_PLT 8
77#define PHY_HOLD_FOR_MUTE 16
78#define PHY_HOLD_FOR_NOT_ASSOC 0x20
79
80#define PHY_MUTE_FOR_PREISM 1
81#define PHY_MUTE_ALL 0xffffffff
82
83#define PHY_NOISE_FIXED_VAL (-95)
84#define PHY_NOISE_FIXED_VAL_NPHY (-92)
85#define PHY_NOISE_FIXED_VAL_LCNPHY (-92)
86
87#define PHY_MODE_CAL 0x0002
88#define PHY_MODE_NOISEM 0x0004
89
90#define BRCMS_TXPWR_DB_FACTOR 4
91
92
93
94
95#define BRCMS_TXPWR_MAX (127)
96
97#define BRCMS_NUM_RATES_CCK 4
98#define BRCMS_NUM_RATES_OFDM 8
99#define BRCMS_NUM_RATES_MCS_1_STREAM 8
100#define BRCMS_NUM_RATES_MCS_2_STREAM 8
101#define BRCMS_NUM_RATES_MCS_3_STREAM 8
102#define BRCMS_NUM_RATES_MCS_4_STREAM 8
103
104#define BRCMS_RSSI_INVALID 0
105
106struct txpwr_limits {
107 u8 cck[BRCMS_NUM_RATES_CCK];
108 u8 ofdm[BRCMS_NUM_RATES_OFDM];
109
110 u8 ofdm_cdd[BRCMS_NUM_RATES_OFDM];
111
112 u8 ofdm_40_siso[BRCMS_NUM_RATES_OFDM];
113 u8 ofdm_40_cdd[BRCMS_NUM_RATES_OFDM];
114
115 u8 mcs_20_siso[BRCMS_NUM_RATES_MCS_1_STREAM];
116 u8 mcs_20_cdd[BRCMS_NUM_RATES_MCS_1_STREAM];
117 u8 mcs_20_stbc[BRCMS_NUM_RATES_MCS_1_STREAM];
118 u8 mcs_20_mimo[BRCMS_NUM_RATES_MCS_2_STREAM];
119
120 u8 mcs_40_siso[BRCMS_NUM_RATES_MCS_1_STREAM];
121 u8 mcs_40_cdd[BRCMS_NUM_RATES_MCS_1_STREAM];
122 u8 mcs_40_stbc[BRCMS_NUM_RATES_MCS_1_STREAM];
123 u8 mcs_40_mimo[BRCMS_NUM_RATES_MCS_2_STREAM];
124 u8 mcs32;
125};
126
127struct tx_power {
128 u32 flags;
129 chanspec_t chanspec;
130 chanspec_t local_chanspec;
131 u8 local_max;
132 u8 local_constraint;
133 s8 antgain[2];
134 u8 rf_cores;
135 u8 est_Pout[4];
136 u8 est_Pout_act[4];
137
138
139 u8 est_Pout_cck;
140 u8 tx_power_max[4];
141 u8 tx_power_max_rate_ind[4];
142 u8 user_limit[WL_TX_POWER_RATES];
143 u8 reg_limit[WL_TX_POWER_RATES];
144 u8 board_limit[WL_TX_POWER_RATES];
145 u8 target[WL_TX_POWER_RATES];
146};
147
148struct tx_inst_power {
149 u8 txpwr_est_Pout[2];
150 u8 txpwr_est_Pout_gofdm;
151};
152
153struct chanvec {
154 u8 vec[MAXCHANNEL / NBBY];
155};
156
157struct shared_phy_params {
158 struct si_pub *sih;
159 void *physhim;
160 uint unit;
161 uint corerev;
162 uint bustype;
163 uint buscorerev;
164 char *vars;
165 u16 vid;
166 u16 did;
167 uint chip;
168 uint chiprev;
169 uint chippkg;
170 uint sromrev;
171 uint boardtype;
172 uint boardrev;
173 uint boardvendor;
174 u32 boardflags;
175 u32 boardflags2;
176};
177
178
179extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp);
180extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, void *regs,
181 int bandtype, char *vars, struct wiphy *wiphy);
182extern void wlc_phy_detach(struct brcms_phy_pub *ppi);
183
184extern bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype,
185 u16 *phyrev, u16 *radioid,
186 u16 *radiover);
187extern bool wlc_phy_get_encore(struct brcms_phy_pub *pih);
188extern u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih);
189
190extern void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate);
191extern void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate);
192extern void wlc_phy_init(struct brcms_phy_pub *ppi, chanspec_t chanspec);
193extern void wlc_phy_watchdog(struct brcms_phy_pub *ppi);
194extern int wlc_phy_down(struct brcms_phy_pub *ppi);
195extern u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih);
196extern void wlc_phy_cal_init(struct brcms_phy_pub *ppi);
197extern void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init);
198
199extern void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi,
200 chanspec_t chanspec);
201extern chanspec_t wlc_phy_chanspec_get(struct brcms_phy_pub *ppi);
202extern void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi,
203 chanspec_t newch);
204extern u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi);
205extern void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw);
206
207extern void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, void *ctx);
208extern void wlc_phy_por_inform(struct brcms_phy_pub *ppi);
209extern void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi);
210extern bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi);
211
212extern void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag);
213
214extern void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on);
215extern void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on);
216
217
218extern void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi);
219
220extern void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi,
221 bool wide_filter);
222extern void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band,
223 chanvec_t *channels);
224extern chanspec_t wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi,
225 uint band);
226
227extern void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan,
228 u8 *_min_, u8 *_max_, int rate);
229extern void wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi,
230 uint chan, u8 *_max_, u8 *_min_);
231extern void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi,
232 uint band, s32 *, s32 *, u32 *);
233extern void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi,
234 struct txpwr_limits *,
235 chanspec_t chanspec);
236extern int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm,
237 bool *override);
238extern int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm,
239 bool override);
240extern void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi,
241 struct txpwr_limits *);
242extern bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi);
243extern void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi,
244 bool hwpwrctrl);
245extern u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi);
246extern u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi);
247extern bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *pih);
248
249extern void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain,
250 u8 rxchain);
251extern void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain,
252 u8 rxchain);
253extern void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain,
254 u8 *rxchain);
255extern u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih);
256extern s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih,
257 chanspec_t chanspec);
258extern void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val);
259
260extern void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason);
261extern void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *ppi);
262extern void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock);
263extern void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi);
264
265extern void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val);
266extern void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi);
267extern void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, mbool id, bool val);
268extern void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, mbool flags);
269
270extern void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type);
271
272extern void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi,
273 struct tx_power *power, uint channel);
274
275extern void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal);
276extern bool wlc_phy_test_ison(struct brcms_phy_pub *ppi);
277extern void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi,
278 u8 txpwr_percent);
279extern void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war);
280extern void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih,
281 bool bf_preempt);
282extern void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap);
283
284extern void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end);
285
286extern void wlc_phy_freqtrack_start(struct brcms_phy_pub *ppi);
287extern void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi);
288
289extern const u8 *wlc_phy_get_ofdm_rate_lookup(void);
290
291extern s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi,
292 u8 mcs_offset);
293extern s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset);
294#endif
295