]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/brcm80211/include/bcmdefs.h
Staging: Add initial release of brcm80211 - Broadcom 802.11n wireless LAN driver.
[karo-tx-linux.git] / drivers / staging / brcm80211 / include / bcmdefs.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 #ifndef _bcmdefs_h_
18 #define _bcmdefs_h_
19
20 /*
21  * One doesn't need to include this file explicitly, gets included automatically if
22  * typedefs.h is included.
23  */
24
25 /* Use BCM_REFERENCE to suppress warnings about intentionally-unused function
26  * arguments or local variables.
27  */
28 #define BCM_REFERENCE(data)     ((void)data)
29
30 /* Reclaiming text and data :
31  * The following macros specify special linker sections that can be reclaimed
32  * after a system is considered 'up'.
33  * BCMATTACHFN is also used for detach functions (it's not worth having a BCMDETACHFN,
34  * as in most cases, the attach function calls the detach function to clean up on error).
35  */
36
37 #define bcmreclaimed            0
38 #define BCMATTACHDATA(_data)    _data
39 #define BCMATTACHFN(_fn)        _fn
40 #define BCMPREATTACHDATA(_data) _data
41 #define BCMPREATTACHFN(_fn)     _fn
42 #define BCMINITDATA(_data)      _data
43 #define BCMINITFN(_fn)          _fn
44 #define BCMUNINITFN(_fn)        _fn
45 #define BCMNMIATTACHFN(_fn)     _fn
46 #define BCMNMIATTACHDATA(_data) _data
47 #define BCMOVERLAY0DATA(_sym)   _sym
48 #define BCMOVERLAY0FN(_fn)      _fn
49 #define BCMOVERLAY1DATA(_sym)   _sym
50 #define BCMOVERLAY1FN(_fn)      _fn
51 #define BCMOVERLAYERRFN(_fn)    _fn
52 #define CONST   const
53 #ifdef mips
54 #define BCMFASTPATH             __attribute__ ((__section__(".text.fastpath")))
55 #else
56 #define BCMFASTPATH
57 #endif
58
59 /* Put some library data/code into ROM to reduce RAM requirements */
60 #define BCMROMDATA(_data)       _data
61 #define BCMROMDAT_NAME(_data)   _data
62 #define BCMROMFN(_fn)           _fn
63 #define BCMROMFN_NAME(_fn)      _fn
64 #define STATIC  static
65 #define BCMROMDAT_ARYSIZ(data)  ARRAYSIZE(data)
66 #define BCMROMDAT_SIZEOF(data)  sizeof(data)
67 #define BCMROMDAT_APATCH(data)
68 #define BCMROMDAT_SPATCH(data)
69
70 /* Bus types */
71 #define SI_BUS                  0       /* SOC Interconnect */
72 #define PCI_BUS                 1       /* PCI target */
73 #define SDIO_BUS                3       /* SDIO target */
74 #define JTAG_BUS                4       /* JTAG */
75 #define USB_BUS                 5       /* USB (does not support R/W REG) */
76 #define SPI_BUS                 6       /* gSPI target */
77 #define RPC_BUS                 7       /* RPC target */
78
79 /* Allows size optimization for single-bus image */
80 #ifdef BCMBUSTYPE
81 #define BUSTYPE(bus)    (BCMBUSTYPE)
82 #else
83 #define BUSTYPE(bus)    (bus)
84 #endif
85
86 /* Allows size optimization for single-backplane image */
87 #ifdef BCMCHIPTYPE
88 #define CHIPTYPE(bus)   (BCMCHIPTYPE)
89 #else
90 #define CHIPTYPE(bus)   (bus)
91 #endif
92
93 /* Allows size optimization for SPROM support */
94 #define SPROMBUS        (PCI_BUS)
95
96 /* Allows size optimization for single-chip image */
97 #ifdef BCMCHIPID
98 #define CHIPID(chip)    (BCMCHIPID)
99 #else
100 #define CHIPID(chip)    (chip)
101 #endif
102
103 #ifdef BCMCHIPREV
104 #define CHIPREV(rev)    (BCMCHIPREV)
105 #else
106 #define CHIPREV(rev)    (rev)
107 #endif
108
109 /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
110 #define DMADDR_MASK_32 0x0      /* Address mask for 32-bits */
111 #define DMADDR_MASK_30 0xc0000000       /* Address mask for 30-bits */
112 #define DMADDR_MASK_0  0xffffffff       /* Address mask for 0-bits (hi-part) */
113
114 #define DMADDRWIDTH_30  30      /* 30-bit addressing capability */
115 #define DMADDRWIDTH_32  32      /* 32-bit addressing capability */
116 #define DMADDRWIDTH_63  63      /* 64-bit addressing capability */
117 #define DMADDRWIDTH_64  64      /* 64-bit addressing capability */
118
119 #ifdef BCMDMA64OSL
120 typedef struct {
121         uint32 loaddr;
122         uint32 hiaddr;
123 } dma64addr_t;
124
125 typedef dma64addr_t dmaaddr_t;
126 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
127 #define PHYSADDRHISET(_pa, _val) \
128         do { \
129                 (_pa).hiaddr = (_val);          \
130         } while (0)
131 #define PHYSADDRLO(_pa) ((_pa).loaddr)
132 #define PHYSADDRLOSET(_pa, _val) \
133         do { \
134                 (_pa).loaddr = (_val);          \
135         } while (0)
136
137 #else
138 typedef unsigned long dmaaddr_t;
139 #define PHYSADDRHI(_pa) (0)
140 #define PHYSADDRHISET(_pa, _val)
141 #define PHYSADDRLO(_pa) ((_pa))
142 #define PHYSADDRLOSET(_pa, _val) \
143         do { \
144                 (_pa) = (_val);                 \
145         } while (0)
146 #endif                          /* BCMDMA64OSL */
147
148 /* One physical DMA segment */
149 typedef struct {
150         dmaaddr_t addr;
151         uint32 length;
152 } hnddma_seg_t;
153
154 #define MAX_DMA_SEGS 4
155
156 typedef struct {
157         void *oshdmah;          /* Opaque handle for OSL to store its information */
158         uint origsize;          /* Size of the virtual packet */
159         uint nsegs;
160         hnddma_seg_t segs[MAX_DMA_SEGS];
161 } hnddma_seg_map_t;
162
163 /* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
164  * By doing, we avoid the need  to allocate an extra buffer for the header when bridging to WL.
165  * There is a compile time check in wlc.c which ensure that this value is at least as big
166  * as TXOFF. This value is used in dma_rxfill (hnddma.c).
167  */
168
169 #define BCMEXTRAHDROOM 172
170
171 /* Headroom required for dongle-to-host communication.  Packets allocated
172  * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
173  * leave this much room in front for low-level message headers which may
174  * be needed to get across the dongle bus to the host.  (These messages
175  * don't go over the network, so room for the full WL header above would
176  * be a waste.).
177 */
178 #define BCMDONGLEHDRSZ 12
179 #define BCMDONGLEPADSZ 16
180
181 #define BCMDONGLEOVERHEAD       (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
182
183 #ifdef BCMDBG
184
185 #define BCMDBG_ERR
186
187 #ifndef BCMDBG_ASSERT
188 #define BCMDBG_ASSERT
189 #endif                          /* BCMDBG_ASSERT */
190
191 #endif                          /* BCMDBG */
192
193 #if defined(BCMDBG_ASSERT)
194 #define BCMASSERT_SUPPORT
195 #endif
196
197 /* Macros for doing definition and get/set of bitfields
198  * Usage example, e.g. a three-bit field (bits 4-6):
199  *    #define <NAME>_M  BITFIELD_MASK(3)
200  *    #define <NAME>_S  4
201  * ...
202  *    regval = R_REG(osh, &regs->regfoo);
203  *    field = GFIELD(regval, <NAME>);
204  *    regval = SFIELD(regval, <NAME>, 1);
205  *    W_REG(osh, &regs->regfoo, regval);
206  */
207 #define BITFIELD_MASK(width) \
208                 (((unsigned)1 << (width)) - 1)
209 #define GFIELD(val, field) \
210                 (((val) >> field ## _S) & field ## _M)
211 #define SFIELD(val, field, bits) \
212                 (((val) & (~(field ## _M << field ## _S))) | \
213                  ((unsigned)(bits) << field ## _S))
214
215 /* define BCMSMALL to remove misc features for memory-constrained environments */
216 #define BCMSPACE
217 #define bcmspace        TRUE    /* if (bcmspace) code is retained */
218
219 /* Max. nvram variable table size */
220 #define MAXSZ_NVRAM_VARS        4096
221
222 #define LOCATOR_EXTERN static
223
224 #endif                          /* _bcmdefs_h_ */