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