162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef B43legacy_H_ 362306a36Sopenharmony_ci#define B43legacy_H_ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/hw_random.h> 662306a36Sopenharmony_ci#include <linux/kernel.h> 762306a36Sopenharmony_ci#include <linux/spinlock.h> 862306a36Sopenharmony_ci#include <linux/interrupt.h> 962306a36Sopenharmony_ci#include <linux/stringify.h> 1062306a36Sopenharmony_ci#include <linux/netdevice.h> 1162306a36Sopenharmony_ci#include <linux/pci.h> 1262306a36Sopenharmony_ci#include <linux/atomic.h> 1362306a36Sopenharmony_ci#include <linux/io.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include <linux/ssb/ssb.h> 1662306a36Sopenharmony_ci#include <linux/ssb/ssb_driver_chipcommon.h> 1762306a36Sopenharmony_ci#include <linux/completion.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#include <net/mac80211.h> 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#include "debugfs.h" 2262306a36Sopenharmony_ci#include "leds.h" 2362306a36Sopenharmony_ci#include "rfkill.h" 2462306a36Sopenharmony_ci#include "phy.h" 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define B43legacy_IRQWAIT_MAX_RETRIES 20 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci/* MMIO offsets */ 3062306a36Sopenharmony_ci#define B43legacy_MMIO_DMA0_REASON 0x20 3162306a36Sopenharmony_ci#define B43legacy_MMIO_DMA0_IRQ_MASK 0x24 3262306a36Sopenharmony_ci#define B43legacy_MMIO_DMA1_REASON 0x28 3362306a36Sopenharmony_ci#define B43legacy_MMIO_DMA1_IRQ_MASK 0x2C 3462306a36Sopenharmony_ci#define B43legacy_MMIO_DMA2_REASON 0x30 3562306a36Sopenharmony_ci#define B43legacy_MMIO_DMA2_IRQ_MASK 0x34 3662306a36Sopenharmony_ci#define B43legacy_MMIO_DMA3_REASON 0x38 3762306a36Sopenharmony_ci#define B43legacy_MMIO_DMA3_IRQ_MASK 0x3C 3862306a36Sopenharmony_ci#define B43legacy_MMIO_DMA4_REASON 0x40 3962306a36Sopenharmony_ci#define B43legacy_MMIO_DMA4_IRQ_MASK 0x44 4062306a36Sopenharmony_ci#define B43legacy_MMIO_DMA5_REASON 0x48 4162306a36Sopenharmony_ci#define B43legacy_MMIO_DMA5_IRQ_MASK 0x4C 4262306a36Sopenharmony_ci#define B43legacy_MMIO_MACCTL 0x120 /* MAC control */ 4362306a36Sopenharmony_ci#define B43legacy_MMIO_MACCMD 0x124 /* MAC command */ 4462306a36Sopenharmony_ci#define B43legacy_MMIO_GEN_IRQ_REASON 0x128 4562306a36Sopenharmony_ci#define B43legacy_MMIO_GEN_IRQ_MASK 0x12C 4662306a36Sopenharmony_ci#define B43legacy_MMIO_RAM_CONTROL 0x130 4762306a36Sopenharmony_ci#define B43legacy_MMIO_RAM_DATA 0x134 4862306a36Sopenharmony_ci#define B43legacy_MMIO_PS_STATUS 0x140 4962306a36Sopenharmony_ci#define B43legacy_MMIO_RADIO_HWENABLED_HI 0x158 5062306a36Sopenharmony_ci#define B43legacy_MMIO_SHM_CONTROL 0x160 5162306a36Sopenharmony_ci#define B43legacy_MMIO_SHM_DATA 0x164 5262306a36Sopenharmony_ci#define B43legacy_MMIO_SHM_DATA_UNALIGNED 0x166 5362306a36Sopenharmony_ci#define B43legacy_MMIO_XMITSTAT_0 0x170 5462306a36Sopenharmony_ci#define B43legacy_MMIO_XMITSTAT_1 0x174 5562306a36Sopenharmony_ci#define B43legacy_MMIO_REV3PLUS_TSF_LOW 0x180 /* core rev >= 3 only */ 5662306a36Sopenharmony_ci#define B43legacy_MMIO_REV3PLUS_TSF_HIGH 0x184 /* core rev >= 3 only */ 5762306a36Sopenharmony_ci#define B43legacy_MMIO_TSF_CFP_REP 0x188 5862306a36Sopenharmony_ci#define B43legacy_MMIO_TSF_CFP_START 0x18C 5962306a36Sopenharmony_ci/* 32-bit DMA */ 6062306a36Sopenharmony_ci#define B43legacy_MMIO_DMA32_BASE0 0x200 6162306a36Sopenharmony_ci#define B43legacy_MMIO_DMA32_BASE1 0x220 6262306a36Sopenharmony_ci#define B43legacy_MMIO_DMA32_BASE2 0x240 6362306a36Sopenharmony_ci#define B43legacy_MMIO_DMA32_BASE3 0x260 6462306a36Sopenharmony_ci#define B43legacy_MMIO_DMA32_BASE4 0x280 6562306a36Sopenharmony_ci#define B43legacy_MMIO_DMA32_BASE5 0x2A0 6662306a36Sopenharmony_ci/* 64-bit DMA */ 6762306a36Sopenharmony_ci#define B43legacy_MMIO_DMA64_BASE0 0x200 6862306a36Sopenharmony_ci#define B43legacy_MMIO_DMA64_BASE1 0x240 6962306a36Sopenharmony_ci#define B43legacy_MMIO_DMA64_BASE2 0x280 7062306a36Sopenharmony_ci#define B43legacy_MMIO_DMA64_BASE3 0x2C0 7162306a36Sopenharmony_ci#define B43legacy_MMIO_DMA64_BASE4 0x300 7262306a36Sopenharmony_ci#define B43legacy_MMIO_DMA64_BASE5 0x340 7362306a36Sopenharmony_ci/* PIO */ 7462306a36Sopenharmony_ci#define B43legacy_MMIO_PIO1_BASE 0x300 7562306a36Sopenharmony_ci#define B43legacy_MMIO_PIO2_BASE 0x310 7662306a36Sopenharmony_ci#define B43legacy_MMIO_PIO3_BASE 0x320 7762306a36Sopenharmony_ci#define B43legacy_MMIO_PIO4_BASE 0x330 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci#define B43legacy_MMIO_PHY_VER 0x3E0 8062306a36Sopenharmony_ci#define B43legacy_MMIO_PHY_RADIO 0x3E2 8162306a36Sopenharmony_ci#define B43legacy_MMIO_PHY0 0x3E6 8262306a36Sopenharmony_ci#define B43legacy_MMIO_ANTENNA 0x3E8 8362306a36Sopenharmony_ci#define B43legacy_MMIO_CHANNEL 0x3F0 8462306a36Sopenharmony_ci#define B43legacy_MMIO_CHANNEL_EXT 0x3F4 8562306a36Sopenharmony_ci#define B43legacy_MMIO_RADIO_CONTROL 0x3F6 8662306a36Sopenharmony_ci#define B43legacy_MMIO_RADIO_DATA_HIGH 0x3F8 8762306a36Sopenharmony_ci#define B43legacy_MMIO_RADIO_DATA_LOW 0x3FA 8862306a36Sopenharmony_ci#define B43legacy_MMIO_PHY_CONTROL 0x3FC 8962306a36Sopenharmony_ci#define B43legacy_MMIO_PHY_DATA 0x3FE 9062306a36Sopenharmony_ci#define B43legacy_MMIO_MACFILTER_CONTROL 0x420 9162306a36Sopenharmony_ci#define B43legacy_MMIO_MACFILTER_DATA 0x422 9262306a36Sopenharmony_ci#define B43legacy_MMIO_RCMTA_COUNT 0x43C /* Receive Match Transmitter Addr */ 9362306a36Sopenharmony_ci#define B43legacy_MMIO_RADIO_HWENABLED_LO 0x49A 9462306a36Sopenharmony_ci#define B43legacy_MMIO_GPIO_CONTROL 0x49C 9562306a36Sopenharmony_ci#define B43legacy_MMIO_GPIO_MASK 0x49E 9662306a36Sopenharmony_ci#define B43legacy_MMIO_TSF_CFP_PRETBTT 0x612 9762306a36Sopenharmony_ci#define B43legacy_MMIO_TSF_0 0x632 /* core rev < 3 only */ 9862306a36Sopenharmony_ci#define B43legacy_MMIO_TSF_1 0x634 /* core rev < 3 only */ 9962306a36Sopenharmony_ci#define B43legacy_MMIO_TSF_2 0x636 /* core rev < 3 only */ 10062306a36Sopenharmony_ci#define B43legacy_MMIO_TSF_3 0x638 /* core rev < 3 only */ 10162306a36Sopenharmony_ci#define B43legacy_MMIO_RNG 0x65A 10262306a36Sopenharmony_ci#define B43legacy_MMIO_POWERUP_DELAY 0x6A8 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* SPROM boardflags_lo values */ 10562306a36Sopenharmony_ci#define B43legacy_BFL_PACTRL 0x0002 10662306a36Sopenharmony_ci#define B43legacy_BFL_RSSI 0x0008 10762306a36Sopenharmony_ci#define B43legacy_BFL_EXTLNA 0x1000 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci/* GPIO register offset, in both ChipCommon and PCI core. */ 11062306a36Sopenharmony_ci#define B43legacy_GPIO_CONTROL 0x6c 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci/* SHM Routing */ 11362306a36Sopenharmony_ci#define B43legacy_SHM_SHARED 0x0001 11462306a36Sopenharmony_ci#define B43legacy_SHM_WIRELESS 0x0002 11562306a36Sopenharmony_ci#define B43legacy_SHM_HW 0x0004 11662306a36Sopenharmony_ci#define B43legacy_SHM_UCODE 0x0300 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci/* SHM Routing modifiers */ 11962306a36Sopenharmony_ci#define B43legacy_SHM_AUTOINC_R 0x0200 /* Read Auto-increment */ 12062306a36Sopenharmony_ci#define B43legacy_SHM_AUTOINC_W 0x0100 /* Write Auto-increment */ 12162306a36Sopenharmony_ci#define B43legacy_SHM_AUTOINC_RW (B43legacy_SHM_AUTOINC_R | \ 12262306a36Sopenharmony_ci B43legacy_SHM_AUTOINC_W) 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci/* Misc SHM_SHARED offsets */ 12562306a36Sopenharmony_ci#define B43legacy_SHM_SH_WLCOREREV 0x0016 /* 802.11 core revision */ 12662306a36Sopenharmony_ci#define B43legacy_SHM_SH_HOSTFLO 0x005E /* Hostflags ucode opts (low) */ 12762306a36Sopenharmony_ci#define B43legacy_SHM_SH_HOSTFHI 0x0060 /* Hostflags ucode opts (high) */ 12862306a36Sopenharmony_ci/* SHM_SHARED crypto engine */ 12962306a36Sopenharmony_ci#define B43legacy_SHM_SH_KEYIDXBLOCK 0x05D4 /* Key index/algorithm block */ 13062306a36Sopenharmony_ci/* SHM_SHARED beacon/AP variables */ 13162306a36Sopenharmony_ci#define B43legacy_SHM_SH_DTIMP 0x0012 /* DTIM period */ 13262306a36Sopenharmony_ci#define B43legacy_SHM_SH_BTL0 0x0018 /* Beacon template length 0 */ 13362306a36Sopenharmony_ci#define B43legacy_SHM_SH_BTL1 0x001A /* Beacon template length 1 */ 13462306a36Sopenharmony_ci#define B43legacy_SHM_SH_BTSFOFF 0x001C /* Beacon TSF offset */ 13562306a36Sopenharmony_ci#define B43legacy_SHM_SH_TIMPOS 0x001E /* TIM position in beacon */ 13662306a36Sopenharmony_ci#define B43legacy_SHM_SH_BEACPHYCTL 0x0054 /* Beacon PHY TX control word */ 13762306a36Sopenharmony_ci/* SHM_SHARED ACK/CTS control */ 13862306a36Sopenharmony_ci#define B43legacy_SHM_SH_ACKCTSPHYCTL 0x0022 /* ACK/CTS PHY control word */ 13962306a36Sopenharmony_ci/* SHM_SHARED probe response variables */ 14062306a36Sopenharmony_ci#define B43legacy_SHM_SH_PRTLEN 0x004A /* Probe Response template length */ 14162306a36Sopenharmony_ci#define B43legacy_SHM_SH_PRMAXTIME 0x0074 /* Probe Response max time */ 14262306a36Sopenharmony_ci#define B43legacy_SHM_SH_PRPHYCTL 0x0188 /* Probe Resp PHY TX control */ 14362306a36Sopenharmony_ci/* SHM_SHARED rate tables */ 14462306a36Sopenharmony_ci#define B43legacy_SHM_SH_OFDMDIRECT 0x0480 /* Pointer to OFDM direct map */ 14562306a36Sopenharmony_ci#define B43legacy_SHM_SH_OFDMBASIC 0x04A0 /* Pointer to OFDM basic rate map */ 14662306a36Sopenharmony_ci#define B43legacy_SHM_SH_CCKDIRECT 0x04C0 /* Pointer to CCK direct map */ 14762306a36Sopenharmony_ci#define B43legacy_SHM_SH_CCKBASIC 0x04E0 /* Pointer to CCK basic rate map */ 14862306a36Sopenharmony_ci/* SHM_SHARED microcode soft registers */ 14962306a36Sopenharmony_ci#define B43legacy_SHM_SH_UCODEREV 0x0000 /* Microcode revision */ 15062306a36Sopenharmony_ci#define B43legacy_SHM_SH_UCODEPATCH 0x0002 /* Microcode patchlevel */ 15162306a36Sopenharmony_ci#define B43legacy_SHM_SH_UCODEDATE 0x0004 /* Microcode date */ 15262306a36Sopenharmony_ci#define B43legacy_SHM_SH_UCODETIME 0x0006 /* Microcode time */ 15362306a36Sopenharmony_ci#define B43legacy_SHM_SH_SPUWKUP 0x0094 /* pre-wakeup for synth PU in us */ 15462306a36Sopenharmony_ci#define B43legacy_SHM_SH_PRETBTT 0x0096 /* pre-TBTT in us */ 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci#define B43legacy_UCODEFLAGS_OFFSET 0x005E 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci/* Hardware Radio Enable masks */ 15962306a36Sopenharmony_ci#define B43legacy_MMIO_RADIO_HWENABLED_HI_MASK (1 << 16) 16062306a36Sopenharmony_ci#define B43legacy_MMIO_RADIO_HWENABLED_LO_MASK (1 << 4) 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci/* HostFlags. See b43legacy_hf_read/write() */ 16362306a36Sopenharmony_ci#define B43legacy_HF_SYMW 0x00000002 /* G-PHY SYM workaround */ 16462306a36Sopenharmony_ci#define B43legacy_HF_GDCW 0x00000020 /* G-PHY DV cancel filter */ 16562306a36Sopenharmony_ci#define B43legacy_HF_OFDMPABOOST 0x00000040 /* Enable PA boost OFDM */ 16662306a36Sopenharmony_ci#define B43legacy_HF_EDCF 0x00000100 /* on if WME/MAC suspended */ 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci/* MacFilter offsets. */ 16962306a36Sopenharmony_ci#define B43legacy_MACFILTER_SELF 0x0000 17062306a36Sopenharmony_ci#define B43legacy_MACFILTER_BSSID 0x0003 17162306a36Sopenharmony_ci#define B43legacy_MACFILTER_MAC 0x0010 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci/* PHYVersioning */ 17462306a36Sopenharmony_ci#define B43legacy_PHYTYPE_B 0x01 17562306a36Sopenharmony_ci#define B43legacy_PHYTYPE_G 0x02 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci/* PHYRegisters */ 17862306a36Sopenharmony_ci#define B43legacy_PHY_G_LO_CONTROL 0x0810 17962306a36Sopenharmony_ci#define B43legacy_PHY_ILT_G_CTRL 0x0472 18062306a36Sopenharmony_ci#define B43legacy_PHY_ILT_G_DATA1 0x0473 18162306a36Sopenharmony_ci#define B43legacy_PHY_ILT_G_DATA2 0x0474 18262306a36Sopenharmony_ci#define B43legacy_PHY_G_PCTL 0x0029 18362306a36Sopenharmony_ci#define B43legacy_PHY_RADIO_BITFIELD 0x0401 18462306a36Sopenharmony_ci#define B43legacy_PHY_G_CRS 0x0429 18562306a36Sopenharmony_ci#define B43legacy_PHY_NRSSILT_CTRL 0x0803 18662306a36Sopenharmony_ci#define B43legacy_PHY_NRSSILT_DATA 0x0804 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* RadioRegisters */ 18962306a36Sopenharmony_ci#define B43legacy_RADIOCTL_ID 0x01 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci/* MAC Control bitfield */ 19262306a36Sopenharmony_ci#define B43legacy_MACCTL_ENABLED 0x00000001 /* MAC Enabled */ 19362306a36Sopenharmony_ci#define B43legacy_MACCTL_PSM_RUN 0x00000002 /* Run Microcode */ 19462306a36Sopenharmony_ci#define B43legacy_MACCTL_PSM_JMP0 0x00000004 /* Microcode jump to 0 */ 19562306a36Sopenharmony_ci#define B43legacy_MACCTL_SHM_ENABLED 0x00000100 /* SHM Enabled */ 19662306a36Sopenharmony_ci#define B43legacy_MACCTL_IHR_ENABLED 0x00000400 /* IHR Region Enabled */ 19762306a36Sopenharmony_ci#define B43legacy_MACCTL_BE 0x00010000 /* Big Endian mode */ 19862306a36Sopenharmony_ci#define B43legacy_MACCTL_INFRA 0x00020000 /* Infrastructure mode */ 19962306a36Sopenharmony_ci#define B43legacy_MACCTL_AP 0x00040000 /* AccessPoint mode */ 20062306a36Sopenharmony_ci#define B43legacy_MACCTL_RADIOLOCK 0x00080000 /* Radio lock */ 20162306a36Sopenharmony_ci#define B43legacy_MACCTL_BEACPROMISC 0x00100000 /* Beacon Promiscuous */ 20262306a36Sopenharmony_ci#define B43legacy_MACCTL_KEEP_BADPLCP 0x00200000 /* Keep bad PLCP frames */ 20362306a36Sopenharmony_ci#define B43legacy_MACCTL_KEEP_CTL 0x00400000 /* Keep control frames */ 20462306a36Sopenharmony_ci#define B43legacy_MACCTL_KEEP_BAD 0x00800000 /* Keep bad frames (FCS) */ 20562306a36Sopenharmony_ci#define B43legacy_MACCTL_PROMISC 0x01000000 /* Promiscuous mode */ 20662306a36Sopenharmony_ci#define B43legacy_MACCTL_HWPS 0x02000000 /* Hardware Power Saving */ 20762306a36Sopenharmony_ci#define B43legacy_MACCTL_AWAKE 0x04000000 /* Device is awake */ 20862306a36Sopenharmony_ci#define B43legacy_MACCTL_TBTTHOLD 0x10000000 /* TBTT Hold */ 20962306a36Sopenharmony_ci#define B43legacy_MACCTL_GMODE 0x80000000 /* G Mode */ 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci/* MAC Command bitfield */ 21262306a36Sopenharmony_ci#define B43legacy_MACCMD_BEACON0_VALID 0x00000001 /* Beacon 0 in template RAM is busy/valid */ 21362306a36Sopenharmony_ci#define B43legacy_MACCMD_BEACON1_VALID 0x00000002 /* Beacon 1 in template RAM is busy/valid */ 21462306a36Sopenharmony_ci#define B43legacy_MACCMD_DFQ_VALID 0x00000004 /* Directed frame queue valid (IBSS PS mode, ATIM) */ 21562306a36Sopenharmony_ci#define B43legacy_MACCMD_CCA 0x00000008 /* Clear channel assessment */ 21662306a36Sopenharmony_ci#define B43legacy_MACCMD_BGNOISE 0x00000010 /* Background noise */ 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_ci/* 802.11 core specific TM State Low flags */ 21962306a36Sopenharmony_ci#define B43legacy_TMSLOW_GMODE 0x20000000 /* G Mode Enable */ 22062306a36Sopenharmony_ci#define B43legacy_TMSLOW_PLLREFSEL 0x00200000 /* PLL Freq Ref Select */ 22162306a36Sopenharmony_ci#define B43legacy_TMSLOW_MACPHYCLKEN 0x00100000 /* MAC PHY Clock Ctrl Enbl */ 22262306a36Sopenharmony_ci#define B43legacy_TMSLOW_PHYRESET 0x00080000 /* PHY Reset */ 22362306a36Sopenharmony_ci#define B43legacy_TMSLOW_PHYCLKEN 0x00040000 /* PHY Clock Enable */ 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci/* 802.11 core specific TM State High flags */ 22662306a36Sopenharmony_ci#define B43legacy_TMSHIGH_FCLOCK 0x00040000 /* Fast Clock Available */ 22762306a36Sopenharmony_ci#define B43legacy_TMSHIGH_GPHY 0x00010000 /* G-PHY avail (rev >= 5) */ 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci#define B43legacy_UCODEFLAG_AUTODIV 0x0001 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci/* Generic-Interrupt reasons. */ 23262306a36Sopenharmony_ci#define B43legacy_IRQ_MAC_SUSPENDED 0x00000001 23362306a36Sopenharmony_ci#define B43legacy_IRQ_BEACON 0x00000002 23462306a36Sopenharmony_ci#define B43legacy_IRQ_TBTT_INDI 0x00000004 /* Target Beacon Transmit Time */ 23562306a36Sopenharmony_ci#define B43legacy_IRQ_BEACON_TX_OK 0x00000008 23662306a36Sopenharmony_ci#define B43legacy_IRQ_BEACON_CANCEL 0x00000010 23762306a36Sopenharmony_ci#define B43legacy_IRQ_ATIM_END 0x00000020 23862306a36Sopenharmony_ci#define B43legacy_IRQ_PMQ 0x00000040 23962306a36Sopenharmony_ci#define B43legacy_IRQ_PIO_WORKAROUND 0x00000100 24062306a36Sopenharmony_ci#define B43legacy_IRQ_MAC_TXERR 0x00000200 24162306a36Sopenharmony_ci#define B43legacy_IRQ_PHY_TXERR 0x00000800 24262306a36Sopenharmony_ci#define B43legacy_IRQ_PMEVENT 0x00001000 24362306a36Sopenharmony_ci#define B43legacy_IRQ_TIMER0 0x00002000 24462306a36Sopenharmony_ci#define B43legacy_IRQ_TIMER1 0x00004000 24562306a36Sopenharmony_ci#define B43legacy_IRQ_DMA 0x00008000 24662306a36Sopenharmony_ci#define B43legacy_IRQ_TXFIFO_FLUSH_OK 0x00010000 24762306a36Sopenharmony_ci#define B43legacy_IRQ_CCA_MEASURE_OK 0x00020000 24862306a36Sopenharmony_ci#define B43legacy_IRQ_NOISESAMPLE_OK 0x00040000 24962306a36Sopenharmony_ci#define B43legacy_IRQ_UCODE_DEBUG 0x08000000 25062306a36Sopenharmony_ci#define B43legacy_IRQ_RFKILL 0x10000000 25162306a36Sopenharmony_ci#define B43legacy_IRQ_TX_OK 0x20000000 25262306a36Sopenharmony_ci#define B43legacy_IRQ_PHY_G_CHANGED 0x40000000 25362306a36Sopenharmony_ci#define B43legacy_IRQ_TIMEOUT 0x80000000 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci#define B43legacy_IRQ_ALL 0xFFFFFFFF 25662306a36Sopenharmony_ci#define B43legacy_IRQ_MASKTEMPLATE (B43legacy_IRQ_MAC_SUSPENDED | \ 25762306a36Sopenharmony_ci B43legacy_IRQ_TBTT_INDI | \ 25862306a36Sopenharmony_ci B43legacy_IRQ_ATIM_END | \ 25962306a36Sopenharmony_ci B43legacy_IRQ_PMQ | \ 26062306a36Sopenharmony_ci B43legacy_IRQ_MAC_TXERR | \ 26162306a36Sopenharmony_ci B43legacy_IRQ_PHY_TXERR | \ 26262306a36Sopenharmony_ci B43legacy_IRQ_DMA | \ 26362306a36Sopenharmony_ci B43legacy_IRQ_TXFIFO_FLUSH_OK | \ 26462306a36Sopenharmony_ci B43legacy_IRQ_NOISESAMPLE_OK | \ 26562306a36Sopenharmony_ci B43legacy_IRQ_UCODE_DEBUG | \ 26662306a36Sopenharmony_ci B43legacy_IRQ_RFKILL | \ 26762306a36Sopenharmony_ci B43legacy_IRQ_TX_OK) 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci/* Device specific rate values. 27062306a36Sopenharmony_ci * The actual values defined here are (rate_in_mbps * 2). 27162306a36Sopenharmony_ci * Some code depends on this. Don't change it. */ 27262306a36Sopenharmony_ci#define B43legacy_CCK_RATE_1MB 2 27362306a36Sopenharmony_ci#define B43legacy_CCK_RATE_2MB 4 27462306a36Sopenharmony_ci#define B43legacy_CCK_RATE_5MB 11 27562306a36Sopenharmony_ci#define B43legacy_CCK_RATE_11MB 22 27662306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_6MB 12 27762306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_9MB 18 27862306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_12MB 24 27962306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_18MB 36 28062306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_24MB 48 28162306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_36MB 72 28262306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_48MB 96 28362306a36Sopenharmony_ci#define B43legacy_OFDM_RATE_54MB 108 28462306a36Sopenharmony_ci/* Convert a b43legacy rate value to a rate in 100kbps */ 28562306a36Sopenharmony_ci#define B43legacy_RATE_TO_100KBPS(rate) (((rate) * 10) / 2) 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_ci#define B43legacy_DEFAULT_SHORT_RETRY_LIMIT 7 28962306a36Sopenharmony_ci#define B43legacy_DEFAULT_LONG_RETRY_LIMIT 4 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci#define B43legacy_PHY_TX_BADNESS_LIMIT 1000 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci/* Max size of a security key */ 29462306a36Sopenharmony_ci#define B43legacy_SEC_KEYSIZE 16 29562306a36Sopenharmony_ci/* Security algorithms. */ 29662306a36Sopenharmony_cienum { 29762306a36Sopenharmony_ci B43legacy_SEC_ALGO_NONE = 0, /* unencrypted, as of TX header. */ 29862306a36Sopenharmony_ci B43legacy_SEC_ALGO_WEP40, 29962306a36Sopenharmony_ci B43legacy_SEC_ALGO_TKIP, 30062306a36Sopenharmony_ci B43legacy_SEC_ALGO_AES, 30162306a36Sopenharmony_ci B43legacy_SEC_ALGO_WEP104, 30262306a36Sopenharmony_ci B43legacy_SEC_ALGO_AES_LEGACY, 30362306a36Sopenharmony_ci}; 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci/* Core Information Registers */ 30662306a36Sopenharmony_ci#define B43legacy_CIR_BASE 0xf00 30762306a36Sopenharmony_ci#define B43legacy_CIR_SBTPSFLAG (B43legacy_CIR_BASE + 0x18) 30862306a36Sopenharmony_ci#define B43legacy_CIR_SBIMSTATE (B43legacy_CIR_BASE + 0x90) 30962306a36Sopenharmony_ci#define B43legacy_CIR_SBINTVEC (B43legacy_CIR_BASE + 0x94) 31062306a36Sopenharmony_ci#define B43legacy_CIR_SBTMSTATELOW (B43legacy_CIR_BASE + 0x98) 31162306a36Sopenharmony_ci#define B43legacy_CIR_SBTMSTATEHIGH (B43legacy_CIR_BASE + 0x9c) 31262306a36Sopenharmony_ci#define B43legacy_CIR_SBIMCONFIGLOW (B43legacy_CIR_BASE + 0xa8) 31362306a36Sopenharmony_ci#define B43legacy_CIR_SB_ID_HI (B43legacy_CIR_BASE + 0xfc) 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci/* sbtmstatehigh state flags */ 31662306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_SERROR 0x00000001 31762306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_BUSY 0x00000004 31862306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_TIMEOUT 0x00000020 31962306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_G_PHY_AVAIL 0x00010000 32062306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_COREFLAGS 0x1FFF0000 32162306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_DMA64BIT 0x10000000 32262306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_GATEDCLK 0x20000000 32362306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_BISTFAILED 0x40000000 32462306a36Sopenharmony_ci#define B43legacy_SBTMSTATEHIGH_BISTCOMPLETE 0x80000000 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_ci/* sbimstate flags */ 32762306a36Sopenharmony_ci#define B43legacy_SBIMSTATE_IB_ERROR 0x20000 32862306a36Sopenharmony_ci#define B43legacy_SBIMSTATE_TIMEOUT 0x40000 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ci#define PFX KBUILD_MODNAME ": " 33162306a36Sopenharmony_ci#ifdef assert 33262306a36Sopenharmony_ci# undef assert 33362306a36Sopenharmony_ci#endif 33462306a36Sopenharmony_ci#ifdef CONFIG_B43LEGACY_DEBUG 33562306a36Sopenharmony_ci# define B43legacy_WARN_ON(x) WARN_ON(x) 33662306a36Sopenharmony_ci# define B43legacy_BUG_ON(expr) \ 33762306a36Sopenharmony_ci do { \ 33862306a36Sopenharmony_ci if (unlikely((expr))) { \ 33962306a36Sopenharmony_ci printk(KERN_INFO PFX "Test (%s) failed\n", \ 34062306a36Sopenharmony_ci #expr); \ 34162306a36Sopenharmony_ci BUG_ON(expr); \ 34262306a36Sopenharmony_ci } \ 34362306a36Sopenharmony_ci } while (0) 34462306a36Sopenharmony_ci# define B43legacy_DEBUG 1 34562306a36Sopenharmony_ci#else 34662306a36Sopenharmony_ci/* This will evaluate the argument even if debugging is disabled. */ 34762306a36Sopenharmony_cistatic inline bool __b43legacy_warn_on_dummy(bool x) { return x; } 34862306a36Sopenharmony_ci# define B43legacy_WARN_ON(x) __b43legacy_warn_on_dummy(unlikely(!!(x))) 34962306a36Sopenharmony_ci# define B43legacy_BUG_ON(x) do { /* nothing */ } while (0) 35062306a36Sopenharmony_ci# define B43legacy_DEBUG 0 35162306a36Sopenharmony_ci#endif 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_cistruct net_device; 35562306a36Sopenharmony_cistruct pci_dev; 35662306a36Sopenharmony_cistruct b43legacy_dmaring; 35762306a36Sopenharmony_cistruct b43legacy_pioqueue; 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci/* The firmware file header */ 36062306a36Sopenharmony_ci#define B43legacy_FW_TYPE_UCODE 'u' 36162306a36Sopenharmony_ci#define B43legacy_FW_TYPE_PCM 'p' 36262306a36Sopenharmony_ci#define B43legacy_FW_TYPE_IV 'i' 36362306a36Sopenharmony_cistruct b43legacy_fw_header { 36462306a36Sopenharmony_ci /* File type */ 36562306a36Sopenharmony_ci u8 type; 36662306a36Sopenharmony_ci /* File format version */ 36762306a36Sopenharmony_ci u8 ver; 36862306a36Sopenharmony_ci u8 __padding[2]; 36962306a36Sopenharmony_ci /* Size of the data. For ucode and PCM this is in bytes. 37062306a36Sopenharmony_ci * For IV this is number-of-ivs. */ 37162306a36Sopenharmony_ci __be32 size; 37262306a36Sopenharmony_ci} __packed; 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci/* Initial Value file format */ 37562306a36Sopenharmony_ci#define B43legacy_IV_OFFSET_MASK 0x7FFF 37662306a36Sopenharmony_ci#define B43legacy_IV_32BIT 0x8000 37762306a36Sopenharmony_cistruct b43legacy_iv { 37862306a36Sopenharmony_ci __be16 offset_size; 37962306a36Sopenharmony_ci union { 38062306a36Sopenharmony_ci __be16 d16; 38162306a36Sopenharmony_ci __be32 d32; 38262306a36Sopenharmony_ci } __packed data; 38362306a36Sopenharmony_ci} __packed; 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ci#define B43legacy_PHYMODE(phytype) (1 << (phytype)) 38662306a36Sopenharmony_ci#define B43legacy_PHYMODE_B B43legacy_PHYMODE \ 38762306a36Sopenharmony_ci ((B43legacy_PHYTYPE_B)) 38862306a36Sopenharmony_ci#define B43legacy_PHYMODE_G B43legacy_PHYMODE \ 38962306a36Sopenharmony_ci ((B43legacy_PHYTYPE_G)) 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_ci/* Value pair to measure the LocalOscillator. */ 39262306a36Sopenharmony_cistruct b43legacy_lopair { 39362306a36Sopenharmony_ci s8 low; 39462306a36Sopenharmony_ci s8 high; 39562306a36Sopenharmony_ci u8 used:1; 39662306a36Sopenharmony_ci}; 39762306a36Sopenharmony_ci#define B43legacy_LO_COUNT (14*4) 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_cistruct b43legacy_phy { 40062306a36Sopenharmony_ci /* Possible PHYMODEs on this PHY */ 40162306a36Sopenharmony_ci u8 possible_phymodes; 40262306a36Sopenharmony_ci /* GMODE bit enabled in MACCTL? */ 40362306a36Sopenharmony_ci bool gmode; 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci /* Analog Type */ 40662306a36Sopenharmony_ci u8 analog; 40762306a36Sopenharmony_ci /* B43legacy_PHYTYPE_ */ 40862306a36Sopenharmony_ci u8 type; 40962306a36Sopenharmony_ci /* PHY revision number. */ 41062306a36Sopenharmony_ci u8 rev; 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci u16 antenna_diversity; 41362306a36Sopenharmony_ci u16 savedpctlreg; 41462306a36Sopenharmony_ci /* Radio versioning */ 41562306a36Sopenharmony_ci u16 radio_manuf; /* Radio manufacturer */ 41662306a36Sopenharmony_ci u16 radio_ver; /* Radio version */ 41762306a36Sopenharmony_ci u8 calibrated:1; 41862306a36Sopenharmony_ci u8 radio_rev; /* Radio revision */ 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci bool dyn_tssi_tbl; /* tssi2dbm is kmalloc()ed. */ 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_ci /* ACI (adjacent channel interference) flags. */ 42362306a36Sopenharmony_ci bool aci_enable; 42462306a36Sopenharmony_ci bool aci_wlan_automatic; 42562306a36Sopenharmony_ci bool aci_hw_rssi; 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci /* Radio switched on/off */ 42862306a36Sopenharmony_ci bool radio_on; 42962306a36Sopenharmony_ci struct { 43062306a36Sopenharmony_ci /* Values saved when turning the radio off. 43162306a36Sopenharmony_ci * They are needed when turning it on again. */ 43262306a36Sopenharmony_ci bool valid; 43362306a36Sopenharmony_ci u16 rfover; 43462306a36Sopenharmony_ci u16 rfoverval; 43562306a36Sopenharmony_ci } radio_off_context; 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci u16 minlowsig[2]; 43862306a36Sopenharmony_ci u16 minlowsigpos[2]; 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci /* LO Measurement Data. 44162306a36Sopenharmony_ci * Use b43legacy_get_lopair() to get a value. 44262306a36Sopenharmony_ci */ 44362306a36Sopenharmony_ci struct b43legacy_lopair *_lo_pairs; 44462306a36Sopenharmony_ci /* TSSI to dBm table in use */ 44562306a36Sopenharmony_ci const s8 *tssi2dbm; 44662306a36Sopenharmony_ci /* idle TSSI value */ 44762306a36Sopenharmony_ci s8 idle_tssi; 44862306a36Sopenharmony_ci /* Target idle TSSI */ 44962306a36Sopenharmony_ci int tgt_idle_tssi; 45062306a36Sopenharmony_ci /* Current idle TSSI */ 45162306a36Sopenharmony_ci int cur_idle_tssi; 45262306a36Sopenharmony_ci 45362306a36Sopenharmony_ci /* LocalOscillator control values. */ 45462306a36Sopenharmony_ci struct b43legacy_txpower_lo_control *lo_control; 45562306a36Sopenharmony_ci /* Values from b43legacy_calc_loopback_gain() */ 45662306a36Sopenharmony_ci s16 max_lb_gain; /* Maximum Loopback gain in hdB */ 45762306a36Sopenharmony_ci s16 trsw_rx_gain; /* TRSW RX gain in hdB */ 45862306a36Sopenharmony_ci s16 lna_lod_gain; /* LNA lod */ 45962306a36Sopenharmony_ci s16 lna_gain; /* LNA */ 46062306a36Sopenharmony_ci s16 pga_gain; /* PGA */ 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci /* Desired TX power level (in dBm). This is set by the user and 46362306a36Sopenharmony_ci * adjusted in b43legacy_phy_xmitpower(). */ 46462306a36Sopenharmony_ci u8 power_level; 46562306a36Sopenharmony_ci 46662306a36Sopenharmony_ci /* Values from b43legacy_calc_loopback_gain() */ 46762306a36Sopenharmony_ci u16 loopback_gain[2]; 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_ci /* TX Power control values. */ 47062306a36Sopenharmony_ci /* B/G PHY */ 47162306a36Sopenharmony_ci struct { 47262306a36Sopenharmony_ci /* Current Radio Attenuation for TXpower recalculation. */ 47362306a36Sopenharmony_ci u16 rfatt; 47462306a36Sopenharmony_ci /* Current Baseband Attenuation for TXpower recalculation. */ 47562306a36Sopenharmony_ci u16 bbatt; 47662306a36Sopenharmony_ci /* Current TXpower control value for TXpower recalculation. */ 47762306a36Sopenharmony_ci u16 txctl1; 47862306a36Sopenharmony_ci u16 txctl2; 47962306a36Sopenharmony_ci }; 48062306a36Sopenharmony_ci /* A PHY */ 48162306a36Sopenharmony_ci struct { 48262306a36Sopenharmony_ci u16 txpwr_offset; 48362306a36Sopenharmony_ci }; 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci /* Current Interference Mitigation mode */ 48662306a36Sopenharmony_ci int interfmode; 48762306a36Sopenharmony_ci /* Stack of saved values from the Interference Mitigation code. 48862306a36Sopenharmony_ci * Each value in the stack is laid out as follows: 48962306a36Sopenharmony_ci * bit 0-11: offset 49062306a36Sopenharmony_ci * bit 12-15: register ID 49162306a36Sopenharmony_ci * bit 16-32: value 49262306a36Sopenharmony_ci * register ID is: 0x1 PHY, 0x2 Radio, 0x3 ILT 49362306a36Sopenharmony_ci */ 49462306a36Sopenharmony_ci#define B43legacy_INTERFSTACK_SIZE 26 49562306a36Sopenharmony_ci u32 interfstack[B43legacy_INTERFSTACK_SIZE]; 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci /* Saved values from the NRSSI Slope calculation */ 49862306a36Sopenharmony_ci s16 nrssi[2]; 49962306a36Sopenharmony_ci s32 nrssislope; 50062306a36Sopenharmony_ci /* In memory nrssi lookup table. */ 50162306a36Sopenharmony_ci s8 nrssi_lt[64]; 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci /* current channel */ 50462306a36Sopenharmony_ci u8 channel; 50562306a36Sopenharmony_ci 50662306a36Sopenharmony_ci u16 lofcal; 50762306a36Sopenharmony_ci 50862306a36Sopenharmony_ci u16 initval; 50962306a36Sopenharmony_ci 51062306a36Sopenharmony_ci /* PHY TX errors counter. */ 51162306a36Sopenharmony_ci atomic_t txerr_cnt; 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci#if B43legacy_DEBUG 51462306a36Sopenharmony_ci /* Manual TX-power control enabled? */ 51562306a36Sopenharmony_ci bool manual_txpower_control; 51662306a36Sopenharmony_ci /* PHY registers locked by b43legacy_phy_lock()? */ 51762306a36Sopenharmony_ci bool phy_locked; 51862306a36Sopenharmony_ci#endif /* B43legacy_DEBUG */ 51962306a36Sopenharmony_ci}; 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ci/* Data structures for DMA transmission, per 80211 core. */ 52262306a36Sopenharmony_cistruct b43legacy_dma { 52362306a36Sopenharmony_ci struct b43legacy_dmaring *tx_ring0; 52462306a36Sopenharmony_ci struct b43legacy_dmaring *tx_ring1; 52562306a36Sopenharmony_ci struct b43legacy_dmaring *tx_ring2; 52662306a36Sopenharmony_ci struct b43legacy_dmaring *tx_ring3; 52762306a36Sopenharmony_ci struct b43legacy_dmaring *tx_ring4; 52862306a36Sopenharmony_ci struct b43legacy_dmaring *tx_ring5; 52962306a36Sopenharmony_ci 53062306a36Sopenharmony_ci struct b43legacy_dmaring *rx_ring0; 53162306a36Sopenharmony_ci struct b43legacy_dmaring *rx_ring3; /* only on core.rev < 5 */ 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_ci u32 translation; /* Routing bits */ 53462306a36Sopenharmony_ci}; 53562306a36Sopenharmony_ci 53662306a36Sopenharmony_ci/* Data structures for PIO transmission, per 80211 core. */ 53762306a36Sopenharmony_cistruct b43legacy_pio { 53862306a36Sopenharmony_ci struct b43legacy_pioqueue *queue0; 53962306a36Sopenharmony_ci struct b43legacy_pioqueue *queue1; 54062306a36Sopenharmony_ci struct b43legacy_pioqueue *queue2; 54162306a36Sopenharmony_ci struct b43legacy_pioqueue *queue3; 54262306a36Sopenharmony_ci}; 54362306a36Sopenharmony_ci 54462306a36Sopenharmony_ci/* Context information for a noise calculation (Link Quality). */ 54562306a36Sopenharmony_cistruct b43legacy_noise_calculation { 54662306a36Sopenharmony_ci u8 channel_at_start; 54762306a36Sopenharmony_ci bool calculation_running; 54862306a36Sopenharmony_ci u8 nr_samples; 54962306a36Sopenharmony_ci s8 samples[8][4]; 55062306a36Sopenharmony_ci}; 55162306a36Sopenharmony_ci 55262306a36Sopenharmony_cistruct b43legacy_stats { 55362306a36Sopenharmony_ci u8 link_noise; 55462306a36Sopenharmony_ci /* Store the last TX/RX times here for updating the leds. */ 55562306a36Sopenharmony_ci unsigned long last_tx; 55662306a36Sopenharmony_ci unsigned long last_rx; 55762306a36Sopenharmony_ci}; 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_cistruct b43legacy_key { 56062306a36Sopenharmony_ci void *keyconf; 56162306a36Sopenharmony_ci bool enabled; 56262306a36Sopenharmony_ci u8 algorithm; 56362306a36Sopenharmony_ci}; 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_ci#define B43legacy_QOS_QUEUE_NUM 4 56662306a36Sopenharmony_ci 56762306a36Sopenharmony_cistruct b43legacy_wldev; 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_ci/* QOS parameters for a queue. */ 57062306a36Sopenharmony_cistruct b43legacy_qos_params { 57162306a36Sopenharmony_ci /* The QOS parameters */ 57262306a36Sopenharmony_ci struct ieee80211_tx_queue_params p; 57362306a36Sopenharmony_ci}; 57462306a36Sopenharmony_ci 57562306a36Sopenharmony_ci/* Data structure for the WLAN parts (802.11 cores) of the b43legacy chip. */ 57662306a36Sopenharmony_cistruct b43legacy_wl { 57762306a36Sopenharmony_ci /* Pointer to the active wireless device on this chip */ 57862306a36Sopenharmony_ci struct b43legacy_wldev *current_dev; 57962306a36Sopenharmony_ci /* Pointer to the ieee80211 hardware data structure */ 58062306a36Sopenharmony_ci struct ieee80211_hw *hw; 58162306a36Sopenharmony_ci 58262306a36Sopenharmony_ci spinlock_t irq_lock; /* locks IRQ */ 58362306a36Sopenharmony_ci struct mutex mutex; /* locks wireless core state */ 58462306a36Sopenharmony_ci spinlock_t leds_lock; /* lock for leds */ 58562306a36Sopenharmony_ci 58662306a36Sopenharmony_ci /* firmware loading work */ 58762306a36Sopenharmony_ci struct work_struct firmware_load; 58862306a36Sopenharmony_ci 58962306a36Sopenharmony_ci /* We can only have one operating interface (802.11 core) 59062306a36Sopenharmony_ci * at a time. General information about this interface follows. 59162306a36Sopenharmony_ci */ 59262306a36Sopenharmony_ci 59362306a36Sopenharmony_ci struct ieee80211_vif *vif; 59462306a36Sopenharmony_ci /* MAC address (can be NULL). */ 59562306a36Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 59662306a36Sopenharmony_ci /* Current BSSID (can be NULL). */ 59762306a36Sopenharmony_ci u8 bssid[ETH_ALEN]; 59862306a36Sopenharmony_ci /* Interface type. (IEEE80211_IF_TYPE_XXX) */ 59962306a36Sopenharmony_ci int if_type; 60062306a36Sopenharmony_ci /* Is the card operating in AP, STA or IBSS mode? */ 60162306a36Sopenharmony_ci bool operating; 60262306a36Sopenharmony_ci /* filter flags */ 60362306a36Sopenharmony_ci unsigned int filter_flags; 60462306a36Sopenharmony_ci /* Stats about the wireless interface */ 60562306a36Sopenharmony_ci struct ieee80211_low_level_stats ieee_stats; 60662306a36Sopenharmony_ci 60762306a36Sopenharmony_ci#ifdef CONFIG_B43LEGACY_HWRNG 60862306a36Sopenharmony_ci struct hwrng rng; 60962306a36Sopenharmony_ci u8 rng_initialized; 61062306a36Sopenharmony_ci char rng_name[30 + 1]; 61162306a36Sopenharmony_ci#endif 61262306a36Sopenharmony_ci 61362306a36Sopenharmony_ci /* List of all wireless devices on this chip */ 61462306a36Sopenharmony_ci struct list_head devlist; 61562306a36Sopenharmony_ci u8 nr_devs; 61662306a36Sopenharmony_ci 61762306a36Sopenharmony_ci bool radiotap_enabled; 61862306a36Sopenharmony_ci bool radio_enabled; 61962306a36Sopenharmony_ci 62062306a36Sopenharmony_ci /* The beacon we are currently using (AP or IBSS mode). 62162306a36Sopenharmony_ci * This beacon stuff is protected by the irq_lock. */ 62262306a36Sopenharmony_ci struct sk_buff *current_beacon; 62362306a36Sopenharmony_ci bool beacon0_uploaded; 62462306a36Sopenharmony_ci bool beacon1_uploaded; 62562306a36Sopenharmony_ci bool beacon_templates_virgin; /* Never wrote the templates? */ 62662306a36Sopenharmony_ci struct work_struct beacon_update_trigger; 62762306a36Sopenharmony_ci /* The current QOS parameters for the 4 queues. */ 62862306a36Sopenharmony_ci struct b43legacy_qos_params qos_params[B43legacy_QOS_QUEUE_NUM]; 62962306a36Sopenharmony_ci 63062306a36Sopenharmony_ci /* Packet transmit work */ 63162306a36Sopenharmony_ci struct work_struct tx_work; 63262306a36Sopenharmony_ci 63362306a36Sopenharmony_ci /* Queue of packets to be transmitted. */ 63462306a36Sopenharmony_ci struct sk_buff_head tx_queue[B43legacy_QOS_QUEUE_NUM]; 63562306a36Sopenharmony_ci 63662306a36Sopenharmony_ci /* Flag that implement the queues stopping. */ 63762306a36Sopenharmony_ci bool tx_queue_stopped[B43legacy_QOS_QUEUE_NUM]; 63862306a36Sopenharmony_ci 63962306a36Sopenharmony_ci}; 64062306a36Sopenharmony_ci 64162306a36Sopenharmony_ci/* Pointers to the firmware data and meta information about it. */ 64262306a36Sopenharmony_cistruct b43legacy_firmware { 64362306a36Sopenharmony_ci /* Microcode */ 64462306a36Sopenharmony_ci const struct firmware *ucode; 64562306a36Sopenharmony_ci /* PCM code */ 64662306a36Sopenharmony_ci const struct firmware *pcm; 64762306a36Sopenharmony_ci /* Initial MMIO values for the firmware */ 64862306a36Sopenharmony_ci const struct firmware *initvals; 64962306a36Sopenharmony_ci /* Initial MMIO values for the firmware, band-specific */ 65062306a36Sopenharmony_ci const struct firmware *initvals_band; 65162306a36Sopenharmony_ci /* Firmware revision */ 65262306a36Sopenharmony_ci u16 rev; 65362306a36Sopenharmony_ci /* Firmware patchlevel */ 65462306a36Sopenharmony_ci u16 patch; 65562306a36Sopenharmony_ci}; 65662306a36Sopenharmony_ci 65762306a36Sopenharmony_ci/* Device (802.11 core) initialization status. */ 65862306a36Sopenharmony_cienum { 65962306a36Sopenharmony_ci B43legacy_STAT_UNINIT = 0, /* Uninitialized. */ 66062306a36Sopenharmony_ci B43legacy_STAT_INITIALIZED = 1, /* Initialized, not yet started. */ 66162306a36Sopenharmony_ci B43legacy_STAT_STARTED = 2, /* Up and running. */ 66262306a36Sopenharmony_ci}; 66362306a36Sopenharmony_ci#define b43legacy_status(wldev) atomic_read(&(wldev)->__init_status) 66462306a36Sopenharmony_ci#define b43legacy_set_status(wldev, stat) do { \ 66562306a36Sopenharmony_ci atomic_set(&(wldev)->__init_status, (stat)); \ 66662306a36Sopenharmony_ci smp_wmb(); \ 66762306a36Sopenharmony_ci } while (0) 66862306a36Sopenharmony_ci 66962306a36Sopenharmony_ci/* *** --- HOW LOCKING WORKS IN B43legacy --- *** 67062306a36Sopenharmony_ci * 67162306a36Sopenharmony_ci * You should always acquire both, wl->mutex and wl->irq_lock unless: 67262306a36Sopenharmony_ci * - You don't need to acquire wl->irq_lock, if the interface is stopped. 67362306a36Sopenharmony_ci * - You don't need to acquire wl->mutex in the IRQ handler, IRQ tasklet 67462306a36Sopenharmony_ci * and packet TX path (and _ONLY_ there.) 67562306a36Sopenharmony_ci */ 67662306a36Sopenharmony_ci 67762306a36Sopenharmony_ci/* Data structure for one wireless device (802.11 core) */ 67862306a36Sopenharmony_cistruct b43legacy_wldev { 67962306a36Sopenharmony_ci struct ssb_device *dev; 68062306a36Sopenharmony_ci struct b43legacy_wl *wl; 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_ci /* The device initialization status. 68362306a36Sopenharmony_ci * Use b43legacy_status() to query. */ 68462306a36Sopenharmony_ci atomic_t __init_status; 68562306a36Sopenharmony_ci /* Saved init status for handling suspend. */ 68662306a36Sopenharmony_ci int suspend_init_status; 68762306a36Sopenharmony_ci 68862306a36Sopenharmony_ci bool __using_pio; /* Using pio rather than dma. */ 68962306a36Sopenharmony_ci bool bad_frames_preempt;/* Use "Bad Frames Preemption". */ 69062306a36Sopenharmony_ci bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM). */ 69162306a36Sopenharmony_ci bool short_preamble; /* TRUE if using short preamble. */ 69262306a36Sopenharmony_ci bool radio_hw_enable; /* State of radio hardware enable bit. */ 69362306a36Sopenharmony_ci 69462306a36Sopenharmony_ci /* PHY/Radio device. */ 69562306a36Sopenharmony_ci struct b43legacy_phy phy; 69662306a36Sopenharmony_ci union { 69762306a36Sopenharmony_ci /* DMA engines. */ 69862306a36Sopenharmony_ci struct b43legacy_dma dma; 69962306a36Sopenharmony_ci /* PIO engines. */ 70062306a36Sopenharmony_ci struct b43legacy_pio pio; 70162306a36Sopenharmony_ci }; 70262306a36Sopenharmony_ci 70362306a36Sopenharmony_ci /* Various statistics about the physical device. */ 70462306a36Sopenharmony_ci struct b43legacy_stats stats; 70562306a36Sopenharmony_ci 70662306a36Sopenharmony_ci /* The device LEDs. */ 70762306a36Sopenharmony_ci struct b43legacy_led led_tx; 70862306a36Sopenharmony_ci struct b43legacy_led led_rx; 70962306a36Sopenharmony_ci struct b43legacy_led led_assoc; 71062306a36Sopenharmony_ci struct b43legacy_led led_radio; 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_ci /* Reason code of the last interrupt. */ 71362306a36Sopenharmony_ci u32 irq_reason; 71462306a36Sopenharmony_ci u32 dma_reason[6]; 71562306a36Sopenharmony_ci /* The currently active generic-interrupt mask. */ 71662306a36Sopenharmony_ci u32 irq_mask; 71762306a36Sopenharmony_ci /* Link Quality calculation context. */ 71862306a36Sopenharmony_ci struct b43legacy_noise_calculation noisecalc; 71962306a36Sopenharmony_ci /* if > 0 MAC is suspended. if == 0 MAC is enabled. */ 72062306a36Sopenharmony_ci int mac_suspended; 72162306a36Sopenharmony_ci 72262306a36Sopenharmony_ci /* Interrupt Service Routine tasklet (bottom-half) */ 72362306a36Sopenharmony_ci struct tasklet_struct isr_tasklet; 72462306a36Sopenharmony_ci 72562306a36Sopenharmony_ci /* Periodic tasks */ 72662306a36Sopenharmony_ci struct delayed_work periodic_work; 72762306a36Sopenharmony_ci unsigned int periodic_state; 72862306a36Sopenharmony_ci 72962306a36Sopenharmony_ci struct work_struct restart_work; 73062306a36Sopenharmony_ci 73162306a36Sopenharmony_ci /* encryption/decryption */ 73262306a36Sopenharmony_ci u16 ktp; /* Key table pointer */ 73362306a36Sopenharmony_ci u8 max_nr_keys; 73462306a36Sopenharmony_ci struct b43legacy_key key[58]; 73562306a36Sopenharmony_ci 73662306a36Sopenharmony_ci /* Firmware data */ 73762306a36Sopenharmony_ci struct b43legacy_firmware fw; 73862306a36Sopenharmony_ci const struct firmware *fwp; /* needed to pass fw pointer */ 73962306a36Sopenharmony_ci 74062306a36Sopenharmony_ci /* completion struct for firmware loading */ 74162306a36Sopenharmony_ci struct completion fw_load_complete; 74262306a36Sopenharmony_ci 74362306a36Sopenharmony_ci /* Devicelist in struct b43legacy_wl (all 802.11 cores) */ 74462306a36Sopenharmony_ci struct list_head list; 74562306a36Sopenharmony_ci 74662306a36Sopenharmony_ci /* Debugging stuff follows. */ 74762306a36Sopenharmony_ci#ifdef CONFIG_B43LEGACY_DEBUG 74862306a36Sopenharmony_ci struct b43legacy_dfsentry *dfsentry; 74962306a36Sopenharmony_ci#endif 75062306a36Sopenharmony_ci}; 75162306a36Sopenharmony_ci 75262306a36Sopenharmony_ci 75362306a36Sopenharmony_cistatic inline 75462306a36Sopenharmony_cistruct b43legacy_wl *hw_to_b43legacy_wl(struct ieee80211_hw *hw) 75562306a36Sopenharmony_ci{ 75662306a36Sopenharmony_ci return hw->priv; 75762306a36Sopenharmony_ci} 75862306a36Sopenharmony_ci 75962306a36Sopenharmony_ci/* Helper function, which returns a boolean. 76062306a36Sopenharmony_ci * TRUE, if PIO is used; FALSE, if DMA is used. 76162306a36Sopenharmony_ci */ 76262306a36Sopenharmony_ci#if defined(CONFIG_B43LEGACY_DMA) && defined(CONFIG_B43LEGACY_PIO) 76362306a36Sopenharmony_cistatic inline 76462306a36Sopenharmony_ciint b43legacy_using_pio(struct b43legacy_wldev *dev) 76562306a36Sopenharmony_ci{ 76662306a36Sopenharmony_ci return dev->__using_pio; 76762306a36Sopenharmony_ci} 76862306a36Sopenharmony_ci#elif defined(CONFIG_B43LEGACY_DMA) 76962306a36Sopenharmony_cistatic inline 77062306a36Sopenharmony_ciint b43legacy_using_pio(struct b43legacy_wldev *dev) 77162306a36Sopenharmony_ci{ 77262306a36Sopenharmony_ci return 0; 77362306a36Sopenharmony_ci} 77462306a36Sopenharmony_ci#elif defined(CONFIG_B43LEGACY_PIO) 77562306a36Sopenharmony_cistatic inline 77662306a36Sopenharmony_ciint b43legacy_using_pio(struct b43legacy_wldev *dev) 77762306a36Sopenharmony_ci{ 77862306a36Sopenharmony_ci return 1; 77962306a36Sopenharmony_ci} 78062306a36Sopenharmony_ci#else 78162306a36Sopenharmony_ci# error "Using neither DMA nor PIO? Confused..." 78262306a36Sopenharmony_ci#endif 78362306a36Sopenharmony_ci 78462306a36Sopenharmony_ci 78562306a36Sopenharmony_cistatic inline 78662306a36Sopenharmony_cistruct b43legacy_wldev *dev_to_b43legacy_wldev(struct device *dev) 78762306a36Sopenharmony_ci{ 78862306a36Sopenharmony_ci struct ssb_device *ssb_dev = dev_to_ssb_dev(dev); 78962306a36Sopenharmony_ci return ssb_get_drvdata(ssb_dev); 79062306a36Sopenharmony_ci} 79162306a36Sopenharmony_ci 79262306a36Sopenharmony_ci/* Is the device operating in a specified mode (IEEE80211_IF_TYPE_XXX). */ 79362306a36Sopenharmony_cistatic inline 79462306a36Sopenharmony_ciint b43legacy_is_mode(struct b43legacy_wl *wl, int type) 79562306a36Sopenharmony_ci{ 79662306a36Sopenharmony_ci return (wl->operating && 79762306a36Sopenharmony_ci wl->if_type == type); 79862306a36Sopenharmony_ci} 79962306a36Sopenharmony_ci 80062306a36Sopenharmony_cistatic inline 80162306a36Sopenharmony_cibool is_bcm_board_vendor(struct b43legacy_wldev *dev) 80262306a36Sopenharmony_ci{ 80362306a36Sopenharmony_ci return (dev->dev->bus->boardinfo.vendor == PCI_VENDOR_ID_BROADCOM); 80462306a36Sopenharmony_ci} 80562306a36Sopenharmony_ci 80662306a36Sopenharmony_cistatic inline 80762306a36Sopenharmony_ciu16 b43legacy_read16(struct b43legacy_wldev *dev, u16 offset) 80862306a36Sopenharmony_ci{ 80962306a36Sopenharmony_ci return ssb_read16(dev->dev, offset); 81062306a36Sopenharmony_ci} 81162306a36Sopenharmony_ci 81262306a36Sopenharmony_cistatic inline 81362306a36Sopenharmony_civoid b43legacy_write16(struct b43legacy_wldev *dev, u16 offset, u16 value) 81462306a36Sopenharmony_ci{ 81562306a36Sopenharmony_ci ssb_write16(dev->dev, offset, value); 81662306a36Sopenharmony_ci} 81762306a36Sopenharmony_ci 81862306a36Sopenharmony_cistatic inline 81962306a36Sopenharmony_ciu32 b43legacy_read32(struct b43legacy_wldev *dev, u16 offset) 82062306a36Sopenharmony_ci{ 82162306a36Sopenharmony_ci return ssb_read32(dev->dev, offset); 82262306a36Sopenharmony_ci} 82362306a36Sopenharmony_ci 82462306a36Sopenharmony_cistatic inline 82562306a36Sopenharmony_civoid b43legacy_write32(struct b43legacy_wldev *dev, u16 offset, u32 value) 82662306a36Sopenharmony_ci{ 82762306a36Sopenharmony_ci ssb_write32(dev->dev, offset, value); 82862306a36Sopenharmony_ci} 82962306a36Sopenharmony_ci 83062306a36Sopenharmony_cistatic inline 83162306a36Sopenharmony_cistruct b43legacy_lopair *b43legacy_get_lopair(struct b43legacy_phy *phy, 83262306a36Sopenharmony_ci u16 radio_attenuation, 83362306a36Sopenharmony_ci u16 baseband_attenuation) 83462306a36Sopenharmony_ci{ 83562306a36Sopenharmony_ci return phy->_lo_pairs + (radio_attenuation 83662306a36Sopenharmony_ci + 14 * (baseband_attenuation / 2)); 83762306a36Sopenharmony_ci} 83862306a36Sopenharmony_ci 83962306a36Sopenharmony_ci 84062306a36Sopenharmony_ci 84162306a36Sopenharmony_ci/* Message printing */ 84262306a36Sopenharmony_ci__printf(2, 3) 84362306a36Sopenharmony_civoid b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...); 84462306a36Sopenharmony_ci__printf(2, 3) 84562306a36Sopenharmony_civoid b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...); 84662306a36Sopenharmony_ci__printf(2, 3) 84762306a36Sopenharmony_civoid b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...); 84862306a36Sopenharmony_ci#if B43legacy_DEBUG 84962306a36Sopenharmony_ci__printf(2, 3) 85062306a36Sopenharmony_civoid b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...); 85162306a36Sopenharmony_ci#else /* DEBUG */ 85262306a36Sopenharmony_ci# define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0) 85362306a36Sopenharmony_ci#endif /* DEBUG */ 85462306a36Sopenharmony_ci 85562306a36Sopenharmony_ci/* Macros for printing a value in Q5.2 format */ 85662306a36Sopenharmony_ci#define Q52_FMT "%u.%u" 85762306a36Sopenharmony_ci#define Q52_ARG(q52) ((q52) / 4), (((q52) & 3) * 100 / 4) 85862306a36Sopenharmony_ci 85962306a36Sopenharmony_ci#endif /* B43legacy_H_ */ 860