2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
34 #define ON 1 /* ON = 1 */
37 #define AUTO (-1) /* Auto = -1 */
40 #define BCMFASTPATH __attribute__ ((__section__(".text.fastpath")))
45 /* Put some library data/code into ROM to reduce RAM requirements */
46 #define BCMROMFN(_fn) _fn
49 #define SI_BUS 0 /* SOC Interconnect */
50 #define PCI_BUS 1 /* PCI target */
51 #define SDIO_BUS 3 /* SDIO target */
52 #define JTAG_BUS 4 /* JTAG */
53 #define USB_BUS 5 /* USB (does not support R/W REG) */
54 #define SPI_BUS 6 /* gSPI target */
55 #define RPC_BUS 7 /* RPC target */
57 /* Allows size optimization for single-bus image */
59 #define BUSTYPE(bus) (BCMBUSTYPE)
61 #define BUSTYPE(bus) (bus)
64 /* Allows size optimization for single-backplane image */
66 #define CHIPTYPE(bus) (BCMCHIPTYPE)
68 #define CHIPTYPE(bus) (bus)
71 /* Allows size optimization for SPROM support */
72 #define SPROMBUS (PCI_BUS)
74 /* Allows size optimization for single-chip image */
76 #define CHIPID(chip) (BCMCHIPID)
78 #define CHIPID(chip) (chip)
82 #define CHIPREV(rev) (BCMCHIPREV)
84 #define CHIPREV(rev) (rev)
87 /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
88 #define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */
89 #define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */
90 #define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */
92 #define DMADDRWIDTH_30 30 /* 30-bit addressing capability */
93 #define DMADDRWIDTH_32 32 /* 32-bit addressing capability */
94 #define DMADDRWIDTH_63 63 /* 64-bit addressing capability */
95 #define DMADDRWIDTH_64 64 /* 64-bit addressing capability */
103 typedef dma64addr_t dmaaddr_t;
104 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
105 #define PHYSADDRHISET(_pa, _val) \
107 (_pa).hiaddr = (_val); \
109 #define PHYSADDRLO(_pa) ((_pa).loaddr)
110 #define PHYSADDRLOSET(_pa, _val) \
112 (_pa).loaddr = (_val); \
116 typedef unsigned long dmaaddr_t;
117 #define PHYSADDRHI(_pa) (0)
118 #define PHYSADDRHISET(_pa, _val)
119 #define PHYSADDRLO(_pa) ((_pa))
120 #define PHYSADDRLOSET(_pa, _val) \
124 #endif /* BCMDMA64OSL */
126 /* One physical DMA segment */
132 #define MAX_DMA_SEGS 4
135 void *oshdmah; /* Opaque handle for OSL to store its information */
136 uint origsize; /* Size of the virtual packet */
138 hnddma_seg_t segs[MAX_DMA_SEGS];
141 /* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
142 * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
143 * There is a compile time check in wlc.c which ensure that this value is at least as big
144 * as TXOFF. This value is used in dma_rxfill (hnddma.c).
147 #define BCMEXTRAHDROOM 172
149 /* Headroom required for dongle-to-host communication. Packets allocated
150 * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
151 * leave this much room in front for low-level message headers which may
152 * be needed to get across the dongle bus to the host. (These messages
153 * don't go over the network, so room for the full WL header above would
156 #define BCMDONGLEHDRSZ 12
157 #define BCMDONGLEPADSZ 16
159 #define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
165 #ifndef BCMDBG_ASSERT
166 #define BCMDBG_ASSERT
167 #endif /* BCMDBG_ASSERT */
171 #if defined(BCMDBG_ASSERT)
172 #define BCMASSERT_SUPPORT
175 /* Macros for doing definition and get/set of bitfields
176 * Usage example, e.g. a three-bit field (bits 4-6):
177 * #define <NAME>_M BITFIELD_MASK(3)
180 * regval = R_REG(osh, ®s->regfoo);
181 * field = GFIELD(regval, <NAME>);
182 * regval = SFIELD(regval, <NAME>, 1);
183 * W_REG(osh, ®s->regfoo, regval);
185 #define BITFIELD_MASK(width) \
186 (((unsigned)1 << (width)) - 1)
187 #define GFIELD(val, field) \
188 (((val) >> field ## _S) & field ## _M)
189 #define SFIELD(val, field, bits) \
190 (((val) & (~(field ## _M << field ## _S))) | \
191 ((unsigned)(bits) << field ## _S))
193 /* define BCMSMALL to remove misc features for memory-constrained environments */
195 #define bcmspace true /* if (bcmspace) code is retained */
197 /* Max. nvram variable table size */
198 #define MAXSZ_NVRAM_VARS 4096
200 #endif /* _bcmdefs_h_ */