]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/brcm80211/include/bcmdefs.h
Staging: brcm80211: s/uint32/u32/
[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
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).
38  */
39
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
47 #ifdef mips
48 #define BCMFASTPATH             __attribute__ ((__section__(".text.fastpath")))
49 #else
50 #define BCMFASTPATH
51 #endif
52
53 /* Put some library data/code into ROM to reduce RAM requirements */
54 #define BCMROMFN(_fn)           _fn
55
56 /* Bus types */
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 */
64
65 /* Allows size optimization for single-bus image */
66 #ifdef BCMBUSTYPE
67 #define BUSTYPE(bus)    (BCMBUSTYPE)
68 #else
69 #define BUSTYPE(bus)    (bus)
70 #endif
71
72 /* Allows size optimization for single-backplane image */
73 #ifdef BCMCHIPTYPE
74 #define CHIPTYPE(bus)   (BCMCHIPTYPE)
75 #else
76 #define CHIPTYPE(bus)   (bus)
77 #endif
78
79 /* Allows size optimization for SPROM support */
80 #define SPROMBUS        (PCI_BUS)
81
82 /* Allows size optimization for single-chip image */
83 #ifdef BCMCHIPID
84 #define CHIPID(chip)    (BCMCHIPID)
85 #else
86 #define CHIPID(chip)    (chip)
87 #endif
88
89 #ifdef BCMCHIPREV
90 #define CHIPREV(rev)    (BCMCHIPREV)
91 #else
92 #define CHIPREV(rev)    (rev)
93 #endif
94
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) */
99
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 */
104
105 #ifdef BCMDMA64OSL
106 typedef struct {
107         u32 loaddr;
108         u32 hiaddr;
109 } dma64addr_t;
110
111 typedef dma64addr_t dmaaddr_t;
112 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
113 #define PHYSADDRHISET(_pa, _val) \
114         do { \
115                 (_pa).hiaddr = (_val);          \
116         } while (0)
117 #define PHYSADDRLO(_pa) ((_pa).loaddr)
118 #define PHYSADDRLOSET(_pa, _val) \
119         do { \
120                 (_pa).loaddr = (_val);          \
121         } while (0)
122
123 #else
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) \
129         do { \
130                 (_pa) = (_val);                 \
131         } while (0)
132 #endif                          /* BCMDMA64OSL */
133
134 /* One physical DMA segment */
135 typedef struct {
136         dmaaddr_t addr;
137         u32 length;
138 } hnddma_seg_t;
139
140 #define MAX_DMA_SEGS 4
141
142 typedef struct {
143         void *oshdmah;          /* Opaque handle for OSL to store its information */
144         uint origsize;          /* Size of the virtual packet */
145         uint nsegs;
146         hnddma_seg_t segs[MAX_DMA_SEGS];
147 } hnddma_seg_map_t;
148
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).
153  */
154
155 #define BCMEXTRAHDROOM 172
156
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
162  * be a waste.).
163 */
164 #define BCMDONGLEHDRSZ 12
165 #define BCMDONGLEPADSZ 16
166
167 #define BCMDONGLEOVERHEAD       (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
168
169 #ifdef BCMDBG
170
171 #define BCMDBG_ERR
172
173 #ifndef BCMDBG_ASSERT
174 #define BCMDBG_ASSERT
175 #endif                          /* BCMDBG_ASSERT */
176
177 #endif                          /* BCMDBG */
178
179 #if defined(BCMDBG_ASSERT)
180 #define BCMASSERT_SUPPORT
181 #endif
182
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)
186  *    #define <NAME>_S  4
187  * ...
188  *    regval = R_REG(osh, &regs->regfoo);
189  *    field = GFIELD(regval, <NAME>);
190  *    regval = SFIELD(regval, <NAME>, 1);
191  *    W_REG(osh, &regs->regfoo, regval);
192  */
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))
200
201 /* define BCMSMALL to remove misc features for memory-constrained environments */
202 #define BCMSPACE
203 #define bcmspace        TRUE    /* if (bcmspace) code is retained */
204
205 /* Max. nvram variable table size */
206 #define MAXSZ_NVRAM_VARS        4096
207
208 #endif                          /* _bcmdefs_h_ */