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