upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / net / wireless / bcm4330 / src / include / bcmdefs.h
1 /*
2  * Misc system wide definitions
3  *
4  * Copyright (C) 1999-2011, Broadcom Corporation
5  * 
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:
11  * 
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.
19  * 
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.
23  *
24  * $Id: bcmdefs.h,v 13.68.2.8 2011-01-08 04:04:19 $
25  */
26
27 #ifndef _bcmdefs_h_
28 #define _bcmdefs_h_
29
30 /*
31  * One doesn't need to include this file explicitly, gets included automatically if
32  * typedefs.h is included.
33  */
34
35 /* Use BCM_REFERENCE to suppress warnings about intentionally-unused function
36  * arguments or local variables.
37  */
38 #define BCM_REFERENCE(data)     ((void)(data))
39
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).
45  */
46
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
62 #define CONST   const
63 #define BCMFASTPATH
64
65
66
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
72 #define STATIC  static
73 #define BCMROMDAT_ARYSIZ(data)  ARRAYSIZE(data)
74 #define BCMROMDAT_SIZEOF(data)  sizeof(data)
75 #define BCMROMDAT_APATCH(data)
76 #define BCMROMDAT_SPATCH(data)
77
78 /* overlay function tagging */
79
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)
92
93
94 /* Bus types */
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 */
103
104 /* Allows size optimization for single-bus image */
105 #ifdef BCMBUSTYPE
106 #define BUSTYPE(bus)    (BCMBUSTYPE)
107 #else
108 #define BUSTYPE(bus)    (bus)
109 #endif
110
111 /* Allows size optimization for single-backplane image */
112 #ifdef BCMCHIPTYPE
113 #define CHIPTYPE(bus)   (BCMCHIPTYPE)
114 #else
115 #define CHIPTYPE(bus)   (bus)
116 #endif
117
118
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)
124 #else
125 #define SPROMBUS        (PCI_BUS)
126 #endif
127
128 /* Allows size optimization for single-chip image */
129 #ifdef BCMCHIPID
130 #define CHIPID(chip)    (BCMCHIPID)
131 #else
132 #define CHIPID(chip)    (chip)
133 #endif
134
135 #ifdef BCMCHIPREV
136 #define CHIPREV(rev)    (BCMCHIPREV)
137 #else
138 #define CHIPREV(rev)    (rev)
139 #endif
140
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) */
145
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 */
150
151 #ifdef BCMDMA64OSL
152 typedef struct {
153         uint32 loaddr;
154         uint32 hiaddr;
155 } dma64addr_t;
156
157 typedef dma64addr_t dmaaddr_t;
158 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
159 #define PHYSADDRHISET(_pa, _val) \
160         do { \
161                 (_pa).hiaddr = (_val);          \
162         } while (0)
163 #define PHYSADDRLO(_pa) ((_pa).loaddr)
164 #define PHYSADDRLOSET(_pa, _val) \
165         do { \
166                 (_pa).loaddr = (_val);          \
167         } while (0)
168
169 #else
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) \
175         do { \
176                 (_pa) = (_val);                 \
177         } while (0)
178 #endif /* BCMDMA64OSL */
179
180 /* One physical DMA segment */
181 typedef struct  {
182         dmaaddr_t addr;
183         uint32    length;
184 } hnddma_seg_t;
185
186 #define MAX_DMA_SEGS 4
187
188
189 typedef struct {
190         void *oshdmah; /* Opaque handle for OSL to store its information */
191         uint origsize; /* Size of the virtual packet */
192         uint nsegs;
193         hnddma_seg_t segs[MAX_DMA_SEGS];
194 } hnddma_seg_map_t;
195
196
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).
201  */
202
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
208 #else
209 #define BCMEXTRAHDROOM 172
210 #endif
211
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
217  * be a waste.).
218 */
219 #define BCMDONGLEHDRSZ 12
220 #define BCMDONGLEPADSZ 16
221
222 #define BCMDONGLEOVERHEAD       (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
223
224
225 #if defined(BCMASSERT_LOG)
226 #define BCMASSERT_SUPPORT
227 #endif 
228
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)
232  *    #define <NAME>_S  4
233  * ...
234  *    regval = R_REG(osh, &regs->regfoo);
235  *    field = GFIELD(regval, <NAME>);
236  *    regval = SFIELD(regval, <NAME>, 1);
237  *    W_REG(osh, &regs->regfoo, regval);
238  */
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))
246
247 /* define BCMSMALL to remove misc features for memory-constrained environments */
248 #ifdef BCMSMALL
249 #undef  BCMSPACE
250 #define bcmspace        FALSE   /* if (bcmspace) code is discarded */
251 #else
252 #define BCMSPACE
253 #define bcmspace        TRUE    /* if (bcmspace) code is retained */
254 #endif
255
256 /* Max. nvram variable table size */
257 #define MAXSZ_NVRAM_VARS        4096
258
259 #define LOCATOR_EXTERN static
260
261 #endif /* _bcmdefs_h_ */