PageRenderTime 44ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/bcmdhd/include/bcmdefs.h

https://gitlab.com/cr3pt/nkernel
C Header | 287 lines | 167 code | 41 blank | 79 comment | 4 complexity | 0cfff4b8a949aa9a0b6d7eff4469f7c0 MD5 | raw file
  1. /*
  2. * Misc system wide definitions
  3. *
  4. * Copyright (C) 1999-2013, Broadcom Corporation
  5. *
  6. * Unless you and Broadcom execute a separate written software license
  7. * agreement governing use of this software, this software is licensed to you
  8. * under the terms of the GNU General Public License version 2 (the "GPL"),
  9. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  10. * following added to such license:
  11. *
  12. * As a special exception, the copyright holders of this software give you
  13. * permission to link this software with independent modules, and to copy and
  14. * distribute the resulting executable under terms of your choice, provided that
  15. * you also meet, for each linked independent module, the terms and conditions of
  16. * the license of that module. An independent module is a module which is not
  17. * derived from this software. The special exception does not apply to any
  18. * modifications of the software.
  19. *
  20. * Notwithstanding the above, under no circumstances may you combine this
  21. * software in any way with any other Broadcom software provided under a license
  22. * other than the GPL, without Broadcom's express prior written consent.
  23. *
  24. * $Id: bcmdefs.h 416231 2013-08-02 07:38:34Z $
  25. */
  26. #ifndef _bcmdefs_h_
  27. #define _bcmdefs_h_
  28. /*
  29. * One doesn't need to include this file explicitly, gets included automatically if
  30. * typedefs.h is included.
  31. */
  32. /* Use BCM_REFERENCE to suppress warnings about intentionally-unused function
  33. * arguments or local variables.
  34. */
  35. #define BCM_REFERENCE(data) ((void)(data))
  36. /* Compile-time assert can be used in place of ASSERT if the expression evaluates
  37. * to a constant at compile time.
  38. */
  39. #define STATIC_ASSERT(expr) { \
  40. /* Make sure the expression is constant. */ \
  41. typedef enum { _STATIC_ASSERT_NOT_CONSTANT = (expr) } _static_assert_e; \
  42. /* Make sure the expression is true. */ \
  43. typedef char STATIC_ASSERT_FAIL[(expr) ? 1 : -1]; \
  44. }
  45. /* Reclaiming text and data :
  46. * The following macros specify special linker sections that can be reclaimed
  47. * after a system is considered 'up'.
  48. * BCMATTACHFN is also used for detach functions (it's not worth having a BCMDETACHFN,
  49. * as in most cases, the attach function calls the detach function to clean up on error).
  50. */
  51. #define bcmreclaimed 0
  52. #define _data _data
  53. #define _fn _fn
  54. #define BCMPREATTACHDATA(_data) _data
  55. #define BCMPREATTACHFN(_fn) _fn
  56. #define _data _data
  57. #define _fn _fn
  58. #define _fn _fn
  59. #define BCMNMIATTACHFN(_fn) _fn
  60. #define BCMNMIATTACHDATA(_data) _data
  61. #define CONST const
  62. /* Do not put BCM47XX and __ARM_ARCH_7A__ to the same line.
  63. * DHD build has problem because the BCM47XX will be excluded in DHD release.
  64. */
  65. #undef BCM47XX_CA9
  66. #ifdef __ARM_ARCH_7A__
  67. #define BCM47XX_CA9
  68. #endif /* __ARM_ARCH_7A__ */
  69. #ifndef BCMFASTPATH
  70. #if defined(BCM47XX_CA9)
  71. #define BCMFASTPATH __attribute__ ((__section__ (".text.fastpath")))
  72. #define BCMFASTPATH_HOST __attribute__ ((__section__ (".text.fastpath_host")))
  73. #else
  74. #define BCMFASTPATH
  75. #define BCMFASTPATH_HOST
  76. #endif
  77. #endif /* BCMFASTPATH */
  78. /* Put some library data/code into ROM to reduce RAM requirements */
  79. #define _data _data
  80. #define BCMROMDAT_NAME(_data) _data
  81. #define _fn _fn
  82. #define _fn _fn
  83. #define STATIC static
  84. #define BCMROMDAT_ARYSIZ(data) ARRAYSIZE(data)
  85. #define BCMROMDAT_SIZEOF(data) sizeof(data)
  86. #define BCMROMDAT_APATCH(data)
  87. #define BCMROMDAT_SPATCH(data)
  88. /* Bus types */
  89. #define SI_BUS 0 /* SOC Interconnect */
  90. #define PCI_BUS 1 /* PCI target */
  91. #define PCMCIA_BUS 2 /* PCMCIA target */
  92. #define SDIO_BUS 3 /* SDIO target */
  93. #define JTAG_BUS 4 /* JTAG */
  94. #define USB_BUS 5 /* USB (does not support R/W REG) */
  95. #define SPI_BUS 6 /* gSPI target */
  96. #define RPC_BUS 7 /* RPC target */
  97. /* Allows size optimization for single-bus image */
  98. #ifdef BCMBUSTYPE
  99. #define BUSTYPE(bus) (BCMBUSTYPE)
  100. #else
  101. #define BUSTYPE(bus) (bus)
  102. #endif
  103. /* Allows size optimization for single-backplane image */
  104. #ifdef BCMCHIPTYPE
  105. #define CHIPTYPE(bus) (BCMCHIPTYPE)
  106. #else
  107. #define CHIPTYPE(bus) (bus)
  108. #endif
  109. /* Allows size optimization for SPROM support */
  110. #if defined(BCMSPROMBUS)
  111. #define SPROMBUS (BCMSPROMBUS)
  112. #elif defined(SI_PCMCIA_SROM)
  113. #define SPROMBUS (PCMCIA_BUS)
  114. #else
  115. #define SPROMBUS (PCI_BUS)
  116. #endif
  117. /* Allows size optimization for single-chip image */
  118. #ifdef BCMCHIPID
  119. #define CHIPID(chip) (BCMCHIPID)
  120. #else
  121. #define CHIPID(chip) (chip)
  122. #endif
  123. #ifdef BCMCHIPREV
  124. #define CHIPREV(rev) (BCMCHIPREV)
  125. #else
  126. #define CHIPREV(rev) (rev)
  127. #endif
  128. /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
  129. #define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */
  130. #define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */
  131. #define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */
  132. #define DMADDRWIDTH_30 30 /* 30-bit addressing capability */
  133. #define DMADDRWIDTH_32 32 /* 32-bit addressing capability */
  134. #define DMADDRWIDTH_63 63 /* 64-bit addressing capability */
  135. #define DMADDRWIDTH_64 64 /* 64-bit addressing capability */
  136. #ifdef BCMDMA64OSL
  137. typedef struct {
  138. uint32 loaddr;
  139. uint32 hiaddr;
  140. } dma64addr_t;
  141. typedef dma64addr_t dmaaddr_t;
  142. #define PHYSADDRHI(_pa) ((_pa).hiaddr)
  143. #define PHYSADDRHISET(_pa, _val) \
  144. do { \
  145. (_pa).hiaddr = (_val); \
  146. } while (0)
  147. #define PHYSADDRLO(_pa) ((_pa).loaddr)
  148. #define PHYSADDRLOSET(_pa, _val) \
  149. do { \
  150. (_pa).loaddr = (_val); \
  151. } while (0)
  152. #else
  153. typedef unsigned long dmaaddr_t;
  154. #define PHYSADDRHI(_pa) (0)
  155. #define PHYSADDRHISET(_pa, _val)
  156. #define PHYSADDRLO(_pa) ((_pa))
  157. #define PHYSADDRLOSET(_pa, _val) \
  158. do { \
  159. (_pa) = (_val); \
  160. } while (0)
  161. #endif /* BCMDMA64OSL */
  162. /* One physical DMA segment */
  163. typedef struct {
  164. dmaaddr_t addr;
  165. uint32 length;
  166. } hnddma_seg_t;
  167. #define MAX_DMA_SEGS 4
  168. typedef struct {
  169. void *oshdmah; /* Opaque handle for OSL to store its information */
  170. uint origsize; /* Size of the virtual packet */
  171. uint nsegs;
  172. hnddma_seg_t segs[MAX_DMA_SEGS];
  173. } hnddma_seg_map_t;
  174. /* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
  175. * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
  176. * There is a compile time check in wlc.c which ensure that this value is at least as big
  177. * as TXOFF. This value is used in dma_rxfill (hnddma.c).
  178. */
  179. #if defined(BCM_RPC_NOCOPY) || defined(BCM_RCP_TXNOCOPY)
  180. /* add 40 bytes to allow for extra RPC header and info */
  181. #define BCMEXTRAHDROOM 260
  182. #else /* BCM_RPC_NOCOPY || BCM_RPC_TXNOCOPY */
  183. #if defined(BCM47XX_CA9)
  184. #define BCMEXTRAHDROOM 224
  185. #else
  186. #define BCMEXTRAHDROOM 204
  187. #endif /* linux && BCM47XX_CA9 */
  188. #endif /* BCM_RPC_NOCOPY || BCM_RPC_TXNOCOPY */
  189. /* Packet alignment for most efficient SDIO (can change based on platform) */
  190. #ifndef SDALIGN
  191. #define SDALIGN 32
  192. #endif
  193. /* Headroom required for dongle-to-host communication. Packets allocated
  194. * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
  195. * leave this much room in front for low-level message headers which may
  196. * be needed to get across the dongle bus to the host. (These messages
  197. * don't go over the network, so room for the full WL header above would
  198. * be a waste.).
  199. */
  200. #define BCMDONGLEHDRSZ 12
  201. #define BCMDONGLEPADSZ 16
  202. #define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
  203. #if defined(NO_BCMDBG_ASSERT)
  204. # undef BCMDBG_ASSERT
  205. # undef BCMASSERT_LOG
  206. #endif
  207. #if defined(BCMASSERT_LOG)
  208. #define BCMASSERT_SUPPORT
  209. #endif
  210. /* Macros for doing definition and get/set of bitfields
  211. * Usage example, e.g. a three-bit field (bits 4-6):
  212. * #define <NAME>_M BITFIELD_MASK(3)
  213. * #define <NAME>_S 4
  214. * ...
  215. * regval = R_REG(osh, &regs->regfoo);
  216. * field = GFIELD(regval, <NAME>);
  217. * regval = SFIELD(regval, <NAME>, 1);
  218. * W_REG(osh, &regs->regfoo, regval);
  219. */
  220. #define BITFIELD_MASK(width) \
  221. (((unsigned)1 << (width)) - 1)
  222. #define GFIELD(val, field) \
  223. (((val) >> field ## _S) & field ## _M)
  224. #define SFIELD(val, field, bits) \
  225. (((val) & (~(field ## _M << field ## _S))) | \
  226. ((unsigned)(bits) << field ## _S))
  227. /* define BCMSMALL to remove misc features for memory-constrained environments */
  228. #ifdef BCMSMALL
  229. #undef BCMSPACE
  230. #define bcmspace FALSE /* if (bcmspace) code is discarded */
  231. #else
  232. #define BCMSPACE
  233. #define bcmspace TRUE /* if (bcmspace) code is retained */
  234. #endif
  235. /* Max. nvram variable table size */
  236. #define MAXSZ_NVRAM_VARS 4096
  237. /* Max size for reclaimable NVRAM array */
  238. #ifdef DL_NVRAM
  239. #define NVRAM_ARRAY_MAXSIZE DL_NVRAM
  240. #else
  241. #define NVRAM_ARRAY_MAXSIZE MAXSZ_NVRAM_VARS
  242. #endif /* DL_NVRAM */
  243. #ifdef BCMUSBDEV_ENABLED
  244. extern uint32 gFWID;
  245. #endif
  246. #endif /* _bcmdefs_h_ */