types.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. #ifndef _BRCM_TYPES_H_
  17. #define _BRCM_TYPES_H_
  18. #include <linux/types.h>
  19. #include <linux/io.h>
  20. #define WL_CHAN_FREQ_RANGE_2G 0
  21. #define WL_CHAN_FREQ_RANGE_5GL 1
  22. #define WL_CHAN_FREQ_RANGE_5GM 2
  23. #define WL_CHAN_FREQ_RANGE_5GH 3
  24. /* boardflags */
  25. /* Board has gpio 9 controlling the PA */
  26. #define BFL_PACTRL 0x00000002
  27. /* Not ok to power down the chip pll and oscillator */
  28. #define BFL_NOPLLDOWN 0x00000020
  29. /* Board supports the Front End Module */
  30. #define BFL_FEM 0x00000800
  31. /* Board has an external LNA in 2.4GHz band */
  32. #define BFL_EXTLNA 0x00001000
  33. /* Board has no PA */
  34. #define BFL_NOPA 0x00010000
  35. /* Power topology uses BUCKBOOST */
  36. #define BFL_BUCKBOOST 0x00200000
  37. /* Board has FEM and switch to share antenna w/ BT */
  38. #define BFL_FEM_BT 0x00400000
  39. /* Power topology doesn't use CBUCK */
  40. #define BFL_NOCBUCK 0x00800000
  41. /* Power topology uses PALDO */
  42. #define BFL_PALDO 0x02000000
  43. /* Board has an external LNA in 5GHz band */
  44. #define BFL_EXTLNA_5GHz 0x10000000
  45. /* boardflags2 */
  46. /* Board has an external rxbb regulator */
  47. #define BFL2_RXBB_INT_REG_DIS 0x00000001
  48. /* Flag to implement alternative A-band PLL settings */
  49. #define BFL2_APLL_WAR 0x00000002
  50. /* Board permits enabling TX Power Control */
  51. #define BFL2_TXPWRCTRL_EN 0x00000004
  52. /* Board supports the 2X4 diversity switch */
  53. #define BFL2_2X4_DIV 0x00000008
  54. /* Board supports 5G band power gain */
  55. #define BFL2_5G_PWRGAIN 0x00000010
  56. /* Board overrides ASPM and Clkreq settings */
  57. #define BFL2_PCIEWAR_OVR 0x00000020
  58. #define BFL2_LEGACY 0x00000080
  59. /* 4321mcm93 board uses Skyworks FEM */
  60. #define BFL2_SKWRKFEM_BRD 0x00000100
  61. /* Board has a WAR for clock-harmonic spurs */
  62. #define BFL2_SPUR_WAR 0x00000200
  63. /* Flag to narrow G-band PLL loop b/w */
  64. #define BFL2_GPLL_WAR 0x00000400
  65. /* Tx CCK pkts on Ant 0 only */
  66. #define BFL2_SINGLEANT_CCK 0x00001000
  67. /* WAR to reduce and avoid clock-harmonic spurs in 2G */
  68. #define BFL2_2G_SPUR_WAR 0x00002000
  69. /* Flag to widen G-band PLL loop b/w */
  70. #define BFL2_GPLL_WAR2 0x00010000
  71. #define BFL2_IPALVLSHIFT_3P3 0x00020000
  72. /* Use internal envelope detector for TX IQCAL */
  73. #define BFL2_INTERNDET_TXIQCAL 0x00040000
  74. /* Keep the buffered Xtal output from radio "ON". Most drivers will turn it
  75. * off without this flag to save power. */
  76. #define BFL2_XTALBUFOUTEN 0x00080000
  77. /*
  78. * board specific GPIO assignment, gpio 0-3 are also customer-configurable
  79. * led
  80. */
  81. /* bit 9 controls the PA on new 4306 boards */
  82. #define BOARD_GPIO_PACTRL 0x200
  83. #define BOARD_GPIO_12 0x1000
  84. #define BOARD_GPIO_13 0x2000
  85. /* **** Core type/rev defaults **** */
  86. #define D11CONF 0x0fffffb0 /* Supported D11 revs: 4, 5, 7-27
  87. * also need to update wlc.h MAXCOREREV
  88. */
  89. #define NCONF 0x000001ff /* Supported nphy revs:
  90. * 0 4321a0
  91. * 1 4321a1
  92. * 2 4321b0/b1/c0/c1
  93. * 3 4322a0
  94. * 4 4322a1
  95. * 5 4716a0
  96. * 6 43222a0, 43224a0
  97. * 7 43226a0
  98. * 8 5357a0, 43236a0
  99. */
  100. #define LCNCONF 0x00000007 /* Supported lcnphy revs:
  101. * 0 4313a0, 4336a0, 4330a0
  102. * 1
  103. * 2 4330a0
  104. */
  105. #define SSLPNCONF 0x0000000f /* Supported sslpnphy revs:
  106. * 0 4329a0/k0
  107. * 1 4329b0/4329C0
  108. * 2 4319a0
  109. * 3 5356a0
  110. */
  111. /********************************************************************
  112. * Phy/Core Configuration. Defines macros to to check core phy/rev *
  113. * compile-time configuration. Defines default core support. *
  114. * ******************************************************************
  115. */
  116. /* Basic macros to check a configuration bitmask */
  117. #define CONF_HAS(config, val) ((config) & (1 << (val)))
  118. #define CONF_MSK(config, mask) ((config) & (mask))
  119. #define MSK_RANGE(low, hi) ((1 << ((hi)+1)) - (1 << (low)))
  120. #define CONF_RANGE(config, low, hi) (CONF_MSK(config, MSK_RANGE(low, high)))
  121. #define CONF_IS(config, val) ((config) == (1 << (val)))
  122. #define CONF_GE(config, val) ((config) & (0-(1 << (val))))
  123. #define CONF_GT(config, val) ((config) & (0-2*(1 << (val))))
  124. #define CONF_LT(config, val) ((config) & ((1 << (val))-1))
  125. #define CONF_LE(config, val) ((config) & (2*(1 << (val))-1))
  126. /* Wrappers for some of the above, specific to config constants */
  127. #define NCONF_HAS(val) CONF_HAS(NCONF, val)
  128. #define NCONF_MSK(mask) CONF_MSK(NCONF, mask)
  129. #define NCONF_IS(val) CONF_IS(NCONF, val)
  130. #define NCONF_GE(val) CONF_GE(NCONF, val)
  131. #define NCONF_GT(val) CONF_GT(NCONF, val)
  132. #define NCONF_LT(val) CONF_LT(NCONF, val)
  133. #define NCONF_LE(val) CONF_LE(NCONF, val)
  134. #define LCNCONF_HAS(val) CONF_HAS(LCNCONF, val)
  135. #define LCNCONF_MSK(mask) CONF_MSK(LCNCONF, mask)
  136. #define LCNCONF_IS(val) CONF_IS(LCNCONF, val)
  137. #define LCNCONF_GE(val) CONF_GE(LCNCONF, val)
  138. #define LCNCONF_GT(val) CONF_GT(LCNCONF, val)
  139. #define LCNCONF_LT(val) CONF_LT(LCNCONF, val)
  140. #define LCNCONF_LE(val) CONF_LE(LCNCONF, val)
  141. #define D11CONF_HAS(val) CONF_HAS(D11CONF, val)
  142. #define D11CONF_MSK(mask) CONF_MSK(D11CONF, mask)
  143. #define D11CONF_IS(val) CONF_IS(D11CONF, val)
  144. #define D11CONF_GE(val) CONF_GE(D11CONF, val)
  145. #define D11CONF_GT(val) CONF_GT(D11CONF, val)
  146. #define D11CONF_LT(val) CONF_LT(D11CONF, val)
  147. #define D11CONF_LE(val) CONF_LE(D11CONF, val)
  148. #define PHYCONF_HAS(val) CONF_HAS(PHYTYPE, val)
  149. #define PHYCONF_IS(val) CONF_IS(PHYTYPE, val)
  150. #define NREV_IS(var, val) \
  151. (NCONF_HAS(val) && (NCONF_IS(val) || ((var) == (val))))
  152. #define NREV_GE(var, val) \
  153. (NCONF_GE(val) && (!NCONF_LT(val) || ((var) >= (val))))
  154. #define NREV_GT(var, val) \
  155. (NCONF_GT(val) && (!NCONF_LE(val) || ((var) > (val))))
  156. #define NREV_LT(var, val) \
  157. (NCONF_LT(val) && (!NCONF_GE(val) || ((var) < (val))))
  158. #define NREV_LE(var, val) \
  159. (NCONF_LE(val) && (!NCONF_GT(val) || ((var) <= (val))))
  160. #define LCNREV_IS(var, val) \
  161. (LCNCONF_HAS(val) && (LCNCONF_IS(val) || ((var) == (val))))
  162. #define LCNREV_GE(var, val) \
  163. (LCNCONF_GE(val) && (!LCNCONF_LT(val) || ((var) >= (val))))
  164. #define LCNREV_GT(var, val) \
  165. (LCNCONF_GT(val) && (!LCNCONF_LE(val) || ((var) > (val))))
  166. #define LCNREV_LT(var, val) \
  167. (LCNCONF_LT(val) && (!LCNCONF_GE(val) || ((var) < (val))))
  168. #define LCNREV_LE(var, val) \
  169. (LCNCONF_LE(val) && (!LCNCONF_GT(val) || ((var) <= (val))))
  170. #define D11REV_IS(var, val) \
  171. (D11CONF_HAS(val) && (D11CONF_IS(val) || ((var) == (val))))
  172. #define D11REV_GE(var, val) \
  173. (D11CONF_GE(val) && (!D11CONF_LT(val) || ((var) >= (val))))
  174. #define D11REV_GT(var, val) \
  175. (D11CONF_GT(val) && (!D11CONF_LE(val) || ((var) > (val))))
  176. #define D11REV_LT(var, val) \
  177. (D11CONF_LT(val) && (!D11CONF_GE(val) || ((var) < (val))))
  178. #define D11REV_LE(var, val) \
  179. (D11CONF_LE(val) && (!D11CONF_GT(val) || ((var) <= (val))))
  180. #define PHYTYPE_IS(var, val)\
  181. (PHYCONF_HAS(val) && (PHYCONF_IS(val) || ((var) == (val))))
  182. /* Set up PHYTYPE automatically: (depends on PHY_TYPE_X, from d11.h) */
  183. #define _PHYCONF_N (1 << PHY_TYPE_N)
  184. #define _PHYCONF_LCN (1 << PHY_TYPE_LCN)
  185. #define _PHYCONF_SSLPN (1 << PHY_TYPE_SSN)
  186. #define PHYTYPE (_PHYCONF_N | _PHYCONF_LCN | _PHYCONF_SSLPN)
  187. /* Utility macro to identify 802.11n (HT) capable PHYs */
  188. #define PHYTYPE_11N_CAP(phytype) \
  189. (PHYTYPE_IS(phytype, PHY_TYPE_N) || \
  190. PHYTYPE_IS(phytype, PHY_TYPE_LCN) || \
  191. PHYTYPE_IS(phytype, PHY_TYPE_SSN))
  192. /* Last but not least: shorter wlc-specific var checks */
  193. #define BRCMS_ISNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_N)
  194. #define BRCMS_ISLCNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_LCN)
  195. #define BRCMS_ISSSLPNPHY(band) PHYTYPE_IS((band)->phytype, PHY_TYPE_SSN)
  196. #define BRCMS_PHY_11N_CAP(band) PHYTYPE_11N_CAP((band)->phytype)
  197. /**********************************************************************
  198. * ------------- End of Core phy/rev configuration. ----------------- *
  199. * ********************************************************************
  200. */
  201. #define BCMMSG(dev, fmt, args...) \
  202. do { \
  203. if (brcm_msg_level & BRCM_DL_INFO) \
  204. wiphy_err(dev, "%s: " fmt, __func__, ##args); \
  205. } while (0)
  206. #ifdef CONFIG_BCM47XX
  207. /*
  208. * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
  209. * transactions. As a fix, a read after write is performed on certain places
  210. * in the code. Older chips and the newer 5357 family don't require this fix.
  211. */
  212. #define bcma_wflush16(c, o, v) \
  213. ({ bcma_write16(c, o, v); (void)bcma_read16(c, o); })
  214. #else
  215. #define bcma_wflush16(c, o, v) bcma_write16(c, o, v)
  216. #endif /* CONFIG_BCM47XX */
  217. /* multi-bool data type: set of bools, mbool is true if any is set */
  218. /* set one bool */
  219. #define mboolset(mb, bit) ((mb) |= (bit))
  220. /* clear one bool */
  221. #define mboolclr(mb, bit) ((mb) &= ~(bit))
  222. /* true if one bool is set */
  223. #define mboolisset(mb, bit) (((mb) & (bit)) != 0)
  224. #define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
  225. #define CEIL(x, y) (((x) + ((y)-1)) / (y))
  226. /* forward declarations */
  227. struct wiphy;
  228. struct ieee80211_sta;
  229. struct ieee80211_tx_queue_params;
  230. struct brcms_info;
  231. struct brcms_c_info;
  232. struct brcms_hardware;
  233. struct brcms_band;
  234. struct dma_pub;
  235. struct si_pub;
  236. struct tx_status;
  237. struct d11rxhdr;
  238. struct txpwr_limits;
  239. /* iovar structure */
  240. struct brcmu_iovar {
  241. const char *name; /* name for lookup and display */
  242. u16 varid; /* id for switch */
  243. u16 flags; /* driver-specific flag bits */
  244. u16 type; /* base type of argument */
  245. u16 minlen; /* min length for buffer vars */
  246. };
  247. /* brcm_msg_level is a bit vector with defs in defs.h */
  248. extern u32 brcm_msg_level;
  249. #endif /* _BRCM_TYPES_H_ */