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.
28 * One doesn't need to include this file explicitly, gets included automatically if
29 * typedefs.h is included.
33 /* Reclaiming text and data :
34 * The following macros specify special linker sections that can be reclaimed
35 * after a system is considered 'up'.
36 * BCMATTACHFN is also used for detach functions (it's not worth having a BCMDETACHFN,
37 * as in most cases, the attach function calls the detach function to clean up on error).
40 #define bcmreclaimed 0
41 #define BCMATTACHDATA(_data) _data
42 #define BCMATTACHFN(_fn) _fn
43 #define BCMINITDATA(_data) _data
44 #define BCMINITFN(_fn) _fn
45 #define BCMUNINITFN(_fn) _fn
46 #define BCMNMIATTACHFN(_fn) _fn
48 #define BCMFASTPATH __attribute__ ((__section__(".text.fastpath")))
53 /* Put some library data/code into ROM to reduce RAM requirements */
54 #define BCMROMFN(_fn) _fn
57 #define SI_BUS 0 /* SOC Interconnect */
58 #define PCI_BUS 1 /* PCI target */
59 #define SDIO_BUS 3 /* SDIO target */
60 #define JTAG_BUS 4 /* JTAG */
61 #define USB_BUS 5 /* USB (does not support R/W REG) */
62 #define SPI_BUS 6 /* gSPI target */
63 #define RPC_BUS 7 /* RPC target */
65 /* Allows size optimization for single-bus image */
67 #define BUSTYPE(bus) (BCMBUSTYPE)
69 #define BUSTYPE(bus) (bus)
72 /* Allows size optimization for single-backplane image */
74 #define CHIPTYPE(bus) (BCMCHIPTYPE)
76 #define CHIPTYPE(bus) (bus)
79 /* Allows size optimization for SPROM support */
80 #define SPROMBUS (PCI_BUS)
82 /* Allows size optimization for single-chip image */
84 #define CHIPID(chip) (BCMCHIPID)
86 #define CHIPID(chip) (chip)
90 #define CHIPREV(rev) (BCMCHIPREV)
92 #define CHIPREV(rev) (rev)
95 /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
96 #define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */
97 #define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */
98 #define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */
100 #define DMADDRWIDTH_30 30 /* 30-bit addressing capability */
101 #define DMADDRWIDTH_32 32 /* 32-bit addressing capability */
102 #define DMADDRWIDTH_63 63 /* 64-bit addressing capability */
103 #define DMADDRWIDTH_64 64 /* 64-bit addressing capability */
111 typedef dma64addr_t dmaaddr_t;
112 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
113 #define PHYSADDRHISET(_pa, _val) \
115 (_pa).hiaddr = (_val); \
117 #define PHYSADDRLO(_pa) ((_pa).loaddr)
118 #define PHYSADDRLOSET(_pa, _val) \
120 (_pa).loaddr = (_val); \
124 typedef unsigned long dmaaddr_t;
125 #define PHYSADDRHI(_pa) (0)
126 #define PHYSADDRHISET(_pa, _val)
127 #define PHYSADDRLO(_pa) ((_pa))
128 #define PHYSADDRLOSET(_pa, _val) \
132 #endif /* BCMDMA64OSL */
134 /* One physical DMA segment */
140 #define MAX_DMA_SEGS 4
143 void *oshdmah; /* Opaque handle for OSL to store its information */
144 uint origsize; /* Size of the virtual packet */
146 hnddma_seg_t segs[MAX_DMA_SEGS];
149 /* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
150 * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
151 * There is a compile time check in wlc.c which ensure that this value is at least as big
152 * as TXOFF. This value is used in dma_rxfill (hnddma.c).
155 #define BCMEXTRAHDROOM 172
157 /* Headroom required for dongle-to-host communication. Packets allocated
158 * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
159 * leave this much room in front for low-level message headers which may
160 * be needed to get across the dongle bus to the host. (These messages
161 * don't go over the network, so room for the full WL header above would
164 #define BCMDONGLEHDRSZ 12
165 #define BCMDONGLEPADSZ 16
167 #define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
173 #ifndef BCMDBG_ASSERT
174 #define BCMDBG_ASSERT
175 #endif /* BCMDBG_ASSERT */
179 #if defined(BCMDBG_ASSERT)
180 #define BCMASSERT_SUPPORT
183 /* Macros for doing definition and get/set of bitfields
184 * Usage example, e.g. a three-bit field (bits 4-6):
185 * #define <NAME>_M BITFIELD_MASK(3)
188 * regval = R_REG(osh, ®s->regfoo);
189 * field = GFIELD(regval, <NAME>);
190 * regval = SFIELD(regval, <NAME>, 1);
191 * W_REG(osh, ®s->regfoo, regval);
193 #define BITFIELD_MASK(width) \
194 (((unsigned)1 << (width)) - 1)
195 #define GFIELD(val, field) \
196 (((val) >> field ## _S) & field ## _M)
197 #define SFIELD(val, field, bits) \
198 (((val) & (~(field ## _M << field ## _S))) | \
199 ((unsigned)(bits) << field ## _S))
201 /* define BCMSMALL to remove misc features for memory-constrained environments */
203 #define bcmspace TRUE /* if (bcmspace) code is retained */
205 /* Max. nvram variable table size */
206 #define MAXSZ_NVRAM_VARS 4096
208 #endif /* _bcmdefs_h_ */