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