Commit | Line | Data |
---|---|---|
f222313a JL |
1 | #ifndef BCM43xx_H_ |
2 | #define BCM43xx_H_ | |
3 | ||
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 | ||
15 | ||
16 | #include "bcm43xx_debugfs.h" | |
17 | #include "bcm43xx_leds.h" | |
18 | ||
19 | ||
20 | #define DRV_NAME __stringify(KBUILD_MODNAME) | |
21 | #define DRV_VERSION __stringify(BCM43xx_VERSION) | |
22 | #define BCM43xx_DRIVER_NAME DRV_NAME " driver " DRV_VERSION | |
23 | #define PFX DRV_NAME ": " | |
24 | ||
25 | #define BCM43xx_SWITCH_CORE_MAX_RETRIES 10 | |
26 | #define BCM43xx_IRQWAIT_MAX_RETRIES 50 | |
27 | #define BCM43xx_TX_TIMEOUT (10 * HZ) | |
28 | ||
29 | #define BCM43xx_IO_SIZE 8192 | |
30 | #define BCM43xx_REG_ACTIVE_CORE 0x80 | |
31 | ||
32 | /* Interrupt Control PCI Configuration Register. (Only on PCI cores with rev >= 6) */ | |
33 | #define BCM43xx_PCICFG_ICR 0x94 | |
34 | /* SPROM control register. */ | |
35 | #define BCM43xx_PCICFG_SPROMCTL 0x88 | |
36 | ||
37 | /* MMIO offsets */ | |
38 | #define BCM43xx_MMIO_DMA1_REASON 0x20 | |
39 | #define BCM43xx_MMIO_DMA1_IRQ_MASK 0x24 | |
40 | #define BCM43xx_MMIO_DMA2_REASON 0x28 | |
41 | #define BCM43xx_MMIO_DMA2_IRQ_MASK 0x2C | |
42 | #define BCM43xx_MMIO_DMA3_REASON 0x30 | |
43 | #define BCM43xx_MMIO_DMA3_IRQ_MASK 0x34 | |
44 | #define BCM43xx_MMIO_DMA4_REASON 0x38 | |
45 | #define BCM43xx_MMIO_DMA4_IRQ_MASK 0x3C | |
46 | #define BCM43xx_MMIO_STATUS_BITFIELD 0x120 | |
47 | #define BCM43xx_MMIO_STATUS2_BITFIELD 0x124 | |
48 | #define BCM43xx_MMIO_GEN_IRQ_REASON 0x128 | |
49 | #define BCM43xx_MMIO_GEN_IRQ_MASK 0x12C | |
50 | #define BCM43xx_MMIO_RAM_CONTROL 0x130 | |
51 | #define BCM43xx_MMIO_RAM_DATA 0x134 | |
52 | #define BCM43xx_MMIO_PS_STATUS 0x140 | |
53 | #define BCM43xx_MMIO_RADIO_HWENABLED_HI 0x158 | |
54 | #define BCM43xx_MMIO_SHM_CONTROL 0x160 | |
55 | #define BCM43xx_MMIO_SHM_DATA 0x164 | |
56 | #define BCM43xx_MMIO_SHM_DATA_UNALIGNED 0x166 | |
57 | #define BCM43xx_MMIO_XMITSTAT_0 0x170 | |
58 | #define BCM43xx_MMIO_XMITSTAT_1 0x174 | |
59 | #define BCM43xx_MMIO_REV3PLUS_TSF_LOW 0x180 /* core rev >= 3 only */ | |
60 | #define BCM43xx_MMIO_REV3PLUS_TSF_HIGH 0x184 /* core rev >= 3 only */ | |
61 | #define BCM43xx_MMIO_DMA1_BASE 0x200 | |
62 | #define BCM43xx_MMIO_DMA2_BASE 0x220 | |
63 | #define BCM43xx_MMIO_DMA3_BASE 0x240 | |
64 | #define BCM43xx_MMIO_DMA4_BASE 0x260 | |
65 | #define BCM43xx_MMIO_PIO1_BASE 0x300 | |
66 | #define BCM43xx_MMIO_PIO2_BASE 0x310 | |
67 | #define BCM43xx_MMIO_PIO3_BASE 0x320 | |
68 | #define BCM43xx_MMIO_PIO4_BASE 0x330 | |
69 | #define BCM43xx_MMIO_PHY_VER 0x3E0 | |
70 | #define BCM43xx_MMIO_PHY_RADIO 0x3E2 | |
71 | #define BCM43xx_MMIO_ANTENNA 0x3E8 | |
72 | #define BCM43xx_MMIO_CHANNEL 0x3F0 | |
73 | #define BCM43xx_MMIO_CHANNEL_EXT 0x3F4 | |
74 | #define BCM43xx_MMIO_RADIO_CONTROL 0x3F6 | |
75 | #define BCM43xx_MMIO_RADIO_DATA_HIGH 0x3F8 | |
76 | #define BCM43xx_MMIO_RADIO_DATA_LOW 0x3FA | |
77 | #define BCM43xx_MMIO_PHY_CONTROL 0x3FC | |
78 | #define BCM43xx_MMIO_PHY_DATA 0x3FE | |
79 | #define BCM43xx_MMIO_MACFILTER_CONTROL 0x420 | |
80 | #define BCM43xx_MMIO_MACFILTER_DATA 0x422 | |
81 | #define BCM43xx_MMIO_RADIO_HWENABLED_LO 0x49A | |
82 | #define BCM43xx_MMIO_GPIO_CONTROL 0x49C | |
83 | #define BCM43xx_MMIO_GPIO_MASK 0x49E | |
84 | #define BCM43xx_MMIO_TSF_0 0x632 /* core rev < 3 only */ | |
85 | #define BCM43xx_MMIO_TSF_1 0x634 /* core rev < 3 only */ | |
86 | #define BCM43xx_MMIO_TSF_2 0x636 /* core rev < 3 only */ | |
87 | #define BCM43xx_MMIO_TSF_3 0x638 /* core rev < 3 only */ | |
88 | #define BCM43xx_MMIO_POWERUP_DELAY 0x6A8 | |
89 | ||
90 | /* SPROM offsets. */ | |
91 | #define BCM43xx_SPROM_BASE 0x1000 | |
92 | #define BCM43xx_SPROM_BOARDFLAGS2 0x1c | |
93 | #define BCM43xx_SPROM_IL0MACADDR 0x24 | |
94 | #define BCM43xx_SPROM_ET0MACADDR 0x27 | |
95 | #define BCM43xx_SPROM_ET1MACADDR 0x2a | |
96 | #define BCM43xx_SPROM_ETHPHY 0x2d | |
97 | #define BCM43xx_SPROM_BOARDREV 0x2e | |
98 | #define BCM43xx_SPROM_PA0B0 0x2f | |
99 | #define BCM43xx_SPROM_PA0B1 0x30 | |
100 | #define BCM43xx_SPROM_PA0B2 0x31 | |
101 | #define BCM43xx_SPROM_WL0GPIO0 0x32 | |
102 | #define BCM43xx_SPROM_WL0GPIO2 0x33 | |
103 | #define BCM43xx_SPROM_MAXPWR 0x34 | |
104 | #define BCM43xx_SPROM_PA1B0 0x35 | |
105 | #define BCM43xx_SPROM_PA1B1 0x36 | |
106 | #define BCM43xx_SPROM_PA1B2 0x37 | |
107 | #define BCM43xx_SPROM_IDL_TSSI_TGT 0x38 | |
108 | #define BCM43xx_SPROM_BOARDFLAGS 0x39 | |
109 | #define BCM43xx_SPROM_ANTENNA_GAIN 0x3a | |
110 | #define BCM43xx_SPROM_VERSION 0x3f | |
111 | ||
112 | /* BCM43xx_SPROM_BOARDFLAGS values */ | |
113 | #define BCM43xx_BFL_BTCOEXIST 0x0001 /* implements Bluetooth coexistance */ | |
114 | #define BCM43xx_BFL_PACTRL 0x0002 /* GPIO 9 controlling the PA */ | |
115 | #define BCM43xx_BFL_AIRLINEMODE 0x0004 /* implements GPIO 13 radio disable indication */ | |
116 | #define BCM43xx_BFL_RSSI 0x0008 /* software calculates nrssi slope. */ | |
117 | #define BCM43xx_BFL_ENETSPI 0x0010 /* has ephy roboswitch spi */ | |
118 | #define BCM43xx_BFL_XTAL_NOSLOW 0x0020 /* no slow clock available */ | |
119 | #define BCM43xx_BFL_CCKHIPWR 0x0040 /* can do high power CCK transmission */ | |
120 | #define BCM43xx_BFL_ENETADM 0x0080 /* has ADMtek switch */ | |
121 | #define BCM43xx_BFL_ENETVLAN 0x0100 /* can do vlan */ | |
122 | #define BCM43xx_BFL_AFTERBURNER 0x0200 /* supports Afterburner mode */ | |
123 | #define BCM43xx_BFL_NOPCI 0x0400 /* leaves PCI floating */ | |
124 | #define BCM43xx_BFL_FEM 0x0800 /* supports the Front End Module */ | |
125 | ||
126 | /* GPIO register offset, in both ChipCommon and PCI core. */ | |
127 | #define BCM43xx_GPIO_CONTROL 0x6c | |
128 | ||
129 | /* SHM Routing */ | |
130 | #define BCM43xx_SHM_SHARED 0x0001 | |
131 | #define BCM43xx_SHM_WIRELESS 0x0002 | |
132 | #define BCM43xx_SHM_PCM 0x0003 | |
133 | #define BCM43xx_SHM_HWMAC 0x0004 | |
134 | #define BCM43xx_SHM_UCODE 0x0300 | |
135 | ||
136 | /* MacFilter offsets. */ | |
137 | #define BCM43xx_MACFILTER_SELF 0x0000 | |
138 | #define BCM43xx_MACFILTER_ASSOC 0x0003 | |
139 | ||
140 | /* Chipcommon registers. */ | |
141 | #define BCM43xx_CHIPCOMMON_CAPABILITIES 0x04 | |
142 | #define BCM43xx_CHIPCOMMON_PLLONDELAY 0xB0 | |
143 | #define BCM43xx_CHIPCOMMON_FREFSELDELAY 0xB4 | |
144 | #define BCM43xx_CHIPCOMMON_SLOWCLKCTL 0xB8 | |
145 | #define BCM43xx_CHIPCOMMON_SYSCLKCTL 0xC0 | |
146 | ||
147 | /* PCI core specific registers. */ | |
148 | #define BCM43xx_PCICORE_BCAST_ADDR 0x50 | |
149 | #define BCM43xx_PCICORE_BCAST_DATA 0x54 | |
150 | #define BCM43xx_PCICORE_SBTOPCI2 0x108 | |
151 | ||
152 | /* SBTOPCI2 values. */ | |
153 | #define BCM43xx_SBTOPCI2_PREFETCH 0x4 | |
154 | #define BCM43xx_SBTOPCI2_BURST 0x8 | |
155 | ||
156 | /* Chipcommon capabilities. */ | |
157 | #define BCM43xx_CAPABILITIES_PCTL 0x00040000 | |
158 | #define BCM43xx_CAPABILITIES_PLLMASK 0x00030000 | |
159 | #define BCM43xx_CAPABILITIES_PLLSHIFT 16 | |
160 | #define BCM43xx_CAPABILITIES_FLASHMASK 0x00000700 | |
161 | #define BCM43xx_CAPABILITIES_FLASHSHIFT 8 | |
162 | #define BCM43xx_CAPABILITIES_EXTBUSPRESENT 0x00000040 | |
163 | #define BCM43xx_CAPABILITIES_UARTGPIO 0x00000020 | |
164 | #define BCM43xx_CAPABILITIES_UARTCLOCKMASK 0x00000018 | |
165 | #define BCM43xx_CAPABILITIES_UARTCLOCKSHIFT 3 | |
166 | #define BCM43xx_CAPABILITIES_MIPSBIGENDIAN 0x00000004 | |
167 | #define BCM43xx_CAPABILITIES_NRUARTSMASK 0x00000003 | |
168 | ||
169 | /* PowerControl */ | |
170 | #define BCM43xx_PCTL_IN 0xB0 | |
171 | #define BCM43xx_PCTL_OUT 0xB4 | |
172 | #define BCM43xx_PCTL_OUTENABLE 0xB8 | |
173 | #define BCM43xx_PCTL_XTAL_POWERUP 0x40 | |
174 | #define BCM43xx_PCTL_PLL_POWERDOWN 0x80 | |
175 | ||
176 | /* PowerControl Clock Modes */ | |
177 | #define BCM43xx_PCTL_CLK_FAST 0x00 | |
178 | #define BCM43xx_PCTL_CLK_SLOW 0x01 | |
179 | #define BCM43xx_PCTL_CLK_DYNAMIC 0x02 | |
180 | ||
181 | #define BCM43xx_PCTL_FORCE_SLOW 0x0800 | |
182 | #define BCM43xx_PCTL_FORCE_PLL 0x1000 | |
183 | #define BCM43xx_PCTL_DYN_XTAL 0x2000 | |
184 | ||
185 | /* COREIDs */ | |
186 | #define BCM43xx_COREID_CHIPCOMMON 0x800 | |
187 | #define BCM43xx_COREID_ILINE20 0x801 | |
188 | #define BCM43xx_COREID_SDRAM 0x803 | |
189 | #define BCM43xx_COREID_PCI 0x804 | |
190 | #define BCM43xx_COREID_MIPS 0x805 | |
191 | #define BCM43xx_COREID_ETHERNET 0x806 | |
192 | #define BCM43xx_COREID_V90 0x807 | |
193 | #define BCM43xx_COREID_USB11_HOSTDEV 0x80a | |
194 | #define BCM43xx_COREID_IPSEC 0x80b | |
195 | #define BCM43xx_COREID_PCMCIA 0x80d | |
196 | #define BCM43xx_COREID_EXT_IF 0x80f | |
197 | #define BCM43xx_COREID_80211 0x812 | |
198 | #define BCM43xx_COREID_MIPS_3302 0x816 | |
199 | #define BCM43xx_COREID_USB11_HOST 0x817 | |
200 | #define BCM43xx_COREID_USB11_DEV 0x818 | |
201 | #define BCM43xx_COREID_USB20_HOST 0x819 | |
202 | #define BCM43xx_COREID_USB20_DEV 0x81a | |
203 | #define BCM43xx_COREID_SDIO_HOST 0x81b | |
204 | ||
205 | /* Core Information Registers */ | |
206 | #define BCM43xx_CIR_BASE 0xf00 | |
207 | #define BCM43xx_CIR_SBTPSFLAG (BCM43xx_CIR_BASE + 0x18) | |
208 | #define BCM43xx_CIR_SBIMSTATE (BCM43xx_CIR_BASE + 0x90) | |
209 | #define BCM43xx_CIR_SBINTVEC (BCM43xx_CIR_BASE + 0x94) | |
210 | #define BCM43xx_CIR_SBTMSTATELOW (BCM43xx_CIR_BASE + 0x98) | |
211 | #define BCM43xx_CIR_SBTMSTATEHIGH (BCM43xx_CIR_BASE + 0x9c) | |
212 | #define BCM43xx_CIR_SBIMCONFIGLOW (BCM43xx_CIR_BASE + 0xa8) | |
213 | #define BCM43xx_CIR_SB_ID_HI (BCM43xx_CIR_BASE + 0xfc) | |
214 | ||
215 | /* Mask to get the Backplane Flag Number from SBTPSFLAG. */ | |
216 | #define BCM43xx_BACKPLANE_FLAG_NR_MASK 0x3f | |
217 | ||
218 | /* SBIMCONFIGLOW values/masks. */ | |
219 | #define BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK 0x00000007 | |
220 | #define BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_SHIFT 0 | |
221 | #define BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK 0x00000070 | |
222 | #define BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_SHIFT 4 | |
223 | #define BCM43xx_SBIMCONFIGLOW_CONNID_MASK 0x00ff0000 | |
224 | #define BCM43xx_SBIMCONFIGLOW_CONNID_SHIFT 16 | |
225 | ||
226 | /* sbtmstatelow state flags */ | |
227 | #define BCM43xx_SBTMSTATELOW_RESET 0x01 | |
228 | #define BCM43xx_SBTMSTATELOW_REJECT 0x02 | |
229 | #define BCM43xx_SBTMSTATELOW_CLOCK 0x10000 | |
230 | #define BCM43xx_SBTMSTATELOW_FORCE_GATE_CLOCK 0x20000 | |
231 | ||
232 | /* sbtmstatehigh state flags */ | |
233 | #define BCM43xx_SBTMSTATEHIGH_SERROR 0x1 | |
234 | #define BCM43xx_SBTMSTATEHIGH_BUSY 0x4 | |
235 | ||
236 | /* sbimstate flags */ | |
237 | #define BCM43xx_SBIMSTATE_IB_ERROR 0x20000 | |
238 | #define BCM43xx_SBIMSTATE_TIMEOUT 0x40000 | |
239 | ||
240 | /* PHYVersioning */ | |
241 | #define BCM43xx_PHYTYPE_A 0x00 | |
242 | #define BCM43xx_PHYTYPE_B 0x01 | |
243 | #define BCM43xx_PHYTYPE_G 0x02 | |
244 | ||
245 | /* PHYRegisters */ | |
246 | #define BCM43xx_PHY_ILT_A_CTRL 0x0072 | |
247 | #define BCM43xx_PHY_ILT_A_DATA1 0x0073 | |
248 | #define BCM43xx_PHY_ILT_A_DATA2 0x0074 | |
249 | #define BCM43xx_PHY_G_LO_CONTROL 0x0810 | |
250 | #define BCM43xx_PHY_ILT_G_CTRL 0x0472 | |
251 | #define BCM43xx_PHY_ILT_G_DATA1 0x0473 | |
252 | #define BCM43xx_PHY_ILT_G_DATA2 0x0474 | |
253 | #define BCM43xx_PHY_A_PCTL 0x007B | |
254 | #define BCM43xx_PHY_G_PCTL 0x0029 | |
255 | #define BCM43xx_PHY_A_CRS 0x0029 | |
256 | #define BCM43xx_PHY_RADIO_BITFIELD 0x0401 | |
257 | #define BCM43xx_PHY_G_CRS 0x0429 | |
258 | #define BCM43xx_PHY_NRSSILT_CTRL 0x0803 | |
259 | #define BCM43xx_PHY_NRSSILT_DATA 0x0804 | |
260 | ||
261 | /* RadioRegisters */ | |
262 | #define BCM43xx_RADIOCTL_ID 0x01 | |
263 | ||
264 | /* StatusBitField */ | |
265 | #define BCM43xx_SBF_MAC_ENABLED 0x00000001 | |
266 | #define BCM43xx_SBF_2 0x00000002 /*FIXME: fix name*/ | |
267 | #define BCM43xx_SBF_CORE_READY 0x00000004 | |
268 | #define BCM43xx_SBF_400 0x00000400 /*FIXME: fix name*/ | |
269 | #define BCM43xx_SBF_4000 0x00004000 /*FIXME: fix name*/ | |
270 | #define BCM43xx_SBF_8000 0x00008000 /*FIXME: fix name*/ | |
271 | #define BCM43xx_SBF_XFER_REG_BYTESWAP 0x00010000 | |
272 | #define BCM43xx_SBF_MODE_NOTADHOC 0x00020000 | |
273 | #define BCM43xx_SBF_MODE_AP 0x00040000 | |
274 | #define BCM43xx_SBF_RADIOREG_LOCK 0x00080000 | |
275 | #define BCM43xx_SBF_MODE_MONITOR 0x00400000 | |
276 | #define BCM43xx_SBF_MODE_PROMISC 0x01000000 | |
277 | #define BCM43xx_SBF_PS1 0x02000000 | |
278 | #define BCM43xx_SBF_PS2 0x04000000 | |
279 | #define BCM43xx_SBF_NO_SSID_BCAST 0x08000000 | |
280 | #define BCM43xx_SBF_TIME_UPDATE 0x10000000 | |
281 | #define BCM43xx_SBF_80000000 0x80000000 /*FIXME: fix name*/ | |
282 | ||
283 | /* MicrocodeFlagsBitfield (addr + lo-word values?)*/ | |
284 | #define BCM43xx_UCODEFLAGS_OFFSET 0x005E | |
285 | ||
286 | #define BCM43xx_UCODEFLAG_AUTODIV 0x0001 | |
287 | #define BCM43xx_UCODEFLAG_UNKBGPHY 0x0002 | |
288 | #define BCM43xx_UCODEFLAG_UNKBPHY 0x0004 | |
289 | #define BCM43xx_UCODEFLAG_UNKGPHY 0x0020 | |
290 | #define BCM43xx_UCODEFLAG_UNKPACTRL 0x0040 | |
291 | #define BCM43xx_UCODEFLAG_JAPAN 0x0080 | |
292 | ||
293 | /* Generic-Interrupt reasons. */ | |
294 | #define BCM43xx_IRQ_READY (1 << 0) | |
295 | #define BCM43xx_IRQ_BEACON (1 << 1) | |
296 | #define BCM43xx_IRQ_PS (1 << 2) | |
297 | #define BCM43xx_IRQ_REG124 (1 << 5) | |
298 | #define BCM43xx_IRQ_PMQ (1 << 6) | |
299 | #define BCM43xx_IRQ_PIO_WORKAROUND (1 << 8) | |
300 | #define BCM43xx_IRQ_XMIT_ERROR (1 << 11) | |
301 | #define BCM43xx_IRQ_RX (1 << 15) | |
302 | #define BCM43xx_IRQ_SCAN (1 << 16) | |
303 | #define BCM43xx_IRQ_NOISE (1 << 18) | |
304 | #define BCM43xx_IRQ_XMIT_STATUS (1 << 29) | |
305 | ||
306 | #define BCM43xx_IRQ_ALL 0xffffffff | |
307 | #define BCM43xx_IRQ_INITIAL (BCM43xx_IRQ_PS | \ | |
308 | BCM43xx_IRQ_REG124 | \ | |
309 | BCM43xx_IRQ_PMQ | \ | |
310 | BCM43xx_IRQ_XMIT_ERROR | \ | |
311 | BCM43xx_IRQ_RX | \ | |
312 | BCM43xx_IRQ_SCAN | \ | |
313 | BCM43xx_IRQ_NOISE | \ | |
314 | BCM43xx_IRQ_XMIT_STATUS) | |
315 | ||
316 | ||
317 | /* Initial default iw_mode */ | |
318 | #define BCM43xx_INITIAL_IWMODE IW_MODE_INFRA | |
319 | ||
320 | /* Values/Masks for the device TX header */ | |
321 | #define BCM43xx_TXHDRFLAG_EXPECTACK 0x0001 | |
322 | #define BCM43xx_TXHDRFLAG_FIRSTFRAGMENT 0x0008 | |
323 | #define BCM43xx_TXHDRFLAG_DESTPSMODE 0x0020 | |
324 | #define BCM43xx_TXHDRFLAG_FALLBACKOFDM 0x0100 | |
325 | #define BCM43xx_TXHDRFLAG_FRAMEBURST 0x0800 | |
326 | ||
327 | #define BCM43xx_TXHDRCTL_OFDM 0x0001 | |
328 | #define BCM43xx_TXHDRCTL_SHORT_PREAMBLE 0x0010 | |
329 | #define BCM43xx_TXHDRCTL_ANTENNADIV_MASK 0x0030 | |
330 | #define BCM43xx_TXHDRCTL_ANTENNADIV_SHIFT 8 | |
331 | ||
332 | #define BCM43xx_TXHDR_WSEC_KEYINDEX_MASK 0x00F0 | |
333 | #define BCM43xx_TXHDR_WSEC_KEYINDEX_SHIFT 4 | |
334 | #define BCM43xx_TXHDR_WSEC_ALGO_MASK 0x0003 | |
335 | #define BCM43xx_TXHDR_WSEC_ALGO_SHIFT 0 | |
336 | ||
337 | /* Bus type PCI. */ | |
338 | #define BCM43xx_BUSTYPE_PCI 0 | |
339 | /* Bus type Silicone Backplane Bus. */ | |
340 | #define BCM43xx_BUSTYPE_SB 1 | |
341 | /* Bus type PCMCIA. */ | |
342 | #define BCM43xx_BUSTYPE_PCMCIA 2 | |
343 | ||
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 | ||
349 | #define BCM43xx_DEFAULT_SHORT_RETRY_LIMIT 7 | |
350 | #define BCM43xx_DEFAULT_LONG_RETRY_LIMIT 4 | |
351 | ||
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 | ||
364 | #ifdef assert | |
365 | # undef assert | |
366 | #endif | |
367 | #ifdef CONFIG_BCM43XX_DEBUG | |
368 | #define assert(expr) \ | |
369 | do { \ | |
370 | if (unlikely(!(expr))) { \ | |
371 | printk(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", \ | |
372 | #expr, __FILE__, __LINE__, __FUNCTION__); \ | |
373 | } \ | |
374 | } while (0) | |
375 | #else | |
376 | #define assert(expr) do { /* nothing */ } while (0) | |
377 | #endif | |
378 | ||
379 | /* rate limited printk(). */ | |
380 | #ifdef printkl | |
381 | # undef printkl | |
382 | #endif | |
383 | #define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0) | |
384 | /* rate limited printk() for debugging */ | |
385 | #ifdef dprintkl | |
386 | # undef dprintkl | |
387 | #endif | |
388 | #ifdef CONFIG_BCM43XX_DEBUG | |
389 | # define dprintkl printkl | |
390 | #else | |
391 | # define dprintkl(f, x...) do { /* nothing */ } while (0) | |
392 | #endif | |
393 | ||
394 | /* Helper macro for if branches. | |
395 | * An if branch marked with this macro is only taken in DEBUG mode. | |
396 | * Example: | |
397 | * if (DEBUG_ONLY(foo == bar)) { | |
398 | * do something | |
399 | * } | |
400 | * In DEBUG mode, the branch will be taken if (foo == bar). | |
401 | * In non-DEBUG mode, the branch will never be taken. | |
402 | */ | |
403 | #ifdef DEBUG_ONLY | |
404 | # undef DEBUG_ONLY | |
405 | #endif | |
406 | #ifdef CONFIG_BCM43XX_DEBUG | |
407 | # define DEBUG_ONLY(x) (x) | |
408 | #else | |
409 | # define DEBUG_ONLY(x) 0 | |
410 | #endif | |
411 | ||
412 | /* debugging printk() */ | |
413 | #ifdef dprintk | |
414 | # undef dprintk | |
415 | #endif | |
416 | #ifdef CONFIG_BCM43XX_DEBUG | |
417 | # define dprintk(f, x...) do { printk(f ,##x); } while (0) | |
418 | #else | |
419 | # define dprintk(f, x...) do { /* nothing */ } while (0) | |
420 | #endif | |
421 | ||
422 | ||
423 | struct net_device; | |
424 | struct pci_dev; | |
425 | struct workqueue_struct; | |
426 | struct bcm43xx_dmaring; | |
427 | struct bcm43xx_pioqueue; | |
428 | ||
429 | struct bcm43xx_initval { | |
430 | u16 offset; | |
431 | u16 size; | |
432 | u32 value; | |
433 | } __attribute__((__packed__)); | |
434 | ||
435 | /* Values for bcm430x_sprominfo.locale */ | |
436 | enum { | |
437 | BCM43xx_LOCALE_WORLD = 0, | |
438 | BCM43xx_LOCALE_THAILAND, | |
439 | BCM43xx_LOCALE_ISRAEL, | |
440 | BCM43xx_LOCALE_JORDAN, | |
441 | BCM43xx_LOCALE_CHINA, | |
442 | BCM43xx_LOCALE_JAPAN, | |
443 | BCM43xx_LOCALE_USA_CANADA_ANZ, | |
444 | BCM43xx_LOCALE_EUROPE, | |
445 | BCM43xx_LOCALE_USA_LOW, | |
446 | BCM43xx_LOCALE_JAPAN_HIGH, | |
447 | BCM43xx_LOCALE_ALL, | |
448 | BCM43xx_LOCALE_NONE, | |
449 | }; | |
450 | ||
451 | #define BCM43xx_SPROM_SIZE 64 /* in 16-bit words. */ | |
452 | struct bcm43xx_sprominfo { | |
453 | u16 boardflags2; | |
454 | u8 il0macaddr[6]; | |
455 | u8 et0macaddr[6]; | |
456 | u8 et1macaddr[6]; | |
457 | u8 et0phyaddr:5; | |
458 | u8 et1phyaddr:5; | |
459 | u8 et0mdcport:1; | |
460 | u8 et1mdcport:1; | |
461 | u8 boardrev; | |
462 | u8 locale:4; | |
463 | u8 antennas_aphy:2; | |
464 | u8 antennas_bgphy:2; | |
465 | u16 pa0b0; | |
466 | u16 pa0b1; | |
467 | u16 pa0b2; | |
468 | u8 wl0gpio0; | |
469 | u8 wl0gpio1; | |
470 | u8 wl0gpio2; | |
471 | u8 wl0gpio3; | |
472 | u8 maxpower_aphy; | |
473 | u8 maxpower_bgphy; | |
474 | u16 pa1b0; | |
475 | u16 pa1b1; | |
476 | u16 pa1b2; | |
477 | u8 idle_tssi_tgt_aphy; | |
478 | u8 idle_tssi_tgt_bgphy; | |
479 | u16 boardflags; | |
480 | u16 antennagain_aphy; | |
481 | u16 antennagain_bgphy; | |
482 | }; | |
483 | ||
484 | /* Value pair to measure the LocalOscillator. */ | |
485 | struct bcm43xx_lopair { | |
486 | s8 low; | |
487 | s8 high; | |
488 | u8 used:1; | |
489 | }; | |
490 | #define BCM43xx_LO_COUNT (14*4) | |
491 | ||
492 | struct bcm43xx_phyinfo { | |
493 | /* Hardware Data */ | |
494 | u8 version; | |
495 | u8 type; | |
496 | u8 rev; | |
497 | u16 antenna_diversity; | |
498 | u16 savedpctlreg; | |
499 | u16 minlowsig[2]; | |
500 | u16 minlowsigpos[2]; | |
501 | u8 connected:1, | |
502 | calibrated:1, | |
503 | is_locked:1, /* used in bcm43xx_phy_{un}lock() */ | |
504 | dyn_tssi_tbl:1; /* used in bcm43xx_phy_init_tssi2dbm_table() */ | |
505 | /* LO Measurement Data. | |
506 | * Use bcm43xx_get_lopair() to get a value. | |
507 | */ | |
508 | struct bcm43xx_lopair *_lo_pairs; | |
509 | ||
510 | /* TSSI to dBm table in use */ | |
511 | const s8 *tssi2dbm; | |
512 | /* idle TSSI value */ | |
513 | s8 idle_tssi; | |
514 | /* PHY lock for core.rev < 3 | |
515 | * This lock is only used by bcm43xx_phy_{un}lock() | |
516 | */ | |
517 | spinlock_t lock; | |
518 | }; | |
519 | ||
520 | ||
521 | struct bcm43xx_radioinfo { | |
522 | u16 manufact; | |
523 | u16 version; | |
524 | u8 revision; | |
525 | ||
526 | /* 0: baseband attenuation, | |
527 | * 1: radio attenuation, | |
528 | * 2: tx_CTL1 | |
529 | * 3: tx_CTL2 | |
530 | */ | |
531 | u16 txpower[4]; | |
532 | /* Current Interference Mitigation mode */ | |
533 | int interfmode; | |
534 | /* Stack of saved values from the Interference Mitigation code */ | |
535 | u16 interfstack[20]; | |
536 | /* Saved values from the NRSSI Slope calculation */ | |
537 | s16 nrssi[2]; | |
538 | s32 nrssislope; | |
539 | /* In memory nrssi lookup table. */ | |
540 | s8 nrssi_lt[64]; | |
541 | ||
542 | /* current channel */ | |
543 | u8 channel; | |
544 | u8 initial_channel; | |
545 | ||
546 | u16 lofcal; | |
547 | ||
548 | u16 initval; | |
549 | ||
550 | u8 enabled:1; | |
551 | /* ACI (adjacent channel interference) flags. */ | |
552 | u8 aci_enable:1, | |
553 | aci_wlan_automatic:1, | |
554 | aci_hw_rssi:1; | |
555 | }; | |
556 | ||
557 | /* Data structures for DMA transmission, per 80211 core. */ | |
558 | struct bcm43xx_dma { | |
559 | struct bcm43xx_dmaring *tx_ring0; | |
560 | struct bcm43xx_dmaring *tx_ring1; | |
561 | struct bcm43xx_dmaring *tx_ring2; | |
562 | struct bcm43xx_dmaring *tx_ring3; | |
563 | struct bcm43xx_dmaring *rx_ring0; | |
564 | struct bcm43xx_dmaring *rx_ring1; /* only available on core.rev < 5 */ | |
565 | }; | |
566 | ||
567 | /* Data structures for PIO transmission, per 80211 core. */ | |
568 | struct bcm43xx_pio { | |
569 | struct bcm43xx_pioqueue *queue0; | |
570 | struct bcm43xx_pioqueue *queue1; | |
571 | struct bcm43xx_pioqueue *queue2; | |
572 | struct bcm43xx_pioqueue *queue3; | |
573 | }; | |
574 | ||
575 | #define BCM43xx_MAX_80211_CORES 2 | |
576 | ||
577 | #define BCM43xx_COREFLAG_AVAILABLE (1 << 0) | |
578 | #define BCM43xx_COREFLAG_ENABLED (1 << 1) | |
579 | #define BCM43xx_COREFLAG_INITIALIZED (1 << 2) | |
580 | ||
581 | #ifdef CONFIG_BCM947XX | |
582 | #define core_offset(bcm) (bcm)->current_core_offset | |
583 | #else | |
584 | #define core_offset(bcm) 0 | |
585 | #endif | |
586 | ||
587 | struct bcm43xx_coreinfo { | |
588 | /** Driver internal flags. See BCM43xx_COREFLAG_* */ | |
589 | u32 flags; | |
590 | /** core_id ID number */ | |
591 | u16 id; | |
592 | /** core_rev revision number */ | |
593 | u8 rev; | |
594 | /** Index number for _switch_core() */ | |
595 | u8 index; | |
596 | /* Pointer to the PHYinfo, which belongs to this core (if 80211 core) */ | |
597 | struct bcm43xx_phyinfo *phy; | |
598 | /* Pointer to the RadioInfo, which belongs to this core (if 80211 core) */ | |
599 | struct bcm43xx_radioinfo *radio; | |
600 | /* Pointer to the DMA rings, which belong to this core (if 80211 core) */ | |
601 | struct bcm43xx_dma *dma; | |
602 | /* Pointer to the PIO queues, which belong to this core (if 80211 core) */ | |
603 | struct bcm43xx_pio *pio; | |
604 | }; | |
605 | ||
606 | /* Context information for a noise calculation (Link Quality). */ | |
607 | struct bcm43xx_noise_calculation { | |
608 | struct bcm43xx_coreinfo *core_at_start; | |
609 | u8 channel_at_start; | |
610 | u8 calculation_running:1; | |
611 | u8 nr_samples; | |
612 | s8 samples[8][4]; | |
613 | }; | |
614 | ||
615 | struct bcm43xx_stats { | |
616 | u8 link_quality; | |
617 | /* Store the last TX/RX times here for updating the leds. */ | |
618 | unsigned long last_tx; | |
619 | unsigned long last_rx; | |
620 | }; | |
621 | ||
622 | struct bcm43xx_key { | |
623 | u8 enabled:1; | |
624 | u8 algorithm; | |
625 | }; | |
626 | ||
627 | struct bcm43xx_private { | |
628 | struct ieee80211_device *ieee; | |
629 | struct ieee80211softmac_device *softmac; | |
630 | ||
631 | struct net_device *net_dev; | |
632 | struct pci_dev *pci_dev; | |
633 | unsigned int irq; | |
634 | ||
635 | void __iomem *mmio_addr; | |
636 | unsigned int mmio_len; | |
637 | ||
638 | spinlock_t lock; | |
639 | ||
640 | /* Driver status flags. */ | |
641 | u32 initialized:1, /* init_board() succeed */ | |
642 | was_initialized:1, /* for PCI suspend/resume. */ | |
643 | shutting_down:1, /* free_board() in progress */ | |
644 | pio_mode:1, /* PIO (if true), or DMA (if false) used. */ | |
645 | bad_frames_preempt:1, /* Use "Bad Frames Preemption" (default off) */ | |
646 | reg124_set_0x4:1, /* Some variable to keep track of IRQ stuff. */ | |
647 | powersaving:1, /* TRUE if we are in PowerSaving mode. FALSE otherwise. */ | |
648 | short_preamble:1, /* TRUE, if short preamble is enabled. */ | |
649 | firmware_norelease:1; /* Do not release the firmware. Used on suspend. */ | |
650 | ||
651 | struct bcm43xx_stats stats; | |
652 | ||
653 | /* Bus type we are connected to. | |
654 | * This is currently always BCM43xx_BUSTYPE_PCI | |
655 | */ | |
656 | u8 bustype; | |
657 | ||
658 | u16 board_vendor; | |
659 | u16 board_type; | |
660 | u16 board_revision; | |
661 | ||
662 | u16 chip_id; | |
663 | u8 chip_rev; | |
664 | ||
665 | struct bcm43xx_sprominfo sprom; | |
666 | #define BCM43xx_NR_LEDS 4 | |
667 | struct bcm43xx_led leds[BCM43xx_NR_LEDS]; | |
668 | ||
669 | /* The currently active core. NULL if not initialized, yet. */ | |
670 | struct bcm43xx_coreinfo *current_core; | |
671 | #ifdef CONFIG_BCM947XX | |
672 | /** current core memory offset */ | |
673 | u32 current_core_offset; | |
674 | #endif | |
675 | struct bcm43xx_coreinfo *active_80211_core; | |
676 | /* coreinfo structs for all possible cores follow. | |
677 | * Note that a core might not exist. | |
678 | * So check the coreinfo flags before using it. | |
679 | */ | |
680 | struct bcm43xx_coreinfo core_chipcommon; | |
681 | struct bcm43xx_coreinfo core_pci; | |
682 | struct bcm43xx_coreinfo core_v90; | |
683 | struct bcm43xx_coreinfo core_pcmcia; | |
684 | struct bcm43xx_coreinfo core_ethernet; | |
685 | struct bcm43xx_coreinfo core_80211[ BCM43xx_MAX_80211_CORES ]; | |
686 | /* Info about the PHY for each 80211 core. */ | |
687 | struct bcm43xx_phyinfo phy[ BCM43xx_MAX_80211_CORES ]; | |
688 | /* Info about the Radio for each 80211 core. */ | |
689 | struct bcm43xx_radioinfo radio[ BCM43xx_MAX_80211_CORES ]; | |
690 | /* DMA */ | |
691 | struct bcm43xx_dma dma[ BCM43xx_MAX_80211_CORES ]; | |
692 | /* PIO */ | |
693 | struct bcm43xx_pio pio[ BCM43xx_MAX_80211_CORES ]; | |
694 | ||
695 | u32 chipcommon_capabilities; | |
696 | ||
697 | /* Reason code of the last interrupt. */ | |
698 | u32 irq_reason; | |
699 | u32 dma_reason[4]; | |
700 | /* saved irq enable/disable state bitfield. */ | |
701 | u32 irq_savedstate; | |
702 | /* Link Quality calculation context. */ | |
703 | struct bcm43xx_noise_calculation noisecalc; | |
704 | ||
705 | /* Threshold values. */ | |
706 | //TODO: The RTS thr has to be _used_. Currently, it is only set via WX. | |
707 | u32 rts_threshold; | |
708 | ||
709 | /* Interrupt Service Routine tasklet (bottom-half) */ | |
710 | struct tasklet_struct isr_tasklet; | |
711 | /* Custom driver work queue. */ | |
712 | struct workqueue_struct *workqueue; | |
713 | ||
714 | /* Periodic tasks */ | |
715 | struct work_struct periodic_work0; | |
716 | #define BCM43xx_PERIODIC_0_DELAY (HZ * 15) | |
717 | struct work_struct periodic_work1; | |
718 | #define BCM43xx_PERIODIC_1_DELAY ((HZ * 60) + HZ / 2) | |
719 | struct work_struct periodic_work2; | |
720 | #define BCM43xx_PERIODIC_2_DELAY ((HZ * 120) + HZ) | |
721 | struct work_struct periodic_work3; | |
722 | #define BCM43xx_PERIODIC_3_DELAY ((HZ * 30) + HZ / 5) | |
723 | ||
724 | struct work_struct restart_work; | |
725 | ||
726 | /* Informational stuff. */ | |
727 | char nick[IW_ESSID_MAX_SIZE + 1]; | |
728 | ||
729 | /* encryption/decryption */ | |
730 | u16 security_offset; | |
731 | struct bcm43xx_key key[54]; | |
732 | u8 default_key_idx; | |
733 | ||
734 | /* Firmware. */ | |
735 | const struct firmware *ucode; | |
736 | const struct firmware *pcm; | |
737 | const struct firmware *initvals0; | |
738 | const struct firmware *initvals1; | |
739 | ||
740 | /* Debugging stuff follows. */ | |
741 | #ifdef CONFIG_BCM43XX_DEBUG | |
742 | struct bcm43xx_dfsentry *dfsentry; | |
743 | atomic_t mmio_print_cnt; | |
744 | atomic_t pcicfg_print_cnt; | |
745 | #endif | |
746 | }; | |
747 | ||
748 | static inline | |
749 | struct bcm43xx_private * bcm43xx_priv(struct net_device *dev) | |
750 | { | |
751 | return ieee80211softmac_priv(dev); | |
752 | } | |
753 | ||
754 | static inline | |
755 | int bcm43xx_num_80211_cores(struct bcm43xx_private *bcm) | |
756 | { | |
757 | int i, cnt = 0; | |
758 | ||
759 | for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { | |
760 | if (bcm->core_80211[i].flags & BCM43xx_COREFLAG_AVAILABLE) | |
761 | cnt++; | |
762 | } | |
763 | ||
764 | return cnt; | |
765 | } | |
766 | ||
767 | /* Are we running in init_board() context? */ | |
768 | static inline | |
769 | int bcm43xx_is_initializing(struct bcm43xx_private *bcm) | |
770 | { | |
771 | if (bcm->initialized) | |
772 | return 0; | |
773 | if (bcm->shutting_down) | |
774 | return 0; | |
775 | return 1; | |
776 | } | |
777 | ||
778 | static inline | |
779 | struct bcm43xx_lopair * bcm43xx_get_lopair(struct bcm43xx_phyinfo *phy, | |
780 | u16 radio_attenuation, | |
781 | u16 baseband_attenuation) | |
782 | { | |
783 | return phy->_lo_pairs + (radio_attenuation + 14 * (baseband_attenuation / 2)); | |
784 | } | |
785 | ||
786 | ||
787 | /* MMIO read/write functions. Debug and non-debug variants. */ | |
788 | #ifdef CONFIG_BCM43XX_DEBUG | |
789 | ||
790 | static inline | |
791 | u16 bcm43xx_read16(struct bcm43xx_private *bcm, u16 offset) | |
792 | { | |
793 | u16 value; | |
794 | ||
795 | value = ioread16(bcm->mmio_addr + core_offset(bcm) + offset); | |
796 | if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) { | |
797 | printk(KERN_INFO PFX "ioread16 offset: 0x%04x, value: 0x%04x\n", | |
798 | offset, value); | |
799 | } | |
800 | ||
801 | return value; | |
802 | } | |
803 | ||
804 | static inline | |
805 | void bcm43xx_write16(struct bcm43xx_private *bcm, u16 offset, u16 value) | |
806 | { | |
807 | iowrite16(value, bcm->mmio_addr + core_offset(bcm) + offset); | |
808 | if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) { | |
809 | printk(KERN_INFO PFX "iowrite16 offset: 0x%04x, value: 0x%04x\n", | |
810 | offset, value); | |
811 | } | |
812 | } | |
813 | ||
814 | static inline | |
815 | u32 bcm43xx_read32(struct bcm43xx_private *bcm, u16 offset) | |
816 | { | |
817 | u32 value; | |
818 | ||
819 | value = ioread32(bcm->mmio_addr + core_offset(bcm) + offset); | |
820 | if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) { | |
821 | printk(KERN_INFO PFX "ioread32 offset: 0x%04x, value: 0x%08x\n", | |
822 | offset, value); | |
823 | } | |
824 | ||
825 | return value; | |
826 | } | |
827 | ||
828 | static inline | |
829 | void bcm43xx_write32(struct bcm43xx_private *bcm, u16 offset, u32 value) | |
830 | { | |
831 | iowrite32(value, bcm->mmio_addr + core_offset(bcm) + offset); | |
832 | if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) { | |
833 | printk(KERN_INFO PFX "iowrite32 offset: 0x%04x, value: 0x%08x\n", | |
834 | offset, value); | |
835 | } | |
836 | } | |
837 | ||
838 | static inline | |
839 | int bcm43xx_pci_read_config16(struct bcm43xx_private *bcm, int offset, u16 *value) | |
840 | { | |
841 | int err; | |
842 | ||
843 | err = pci_read_config_word(bcm->pci_dev, offset, value); | |
844 | if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) { | |
845 | printk(KERN_INFO PFX "pciread16 offset: 0x%08x, value: 0x%04x, err: %d\n", | |
846 | offset, *value, err); | |
847 | } | |
848 | ||
849 | return err; | |
850 | } | |
851 | ||
852 | static inline | |
853 | int bcm43xx_pci_read_config32(struct bcm43xx_private *bcm, int offset, u32 *value) | |
854 | { | |
855 | int err; | |
856 | ||
857 | err = pci_read_config_dword(bcm->pci_dev, offset, value); | |
858 | if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) { | |
859 | printk(KERN_INFO PFX "pciread32 offset: 0x%08x, value: 0x%08x, err: %d\n", | |
860 | offset, *value, err); | |
861 | } | |
862 | ||
863 | return err; | |
864 | } | |
865 | ||
866 | static inline | |
867 | int bcm43xx_pci_write_config16(struct bcm43xx_private *bcm, int offset, u16 value) | |
868 | { | |
869 | int err; | |
870 | ||
871 | err = pci_write_config_word(bcm->pci_dev, offset, value); | |
872 | if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) { | |
873 | printk(KERN_INFO PFX "pciwrite16 offset: 0x%08x, value: 0x%04x, err: %d\n", | |
874 | offset, value, err); | |
875 | } | |
876 | ||
877 | return err; | |
878 | } | |
879 | ||
880 | static inline | |
881 | int bcm43xx_pci_write_config32(struct bcm43xx_private *bcm, int offset, u32 value) | |
882 | { | |
883 | int err; | |
884 | ||
885 | err = pci_write_config_dword(bcm->pci_dev, offset, value); | |
886 | if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) { | |
887 | printk(KERN_INFO PFX "pciwrite32 offset: 0x%08x, value: 0x%08x, err: %d\n", | |
888 | offset, value, err); | |
889 | } | |
890 | ||
891 | return err; | |
892 | } | |
893 | ||
894 | #define bcm43xx_mmioprint_initial(bcm, value) atomic_set(&(bcm)->mmio_print_cnt, (value)) | |
895 | #define bcm43xx_mmioprint_enable(bcm) atomic_inc(&(bcm)->mmio_print_cnt) | |
896 | #define bcm43xx_mmioprint_disable(bcm) atomic_dec(&(bcm)->mmio_print_cnt) | |
897 | #define bcm43xx_pciprint_initial(bcm, value) atomic_set(&(bcm)->pcicfg_print_cnt, (value)) | |
898 | #define bcm43xx_pciprint_enable(bcm) atomic_inc(&(bcm)->pcicfg_print_cnt) | |
899 | #define bcm43xx_pciprint_disable(bcm) atomic_dec(&(bcm)->pcicfg_print_cnt) | |
900 | ||
901 | #else /* CONFIG_BCM43XX_DEBUG*/ | |
902 | ||
903 | #define bcm43xx_read16(bcm, offset) ioread16((bcm)->mmio_addr + core_offset(bcm) + (offset)) | |
904 | #define bcm43xx_write16(bcm, offset, value) iowrite16((value), (bcm)->mmio_addr + core_offset(bcm) + (offset)) | |
905 | #define bcm43xx_read32(bcm, offset) ioread32((bcm)->mmio_addr + core_offset(bcm) + (offset)) | |
906 | #define bcm43xx_write32(bcm, offset, value) iowrite32((value), (bcm)->mmio_addr + core_offset(bcm) + (offset)) | |
907 | #define bcm43xx_pci_read_config16(bcm, o, v) pci_read_config_word((bcm)->pci_dev, (o), (v)) | |
908 | #define bcm43xx_pci_read_config32(bcm, o, v) pci_read_config_dword((bcm)->pci_dev, (o), (v)) | |
909 | #define bcm43xx_pci_write_config16(bcm, o, v) pci_write_config_word((bcm)->pci_dev, (o), (v)) | |
910 | #define bcm43xx_pci_write_config32(bcm, o, v) pci_write_config_dword((bcm)->pci_dev, (o), (v)) | |
911 | ||
912 | #define bcm43xx_mmioprint_initial(x, y) do { /* nothing */ } while (0) | |
913 | #define bcm43xx_mmioprint_enable(x) do { /* nothing */ } while (0) | |
914 | #define bcm43xx_mmioprint_disable(x) do { /* nothing */ } while (0) | |
915 | #define bcm43xx_pciprint_initial(bcm, value) do { /* nothing */ } while (0) | |
916 | #define bcm43xx_pciprint_enable(bcm) do { /* nothing */ } while (0) | |
917 | #define bcm43xx_pciprint_disable(bcm) do { /* nothing */ } while (0) | |
918 | ||
919 | #endif /* CONFIG_BCM43XX_DEBUG*/ | |
920 | ||
921 | ||
922 | /** Limit a value between two limits */ | |
923 | #ifdef limit_value | |
924 | # undef limit_value | |
925 | #endif | |
926 | #define limit_value(value, min, max) \ | |
927 | ({ \ | |
928 | typeof(value) __value = (value); \ | |
929 | typeof(value) __min = (min); \ | |
930 | typeof(value) __max = (max); \ | |
931 | if (__value < __min) \ | |
932 | __value = __min; \ | |
933 | else if (__value > __max) \ | |
934 | __value = __max; \ | |
935 | __value; \ | |
936 | }) | |
937 | ||
938 | ||
939 | /* | |
940 | * Compatibility stuff follows | |
941 | */ | |
942 | ||
943 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15) | |
944 | # error "The bcm43xx driver does not support kernels < 2.6.15" | |
945 | # error "The driver will _NOT_ compile on your kernel. Please upgrade to the latest 2.6 kernel." | |
946 | # error "DO NOT COMPLAIN ABOUT BUGS. UPDATE FIRST AND TRY AGAIN." | |
947 | #else | |
948 | # if !defined(CONFIG_IEEE80211_MODULE) && !defined(CONFIG_IEEE80211) | |
949 | # error "Generic IEEE 802.11 Networking Stack (CONFIG_IEEE80211) not available." | |
950 | # endif | |
951 | #endif | |
952 | #ifdef IEEE80211SOFTMAC_API | |
953 | # if IEEE80211SOFTMAC_API != 0 | |
954 | # warning "Incompatible SoftMAC subsystem installed." | |
955 | # endif | |
956 | #else | |
957 | # error "The bcm43xx driver requires the SoftMAC subsystem." | |
958 | # error "SEE >>>>>> http://softmac.sipsolutions.net/ <<<<<<" | |
959 | #endif | |
960 | ||
961 | #endif /* BCM43xx_H_ */ |