]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h
96e15163222b37e0e38f16b8ac90ca8cfb1dae11
[karo-tx-linux.git] / drivers / net / wireless / brcm80211 / brcmsmac / phy / phy_hal.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 /*
18  * phy_hal.h:  functionality exported from the phy to higher layers
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 /* a large TX Power as an init value to factor out of min() calculations,
93  * keep low enough to fit in an s8, units are .25 dBm
94  */
95 #define BRCMS_TXPWR_MAX         (127)   /* ~32 dBm = 1,500 mW */
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      /* invalid RSSI value */
105
106 struct d11regs;
107 struct phy_shim_info;
108
109 struct txpwr_limits {
110         u8 cck[BRCMS_NUM_RATES_CCK];
111         u8 ofdm[BRCMS_NUM_RATES_OFDM];
112
113         u8 ofdm_cdd[BRCMS_NUM_RATES_OFDM];
114
115         u8 ofdm_40_siso[BRCMS_NUM_RATES_OFDM];
116         u8 ofdm_40_cdd[BRCMS_NUM_RATES_OFDM];
117
118         u8 mcs_20_siso[BRCMS_NUM_RATES_MCS_1_STREAM];
119         u8 mcs_20_cdd[BRCMS_NUM_RATES_MCS_1_STREAM];
120         u8 mcs_20_stbc[BRCMS_NUM_RATES_MCS_1_STREAM];
121         u8 mcs_20_mimo[BRCMS_NUM_RATES_MCS_2_STREAM];
122
123         u8 mcs_40_siso[BRCMS_NUM_RATES_MCS_1_STREAM];
124         u8 mcs_40_cdd[BRCMS_NUM_RATES_MCS_1_STREAM];
125         u8 mcs_40_stbc[BRCMS_NUM_RATES_MCS_1_STREAM];
126         u8 mcs_40_mimo[BRCMS_NUM_RATES_MCS_2_STREAM];
127         u8 mcs32;
128 };
129
130 struct tx_power {
131         u32 flags;
132         u16 chanspec;   /* txpwr report for this channel */
133         u16 local_chanspec;     /* channel on which we are associated */
134         u8 local_max;   /* local max according to the AP */
135         u8 local_constraint;    /* local constraint according to the AP */
136         s8 antgain[2];  /* Ant gain for each band - from SROM */
137         u8 rf_cores;            /* count of RF Cores being reported */
138         u8 est_Pout[4]; /* Latest tx power out estimate per RF chain */
139         u8 est_Pout_act[4];     /* Latest tx power out estimate per RF chain
140                                  * without adjustment */
141         u8 est_Pout_cck;        /* Latest CCK tx power out estimate */
142         u8 tx_power_max[4];     /* Maximum target power among all rates */
143         /* Index of the rate with the max target power */
144         u8 tx_power_max_rate_ind[4];
145         /* User limit */
146         u8 user_limit[WL_TX_POWER_RATES];
147         /* Regulatory power limit */
148         u8 reg_limit[WL_TX_POWER_RATES];
149         /* Max power board can support (SROM) */
150         u8 board_limit[WL_TX_POWER_RATES];
151         /* Latest target power */
152         u8 target[WL_TX_POWER_RATES];
153 };
154
155 struct tx_inst_power {
156         u8 txpwr_est_Pout[2];   /* Latest estimate for 2.4 and 5 Ghz */
157         u8 txpwr_est_Pout_gofdm;        /* Pwr estimate for 2.4 OFDM */
158 };
159
160 struct brcms_chanvec {
161         u8 vec[MAXCHANNEL / NBBY];
162 };
163
164 struct shared_phy_params {
165         struct si_pub *sih;
166         struct phy_shim_info *physhim;
167         uint unit;
168         uint corerev;
169         uint buscorerev;
170         u16 vid;
171         u16 did;
172         uint chip;
173         uint chiprev;
174         uint chippkg;
175         uint sromrev;
176         uint boardtype;
177         uint boardrev;
178         uint boardvendor;
179         u32 boardflags;
180         u32 boardflags2;
181 };
182
183
184 extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp);
185 extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh,
186                                             struct d11regs __iomem *regs,
187                                             int bandtype, struct wiphy *wiphy);
188 extern void wlc_phy_detach(struct brcms_phy_pub *ppi);
189
190 extern bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype,
191                                    u16 *phyrev, u16 *radioid,
192                                    u16 *radiover);
193 extern bool wlc_phy_get_encore(struct brcms_phy_pub *pih);
194 extern u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih);
195
196 extern void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate);
197 extern void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate);
198 extern void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec);
199 extern void wlc_phy_watchdog(struct brcms_phy_pub *ppi);
200 extern int wlc_phy_down(struct brcms_phy_pub *ppi);
201 extern u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih);
202 extern void wlc_phy_cal_init(struct brcms_phy_pub *ppi);
203 extern void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init);
204
205 extern void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi,
206                                  u16 chanspec);
207 extern u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi);
208 extern void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi,
209                                        u16 newch);
210 extern u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi);
211 extern void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw);
212
213 extern int wlc_phy_rssi_compute(struct brcms_phy_pub *pih,
214                                 struct d11rxhdr *rxh);
215 extern void wlc_phy_por_inform(struct brcms_phy_pub *ppi);
216 extern void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi);
217 extern bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi);
218
219 extern void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag);
220
221 extern void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on);
222 extern void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on);
223
224
225 extern void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi);
226
227 extern void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi,
228                                                  bool wide_filter);
229 extern void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band,
230                                           struct brcms_chanvec *channels);
231 extern u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi,
232                                          uint band);
233
234 extern void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan,
235                                       u8 *_min_, u8 *_max_, int rate);
236 extern void wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi,
237                                               uint chan, u8 *_max_, u8 *_min_);
238 extern void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi,
239                                             uint band, s32 *, s32 *, u32 *);
240 extern void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi,
241                                       struct txpwr_limits *,
242                                       u16 chanspec);
243 extern int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm,
244                                bool *override);
245 extern int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm,
246                                bool override);
247 extern void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi,
248                                        struct txpwr_limits *);
249 extern bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi);
250 extern void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi,
251                                         bool hwpwrctrl);
252 extern u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi);
253 extern u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi);
254 extern bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *pih);
255
256 extern void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain,
257                                    u8 rxchain);
258 extern void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain,
259                                   u8 rxchain);
260 extern void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain,
261                                   u8 *rxchain);
262 extern u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih);
263 extern s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih,
264                                  u16 chanspec);
265 extern void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val);
266
267 extern void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason);
268 extern void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *ppi);
269 extern void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock);
270 extern void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi);
271
272 extern void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val);
273 extern void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi);
274 extern void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val);
275 extern void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags);
276
277 extern void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type);
278
279 extern void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi,
280                                         struct tx_power *power, uint channel);
281
282 extern void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal);
283 extern bool wlc_phy_test_ison(struct brcms_phy_pub *ppi);
284 extern void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi,
285                                       u8 txpwr_percent);
286 extern void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war);
287 extern void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih,
288                                       bool bf_preempt);
289 extern void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap);
290
291 extern void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end);
292
293 extern void wlc_phy_freqtrack_start(struct brcms_phy_pub *ppi);
294 extern void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi);
295
296 extern const u8 *wlc_phy_get_ofdm_rate_lookup(void);
297
298 extern s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi,
299                                              u8 mcs_offset);
300 extern s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset);
301 #endif                          /* _BRCM_PHY_HAL_H_ */