2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
17 #ifndef _BRCM_TYPES_H_
18 #define _BRCM_TYPES_H_
20 #include <linux/types.h>
23 #define SI_BUS 0 /* SOC Interconnect */
24 #define PCI_BUS 1 /* PCI target */
25 #define SDIO_BUS 3 /* SDIO target */
26 #define JTAG_BUS 4 /* JTAG */
27 #define USB_BUS 5 /* USB (does not support R/W REG) */
28 #define SPI_BUS 6 /* gSPI target */
29 #define RPC_BUS 7 /* RPC target */
31 #define WL_CHAN_FREQ_RANGE_2G 0
32 #define WL_CHAN_FREQ_RANGE_5GL 1
33 #define WL_CHAN_FREQ_RANGE_5GM 2
34 #define WL_CHAN_FREQ_RANGE_5GH 3
36 #define MAX_DMA_SEGS 4
39 #define BFL_PACTRL 0x00000002 /* Board has gpio 9 controlling the PA */
40 #define BFL_NOPLLDOWN 0x00000020 /* Not ok to power down the chip pll and oscillator */
41 #define BFL_FEM 0x00000800 /* Board supports the Front End Module */
42 #define BFL_EXTLNA 0x00001000 /* Board has an external LNA in 2.4GHz band */
43 #define BFL_NOPA 0x00010000 /* Board has no PA */
44 #define BFL_BUCKBOOST 0x00200000 /* Power topology uses BUCKBOOST */
45 #define BFL_FEM_BT 0x00400000 /* Board has FEM and switch to share antenna w/ BT */
46 #define BFL_NOCBUCK 0x00800000 /* Power topology doesn't use CBUCK */
47 #define BFL_PALDO 0x02000000 /* Power topology uses PALDO */
48 #define BFL_EXTLNA_5GHz 0x10000000 /* Board has an external LNA in 5GHz band */
51 #define BFL2_RXBB_INT_REG_DIS 0x00000001 /* Board has an external rxbb regulator */
52 #define BFL2_APLL_WAR 0x00000002 /* Flag to implement alternative A-band PLL settings */
53 #define BFL2_TXPWRCTRL_EN 0x00000004 /* Board permits enabling TX Power Control */
54 #define BFL2_2X4_DIV 0x00000008 /* Board supports the 2X4 diversity switch */
55 #define BFL2_5G_PWRGAIN 0x00000010 /* Board supports 5G band power gain */
56 #define BFL2_PCIEWAR_OVR 0x00000020 /* Board overrides ASPM and Clkreq settings */
57 #define BFL2_LEGACY 0x00000080
58 #define BFL2_SKWRKFEM_BRD 0x00000100 /* 4321mcm93 board uses Skyworks FEM */
59 #define BFL2_SPUR_WAR 0x00000200 /* Board has a WAR for clock-harmonic spurs */
60 #define BFL2_GPLL_WAR 0x00000400 /* Flag to narrow G-band PLL loop b/w */
61 #define BFL2_SINGLEANT_CCK 0x00001000 /* Tx CCK pkts on Ant 0 only */
62 #define BFL2_2G_SPUR_WAR 0x00002000 /* WAR to reduce and avoid clock-harmonic spurs in 2G */
63 #define BFL2_GPLL_WAR2 0x00010000 /* Flag to widen G-band PLL loop b/w */
64 #define BFL2_IPALVLSHIFT_3P3 0x00020000
65 #define BFL2_INTERNDET_TXIQCAL 0x00040000 /* Use internal envelope detector for TX IQCAL */
66 #define BFL2_XTALBUFOUTEN 0x00080000 /* Keep the buffered Xtal output from radio "ON"
67 * Most drivers will turn it off without this flag
71 /* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
72 #define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
73 #define BOARD_GPIO_12 0x1000 /* gpio 12 */
74 #define BOARD_GPIO_13 0x2000 /* gpio 13 */
76 /* **** Core type/rev defaults **** */
77 #define D11CONF 0x0fffffb0 /* Supported D11 revs: 4, 5, 7-27
78 * also need to update wlc.h MAXCOREREV
81 #define NCONF 0x000001ff /* Supported nphy revs:
93 #define LCNCONF 0x00000007 /* Supported lcnphy revs:
94 * 0 4313a0, 4336a0, 4330a0
99 #define SSLPNCONF 0x0000000f /* Supported sslpnphy revs:
106 /********************************************************************
107 * Phy/Core Configuration. Defines macros to to check core phy/rev *
108 * compile-time configuration. Defines default core support. *
109 * ******************************************************************
112 /* Basic macros to check a configuration bitmask */
114 #define CONF_HAS(config, val) ((config) & (1 << (val)))
115 #define CONF_MSK(config, mask) ((config) & (mask))
116 #define MSK_RANGE(low, hi) ((1 << ((hi)+1)) - (1 << (low)))
117 #define CONF_RANGE(config, low, hi) (CONF_MSK(config, MSK_RANGE(low, high)))
119 #define CONF_IS(config, val) ((config) == (1 << (val)))
120 #define CONF_GE(config, val) ((config) & (0-(1 << (val))))
121 #define CONF_GT(config, val) ((config) & (0-2*(1 << (val))))
122 #define CONF_LT(config, val) ((config) & ((1 << (val))-1))
123 #define CONF_LE(config, val) ((config) & (2*(1 << (val))-1))
125 /* Wrappers for some of the above, specific to config constants */
127 #define NCONF_HAS(val) CONF_HAS(NCONF, val)
128 #define NCONF_MSK(mask) CONF_MSK(NCONF, mask)
129 #define NCONF_IS(val) CONF_IS(NCONF, val)
130 #define NCONF_GE(val) CONF_GE(NCONF, val)
131 #define NCONF_GT(val) CONF_GT(NCONF, val)
132 #define NCONF_LT(val) CONF_LT(NCONF, val)
133 #define NCONF_LE(val) CONF_LE(NCONF, val)
135 #define LCNCONF_HAS(val) CONF_HAS(LCNCONF, val)
136 #define LCNCONF_MSK(mask) CONF_MSK(LCNCONF, mask)
137 #define LCNCONF_IS(val) CONF_IS(LCNCONF, val)
138 #define LCNCONF_GE(val) CONF_GE(LCNCONF, val)
139 #define LCNCONF_GT(val) CONF_GT(LCNCONF, val)
140 #define LCNCONF_LT(val) CONF_LT(LCNCONF, val)
141 #define LCNCONF_LE(val) CONF_LE(LCNCONF, val)
143 #define D11CONF_HAS(val) CONF_HAS(D11CONF, val)
144 #define D11CONF_MSK(mask) CONF_MSK(D11CONF, mask)
145 #define D11CONF_IS(val) CONF_IS(D11CONF, val)
146 #define D11CONF_GE(val) CONF_GE(D11CONF, val)
147 #define D11CONF_GT(val) CONF_GT(D11CONF, val)
148 #define D11CONF_LT(val) CONF_LT(D11CONF, val)
149 #define D11CONF_LE(val) CONF_LE(D11CONF, val)
151 #define PHYCONF_HAS(val) CONF_HAS(PHYTYPE, val)
152 #define PHYCONF_IS(val) CONF_IS(PHYTYPE, val)
154 #define NREV_IS(var, val) (NCONF_HAS(val) && (NCONF_IS(val) || ((var) == (val))))
155 #define NREV_GE(var, val) (NCONF_GE(val) && (!NCONF_LT(val) || ((var) >= (val))))
156 #define NREV_GT(var, val) (NCONF_GT(val) && (!NCONF_LE(val) || ((var) > (val))))
157 #define NREV_LT(var, val) (NCONF_LT(val) && (!NCONF_GE(val) || ((var) < (val))))
158 #define NREV_LE(var, val) (NCONF_LE(val) && (!NCONF_GT(val) || ((var) <= (val))))
160 #define LCNREV_IS(var, val) (LCNCONF_HAS(val) && (LCNCONF_IS(val) || ((var) == (val))))
161 #define LCNREV_GE(var, val) (LCNCONF_GE(val) && (!LCNCONF_LT(val) || ((var) >= (val))))
162 #define LCNREV_GT(var, val) (LCNCONF_GT(val) && (!LCNCONF_LE(val) || ((var) > (val))))
163 #define LCNREV_LT(var, val) (LCNCONF_LT(val) && (!LCNCONF_GE(val) || ((var) < (val))))
164 #define LCNREV_LE(var, val) (LCNCONF_LE(val) && (!LCNCONF_GT(val) || ((var) <= (val))))
166 #define D11REV_IS(var, val) (D11CONF_HAS(val) && (D11CONF_IS(val) || ((var) == (val))))
167 #define D11REV_GE(var, val) (D11CONF_GE(val) && (!D11CONF_LT(val) || ((var) >= (val))))
168 #define D11REV_GT(var, val) (D11CONF_GT(val) && (!D11CONF_LE(val) || ((var) > (val))))
169 #define D11REV_LT(var, val) (D11CONF_LT(val) && (!D11CONF_GE(val) || ((var) < (val))))
170 #define D11REV_LE(var, val) (D11CONF_LE(val) && (!D11CONF_GT(val) || ((var) <= (val))))
172 #define PHYTYPE_IS(var, val) (PHYCONF_HAS(val) && (PHYCONF_IS(val) || ((var) == (val))))
174 /* Finally, early-exit from switch case if anyone wants it... */
176 #define CASECHECK(config, val) if (!(CONF_HAS(config, val))) break
177 #define CASEMSK(config, mask) if (!(CONF_MSK(config, mask))) break
179 /* Set up PHYTYPE automatically: (depends on PHY_TYPE_X, from d11.h) */
181 #define _PHYCONF_N (1 << PHY_TYPE_N)
182 #define _PHYCONF_LCN (1 << PHY_TYPE_LCN)
183 #define _PHYCONF_SSLPN (1 << PHY_TYPE_SSN)
185 #define PHYTYPE (_PHYCONF_N | _PHYCONF_LCN | _PHYCONF_SSLPN)
187 /* Utility macro to identify 802.11n (HT) capable PHYs */
188 #define PHYTYPE_11N_CAP(phytype) \
189 (PHYTYPE_IS(phytype, PHY_TYPE_N) || \
190 PHYTYPE_IS(phytype, PHY_TYPE_LCN) || \
191 PHYTYPE_IS(phytype, PHY_TYPE_SSN))
193 /* Last but not least: shorter wlc-specific var checks */
194 #define WLCISNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_N)
195 #define WLCISLCNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_LCN)
196 #define WLCISSSLPNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_SSN)
198 #define WLC_PHY_11N_CAP(band) PHYTYPE_11N_CAP((band)->phytype)
200 /**********************************************************************
201 * ------------- End of Core phy/rev configuration. ----------------- *
202 * ********************************************************************
205 /*************************************************
206 * Defaults for tunables (e.g. sizing constants)
208 * For each new tunable, add a member to the end
209 * of wlc_tunables_t in wlc_pub.h to enable
210 * runtime checks of tunable values. (Directly
211 * using the macros in code invalidates ROM code)
213 * ***********************************************
215 #define NTXD 256 /* Max # of entries in Tx FIFO based on 4kb page size */
216 #define NRXD 256 /* Max # of entries in Rx FIFO based on 4kb page size */
217 #define NRXBUFPOST 32 /* try to keep this # rbufs posted to the chip */
218 #define MAXSCB 32 /* Maximum SCBs in cache for STA */
219 #define AMPDU_NUM_MPDU 16 /* max allowed number of mpdus in an ampdu (2 streams) */
221 /* Count of packet callback structures. either of following
222 * 1. Set to the number of SCBs since a STA
223 * can queue up a rate callback for each IBSS STA it knows about, and an AP can
224 * queue up an "are you there?" Null Data callback for each associated STA
225 * 2. controlled by tunable config file
227 #define MAXPKTCB MAXSCB /* Max number of packet callbacks */
229 /* NetBSD also needs to keep track of this */
230 #define WLC_MAX_UCODE_BSS (16) /* Number of BSS handled in ucode bcn/prb */
231 #define WLC_MAX_UCODE_BSS4 (4) /* Number of BSS handled in sw bcn/prb */
232 #define WLC_MAXBSSCFG (1) /* max # BSS configs */
233 #define MAXBSS 64 /* max # available networks */
234 #define WLC_DATAHIWAT 50 /* data msg txq hiwat mark */
235 #define WLC_AMPDUDATAHIWAT 255
237 /* bounded rx loops */
238 #define RXBND 8 /* max # frames to process in wlc_recv() */
239 #define TXSBND 8 /* max # tx status to process in wlc_txstatus() */
241 #define WLBANDINITFN(_fn) _fn
243 #define BAND_5G(bt) ((bt) == WLC_BAND_5G)
244 #define BAND_2G(bt) ((bt) == WLC_BAND_2G)
246 #define BCMMSG(dev, fmt, args...) \
248 if (brcm_msg_level & LOG_TRACE_VAL) \
249 wiphy_err(dev, "%s: " fmt, __func__, ##args); \
252 #define WL_ERROR_ON() (brcm_msg_level & LOG_ERROR_VAL)
254 /* register access macros */
259 sizeof(*(r)) == sizeof(u8) ? \
260 readb((volatile u8*)(r)) : \
261 sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \
262 readl((volatile u32*)(r)); \
267 __typeof(*(r)) __osl_v; \
268 __asm__ __volatile__("sync"); \
269 switch (sizeof(*(r))) { \
271 __osl_v = readb((volatile u8*)(r)); \
274 __osl_v = readw((volatile u16*)(r)); \
278 readl((volatile u32*)(r)); \
281 __asm__ __volatile__("sync"); \
284 #endif /* __mips__ */
286 #define W_REG(r, v) do { \
287 switch (sizeof(*(r))) { \
289 writeb((u8)(v), (volatile u8*)(r)); break; \
291 writew((u16)(v), (volatile u16*)(r)); break; \
293 writel((u32)(v), (volatile u32*)(r)); break; \
296 #else /* __BIG_ENDIAN */
299 __typeof(*(r)) __osl_v; \
300 switch (sizeof(*(r))) { \
303 readb((volatile u8*)((r)^3)); \
307 readw((volatile u16*)((r)^2)); \
310 __osl_v = readl((volatile u32*)(r)); \
316 #define W_REG(r, v) do { \
317 switch (sizeof(*(r))) { \
320 (volatile u8*)((r)^3)); break; \
323 (volatile u16*)((r)^2)); break; \
326 (volatile u32*)(r)); break; \
329 #endif /* __BIG_ENDIAN */
333 * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
334 * transactions. As a fix, a read after write is performed on certain places
335 * in the code. Older chips and the newer 5357 family don't require this fix.
337 #define W_REG_FLUSH(r, v) ({ W_REG((r), (v)); (void)R_REG(r); })
339 #define W_REG_FLUSH(r, v) W_REG((r), (v))
340 #endif /* __mips__ */
342 #define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
343 #define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
345 #define SET_REG(r, mask, val) \
346 W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
348 /* multi-bool data type: set of bools, mbool is true if any is set */
350 #define mboolset(mb, bit) ((mb) |= (bit)) /* set one bool */
351 #define mboolclr(mb, bit) ((mb) &= ~(bit)) /* clear one bool */
352 #define mboolisset(mb, bit) (((mb) & (bit)) != 0) /* true if one bool is set */
353 #define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
355 /* forward declarations */
375 typedef struct gpioh_item gpioh_item_t;
376 typedef struct si_info si_info_t;
377 typedef struct wlc_bmac_state wlc_bmac_state_t;
378 typedef struct locale_info locale_info_t;
379 typedef struct locale_mimo_info locale_mimo_info_t;
380 typedef struct country_info country_info_t;
381 typedef struct wlc_cm_info wlc_cm_info_t;
382 typedef volatile struct intctrlregs intctrlregs_t;
383 typedef volatile struct pio2regs pio2regs_t;
384 typedef volatile struct pio2regp pio2regp_t;
385 typedef struct ofdm_phy_hdr ofdm_phy_hdr_t;
386 typedef struct cck_phy_hdr cck_phy_hdr_t;
387 typedef struct d11txh d11txh_t;
388 typedef struct tx_status tx_status_t;
389 typedef struct shm_acparams shm_acparams_t;
390 typedef struct d11rxhdr d11rxhdr_t;
391 typedef struct wlc_d11rxhdr wlc_d11rxhdr_t;
392 typedef volatile struct pio4regs pio4regs_t;
393 typedef volatile struct pio4regp pio4regp_t;
394 typedef volatile struct fifo64 fifo64_t;
395 typedef volatile struct d11regs d11regs_t;
396 typedef struct macstat macstat_t;
397 typedef struct d11cnt d11cnt_t;
398 typedef volatile struct dma32diag dma32diag_t;
399 typedef volatile struct dma64regs dma64regs_t;
400 typedef enum txd_range txd_range_t;
401 typedef struct di_fcn_s di_fcn_t;
402 typedef struct wsec_iv wsec_iv_t;
403 typedef struct wsec_key wsec_key_t;
404 typedef struct edcf_acparam edcf_acparam_t;
405 typedef struct wme_param_ie wme_param_ie_t;
406 typedef struct wlc_phy_shim_info wlc_phy_shim_info_t;
407 typedef struct wlc_tunables wlc_tunables_t;
408 typedef struct wlc_rateset wlc_rateset_t;
409 typedef struct wlc_bss_info wlc_bss_info_t;
410 typedef struct wl_rxsts wl_rxsts_t;
411 typedef struct wlc_antselcfg wlc_antselcfg_t;
412 typedef struct mcs_info mcs_info_t;
413 typedef u32 ratespec_t;
414 typedef struct scb_ampdu_tid_ini scb_ampdu_tid_ini_t;
415 typedef struct scb_ampdu scb_ampdu_t;
416 typedef struct txpwr_limits txpwr_limits_t;
417 typedef struct tx_power tx_power_t;
418 typedef struct tx_inst_power tx_inst_power_t;
419 typedef struct chanvec chanvec_t;
420 typedef struct shared_phy shared_phy_t;
421 typedef struct shared_phy_params shared_phy_params_t;
422 typedef struct phy_pub wlc_phy_t;
423 typedef struct wlc_phy_srom_fem wlc_phy_srom_fem_t;
424 typedef struct phy_info phy_info_t;
425 typedef enum phy_cal_mode phy_cal_mode_t;
426 typedef struct phy_table_info phy_table_info_t;
427 typedef struct phytbl_info phytbl_info_t;
428 typedef struct interference_info interference_info_t;
429 typedef struct aci_save_gphy aci_save_gphy_t;
430 typedef struct lo_complex_abgphy_info lo_complex_abgphy_info_t;
431 typedef struct nphy_iq_comp nphy_iq_comp_t;
432 typedef struct nphy_txpwrindex phy_txpwrindex_t;
433 typedef struct txiqcal_cache txiqcal_cache_t;
434 typedef struct nphy_pwrctrl phy_pwrctrl_t;
435 typedef struct nphy_txgains nphy_txgains_t;
436 typedef struct nphy_noisevar_buf phy_noisevar_buf_t;
437 typedef struct rssical_cache rssical_cache_t;
438 typedef struct lcnphy_cal_results lcnphy_cal_results_t;
439 typedef struct phy_info_nphy phy_info_nphy_t;
440 typedef struct phy_info_lcnphy phy_info_lcnphy_t;
441 typedef struct phy_func_ptr phy_func_ptr_t;
443 typedef struct _cs32 cs32;
444 typedef struct radio_regs radio_regs_t;
445 typedef struct radio_20xx_regs radio_20xx_regs_t;
446 typedef struct lcnphy_radio_regs lcnphy_radio_regs_t;
447 typedef struct phy_iq_est phy_iq_est_t;
448 typedef phytbl_info_t dot11lcnphytbl_info_t;
449 typedef struct _lcnphy_tx_gain_tbl_entry lcnphy_tx_gain_tbl_entry;
450 typedef phytbl_info_t mimophytbl_info_t;
451 typedef volatile union pmqreg pmqreg_t;
452 typedef enum _ePsmScratchPadRegDefinitions ePsmScratchPadRegDefinitions;
454 /* brcm_msg_level is a bit vector with defs in defs.h */
455 extern u32 brcm_msg_level;
457 #endif /* _BRCM_TYPES_H_ */