]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/staging/brcm80211/include/bcmdefs.h
Staging: brcm80211: remove BCMATTACHFN macro
[net-next-2.6.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  */
37 #define BCMINITDATA(_data)      _data
38 #define BCMINITFN(_fn)          _fn
39 #define BCMUNINITFN(_fn)        _fn
40 #define BCMNMIATTACHFN(_fn)     _fn
41 #ifdef mips
42 #define BCMFASTPATH             __attribute__ ((__section__(".text.fastpath")))
43 #else
44 #define BCMFASTPATH
45 #endif
46
47 /* Put some library data/code into ROM to reduce RAM requirements */
48 #define BCMROMFN(_fn)           _fn
49
50 /* Bus types */
51 #define SI_BUS                  0       /* SOC Interconnect */
52 #define PCI_BUS                 1       /* PCI target */
53 #define SDIO_BUS                3       /* SDIO target */
54 #define JTAG_BUS                4       /* JTAG */
55 #define USB_BUS                 5       /* USB (does not support R/W REG) */
56 #define SPI_BUS                 6       /* gSPI target */
57 #define RPC_BUS                 7       /* RPC target */
58
59 /* Allows size optimization for single-bus image */
60 #ifdef BCMBUSTYPE
61 #define BUSTYPE(bus)    (BCMBUSTYPE)
62 #else
63 #define BUSTYPE(bus)    (bus)
64 #endif
65
66 /* Allows size optimization for single-backplane image */
67 #ifdef BCMCHIPTYPE
68 #define CHIPTYPE(bus)   (BCMCHIPTYPE)
69 #else
70 #define CHIPTYPE(bus)   (bus)
71 #endif
72
73 /* Allows size optimization for SPROM support */
74 #define SPROMBUS        (PCI_BUS)
75
76 /* Allows size optimization for single-chip image */
77 #ifdef BCMCHIPID
78 #define CHIPID(chip)    (BCMCHIPID)
79 #else
80 #define CHIPID(chip)    (chip)
81 #endif
82
83 #ifdef BCMCHIPREV
84 #define CHIPREV(rev)    (BCMCHIPREV)
85 #else
86 #define CHIPREV(rev)    (rev)
87 #endif
88
89 /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
90 #define DMADDR_MASK_32 0x0      /* Address mask for 32-bits */
91 #define DMADDR_MASK_30 0xc0000000       /* Address mask for 30-bits */
92 #define DMADDR_MASK_0  0xffffffff       /* Address mask for 0-bits (hi-part) */
93
94 #define DMADDRWIDTH_30  30      /* 30-bit addressing capability */
95 #define DMADDRWIDTH_32  32      /* 32-bit addressing capability */
96 #define DMADDRWIDTH_63  63      /* 64-bit addressing capability */
97 #define DMADDRWIDTH_64  64      /* 64-bit addressing capability */
98
99 #ifdef BCMDMA64OSL
100 typedef struct {
101         u32 loaddr;
102         u32 hiaddr;
103 } dma64addr_t;
104
105 typedef dma64addr_t dmaaddr_t;
106 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
107 #define PHYSADDRHISET(_pa, _val) \
108         do { \
109                 (_pa).hiaddr = (_val);          \
110         } while (0)
111 #define PHYSADDRLO(_pa) ((_pa).loaddr)
112 #define PHYSADDRLOSET(_pa, _val) \
113         do { \
114                 (_pa).loaddr = (_val);          \
115         } while (0)
116
117 #else
118 typedef unsigned long dmaaddr_t;
119 #define PHYSADDRHI(_pa) (0)
120 #define PHYSADDRHISET(_pa, _val)
121 #define PHYSADDRLO(_pa) ((_pa))
122 #define PHYSADDRLOSET(_pa, _val) \
123         do { \
124                 (_pa) = (_val);                 \
125         } while (0)
126 #endif                          /* BCMDMA64OSL */
127
128 /* One physical DMA segment */
129 typedef struct {
130         dmaaddr_t addr;
131         u32 length;
132 } hnddma_seg_t;
133
134 #define MAX_DMA_SEGS 4
135
136 typedef struct {
137         void *oshdmah;          /* Opaque handle for OSL to store its information */
138         uint origsize;          /* Size of the virtual packet */
139         uint nsegs;
140         hnddma_seg_t segs[MAX_DMA_SEGS];
141 } hnddma_seg_map_t;
142
143 /* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
144  * By doing, we avoid the need  to allocate an extra buffer for the header when bridging to WL.
145  * There is a compile time check in wlc.c which ensure that this value is at least as big
146  * as TXOFF. This value is used in dma_rxfill (hnddma.c).
147  */
148
149 #define BCMEXTRAHDROOM 172
150
151 /* Headroom required for dongle-to-host communication.  Packets allocated
152  * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
153  * leave this much room in front for low-level message headers which may
154  * be needed to get across the dongle bus to the host.  (These messages
155  * don't go over the network, so room for the full WL header above would
156  * be a waste.).
157 */
158 #define BCMDONGLEHDRSZ 12
159 #define BCMDONGLEPADSZ 16
160
161 #define BCMDONGLEOVERHEAD       (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
162
163 #ifdef BCMDBG
164
165 #define BCMDBG_ERR
166
167 #ifndef BCMDBG_ASSERT
168 #define BCMDBG_ASSERT
169 #endif                          /* BCMDBG_ASSERT */
170
171 #endif                          /* BCMDBG */
172
173 #if defined(BCMDBG_ASSERT)
174 #define BCMASSERT_SUPPORT
175 #endif
176
177 /* Macros for doing definition and get/set of bitfields
178  * Usage example, e.g. a three-bit field (bits 4-6):
179  *    #define <NAME>_M  BITFIELD_MASK(3)
180  *    #define <NAME>_S  4
181  * ...
182  *    regval = R_REG(osh, &regs->regfoo);
183  *    field = GFIELD(regval, <NAME>);
184  *    regval = SFIELD(regval, <NAME>, 1);
185  *    W_REG(osh, &regs->regfoo, regval);
186  */
187 #define BITFIELD_MASK(width) \
188                 (((unsigned)1 << (width)) - 1)
189 #define GFIELD(val, field) \
190                 (((val) >> field ## _S) & field ## _M)
191 #define SFIELD(val, field, bits) \
192                 (((val) & (~(field ## _M << field ## _S))) | \
193                  ((unsigned)(bits) << field ## _S))
194
195 /* define BCMSMALL to remove misc features for memory-constrained environments */
196 #define BCMSPACE
197 #define bcmspace        TRUE    /* if (bcmspace) code is retained */
198
199 /* Max. nvram variable table size */
200 #define MAXSZ_NVRAM_VARS        4096
201
202 #endif                          /* _bcmdefs_h_ */