Tomato-ND 1.21
[tomato.git] / release / src / include / bcmdefs.h
blob4886c7f5935321f44eac90f11a65d14a99238b65
1 /*
2 * Misc system wide definitions
4 * Copyright 2006, Broadcom Corporation
5 * All Rights Reserved.
6 *
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11 * $Id$
14 #ifndef _bcmdefs_h_
15 #define _bcmdefs_h_
18 * One doesn't need to include this file explicitly, gets included automatically if
19 * typedefs.h is included.
22 /* Reclaiming text and data :
23 * The following macros specify special linker sections that can be reclaimed
24 * after a system is considered 'up'.
26 #if defined(BCMRECLAIM)
27 extern bool bcmreclaimed;
28 #define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data
29 #define BCMINITFN(_fn) __attribute__ ((noinline, __section__ (".textini." #_fn))) _fn
30 #else
31 #define BCMINITDATA(_data) _data
32 #define BCMINITFN(_fn) _fn
33 #define bcmreclaimed 0
34 #endif
36 /* Reclaim uninit functions if BCMNODOWN is defined */
37 /* and if they are not already removed by -gc-sections */
38 #ifdef BCMNODOWN
39 #define BCMUNINITFN(_fn) BCMINITFN(_fn)
40 #else
41 #define BCMUNINITFN(_fn) _fn
42 #endif
44 #ifdef BCMRECLAIM
45 #define CONST
46 #else
47 #define CONST const
48 #endif /* BCMRECLAIM */
50 /* Compatibility with old-style BCMRECLAIM */
51 #define BCMINIT(_id) _id
54 /* Put some library data/code into ROM to reduce RAM requirements */
55 #if defined(BCMROMOFFLOAD)
56 #define BCMROMDATA(_data) __attribute__ ((__section__ (".datarom." #_data))) _data
57 #define BCMROMFN(_fn) __attribute__ ((noinline, long_call)) _fn
58 #else
59 #define BCMROMDATA(_data) _data
60 #define BCMROMFN(_fn) _fn
61 #endif
63 /* Bus types */
64 #define SB_BUS 0 /* Silicon Backplane */
65 #define PCI_BUS 1 /* PCI target */
66 #define PCMCIA_BUS 2 /* PCMCIA target */
67 #define SDIO_BUS 3 /* SDIO target */
68 #define JTAG_BUS 4 /* JTAG */
69 #define USB_BUS 5 /* USB (does not support R/W REG) */
71 /* Allows optimization for single-bus support */
72 #ifdef BCMBUSTYPE
73 #define BUSTYPE(bus) (BCMBUSTYPE)
74 #else
75 #define BUSTYPE(bus) (bus)
76 #endif
78 /* Tell where the SPROM is hanging off */
79 #if defined(BCMSPROMBUS)
80 #define SPROMBUS (BCMSPROMBUS)
81 #elif defined(SB_PCMCIA_SROM)
82 #define SPROMBUS (PCMCIA_BUS)
83 #else
84 #define SPROMBUS (PCI_BUS)
85 #endif
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 */
97 /* packet headroom necessary to accomodate the largest header in the system, (i.e TXOFF).
98 * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
99 * There is a compile time check in wlc.c which ensure that this value is at least as big
100 * as TXOFF. This value is used in dma_rxfill (hnddma.c).
102 #define BCMEXTRAHDROOM 160
104 /* Headroom required for dongle-to-host communication. Packets allocated
105 * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
106 * leave this much room in front for low-level message headers which may
107 * be needed to get across the dongle bus to the host. (These messages
108 * don't go over the network, so room for the full WL header above would
109 * be a waste.).
111 #ifdef BCMUSBDEV
112 #define BCMDONGLEHDRSZ 0
113 #else
114 #define BCMDONGLEHDRSZ 8
115 #endif
117 #ifdef BCMDBG
119 #define BCMDBG_ERR
121 #ifndef BCMDBG_ASSERT
122 #define BCMDBG_ASSERT
123 #endif /* BCMDBG_ASSERT */
125 #endif /* BCMDBG */
127 /* Brett's nifty macros for doing definition and get/set of bitfields
128 * Usage example, e.g. a three-bit field (bits 4-6):
129 * #define <NAME>_M BITFIELD_MASK(3)
130 * #define <NAME>_S 4
131 * ...
132 * regval = R_REG(osh, &regs->regfoo);
133 * field = GFIELD(regval, <NAME>);
134 * regval = SFIELD(regval, <NAME>, 1);
135 * W_REG(osh, &regs->regfoo, regval);
137 #define BITFIELD_MASK(width) ((1 << width)-1)
138 #define GFIELD(val, field) ((val >> field ## _S) & field ## _M)
139 #define SFIELD(val, field, bits) ((val & (~(field ## _M << field ## _S))) | (bits << field ## _S))
141 /* define BCMSMALL to remove misc features for memory constrained enviroments */
142 #ifdef BCMSMALL
143 #undef BCMSPACE
144 #define bcmspace FALSE /* if (bcmspace) code is discarded */
145 #else
146 #define BCMSPACE
147 #define bcmspace TRUE /* if (bcmspace) code is retained */
148 #endif
150 #endif /* _bcmdefs_h_ */