2 * Misc system wide definitions
4 * Copyright (C) 1999-2011, Broadcom Corporation
6 * Unless you and Broadcom execute a separate written software license
7 * agreement governing use of this software, this software is licensed to you
8 * under the terms of the GNU General Public License version 2 (the "GPL"),
9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10 * following added to such license:
12 * As a special exception, the copyright holders of this software give you
13 * permission to link this software with independent modules, and to copy and
14 * distribute the resulting executable under terms of your choice, provided that
15 * you also meet, for each linked independent module, the terms and conditions of
16 * the license of that module. An independent module is a module which is not
17 * derived from this software. The special exception does not apply to any
18 * modifications of the software.
20 * Notwithstanding the above, under no circumstances may you combine this
21 * software in any way with any other Broadcom software provided under a license
22 * other than the GPL, without Broadcom's express prior written consent.
24 * $Id: bcmdefs.h,v 13.68.2.8 2011-01-08 04:04:19 $
31 * One doesn't need to include this file explicitly, gets included automatically if
32 * typedefs.h is included.
35 /* Use BCM_REFERENCE to suppress warnings about intentionally-unused function
36 * arguments or local variables.
38 #define BCM_REFERENCE(data) ((void)(data))
40 /* Reclaiming text and data :
41 * The following macros specify special linker sections that can be reclaimed
42 * after a system is considered 'up'.
43 * BCMATTACHFN is also used for detach functions (it's not worth having a BCMDETACHFN,
44 * as in most cases, the attach function calls the detach function to clean up on error).
47 #define bcmreclaimed 0
48 #define BCMATTACHDATA(_data) _data
49 #define BCMATTACHFN(_fn) _fn
50 #define BCMPREATTACHDATA(_data) _data
51 #define BCMPREATTACHFN(_fn) _fn
52 #define BCMINITDATA(_data) _data
53 #define BCMINITFN(_fn) _fn
54 #define BCMUNINITFN(_fn) _fn
55 #define BCMNMIATTACHFN(_fn) _fn
56 #define BCMNMIATTACHDATA(_data) _data
57 #define BCMOVERLAY0DATA(_sym) _sym
58 #define BCMOVERLAY0FN(_fn) _fn
59 #define BCMOVERLAY1DATA(_sym) _sym
60 #define BCMOVERLAY1FN(_fn) _fn
61 #define BCMOVERLAYERRFN(_fn) _fn
67 /* Put some library data/code into ROM to reduce RAM requirements */
68 #define BCMROMDATA(_data) _data
69 #define BCMROMDAT_NAME(_data) _data
70 #define BCMROMFN(_fn) _fn
71 #define BCMROMFN_NAME(_fn) _fn
73 #define BCMROMDAT_ARYSIZ(data) ARRAYSIZE(data)
74 #define BCMROMDAT_SIZEOF(data) sizeof(data)
75 #define BCMROMDAT_APATCH(data)
76 #define BCMROMDAT_SPATCH(data)
78 /* overlay function tagging */
80 #define OVERLAY_INLINE
81 #define OSTATIC static
82 #define BCMOVERLAYDATA(_ovly, _sym) _sym
83 #define BCMOVERLAYFN(_ovly, _fn) _fn
84 #define BCMOVERLAYERRFN(_fn) _fn
85 #define BCMROMOVERLAYDATA(_ovly, _data) BCMROMDATA(_data)
86 #define BCMROMOVERLAYFN(_ovly, _fn) BCMROMFN(_fn)
87 #define BCMATTACHOVERLAYDATA(_ovly, _sym) BCMATTACHDATA(_sym)
88 #define BCMATTACHOVERLAYFN(_ovly, _fn) BCMATTACHFN(_fn)
89 #define BCMINITOVERLAYDATA(_ovly, _sym) BCMINITDATA(_sym)
90 #define BCMINITOVERLAYFN(_ovly, _fn) BCMINITFN(_fn)
91 #define BCMUNINITOVERLAYFN(_ovly, _fn) BCMUNINITFN(_fn)
95 #define SI_BUS 0 /* SOC Interconnect */
96 #define PCI_BUS 1 /* PCI target */
97 #define PCMCIA_BUS 2 /* PCMCIA target */
98 #define SDIO_BUS 3 /* SDIO target */
99 #define JTAG_BUS 4 /* JTAG */
100 #define USB_BUS 5 /* USB (does not support R/W REG) */
101 #define SPI_BUS 6 /* gSPI target */
102 #define RPC_BUS 7 /* RPC target */
104 /* Allows size optimization for single-bus image */
106 #define BUSTYPE(bus) (BCMBUSTYPE)
108 #define BUSTYPE(bus) (bus)
111 /* Allows size optimization for single-backplane image */
113 #define CHIPTYPE(bus) (BCMCHIPTYPE)
115 #define CHIPTYPE(bus) (bus)
119 /* Allows size optimization for SPROM support */
120 #if defined(BCMSPROMBUS)
121 #define SPROMBUS (BCMSPROMBUS)
122 #elif defined(SI_PCMCIA_SROM)
123 #define SPROMBUS (PCMCIA_BUS)
125 #define SPROMBUS (PCI_BUS)
128 /* Allows size optimization for single-chip image */
130 #define CHIPID(chip) (BCMCHIPID)
132 #define CHIPID(chip) (chip)
136 #define CHIPREV(rev) (BCMCHIPREV)
138 #define CHIPREV(rev) (rev)
141 /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
142 #define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */
143 #define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */
144 #define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */
146 #define DMADDRWIDTH_30 30 /* 30-bit addressing capability */
147 #define DMADDRWIDTH_32 32 /* 32-bit addressing capability */
148 #define DMADDRWIDTH_63 63 /* 64-bit addressing capability */
149 #define DMADDRWIDTH_64 64 /* 64-bit addressing capability */
157 typedef dma64addr_t dmaaddr_t;
158 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
159 #define PHYSADDRHISET(_pa, _val) \
161 (_pa).hiaddr = (_val); \
163 #define PHYSADDRLO(_pa) ((_pa).loaddr)
164 #define PHYSADDRLOSET(_pa, _val) \
166 (_pa).loaddr = (_val); \
170 typedef unsigned long dmaaddr_t;
171 #define PHYSADDRHI(_pa) (0)
172 #define PHYSADDRHISET(_pa, _val)
173 #define PHYSADDRLO(_pa) ((_pa))
174 #define PHYSADDRLOSET(_pa, _val) \
178 #endif /* BCMDMA64OSL */
180 /* One physical DMA segment */
186 #define MAX_DMA_SEGS 4
190 void *oshdmah; /* Opaque handle for OSL to store its information */
191 uint origsize; /* Size of the virtual packet */
193 hnddma_seg_t segs[MAX_DMA_SEGS];
197 /* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
198 * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
199 * There is a compile time check in wlc.c which ensure that this value is at least as big
200 * as TXOFF. This value is used in dma_rxfill (hnddma.c).
203 #if defined(BCM_RPC_NOCOPY) || defined(BCM_RCP_TXNOCOPY)
204 /* add 40 bytes to allow for extra RPC header and info */
205 #define BCMEXTRAHDROOM 220
206 #elif defined(BCM43237) && defined(BCMPKTPOOL) && defined(DMATXRC)
207 #define BCMEXTRAHDROOM 0
209 #define BCMEXTRAHDROOM 172
212 /* Headroom required for dongle-to-host communication. Packets allocated
213 * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
214 * leave this much room in front for low-level message headers which may
215 * be needed to get across the dongle bus to the host. (These messages
216 * don't go over the network, so room for the full WL header above would
219 #define BCMDONGLEHDRSZ 12
220 #define BCMDONGLEPADSZ 16
222 #define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
225 #if defined(BCMASSERT_LOG)
226 #define BCMASSERT_SUPPORT
229 /* Macros for doing definition and get/set of bitfields
230 * Usage example, e.g. a three-bit field (bits 4-6):
231 * #define <NAME>_M BITFIELD_MASK(3)
234 * regval = R_REG(osh, ®s->regfoo);
235 * field = GFIELD(regval, <NAME>);
236 * regval = SFIELD(regval, <NAME>, 1);
237 * W_REG(osh, ®s->regfoo, regval);
239 #define BITFIELD_MASK(width) \
240 (((unsigned)1 << (width)) - 1)
241 #define GFIELD(val, field) \
242 (((val) >> field ## _S) & field ## _M)
243 #define SFIELD(val, field, bits) \
244 (((val) & (~(field ## _M << field ## _S))) | \
245 ((unsigned)(bits) << field ## _S))
247 /* define BCMSMALL to remove misc features for memory-constrained environments */
250 #define bcmspace FALSE /* if (bcmspace) code is discarded */
253 #define bcmspace TRUE /* if (bcmspace) code is retained */
256 /* Max. nvram variable table size */
257 #define MAXSZ_NVRAM_VARS 4096
259 #define LOCATOR_EXTERN static
261 #endif /* _bcmdefs_h_ */