blob: dc52e9dbb8b5ac2178c7a869b4ff7e7fba42b15e [file] [log] [blame]
Henry Ptasinskia9533e72010-09-08 21:04:42 -07001/*
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
Henry Ptasinskicf2b4482010-09-20 22:33:12 -070020#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
Greg Kroah-Hartmana1c16ed2010-10-21 11:17:44 -070027
28
29#ifndef OFF
30#define OFF 0
31#endif
32
33#ifndef ON
34#define ON 1 /* ON = 1 */
35#endif
36
37#define AUTO (-1) /* Auto = -1 */
Henry Ptasinskia9533e72010-09-08 21:04:42 -070038
Henry Ptasinskia9533e72010-09-08 21:04:42 -070039#ifdef mips
40#define BCMFASTPATH __attribute__ ((__section__(".text.fastpath")))
41#else
42#define BCMFASTPATH
43#endif
44
45/* Put some library data/code into ROM to reduce RAM requirements */
Henry Ptasinskia9533e72010-09-08 21:04:42 -070046#define BCMROMFN(_fn) _fn
Henry Ptasinskia9533e72010-09-08 21:04:42 -070047
48/* Bus types */
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 */
56
57/* Allows size optimization for single-bus image */
58#ifdef BCMBUSTYPE
59#define BUSTYPE(bus) (BCMBUSTYPE)
60#else
61#define BUSTYPE(bus) (bus)
62#endif
63
64/* Allows size optimization for single-backplane image */
65#ifdef BCMCHIPTYPE
66#define CHIPTYPE(bus) (BCMCHIPTYPE)
67#else
68#define CHIPTYPE(bus) (bus)
69#endif
70
71/* Allows size optimization for SPROM support */
72#define SPROMBUS (PCI_BUS)
73
74/* Allows size optimization for single-chip image */
75#ifdef BCMCHIPID
76#define CHIPID(chip) (BCMCHIPID)
77#else
78#define CHIPID(chip) (chip)
79#endif
80
81#ifdef BCMCHIPREV
82#define CHIPREV(rev) (BCMCHIPREV)
83#else
84#define CHIPREV(rev) (rev)
85#endif
86
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) */
91
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 */
96
97#ifdef BCMDMA64OSL
98typedef struct {
Greg Kroah-Hartman66cbd3a2010-10-08 11:05:47 -070099 u32 loaddr;
100 u32 hiaddr;
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700101} dma64addr_t;
102
103typedef dma64addr_t dmaaddr_t;
104#define PHYSADDRHI(_pa) ((_pa).hiaddr)
105#define PHYSADDRHISET(_pa, _val) \
106 do { \
107 (_pa).hiaddr = (_val); \
108 } while (0)
109#define PHYSADDRLO(_pa) ((_pa).loaddr)
110#define PHYSADDRLOSET(_pa, _val) \
111 do { \
112 (_pa).loaddr = (_val); \
113 } while (0)
114
115#else
116typedef unsigned long dmaaddr_t;
117#define PHYSADDRHI(_pa) (0)
118#define PHYSADDRHISET(_pa, _val)
119#define PHYSADDRLO(_pa) ((_pa))
120#define PHYSADDRLOSET(_pa, _val) \
121 do { \
122 (_pa) = (_val); \
123 } while (0)
124#endif /* BCMDMA64OSL */
125
126/* One physical DMA segment */
127typedef struct {
128 dmaaddr_t addr;
Greg Kroah-Hartman66cbd3a2010-10-08 11:05:47 -0700129 u32 length;
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700130} hnddma_seg_t;
131
132#define MAX_DMA_SEGS 4
133
134typedef struct {
135 void *oshdmah; /* Opaque handle for OSL to store its information */
136 uint origsize; /* Size of the virtual packet */
137 uint nsegs;
138 hnddma_seg_t segs[MAX_DMA_SEGS];
139} hnddma_seg_map_t;
140
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).
145 */
146
147#define BCMEXTRAHDROOM 172
148
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
154 * be a waste.).
155*/
156#define BCMDONGLEHDRSZ 12
157#define BCMDONGLEPADSZ 16
158
159#define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
160
161#ifdef BCMDBG
162
163#define BCMDBG_ERR
164
165#ifndef BCMDBG_ASSERT
166#define BCMDBG_ASSERT
167#endif /* BCMDBG_ASSERT */
168
169#endif /* BCMDBG */
170
171#if defined(BCMDBG_ASSERT)
172#define BCMASSERT_SUPPORT
173#endif
174
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)
178 * #define <NAME>_S 4
179 * ...
180 * regval = R_REG(osh, &regs->regfoo);
181 * field = GFIELD(regval, <NAME>);
182 * regval = SFIELD(regval, <NAME>, 1);
183 * W_REG(osh, &regs->regfoo, regval);
184 */
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))
192
193/* define BCMSMALL to remove misc features for memory-constrained environments */
194#define BCMSPACE
Greg Kroah-Hartman0f0881b2010-10-12 12:15:18 -0700195#define bcmspace true /* if (bcmspace) code is retained */
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700196
197/* Max. nvram variable table size */
198#define MAXSZ_NVRAM_VARS 4096
199
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700200#endif /* _bcmdefs_h_ */