staging: brcm80211: remove redundant CHIPREV macro
[cascardo/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
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 */
38
39 #ifdef mips
40 #define BCMFASTPATH             __attribute__ ((__section__(".text.fastpath")))
41 #else
42 #define BCMFASTPATH
43 #endif
44
45 /* Bus types */
46 #define SI_BUS                  0       /* SOC Interconnect */
47 #define PCI_BUS                 1       /* PCI target */
48 #define SDIO_BUS                3       /* SDIO target */
49 #define JTAG_BUS                4       /* JTAG */
50 #define USB_BUS                 5       /* USB (does not support R/W REG) */
51 #define SPI_BUS                 6       /* gSPI target */
52 #define RPC_BUS                 7       /* RPC target */
53
54
55 /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
56 #define DMADDR_MASK_32 0x0      /* Address mask for 32-bits */
57 #define DMADDR_MASK_30 0xc0000000       /* Address mask for 30-bits */
58 #define DMADDR_MASK_0  0xffffffff       /* Address mask for 0-bits (hi-part) */
59
60 #define DMADDRWIDTH_30  30      /* 30-bit addressing capability */
61 #define DMADDRWIDTH_32  32      /* 32-bit addressing capability */
62 #define DMADDRWIDTH_63  63      /* 64-bit addressing capability */
63 #define DMADDRWIDTH_64  64      /* 64-bit addressing capability */
64
65 #ifdef BCMDMA64OSL
66 typedef struct {
67         u32 loaddr;
68         u32 hiaddr;
69 } dma64addr_t;
70
71 typedef dma64addr_t dmaaddr_t;
72 #define PHYSADDRHI(_pa) ((_pa).hiaddr)
73 #define PHYSADDRHISET(_pa, _val) \
74         do { \
75                 (_pa).hiaddr = (_val);          \
76         } while (0)
77 #define PHYSADDRLO(_pa) ((_pa).loaddr)
78 #define PHYSADDRLOSET(_pa, _val) \
79         do { \
80                 (_pa).loaddr = (_val);          \
81         } while (0)
82
83 #else
84 typedef unsigned long dmaaddr_t;
85 #define PHYSADDRHI(_pa) (0)
86 #define PHYSADDRHISET(_pa, _val)
87 #define PHYSADDRLO(_pa) ((_pa))
88 #define PHYSADDRLOSET(_pa, _val) \
89         do { \
90                 (_pa) = (_val);                 \
91         } while (0)
92 #endif                          /* BCMDMA64OSL */
93
94 /* One physical DMA segment */
95 typedef struct {
96         dmaaddr_t addr;
97         u32 length;
98 } hnddma_seg_t;
99
100 #define MAX_DMA_SEGS 4
101
102 typedef struct {
103         void *oshdmah;          /* Opaque handle for OSL to store its information */
104         uint origsize;          /* Size of the virtual packet */
105         uint nsegs;
106         hnddma_seg_t segs[MAX_DMA_SEGS];
107 } hnddma_seg_map_t;
108
109 /* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
110  * By doing, we avoid the need  to allocate an extra buffer for the header when bridging to WL.
111  * There is a compile time check in wlc.c which ensure that this value is at least as big
112  * as TXOFF. This value is used in dma_rxfill (hnddma.c).
113  */
114
115 #define BCMEXTRAHDROOM 172
116
117 #ifdef BCMDBG
118 #ifndef BCMDBG_ASSERT
119 #define BCMDBG_ASSERT
120 #endif  /* BCMDBG_ASSERT */
121 #endif  /* BCMDBG */
122
123 /* Macros for doing definition and get/set of bitfields
124  * Usage example, e.g. a three-bit field (bits 4-6):
125  *    #define <NAME>_M  BITFIELD_MASK(3)
126  *    #define <NAME>_S  4
127  * ...
128  *    regval = R_REG(osh, &regs->regfoo);
129  *    field = GFIELD(regval, <NAME>);
130  *    regval = SFIELD(regval, <NAME>, 1);
131  *    W_REG(osh, &regs->regfoo, regval);
132  */
133 #define BITFIELD_MASK(width) \
134                 (((unsigned)1 << (width)) - 1)
135 #define GFIELD(val, field) \
136                 (((val) >> field ## _S) & field ## _M)
137 #define SFIELD(val, field, bits) \
138                 (((val) & (~(field ## _M << field ## _S))) | \
139                  ((unsigned)(bits) << field ## _S))
140
141 /* Max. nvram variable table size */
142 #define MAXSZ_NVRAM_VARS        4096
143
144 /* handle forward declaration */
145 struct wl_info;
146
147 #endif                          /* _bcmdefs_h_ */