bcm43xx.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. #ifndef BCM43xx_H_
  2. #define BCM43xx_H_
  3. #include <linux/hw_random.h>
  4. #include <linux/version.h>
  5. #include <linux/kernel.h>
  6. #include <linux/spinlock.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/stringify.h>
  9. #include <linux/pci.h>
  10. #include <net/ieee80211.h>
  11. #include <net/ieee80211softmac.h>
  12. #include <asm/atomic.h>
  13. #include <asm/io.h>
  14. #include "bcm43xx_debugfs.h"
  15. #include "bcm43xx_leds.h"
  16. #define PFX KBUILD_MODNAME ": "
  17. #define BCM43xx_SWITCH_CORE_MAX_RETRIES 50
  18. #define BCM43xx_IRQWAIT_MAX_RETRIES 50
  19. #define BCM43xx_IO_SIZE 8192
  20. /* Active Core PCI Configuration Register. */
  21. #define BCM43xx_PCICFG_ACTIVE_CORE 0x80
  22. /* SPROM control register. */
  23. #define BCM43xx_PCICFG_SPROMCTL 0x88
  24. /* Interrupt Control PCI Configuration Register. (Only on PCI cores with rev >= 6) */
  25. #define BCM43xx_PCICFG_ICR 0x94
  26. /* MMIO offsets */
  27. #define BCM43xx_MMIO_DMA0_REASON 0x20
  28. #define BCM43xx_MMIO_DMA0_IRQ_MASK 0x24
  29. #define BCM43xx_MMIO_DMA1_REASON 0x28
  30. #define BCM43xx_MMIO_DMA1_IRQ_MASK 0x2C
  31. #define BCM43xx_MMIO_DMA2_REASON 0x30
  32. #define BCM43xx_MMIO_DMA2_IRQ_MASK 0x34
  33. #define BCM43xx_MMIO_DMA3_REASON 0x38
  34. #define BCM43xx_MMIO_DMA3_IRQ_MASK 0x3C
  35. #define BCM43xx_MMIO_DMA4_REASON 0x40
  36. #define BCM43xx_MMIO_DMA4_IRQ_MASK 0x44
  37. #define BCM43xx_MMIO_DMA5_REASON 0x48
  38. #define BCM43xx_MMIO_DMA5_IRQ_MASK 0x4C
  39. #define BCM43xx_MMIO_STATUS_BITFIELD 0x120
  40. #define BCM43xx_MMIO_STATUS2_BITFIELD 0x124
  41. #define BCM43xx_MMIO_GEN_IRQ_REASON 0x128
  42. #define BCM43xx_MMIO_GEN_IRQ_MASK 0x12C
  43. #define BCM43xx_MMIO_RAM_CONTROL 0x130
  44. #define BCM43xx_MMIO_RAM_DATA 0x134
  45. #define BCM43xx_MMIO_PS_STATUS 0x140
  46. #define BCM43xx_MMIO_RADIO_HWENABLED_HI 0x158
  47. #define BCM43xx_MMIO_SHM_CONTROL 0x160
  48. #define BCM43xx_MMIO_SHM_DATA 0x164
  49. #define BCM43xx_MMIO_SHM_DATA_UNALIGNED 0x166
  50. #define BCM43xx_MMIO_XMITSTAT_0 0x170
  51. #define BCM43xx_MMIO_XMITSTAT_1 0x174
  52. #define BCM43xx_MMIO_REV3PLUS_TSF_LOW 0x180 /* core rev >= 3 only */
  53. #define BCM43xx_MMIO_REV3PLUS_TSF_HIGH 0x184 /* core rev >= 3 only */
  54. /* 32-bit DMA */
  55. #define BCM43xx_MMIO_DMA32_BASE0 0x200
  56. #define BCM43xx_MMIO_DMA32_BASE1 0x220
  57. #define BCM43xx_MMIO_DMA32_BASE2 0x240
  58. #define BCM43xx_MMIO_DMA32_BASE3 0x260
  59. #define BCM43xx_MMIO_DMA32_BASE4 0x280
  60. #define BCM43xx_MMIO_DMA32_BASE5 0x2A0
  61. /* 64-bit DMA */
  62. #define BCM43xx_MMIO_DMA64_BASE0 0x200
  63. #define BCM43xx_MMIO_DMA64_BASE1 0x240
  64. #define BCM43xx_MMIO_DMA64_BASE2 0x280
  65. #define BCM43xx_MMIO_DMA64_BASE3 0x2C0
  66. #define BCM43xx_MMIO_DMA64_BASE4 0x300
  67. #define BCM43xx_MMIO_DMA64_BASE5 0x340
  68. /* PIO */
  69. #define BCM43xx_MMIO_PIO1_BASE 0x300
  70. #define BCM43xx_MMIO_PIO2_BASE 0x310
  71. #define BCM43xx_MMIO_PIO3_BASE 0x320
  72. #define BCM43xx_MMIO_PIO4_BASE 0x330
  73. #define BCM43xx_MMIO_PHY_VER 0x3E0
  74. #define BCM43xx_MMIO_PHY_RADIO 0x3E2
  75. #define BCM43xx_MMIO_ANTENNA 0x3E8
  76. #define BCM43xx_MMIO_CHANNEL 0x3F0
  77. #define BCM43xx_MMIO_CHANNEL_EXT 0x3F4
  78. #define BCM43xx_MMIO_RADIO_CONTROL 0x3F6
  79. #define BCM43xx_MMIO_RADIO_DATA_HIGH 0x3F8
  80. #define BCM43xx_MMIO_RADIO_DATA_LOW 0x3FA
  81. #define BCM43xx_MMIO_PHY_CONTROL 0x3FC
  82. #define BCM43xx_MMIO_PHY_DATA 0x3FE
  83. #define BCM43xx_MMIO_MACFILTER_CONTROL 0x420
  84. #define BCM43xx_MMIO_MACFILTER_DATA 0x422
  85. #define BCM43xx_MMIO_RADIO_HWENABLED_LO 0x49A
  86. #define BCM43xx_MMIO_GPIO_CONTROL 0x49C
  87. #define BCM43xx_MMIO_GPIO_MASK 0x49E
  88. #define BCM43xx_MMIO_TSF_0 0x632 /* core rev < 3 only */
  89. #define BCM43xx_MMIO_TSF_1 0x634 /* core rev < 3 only */
  90. #define BCM43xx_MMIO_TSF_2 0x636 /* core rev < 3 only */
  91. #define BCM43xx_MMIO_TSF_3 0x638 /* core rev < 3 only */
  92. #define BCM43xx_MMIO_RNG 0x65A
  93. #define BCM43xx_MMIO_POWERUP_DELAY 0x6A8
  94. /* SPROM offsets. */
  95. #define BCM43xx_SPROM_BASE 0x1000
  96. #define BCM43xx_SPROM_BOARDFLAGS2 0x1c
  97. #define BCM43xx_SPROM_IL0MACADDR 0x24
  98. #define BCM43xx_SPROM_ET0MACADDR 0x27
  99. #define BCM43xx_SPROM_ET1MACADDR 0x2a
  100. #define BCM43xx_SPROM_ETHPHY 0x2d
  101. #define BCM43xx_SPROM_BOARDREV 0x2e
  102. #define BCM43xx_SPROM_PA0B0 0x2f
  103. #define BCM43xx_SPROM_PA0B1 0x30
  104. #define BCM43xx_SPROM_PA0B2 0x31
  105. #define BCM43xx_SPROM_WL0GPIO0 0x32
  106. #define BCM43xx_SPROM_WL0GPIO2 0x33
  107. #define BCM43xx_SPROM_MAXPWR 0x34
  108. #define BCM43xx_SPROM_PA1B0 0x35
  109. #define BCM43xx_SPROM_PA1B1 0x36
  110. #define BCM43xx_SPROM_PA1B2 0x37
  111. #define BCM43xx_SPROM_IDL_TSSI_TGT 0x38
  112. #define BCM43xx_SPROM_BOARDFLAGS 0x39
  113. #define BCM43xx_SPROM_ANTENNA_GAIN 0x3a
  114. #define BCM43xx_SPROM_VERSION 0x3f
  115. /* BCM43xx_SPROM_BOARDFLAGS values */
  116. #define BCM43xx_BFL_BTCOEXIST 0x0001 /* implements Bluetooth coexistance */
  117. #define BCM43xx_BFL_PACTRL 0x0002 /* GPIO 9 controlling the PA */
  118. #define BCM43xx_BFL_AIRLINEMODE 0x0004 /* implements GPIO 13 radio disable indication */
  119. #define BCM43xx_BFL_RSSI 0x0008 /* software calculates nrssi slope. */
  120. #define BCM43xx_BFL_ENETSPI 0x0010 /* has ephy roboswitch spi */
  121. #define BCM43xx_BFL_XTAL_NOSLOW 0x0020 /* no slow clock available */
  122. #define BCM43xx_BFL_CCKHIPWR 0x0040 /* can do high power CCK transmission */
  123. #define BCM43xx_BFL_ENETADM 0x0080 /* has ADMtek switch */
  124. #define BCM43xx_BFL_ENETVLAN 0x0100 /* can do vlan */
  125. #define BCM43xx_BFL_AFTERBURNER 0x0200 /* supports Afterburner mode */
  126. #define BCM43xx_BFL_NOPCI 0x0400 /* leaves PCI floating */
  127. #define BCM43xx_BFL_FEM 0x0800 /* supports the Front End Module */
  128. #define BCM43xx_BFL_EXTLNA 0x1000 /* has an external LNA */
  129. #define BCM43xx_BFL_HGPA 0x2000 /* had high gain PA */
  130. #define BCM43xx_BFL_BTCMOD 0x4000 /* BFL_BTCOEXIST is given in alternate GPIOs */
  131. #define BCM43xx_BFL_ALTIQ 0x8000 /* alternate I/Q settings */
  132. /* GPIO register offset, in both ChipCommon and PCI core. */
  133. #define BCM43xx_GPIO_CONTROL 0x6c
  134. /* SHM Routing */
  135. #define BCM43xx_SHM_SHARED 0x0001
  136. #define BCM43xx_SHM_WIRELESS 0x0002
  137. #define BCM43xx_SHM_PCM 0x0003
  138. #define BCM43xx_SHM_HWMAC 0x0004
  139. #define BCM43xx_SHM_UCODE 0x0300
  140. /* MacFilter offsets. */
  141. #define BCM43xx_MACFILTER_SELF 0x0000
  142. #define BCM43xx_MACFILTER_ASSOC 0x0003
  143. /* Chipcommon registers. */
  144. #define BCM43xx_CHIPCOMMON_CAPABILITIES 0x04
  145. #define BCM43xx_CHIPCOMMON_CTL 0x28
  146. #define BCM43xx_CHIPCOMMON_PLLONDELAY 0xB0
  147. #define BCM43xx_CHIPCOMMON_FREFSELDELAY 0xB4
  148. #define BCM43xx_CHIPCOMMON_SLOWCLKCTL 0xB8
  149. #define BCM43xx_CHIPCOMMON_SYSCLKCTL 0xC0
  150. /* PCI core specific registers. */
  151. #define BCM43xx_PCICORE_BCAST_ADDR 0x50
  152. #define BCM43xx_PCICORE_BCAST_DATA 0x54
  153. #define BCM43xx_PCICORE_SBTOPCI2 0x108
  154. /* SBTOPCI2 values. */
  155. #define BCM43xx_SBTOPCI2_PREFETCH 0x4
  156. #define BCM43xx_SBTOPCI2_BURST 0x8
  157. #define BCM43xx_SBTOPCI2_MEMREAD_MULTI 0x20
  158. /* PCI-E core registers. */
  159. #define BCM43xx_PCIECORE_REG_ADDR 0x0130
  160. #define BCM43xx_PCIECORE_REG_DATA 0x0134
  161. #define BCM43xx_PCIECORE_MDIO_CTL 0x0128
  162. #define BCM43xx_PCIECORE_MDIO_DATA 0x012C
  163. /* PCI-E registers. */
  164. #define BCM43xx_PCIE_TLP_WORKAROUND 0x0004
  165. #define BCM43xx_PCIE_DLLP_LINKCTL 0x0100
  166. /* PCI-E MDIO bits. */
  167. #define BCM43xx_PCIE_MDIO_ST 0x40000000
  168. #define BCM43xx_PCIE_MDIO_WT 0x10000000
  169. #define BCM43xx_PCIE_MDIO_DEV 22
  170. #define BCM43xx_PCIE_MDIO_REG 18
  171. #define BCM43xx_PCIE_MDIO_TA 0x00020000
  172. #define BCM43xx_PCIE_MDIO_TC 0x0100
  173. /* MDIO devices. */
  174. #define BCM43xx_MDIO_SERDES_RX 0x1F
  175. /* SERDES RX registers. */
  176. #define BCM43xx_SERDES_RXTIMER 0x2
  177. #define BCM43xx_SERDES_CDR 0x6
  178. #define BCM43xx_SERDES_CDR_BW 0x7
  179. /* Chipcommon capabilities. */
  180. #define BCM43xx_CAPABILITIES_PCTL 0x00040000
  181. #define BCM43xx_CAPABILITIES_PLLMASK 0x00030000
  182. #define BCM43xx_CAPABILITIES_PLLSHIFT 16
  183. #define BCM43xx_CAPABILITIES_FLASHMASK 0x00000700
  184. #define BCM43xx_CAPABILITIES_FLASHSHIFT 8
  185. #define BCM43xx_CAPABILITIES_EXTBUSPRESENT 0x00000040
  186. #define BCM43xx_CAPABILITIES_UARTGPIO 0x00000020
  187. #define BCM43xx_CAPABILITIES_UARTCLOCKMASK 0x00000018
  188. #define BCM43xx_CAPABILITIES_UARTCLOCKSHIFT 3
  189. #define BCM43xx_CAPABILITIES_MIPSBIGENDIAN 0x00000004
  190. #define BCM43xx_CAPABILITIES_NRUARTSMASK 0x00000003
  191. /* PowerControl */
  192. #define BCM43xx_PCTL_IN 0xB0
  193. #define BCM43xx_PCTL_OUT 0xB4
  194. #define BCM43xx_PCTL_OUTENABLE 0xB8
  195. #define BCM43xx_PCTL_XTAL_POWERUP 0x40
  196. #define BCM43xx_PCTL_PLL_POWERDOWN 0x80
  197. /* PowerControl Clock Modes */
  198. #define BCM43xx_PCTL_CLK_FAST 0x00
  199. #define BCM43xx_PCTL_CLK_SLOW 0x01
  200. #define BCM43xx_PCTL_CLK_DYNAMIC 0x02
  201. #define BCM43xx_PCTL_FORCE_SLOW 0x0800
  202. #define BCM43xx_PCTL_FORCE_PLL 0x1000
  203. #define BCM43xx_PCTL_DYN_XTAL 0x2000
  204. /* COREIDs */
  205. #define BCM43xx_COREID_CHIPCOMMON 0x800
  206. #define BCM43xx_COREID_ILINE20 0x801
  207. #define BCM43xx_COREID_SDRAM 0x803
  208. #define BCM43xx_COREID_PCI 0x804
  209. #define BCM43xx_COREID_MIPS 0x805
  210. #define BCM43xx_COREID_ETHERNET 0x806
  211. #define BCM43xx_COREID_V90 0x807
  212. #define BCM43xx_COREID_USB11_HOSTDEV 0x80a
  213. #define BCM43xx_COREID_IPSEC 0x80b
  214. #define BCM43xx_COREID_PCMCIA 0x80d
  215. #define BCM43xx_COREID_EXT_IF 0x80f
  216. #define BCM43xx_COREID_80211 0x812
  217. #define BCM43xx_COREID_MIPS_3302 0x816
  218. #define BCM43xx_COREID_USB11_HOST 0x817
  219. #define BCM43xx_COREID_USB11_DEV 0x818
  220. #define BCM43xx_COREID_USB20_HOST 0x819
  221. #define BCM43xx_COREID_USB20_DEV 0x81a
  222. #define BCM43xx_COREID_SDIO_HOST 0x81b
  223. #define BCM43xx_COREID_PCIE 0x820
  224. /* Core Information Registers */
  225. #define BCM43xx_CIR_BASE 0xf00
  226. #define BCM43xx_CIR_SBTPSFLAG (BCM43xx_CIR_BASE + 0x18)
  227. #define BCM43xx_CIR_SBIMSTATE (BCM43xx_CIR_BASE + 0x90)
  228. #define BCM43xx_CIR_SBINTVEC (BCM43xx_CIR_BASE + 0x94)
  229. #define BCM43xx_CIR_SBTMSTATELOW (BCM43xx_CIR_BASE + 0x98)
  230. #define BCM43xx_CIR_SBTMSTATEHIGH (BCM43xx_CIR_BASE + 0x9c)
  231. #define BCM43xx_CIR_SBIMCONFIGLOW (BCM43xx_CIR_BASE + 0xa8)
  232. #define BCM43xx_CIR_SB_ID_HI (BCM43xx_CIR_BASE + 0xfc)
  233. /* Mask to get the Backplane Flag Number from SBTPSFLAG. */
  234. #define BCM43xx_BACKPLANE_FLAG_NR_MASK 0x3f
  235. /* SBIMCONFIGLOW values/masks. */
  236. #define BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK 0x00000007
  237. #define BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_SHIFT 0
  238. #define BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK 0x00000070
  239. #define BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_SHIFT 4
  240. #define BCM43xx_SBIMCONFIGLOW_CONNID_MASK 0x00ff0000
  241. #define BCM43xx_SBIMCONFIGLOW_CONNID_SHIFT 16
  242. /* sbtmstatelow state flags */
  243. #define BCM43xx_SBTMSTATELOW_RESET 0x01
  244. #define BCM43xx_SBTMSTATELOW_REJECT 0x02
  245. #define BCM43xx_SBTMSTATELOW_CLOCK 0x10000
  246. #define BCM43xx_SBTMSTATELOW_FORCE_GATE_CLOCK 0x20000
  247. /* sbtmstatehigh state flags */
  248. #define BCM43xx_SBTMSTATEHIGH_SERROR 0x00000001
  249. #define BCM43xx_SBTMSTATEHIGH_BUSY 0x00000004
  250. #define BCM43xx_SBTMSTATEHIGH_TIMEOUT 0x00000020
  251. #define BCM43xx_SBTMSTATEHIGH_COREFLAGS 0x1FFF0000
  252. #define BCM43xx_SBTMSTATEHIGH_DMA64BIT 0x10000000
  253. #define BCM43xx_SBTMSTATEHIGH_GATEDCLK 0x20000000
  254. #define BCM43xx_SBTMSTATEHIGH_BISTFAILED 0x40000000
  255. #define BCM43xx_SBTMSTATEHIGH_BISTCOMPLETE 0x80000000
  256. /* sbimstate flags */
  257. #define BCM43xx_SBIMSTATE_IB_ERROR 0x20000
  258. #define BCM43xx_SBIMSTATE_TIMEOUT 0x40000
  259. /* PHYVersioning */
  260. #define BCM43xx_PHYTYPE_A 0x00
  261. #define BCM43xx_PHYTYPE_B 0x01
  262. #define BCM43xx_PHYTYPE_G 0x02
  263. /* PHYRegisters */
  264. #define BCM43xx_PHY_ILT_A_CTRL 0x0072
  265. #define BCM43xx_PHY_ILT_A_DATA1 0x0073
  266. #define BCM43xx_PHY_ILT_A_DATA2 0x0074
  267. #define BCM43xx_PHY_G_LO_CONTROL 0x0810
  268. #define BCM43xx_PHY_ILT_G_CTRL 0x0472
  269. #define BCM43xx_PHY_ILT_G_DATA1 0x0473
  270. #define BCM43xx_PHY_ILT_G_DATA2 0x0474
  271. #define BCM43xx_PHY_A_PCTL 0x007B
  272. #define BCM43xx_PHY_G_PCTL 0x0029
  273. #define BCM43xx_PHY_A_CRS 0x0029
  274. #define BCM43xx_PHY_RADIO_BITFIELD 0x0401
  275. #define BCM43xx_PHY_G_CRS 0x0429
  276. #define BCM43xx_PHY_NRSSILT_CTRL 0x0803
  277. #define BCM43xx_PHY_NRSSILT_DATA 0x0804
  278. /* RadioRegisters */
  279. #define BCM43xx_RADIOCTL_ID 0x01
  280. /* StatusBitField */
  281. #define BCM43xx_SBF_MAC_ENABLED 0x00000001
  282. #define BCM43xx_SBF_2 0x00000002 /*FIXME: fix name*/
  283. #define BCM43xx_SBF_CORE_READY 0x00000004
  284. #define BCM43xx_SBF_400 0x00000400 /*FIXME: fix name*/
  285. #define BCM43xx_SBF_4000 0x00004000 /*FIXME: fix name*/
  286. #define BCM43xx_SBF_8000 0x00008000 /*FIXME: fix name*/
  287. #define BCM43xx_SBF_XFER_REG_BYTESWAP 0x00010000
  288. #define BCM43xx_SBF_MODE_NOTADHOC 0x00020000
  289. #define BCM43xx_SBF_MODE_AP 0x00040000
  290. #define BCM43xx_SBF_RADIOREG_LOCK 0x00080000
  291. #define BCM43xx_SBF_MODE_MONITOR 0x00400000
  292. #define BCM43xx_SBF_MODE_PROMISC 0x01000000
  293. #define BCM43xx_SBF_PS1 0x02000000
  294. #define BCM43xx_SBF_PS2 0x04000000
  295. #define BCM43xx_SBF_NO_SSID_BCAST 0x08000000
  296. #define BCM43xx_SBF_TIME_UPDATE 0x10000000
  297. #define BCM43xx_SBF_80000000 0x80000000 /*FIXME: fix name*/
  298. /* Microcode */
  299. #define BCM43xx_UCODE_REVISION 0x0000
  300. #define BCM43xx_UCODE_PATCHLEVEL 0x0002
  301. #define BCM43xx_UCODE_DATE 0x0004
  302. #define BCM43xx_UCODE_TIME 0x0006
  303. #define BCM43xx_UCODE_STATUS 0x0040
  304. /* MicrocodeFlagsBitfield (addr + lo-word values?)*/
  305. #define BCM43xx_UCODEFLAGS_OFFSET 0x005E
  306. #define BCM43xx_UCODEFLAG_AUTODIV 0x0001
  307. #define BCM43xx_UCODEFLAG_UNKBGPHY 0x0002
  308. #define BCM43xx_UCODEFLAG_UNKBPHY 0x0004
  309. #define BCM43xx_UCODEFLAG_UNKGPHY 0x0020
  310. #define BCM43xx_UCODEFLAG_UNKPACTRL 0x0040
  311. #define BCM43xx_UCODEFLAG_JAPAN 0x0080
  312. /* Hardware Radio Enable masks */
  313. #define BCM43xx_MMIO_RADIO_HWENABLED_HI_MASK (1 << 16)
  314. #define BCM43xx_MMIO_RADIO_HWENABLED_LO_MASK (1 << 4)
  315. /* Generic-Interrupt reasons. */
  316. #define BCM43xx_IRQ_READY (1 << 0)
  317. #define BCM43xx_IRQ_BEACON (1 << 1)
  318. #define BCM43xx_IRQ_PS (1 << 2)
  319. #define BCM43xx_IRQ_REG124 (1 << 5)
  320. #define BCM43xx_IRQ_PMQ (1 << 6)
  321. #define BCM43xx_IRQ_PIO_WORKAROUND (1 << 8)
  322. #define BCM43xx_IRQ_XMIT_ERROR (1 << 11)
  323. #define BCM43xx_IRQ_RX (1 << 15)
  324. #define BCM43xx_IRQ_SCAN (1 << 16)
  325. #define BCM43xx_IRQ_NOISE (1 << 18)
  326. #define BCM43xx_IRQ_XMIT_STATUS (1 << 29)
  327. #define BCM43xx_IRQ_ALL 0xffffffff
  328. #define BCM43xx_IRQ_INITIAL (BCM43xx_IRQ_PS | \
  329. BCM43xx_IRQ_REG124 | \
  330. BCM43xx_IRQ_PMQ | \
  331. BCM43xx_IRQ_XMIT_ERROR | \
  332. BCM43xx_IRQ_RX | \
  333. BCM43xx_IRQ_SCAN | \
  334. BCM43xx_IRQ_NOISE | \
  335. BCM43xx_IRQ_XMIT_STATUS)
  336. /* Initial default iw_mode */
  337. #define BCM43xx_INITIAL_IWMODE IW_MODE_INFRA
  338. /* Bus type PCI. */
  339. #define BCM43xx_BUSTYPE_PCI 0
  340. /* Bus type Silicone Backplane Bus. */
  341. #define BCM43xx_BUSTYPE_SB 1
  342. /* Bus type PCMCIA. */
  343. #define BCM43xx_BUSTYPE_PCMCIA 2
  344. /* Threshold values. */
  345. #define BCM43xx_MIN_RTS_THRESHOLD 1U
  346. #define BCM43xx_MAX_RTS_THRESHOLD 2304U
  347. #define BCM43xx_DEFAULT_RTS_THRESHOLD BCM43xx_MAX_RTS_THRESHOLD
  348. #define BCM43xx_DEFAULT_SHORT_RETRY_LIMIT 7
  349. #define BCM43xx_DEFAULT_LONG_RETRY_LIMIT 4
  350. /* FIXME: the next line is a guess as to what the maximum RSSI value might be */
  351. #define RX_RSSI_MAX 60
  352. /* Max size of a security key */
  353. #define BCM43xx_SEC_KEYSIZE 16
  354. /* Security algorithms. */
  355. enum {
  356. BCM43xx_SEC_ALGO_NONE = 0, /* unencrypted, as of TX header. */
  357. BCM43xx_SEC_ALGO_WEP,
  358. BCM43xx_SEC_ALGO_UNKNOWN,
  359. BCM43xx_SEC_ALGO_AES,
  360. BCM43xx_SEC_ALGO_WEP104,
  361. BCM43xx_SEC_ALGO_TKIP,
  362. };
  363. #ifdef assert
  364. # undef assert
  365. #endif
  366. #ifdef CONFIG_BCM43XX_DEBUG
  367. #define assert(expr) \
  368. do { \
  369. if (unlikely(!(expr))) { \
  370. printk(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", \
  371. #expr, __FILE__, __LINE__, __FUNCTION__); \
  372. } \
  373. } while (0)
  374. #else
  375. #define assert(expr) do { /* nothing */ } while (0)
  376. #endif
  377. /* rate limited printk(). */
  378. #ifdef printkl
  379. # undef printkl
  380. #endif
  381. #define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
  382. /* rate limited printk() for debugging */
  383. #ifdef dprintkl
  384. # undef dprintkl
  385. #endif
  386. #ifdef CONFIG_BCM43XX_DEBUG
  387. # define dprintkl printkl
  388. #else
  389. # define dprintkl(f, x...) do { /* nothing */ } while (0)
  390. #endif
  391. /* Helper macro for if branches.
  392. * An if branch marked with this macro is only taken in DEBUG mode.
  393. * Example:
  394. * if (DEBUG_ONLY(foo == bar)) {
  395. * do something
  396. * }
  397. * In DEBUG mode, the branch will be taken if (foo == bar).
  398. * In non-DEBUG mode, the branch will never be taken.
  399. */
  400. #ifdef DEBUG_ONLY
  401. # undef DEBUG_ONLY
  402. #endif
  403. #ifdef CONFIG_BCM43XX_DEBUG
  404. # define DEBUG_ONLY(x) (x)
  405. #else
  406. # define DEBUG_ONLY(x) 0
  407. #endif
  408. /* debugging printk() */
  409. #ifdef dprintk
  410. # undef dprintk
  411. #endif
  412. #ifdef CONFIG_BCM43XX_DEBUG
  413. # define dprintk(f, x...) do { printk(f ,##x); } while (0)
  414. #else
  415. # define dprintk(f, x...) do { /* nothing */ } while (0)
  416. #endif
  417. struct net_device;
  418. struct pci_dev;
  419. struct bcm43xx_dmaring;
  420. struct bcm43xx_pioqueue;
  421. struct bcm43xx_initval {
  422. u16 offset;
  423. u16 size;
  424. u32 value;
  425. } __attribute__((__packed__));
  426. /* Values for bcm430x_sprominfo.locale */
  427. enum {
  428. BCM43xx_LOCALE_WORLD = 0,
  429. BCM43xx_LOCALE_THAILAND,
  430. BCM43xx_LOCALE_ISRAEL,
  431. BCM43xx_LOCALE_JORDAN,
  432. BCM43xx_LOCALE_CHINA,
  433. BCM43xx_LOCALE_JAPAN,
  434. BCM43xx_LOCALE_USA_CANADA_ANZ,
  435. BCM43xx_LOCALE_EUROPE,
  436. BCM43xx_LOCALE_USA_LOW,
  437. BCM43xx_LOCALE_JAPAN_HIGH,
  438. BCM43xx_LOCALE_ALL,
  439. BCM43xx_LOCALE_NONE,
  440. };
  441. #define BCM43xx_SPROM_SIZE 64 /* in 16-bit words. */
  442. struct bcm43xx_sprominfo {
  443. u16 boardflags2;
  444. u8 il0macaddr[6];
  445. u8 et0macaddr[6];
  446. u8 et1macaddr[6];
  447. u8 et0phyaddr:5;
  448. u8 et1phyaddr:5;
  449. u8 et0mdcport:1;
  450. u8 et1mdcport:1;
  451. u8 boardrev;
  452. u8 locale:4;
  453. u8 antennas_aphy:2;
  454. u8 antennas_bgphy:2;
  455. u16 pa0b0;
  456. u16 pa0b1;
  457. u16 pa0b2;
  458. u8 wl0gpio0;
  459. u8 wl0gpio1;
  460. u8 wl0gpio2;
  461. u8 wl0gpio3;
  462. u8 maxpower_aphy;
  463. u8 maxpower_bgphy;
  464. u16 pa1b0;
  465. u16 pa1b1;
  466. u16 pa1b2;
  467. u8 idle_tssi_tgt_aphy;
  468. u8 idle_tssi_tgt_bgphy;
  469. u16 boardflags;
  470. u16 antennagain_aphy;
  471. u16 antennagain_bgphy;
  472. };
  473. /* Value pair to measure the LocalOscillator. */
  474. struct bcm43xx_lopair {
  475. s8 low;
  476. s8 high;
  477. u8 used:1;
  478. };
  479. #define BCM43xx_LO_COUNT (14*4)
  480. struct bcm43xx_phyinfo {
  481. /* Hardware Data */
  482. u8 version;
  483. u8 type;
  484. u8 rev;
  485. u16 antenna_diversity;
  486. u16 savedpctlreg;
  487. u16 minlowsig[2];
  488. u16 minlowsigpos[2];
  489. u8 connected:1,
  490. calibrated:1,
  491. is_locked:1, /* used in bcm43xx_phy_{un}lock() */
  492. dyn_tssi_tbl:1; /* used in bcm43xx_phy_init_tssi2dbm_table() */
  493. /* LO Measurement Data.
  494. * Use bcm43xx_get_lopair() to get a value.
  495. */
  496. struct bcm43xx_lopair *_lo_pairs;
  497. /* TSSI to dBm table in use */
  498. const s8 *tssi2dbm;
  499. /* idle TSSI value */
  500. s8 idle_tssi;
  501. /* Values from bcm43xx_calc_loopback_gain() */
  502. u16 loopback_gain[2];
  503. /* PHY lock for core.rev < 3
  504. * This lock is only used by bcm43xx_phy_{un}lock()
  505. */
  506. spinlock_t lock;
  507. /* Firmware. */
  508. const struct firmware *ucode;
  509. const struct firmware *pcm;
  510. const struct firmware *initvals0;
  511. const struct firmware *initvals1;
  512. };
  513. struct bcm43xx_radioinfo {
  514. u16 manufact;
  515. u16 version;
  516. u8 revision;
  517. /* Desired TX power in dBm Q5.2 */
  518. u16 txpower_desired;
  519. /* TX Power control values. */
  520. union {
  521. /* B/G PHY */
  522. struct {
  523. u16 baseband_atten;
  524. u16 radio_atten;
  525. u16 txctl1;
  526. u16 txctl2;
  527. };
  528. /* A PHY */
  529. struct {
  530. u16 txpwr_offset;
  531. };
  532. };
  533. /* Current Interference Mitigation mode */
  534. int interfmode;
  535. /* Stack of saved values from the Interference Mitigation code.
  536. * Each value in the stack is layed out as follows:
  537. * bit 0-11: offset
  538. * bit 12-15: register ID
  539. * bit 16-32: value
  540. * register ID is: 0x1 PHY, 0x2 Radio, 0x3 ILT
  541. */
  542. #define BCM43xx_INTERFSTACK_SIZE 26
  543. u32 interfstack[BCM43xx_INTERFSTACK_SIZE];
  544. /* Saved values from the NRSSI Slope calculation */
  545. s16 nrssi[2];
  546. s32 nrssislope;
  547. /* In memory nrssi lookup table. */
  548. s8 nrssi_lt[64];
  549. /* current channel */
  550. u8 channel;
  551. u8 initial_channel;
  552. u16 lofcal;
  553. u16 initval;
  554. u8 enabled:1;
  555. /* ACI (adjacent channel interference) flags. */
  556. u8 aci_enable:1,
  557. aci_wlan_automatic:1,
  558. aci_hw_rssi:1;
  559. };
  560. /* Data structures for DMA transmission, per 80211 core. */
  561. struct bcm43xx_dma {
  562. struct bcm43xx_dmaring *tx_ring0;
  563. struct bcm43xx_dmaring *tx_ring1;
  564. struct bcm43xx_dmaring *tx_ring2;
  565. struct bcm43xx_dmaring *tx_ring3;
  566. struct bcm43xx_dmaring *tx_ring4;
  567. struct bcm43xx_dmaring *tx_ring5;
  568. struct bcm43xx_dmaring *rx_ring0;
  569. struct bcm43xx_dmaring *rx_ring3; /* only available on core.rev < 5 */
  570. };
  571. /* Data structures for PIO transmission, per 80211 core. */
  572. struct bcm43xx_pio {
  573. struct bcm43xx_pioqueue *queue0;
  574. struct bcm43xx_pioqueue *queue1;
  575. struct bcm43xx_pioqueue *queue2;
  576. struct bcm43xx_pioqueue *queue3;
  577. };
  578. #define BCM43xx_MAX_80211_CORES 2
  579. #ifdef CONFIG_BCM947XX
  580. #define core_offset(bcm) (bcm)->current_core_offset
  581. #else
  582. #define core_offset(bcm) 0
  583. #endif
  584. /* Generic information about a core. */
  585. struct bcm43xx_coreinfo {
  586. u8 available:1,
  587. enabled:1,
  588. initialized:1;
  589. /** core_rev revision number */
  590. u8 rev;
  591. /** Index number for _switch_core() */
  592. u8 index;
  593. /** core_id ID number */
  594. u16 id;
  595. /** Core-specific data. */
  596. void *priv;
  597. };
  598. /* Additional information for each 80211 core. */
  599. struct bcm43xx_coreinfo_80211 {
  600. /* PHY device. */
  601. struct bcm43xx_phyinfo phy;
  602. /* Radio device. */
  603. struct bcm43xx_radioinfo radio;
  604. union {
  605. /* DMA context. */
  606. struct bcm43xx_dma dma;
  607. /* PIO context. */
  608. struct bcm43xx_pio pio;
  609. };
  610. };
  611. /* Context information for a noise calculation (Link Quality). */
  612. struct bcm43xx_noise_calculation {
  613. struct bcm43xx_coreinfo *core_at_start;
  614. u8 channel_at_start;
  615. u8 calculation_running:1;
  616. u8 nr_samples;
  617. s8 samples[8][4];
  618. };
  619. struct bcm43xx_stats {
  620. u8 noise;
  621. struct iw_statistics wstats;
  622. /* Store the last TX/RX times here for updating the leds. */
  623. unsigned long last_tx;
  624. unsigned long last_rx;
  625. };
  626. struct bcm43xx_key {
  627. u8 enabled:1;
  628. u8 algorithm;
  629. };
  630. /* Driver initialization status. */
  631. enum {
  632. BCM43xx_STAT_UNINIT, /* Uninitialized. */
  633. BCM43xx_STAT_INITIALIZING, /* init_board() in progress. */
  634. BCM43xx_STAT_INITIALIZED, /* Fully operational. */
  635. BCM43xx_STAT_SHUTTINGDOWN, /* free_board() in progress. */
  636. BCM43xx_STAT_RESTARTING, /* controller_restart() called. */
  637. };
  638. #define bcm43xx_status(bcm) atomic_read(&(bcm)->init_status)
  639. #define bcm43xx_set_status(bcm, stat) do { \
  640. atomic_set(&(bcm)->init_status, (stat)); \
  641. smp_wmb(); \
  642. } while (0)
  643. /* *** THEORY OF LOCKING ***
  644. *
  645. * We have two different locks in the bcm43xx driver.
  646. * => bcm->mutex: General sleeping mutex. Protects struct bcm43xx_private
  647. * and the device registers. This mutex does _not_ protect
  648. * against concurrency from the IRQ handler.
  649. * => bcm->irq_lock: IRQ spinlock. Protects against IRQ handler concurrency.
  650. *
  651. * Please note that, if you only take the irq_lock, you are not protected
  652. * against concurrency from the periodic work handlers.
  653. * Most times you want to take _both_ locks.
  654. */
  655. struct bcm43xx_private {
  656. struct ieee80211_device *ieee;
  657. struct ieee80211softmac_device *softmac;
  658. struct net_device *net_dev;
  659. struct pci_dev *pci_dev;
  660. unsigned int irq;
  661. void __iomem *mmio_addr;
  662. spinlock_t irq_lock;
  663. struct mutex mutex;
  664. /* Driver initialization status BCM43xx_STAT_*** */
  665. atomic_t init_status;
  666. u16 was_initialized:1, /* for PCI suspend/resume. */
  667. __using_pio:1, /* Internal, use bcm43xx_using_pio(). */
  668. bad_frames_preempt:1, /* Use "Bad Frames Preemption" (default off) */
  669. reg124_set_0x4:1, /* Some variable to keep track of IRQ stuff. */
  670. short_preamble:1, /* TRUE, if short preamble is enabled. */
  671. firmware_norelease:1, /* Do not release the firmware. Used on suspend. */
  672. radio_hw_enable:1; /* TRUE if radio is hardware enabled */
  673. struct bcm43xx_stats stats;
  674. /* Bus type we are connected to.
  675. * This is currently always BCM43xx_BUSTYPE_PCI
  676. */
  677. u8 bustype;
  678. u16 board_vendor;
  679. u16 board_type;
  680. u16 board_revision;
  681. u16 chip_id;
  682. u8 chip_rev;
  683. u8 chip_package;
  684. struct bcm43xx_sprominfo sprom;
  685. #define BCM43xx_NR_LEDS 4
  686. struct bcm43xx_led leds[BCM43xx_NR_LEDS];
  687. spinlock_t leds_lock;
  688. /* The currently active core. */
  689. struct bcm43xx_coreinfo *current_core;
  690. #ifdef CONFIG_BCM947XX
  691. /** current core memory offset */
  692. u32 current_core_offset;
  693. #endif
  694. struct bcm43xx_coreinfo *active_80211_core;
  695. /* coreinfo structs for all possible cores follow.
  696. * Note that a core might not exist.
  697. * So check the coreinfo flags before using it.
  698. */
  699. struct bcm43xx_coreinfo core_chipcommon;
  700. struct bcm43xx_coreinfo core_pci;
  701. struct bcm43xx_coreinfo core_80211[ BCM43xx_MAX_80211_CORES ];
  702. /* Additional information, specific to the 80211 cores. */
  703. struct bcm43xx_coreinfo_80211 core_80211_ext[ BCM43xx_MAX_80211_CORES ];
  704. /* Number of available 80211 cores. */
  705. int nr_80211_available;
  706. u32 chipcommon_capabilities;
  707. /* Reason code of the last interrupt. */
  708. u32 irq_reason;
  709. u32 dma_reason[6];
  710. /* saved irq enable/disable state bitfield. */
  711. u32 irq_savedstate;
  712. /* Link Quality calculation context. */
  713. struct bcm43xx_noise_calculation noisecalc;
  714. /* if > 0 MAC is suspended. if == 0 MAC is enabled. */
  715. int mac_suspended;
  716. /* Threshold values. */
  717. //TODO: The RTS thr has to be _used_. Currently, it is only set via WX.
  718. u32 rts_threshold;
  719. /* Interrupt Service Routine tasklet (bottom-half) */
  720. struct tasklet_struct isr_tasklet;
  721. /* Periodic tasks */
  722. struct delayed_work periodic_work;
  723. unsigned int periodic_state;
  724. struct work_struct restart_work;
  725. /* Informational stuff. */
  726. char nick[IW_ESSID_MAX_SIZE + 1];
  727. /* encryption/decryption */
  728. u16 security_offset;
  729. struct bcm43xx_key key[54];
  730. u8 default_key_idx;
  731. /* Random Number Generator. */
  732. struct hwrng rng;
  733. char rng_name[20 + 1];
  734. /* Debugging stuff follows. */
  735. #ifdef CONFIG_BCM43XX_DEBUG
  736. struct bcm43xx_dfsentry *dfsentry;
  737. #endif
  738. };
  739. static inline
  740. struct bcm43xx_private * bcm43xx_priv(struct net_device *dev)
  741. {
  742. return ieee80211softmac_priv(dev);
  743. }
  744. struct device;
  745. static inline
  746. struct bcm43xx_private * dev_to_bcm(struct device *dev)
  747. {
  748. struct net_device *net_dev;
  749. struct bcm43xx_private *bcm;
  750. net_dev = dev_get_drvdata(dev);
  751. bcm = bcm43xx_priv(net_dev);
  752. return bcm;
  753. }
  754. /* Helper function, which returns a boolean.
  755. * TRUE, if PIO is used; FALSE, if DMA is used.
  756. */
  757. #if defined(CONFIG_BCM43XX_DMA) && defined(CONFIG_BCM43XX_PIO)
  758. static inline
  759. int bcm43xx_using_pio(struct bcm43xx_private *bcm)
  760. {
  761. return bcm->__using_pio;
  762. }
  763. #elif defined(CONFIG_BCM43XX_DMA)
  764. static inline
  765. int bcm43xx_using_pio(struct bcm43xx_private *bcm)
  766. {
  767. return 0;
  768. }
  769. #elif defined(CONFIG_BCM43XX_PIO)
  770. static inline
  771. int bcm43xx_using_pio(struct bcm43xx_private *bcm)
  772. {
  773. return 1;
  774. }
  775. #else
  776. # error "Using neither DMA nor PIO? Confused..."
  777. #endif
  778. /* Helper functions to access data structures private to the 80211 cores.
  779. * Note that we _must_ have an 80211 core mapped when calling
  780. * any of these functions.
  781. */
  782. static inline
  783. struct bcm43xx_coreinfo_80211 *
  784. bcm43xx_current_80211_priv(struct bcm43xx_private *bcm)
  785. {
  786. assert(bcm->current_core->id == BCM43xx_COREID_80211);
  787. return bcm->current_core->priv;
  788. }
  789. static inline
  790. struct bcm43xx_pio * bcm43xx_current_pio(struct bcm43xx_private *bcm)
  791. {
  792. assert(bcm43xx_using_pio(bcm));
  793. return &(bcm43xx_current_80211_priv(bcm)->pio);
  794. }
  795. static inline
  796. struct bcm43xx_dma * bcm43xx_current_dma(struct bcm43xx_private *bcm)
  797. {
  798. assert(!bcm43xx_using_pio(bcm));
  799. return &(bcm43xx_current_80211_priv(bcm)->dma);
  800. }
  801. static inline
  802. struct bcm43xx_phyinfo * bcm43xx_current_phy(struct bcm43xx_private *bcm)
  803. {
  804. return &(bcm43xx_current_80211_priv(bcm)->phy);
  805. }
  806. static inline
  807. struct bcm43xx_radioinfo * bcm43xx_current_radio(struct bcm43xx_private *bcm)
  808. {
  809. return &(bcm43xx_current_80211_priv(bcm)->radio);
  810. }
  811. static inline
  812. struct bcm43xx_lopair * bcm43xx_get_lopair(struct bcm43xx_phyinfo *phy,
  813. u16 radio_attenuation,
  814. u16 baseband_attenuation)
  815. {
  816. return phy->_lo_pairs + (radio_attenuation + 14 * (baseband_attenuation / 2));
  817. }
  818. static inline
  819. u16 bcm43xx_read16(struct bcm43xx_private *bcm, u16 offset)
  820. {
  821. return ioread16(bcm->mmio_addr + core_offset(bcm) + offset);
  822. }
  823. static inline
  824. void bcm43xx_write16(struct bcm43xx_private *bcm, u16 offset, u16 value)
  825. {
  826. iowrite16(value, bcm->mmio_addr + core_offset(bcm) + offset);
  827. }
  828. static inline
  829. u32 bcm43xx_read32(struct bcm43xx_private *bcm, u16 offset)
  830. {
  831. return ioread32(bcm->mmio_addr + core_offset(bcm) + offset);
  832. }
  833. static inline
  834. void bcm43xx_write32(struct bcm43xx_private *bcm, u16 offset, u32 value)
  835. {
  836. iowrite32(value, bcm->mmio_addr + core_offset(bcm) + offset);
  837. }
  838. static inline
  839. int bcm43xx_pci_read_config16(struct bcm43xx_private *bcm, int offset, u16 *value)
  840. {
  841. return pci_read_config_word(bcm->pci_dev, offset, value);
  842. }
  843. static inline
  844. int bcm43xx_pci_read_config32(struct bcm43xx_private *bcm, int offset, u32 *value)
  845. {
  846. return pci_read_config_dword(bcm->pci_dev, offset, value);
  847. }
  848. static inline
  849. int bcm43xx_pci_write_config16(struct bcm43xx_private *bcm, int offset, u16 value)
  850. {
  851. return pci_write_config_word(bcm->pci_dev, offset, value);
  852. }
  853. static inline
  854. int bcm43xx_pci_write_config32(struct bcm43xx_private *bcm, int offset, u32 value)
  855. {
  856. return pci_write_config_dword(bcm->pci_dev, offset, value);
  857. }
  858. /** Limit a value between two limits */
  859. #ifdef limit_value
  860. # undef limit_value
  861. #endif
  862. #define limit_value(value, min, max) \
  863. ({ \
  864. typeof(value) __value = (value); \
  865. typeof(value) __min = (min); \
  866. typeof(value) __max = (max); \
  867. if (__value < __min) \
  868. __value = __min; \
  869. else if (__value > __max) \
  870. __value = __max; \
  871. __value; \
  872. })
  873. /** Helpers to print MAC addresses. */
  874. #define BCM43xx_MACFMT "%02x:%02x:%02x:%02x:%02x:%02x"
  875. #define BCM43xx_MACARG(x) ((u8*)(x))[0], ((u8*)(x))[1], \
  876. ((u8*)(x))[2], ((u8*)(x))[3], \
  877. ((u8*)(x))[4], ((u8*)(x))[5]
  878. #endif /* BCM43xx_H_ */