1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2d4a17304SKalle Valo #ifndef ADM8211_H 3d4a17304SKalle Valo #define ADM8211_H 4d4a17304SKalle Valo 5d4a17304SKalle Valo /* ADM8211 Registers */ 6d4a17304SKalle Valo 7d4a17304SKalle Valo /* CR32 (SIG) signature */ 8d4a17304SKalle Valo #define ADM8211_SIG1 0x82011317 /* ADM8211A */ 9d4a17304SKalle Valo #define ADM8211_SIG2 0x82111317 /* ADM8211B/ADM8211C */ 10d4a17304SKalle Valo 11d4a17304SKalle Valo #define ADM8211_CSR_READ(r) ioread32(&priv->map->r) 12d4a17304SKalle Valo #define ADM8211_CSR_WRITE(r, val) iowrite32((val), &priv->map->r) 13d4a17304SKalle Valo 14d4a17304SKalle Valo /* CSR (Host Control and Status Registers) */ 15d4a17304SKalle Valo struct adm8211_csr { 16d4a17304SKalle Valo __le32 PAR; /* 0x00 CSR0 */ 17d4a17304SKalle Valo __le32 FRCTL; /* 0x04 CSR0A */ 18d4a17304SKalle Valo __le32 TDR; /* 0x08 CSR1 */ 19d4a17304SKalle Valo __le32 WTDP; /* 0x0C CSR1A */ 20d4a17304SKalle Valo __le32 RDR; /* 0x10 CSR2 */ 21d4a17304SKalle Valo __le32 WRDP; /* 0x14 CSR2A */ 22d4a17304SKalle Valo __le32 RDB; /* 0x18 CSR3 */ 23d4a17304SKalle Valo __le32 TDBH; /* 0x1C CSR3A */ 24d4a17304SKalle Valo __le32 TDBD; /* 0x20 CSR4 */ 25d4a17304SKalle Valo __le32 TDBP; /* 0x24 CSR4A */ 26d4a17304SKalle Valo __le32 STSR; /* 0x28 CSR5 */ 27d4a17304SKalle Valo __le32 TDBB; /* 0x2C CSR5A */ 28d4a17304SKalle Valo __le32 NAR; /* 0x30 CSR6 */ 29d4a17304SKalle Valo __le32 CSR6A; /* reserved */ 30d4a17304SKalle Valo __le32 IER; /* 0x38 CSR7 */ 31d4a17304SKalle Valo __le32 TKIPSCEP; /* 0x3C CSR7A */ 32d4a17304SKalle Valo __le32 LPC; /* 0x40 CSR8 */ 33d4a17304SKalle Valo __le32 CSR_TEST1; /* 0x44 CSR8A */ 34d4a17304SKalle Valo __le32 SPR; /* 0x48 CSR9 */ 35d4a17304SKalle Valo __le32 CSR_TEST0; /* 0x4C CSR9A */ 36d4a17304SKalle Valo __le32 WCSR; /* 0x50 CSR10 */ 37d4a17304SKalle Valo __le32 WPDR; /* 0x54 CSR10A */ 38d4a17304SKalle Valo __le32 GPTMR; /* 0x58 CSR11 */ 39d4a17304SKalle Valo __le32 GPIO; /* 0x5C CSR11A */ 40d4a17304SKalle Valo __le32 BBPCTL; /* 0x60 CSR12 */ 41d4a17304SKalle Valo __le32 SYNCTL; /* 0x64 CSR12A */ 42d4a17304SKalle Valo __le32 PLCPHD; /* 0x68 CSR13 */ 43d4a17304SKalle Valo __le32 MMIWA; /* 0x6C CSR13A */ 44d4a17304SKalle Valo __le32 MMIRD0; /* 0x70 CSR14 */ 45d4a17304SKalle Valo __le32 MMIRD1; /* 0x74 CSR14A */ 46d4a17304SKalle Valo __le32 TXBR; /* 0x78 CSR15 */ 47d4a17304SKalle Valo __le32 SYNDATA; /* 0x7C CSR15A */ 48d4a17304SKalle Valo __le32 ALCS; /* 0x80 CSR16 */ 49d4a17304SKalle Valo __le32 TOFS2; /* 0x84 CSR17 */ 50d4a17304SKalle Valo __le32 CMDR; /* 0x88 CSR18 */ 51d4a17304SKalle Valo __le32 PCIC; /* 0x8C CSR19 */ 52d4a17304SKalle Valo __le32 PMCSR; /* 0x90 CSR20 */ 53d4a17304SKalle Valo __le32 PAR0; /* 0x94 CSR21 */ 54d4a17304SKalle Valo __le32 PAR1; /* 0x98 CSR22 */ 55d4a17304SKalle Valo __le32 MAR0; /* 0x9C CSR23 */ 56d4a17304SKalle Valo __le32 MAR1; /* 0xA0 CSR24 */ 57d4a17304SKalle Valo __le32 ATIMDA0; /* 0xA4 CSR25 */ 58d4a17304SKalle Valo __le32 ABDA1; /* 0xA8 CSR26 */ 59d4a17304SKalle Valo __le32 BSSID0; /* 0xAC CSR27 */ 60d4a17304SKalle Valo __le32 TXLMT; /* 0xB0 CSR28 */ 61d4a17304SKalle Valo __le32 MIBCNT; /* 0xB4 CSR29 */ 62d4a17304SKalle Valo __le32 BCNT; /* 0xB8 CSR30 */ 63d4a17304SKalle Valo __le32 TSFTH; /* 0xBC CSR31 */ 64d4a17304SKalle Valo __le32 TSC; /* 0xC0 CSR32 */ 65d4a17304SKalle Valo __le32 SYNRF; /* 0xC4 CSR33 */ 66d4a17304SKalle Valo __le32 BPLI; /* 0xC8 CSR34 */ 67d4a17304SKalle Valo __le32 CAP0; /* 0xCC CSR35 */ 68d4a17304SKalle Valo __le32 CAP1; /* 0xD0 CSR36 */ 69d4a17304SKalle Valo __le32 RMD; /* 0xD4 CSR37 */ 70d4a17304SKalle Valo __le32 CFPP; /* 0xD8 CSR38 */ 71d4a17304SKalle Valo __le32 TOFS0; /* 0xDC CSR39 */ 72d4a17304SKalle Valo __le32 TOFS1; /* 0xE0 CSR40 */ 73d4a17304SKalle Valo __le32 IFST; /* 0xE4 CSR41 */ 74d4a17304SKalle Valo __le32 RSPT; /* 0xE8 CSR42 */ 75d4a17304SKalle Valo __le32 TSFTL; /* 0xEC CSR43 */ 76d4a17304SKalle Valo __le32 WEPCTL; /* 0xF0 CSR44 */ 77d4a17304SKalle Valo __le32 WESK; /* 0xF4 CSR45 */ 78d4a17304SKalle Valo __le32 WEPCNT; /* 0xF8 CSR46 */ 79d4a17304SKalle Valo __le32 MACTEST; /* 0xFC CSR47 */ 80d4a17304SKalle Valo __le32 FER; /* 0x100 */ 81d4a17304SKalle Valo __le32 FEMR; /* 0x104 */ 82d4a17304SKalle Valo __le32 FPSR; /* 0x108 */ 83d4a17304SKalle Valo __le32 FFER; /* 0x10C */ 84d4a17304SKalle Valo } __packed; 85d4a17304SKalle Valo 86d4a17304SKalle Valo /* CSR0 - PAR (PCI Address Register) */ 87d4a17304SKalle Valo #define ADM8211_PAR_MWIE (1 << 24) 88d4a17304SKalle Valo #define ADM8211_PAR_MRLE (1 << 23) 89d4a17304SKalle Valo #define ADM8211_PAR_MRME (1 << 21) 90d4a17304SKalle Valo #define ADM8211_PAR_RAP ((1 << 18) | (1 << 17)) 91d4a17304SKalle Valo #define ADM8211_PAR_CAL ((1 << 15) | (1 << 14)) 92d4a17304SKalle Valo #define ADM8211_PAR_PBL 0x00003f00 93d4a17304SKalle Valo #define ADM8211_PAR_BLE (1 << 7) 94d4a17304SKalle Valo #define ADM8211_PAR_DSL 0x0000007c 95d4a17304SKalle Valo #define ADM8211_PAR_BAR (1 << 1) 96d4a17304SKalle Valo #define ADM8211_PAR_SWR (1 << 0) 97d4a17304SKalle Valo 98d4a17304SKalle Valo /* CSR1 - FRCTL (Frame Control Register) */ 99d4a17304SKalle Valo #define ADM8211_FRCTL_PWRMGT (1 << 31) 100d4a17304SKalle Valo #define ADM8211_FRCTL_MAXPSP (1 << 27) 101d4a17304SKalle Valo #define ADM8211_FRCTL_DRVPRSP (1 << 26) 102d4a17304SKalle Valo #define ADM8211_FRCTL_DRVBCON (1 << 25) 103d4a17304SKalle Valo #define ADM8211_FRCTL_AID 0x0000ffff 104d4a17304SKalle Valo #define ADM8211_FRCTL_AID_ON 0x0000c000 105d4a17304SKalle Valo 106d4a17304SKalle Valo /* CSR5 - STSR (Status Register) */ 107d4a17304SKalle Valo #define ADM8211_STSR_PCF (1 << 31) 108d4a17304SKalle Valo #define ADM8211_STSR_BCNTC (1 << 30) 109d4a17304SKalle Valo #define ADM8211_STSR_GPINT (1 << 29) 110d4a17304SKalle Valo #define ADM8211_STSR_LinkOff (1 << 28) 111d4a17304SKalle Valo #define ADM8211_STSR_ATIMTC (1 << 27) 112d4a17304SKalle Valo #define ADM8211_STSR_TSFTF (1 << 26) 113d4a17304SKalle Valo #define ADM8211_STSR_TSCZ (1 << 25) 114d4a17304SKalle Valo #define ADM8211_STSR_LinkOn (1 << 24) 115d4a17304SKalle Valo #define ADM8211_STSR_SQL (1 << 23) 116d4a17304SKalle Valo #define ADM8211_STSR_WEPTD (1 << 22) 117d4a17304SKalle Valo #define ADM8211_STSR_ATIME (1 << 21) 118d4a17304SKalle Valo #define ADM8211_STSR_TBTT (1 << 20) 119d4a17304SKalle Valo #define ADM8211_STSR_NISS (1 << 16) 120d4a17304SKalle Valo #define ADM8211_STSR_AISS (1 << 15) 121d4a17304SKalle Valo #define ADM8211_STSR_TEIS (1 << 14) 122d4a17304SKalle Valo #define ADM8211_STSR_FBE (1 << 13) 123d4a17304SKalle Valo #define ADM8211_STSR_REIS (1 << 12) 124d4a17304SKalle Valo #define ADM8211_STSR_GPTT (1 << 11) 125d4a17304SKalle Valo #define ADM8211_STSR_RPS (1 << 8) 126d4a17304SKalle Valo #define ADM8211_STSR_RDU (1 << 7) 127d4a17304SKalle Valo #define ADM8211_STSR_RCI (1 << 6) 128d4a17304SKalle Valo #define ADM8211_STSR_TUF (1 << 5) 129d4a17304SKalle Valo #define ADM8211_STSR_TRT (1 << 4) 130d4a17304SKalle Valo #define ADM8211_STSR_TLT (1 << 3) 131d4a17304SKalle Valo #define ADM8211_STSR_TDU (1 << 2) 132d4a17304SKalle Valo #define ADM8211_STSR_TPS (1 << 1) 133d4a17304SKalle Valo #define ADM8211_STSR_TCI (1 << 0) 134d4a17304SKalle Valo 135d4a17304SKalle Valo /* CSR6 - NAR (Network Access Register) */ 136d4a17304SKalle Valo #define ADM8211_NAR_TXCF (1 << 31) 137d4a17304SKalle Valo #define ADM8211_NAR_HF (1 << 30) 138d4a17304SKalle Valo #define ADM8211_NAR_UTR (1 << 29) 139d4a17304SKalle Valo #define ADM8211_NAR_SQ (1 << 28) 140d4a17304SKalle Valo #define ADM8211_NAR_CFP (1 << 27) 141d4a17304SKalle Valo #define ADM8211_NAR_SF (1 << 21) 142d4a17304SKalle Valo #define ADM8211_NAR_TR ((1 << 15) | (1 << 14)) 143d4a17304SKalle Valo #define ADM8211_NAR_ST (1 << 13) 144d4a17304SKalle Valo #define ADM8211_NAR_OM ((1 << 11) | (1 << 10)) 145d4a17304SKalle Valo #define ADM8211_NAR_MM (1 << 7) 146d4a17304SKalle Valo #define ADM8211_NAR_PR (1 << 6) 147d4a17304SKalle Valo #define ADM8211_NAR_EA (1 << 5) 148d4a17304SKalle Valo #define ADM8211_NAR_PB (1 << 3) 149d4a17304SKalle Valo #define ADM8211_NAR_STPDMA (1 << 2) 150d4a17304SKalle Valo #define ADM8211_NAR_SR (1 << 1) 151d4a17304SKalle Valo #define ADM8211_NAR_CTX (1 << 0) 152d4a17304SKalle Valo 153d4a17304SKalle Valo #define ADM8211_IDLE() \ 154d4a17304SKalle Valo do { \ 155d4a17304SKalle Valo if (priv->nar & (ADM8211_NAR_SR | ADM8211_NAR_ST)) { \ 156d4a17304SKalle Valo ADM8211_CSR_WRITE(NAR, priv->nar & \ 157d4a17304SKalle Valo ~(ADM8211_NAR_SR | ADM8211_NAR_ST));\ 158d4a17304SKalle Valo ADM8211_CSR_READ(NAR); \ 159d4a17304SKalle Valo msleep(20); \ 160d4a17304SKalle Valo } \ 161d4a17304SKalle Valo } while (0) 162d4a17304SKalle Valo 163d4a17304SKalle Valo #define ADM8211_IDLE_RX() \ 164d4a17304SKalle Valo do { \ 165d4a17304SKalle Valo if (priv->nar & ADM8211_NAR_SR) { \ 166d4a17304SKalle Valo ADM8211_CSR_WRITE(NAR, priv->nar & ~ADM8211_NAR_SR); \ 167d4a17304SKalle Valo ADM8211_CSR_READ(NAR); \ 168d4a17304SKalle Valo mdelay(20); \ 169d4a17304SKalle Valo } \ 170d4a17304SKalle Valo } while (0) 171d4a17304SKalle Valo 172d4a17304SKalle Valo #define ADM8211_RESTORE() \ 173d4a17304SKalle Valo do { \ 174d4a17304SKalle Valo if (priv->nar & (ADM8211_NAR_SR | ADM8211_NAR_ST)) \ 175d4a17304SKalle Valo ADM8211_CSR_WRITE(NAR, priv->nar); \ 176d4a17304SKalle Valo } while (0) 177d4a17304SKalle Valo 178d4a17304SKalle Valo /* CSR7 - IER (Interrupt Enable Register) */ 179d4a17304SKalle Valo #define ADM8211_IER_PCFIE (1 << 31) 180d4a17304SKalle Valo #define ADM8211_IER_BCNTCIE (1 << 30) 181d4a17304SKalle Valo #define ADM8211_IER_GPIE (1 << 29) 182d4a17304SKalle Valo #define ADM8211_IER_LinkOffIE (1 << 28) 183d4a17304SKalle Valo #define ADM8211_IER_ATIMTCIE (1 << 27) 184d4a17304SKalle Valo #define ADM8211_IER_TSFTFIE (1 << 26) 185d4a17304SKalle Valo #define ADM8211_IER_TSCZE (1 << 25) 186d4a17304SKalle Valo #define ADM8211_IER_LinkOnIE (1 << 24) 187d4a17304SKalle Valo #define ADM8211_IER_SQLIE (1 << 23) 188d4a17304SKalle Valo #define ADM8211_IER_WEPIE (1 << 22) 189d4a17304SKalle Valo #define ADM8211_IER_ATIMEIE (1 << 21) 190d4a17304SKalle Valo #define ADM8211_IER_TBTTIE (1 << 20) 191d4a17304SKalle Valo #define ADM8211_IER_NIE (1 << 16) 192d4a17304SKalle Valo #define ADM8211_IER_AIE (1 << 15) 193d4a17304SKalle Valo #define ADM8211_IER_TEIE (1 << 14) 194d4a17304SKalle Valo #define ADM8211_IER_FBEIE (1 << 13) 195d4a17304SKalle Valo #define ADM8211_IER_REIE (1 << 12) 196d4a17304SKalle Valo #define ADM8211_IER_GPTIE (1 << 11) 197d4a17304SKalle Valo #define ADM8211_IER_RSIE (1 << 8) 198d4a17304SKalle Valo #define ADM8211_IER_RUIE (1 << 7) 199d4a17304SKalle Valo #define ADM8211_IER_RCIE (1 << 6) 200d4a17304SKalle Valo #define ADM8211_IER_TUIE (1 << 5) 201d4a17304SKalle Valo #define ADM8211_IER_TRTIE (1 << 4) 202d4a17304SKalle Valo #define ADM8211_IER_TLTTIE (1 << 3) 203d4a17304SKalle Valo #define ADM8211_IER_TDUIE (1 << 2) 204d4a17304SKalle Valo #define ADM8211_IER_TPSIE (1 << 1) 205d4a17304SKalle Valo #define ADM8211_IER_TCIE (1 << 0) 206d4a17304SKalle Valo 207d4a17304SKalle Valo /* CSR9 - SPR (Serial Port Register) */ 208d4a17304SKalle Valo #define ADM8211_SPR_SRS (1 << 11) 209d4a17304SKalle Valo #define ADM8211_SPR_SDO (1 << 3) 210d4a17304SKalle Valo #define ADM8211_SPR_SDI (1 << 2) 211d4a17304SKalle Valo #define ADM8211_SPR_SCLK (1 << 1) 212d4a17304SKalle Valo #define ADM8211_SPR_SCS (1 << 0) 213d4a17304SKalle Valo 214d4a17304SKalle Valo /* CSR9A - CSR_TEST0 */ 215d4a17304SKalle Valo #define ADM8211_CSR_TEST0_EPNE (1 << 18) 216d4a17304SKalle Valo #define ADM8211_CSR_TEST0_EPSNM (1 << 17) 217d4a17304SKalle Valo #define ADM8211_CSR_TEST0_EPTYP (1 << 16) 218d4a17304SKalle Valo #define ADM8211_CSR_TEST0_EPRLD (1 << 15) 219d4a17304SKalle Valo 220d4a17304SKalle Valo /* CSR10 - WCSR (Wake-up Control/Status Register) */ 221d4a17304SKalle Valo #define ADM8211_WCSR_CRCT (1 << 30) 222d4a17304SKalle Valo #define ADM8211_WCSR_TSFTWE (1 << 20) 223d4a17304SKalle Valo #define ADM8211_WCSR_TIMWE (1 << 19) 224d4a17304SKalle Valo #define ADM8211_WCSR_ATIMWE (1 << 18) 225d4a17304SKalle Valo #define ADM8211_WCSR_KEYWE (1 << 17) 226d4a17304SKalle Valo #define ADM8211_WCSR_MPRE (1 << 9) 227d4a17304SKalle Valo #define ADM8211_WCSR_LSOE (1 << 8) 228d4a17304SKalle Valo #define ADM8211_WCSR_KEYUP (1 << 6) 229d4a17304SKalle Valo #define ADM8211_WCSR_TSFTW (1 << 5) 230d4a17304SKalle Valo #define ADM8211_WCSR_TIMW (1 << 4) 231d4a17304SKalle Valo #define ADM8211_WCSR_ATIMW (1 << 3) 232d4a17304SKalle Valo #define ADM8211_WCSR_MPR (1 << 1) 233d4a17304SKalle Valo #define ADM8211_WCSR_LSO (1 << 0) 234d4a17304SKalle Valo 235d4a17304SKalle Valo /* CSR11A - GPIO */ 236d4a17304SKalle Valo #define ADM8211_CSR_GPIO_EN5 (1 << 17) 237d4a17304SKalle Valo #define ADM8211_CSR_GPIO_EN4 (1 << 16) 238d4a17304SKalle Valo #define ADM8211_CSR_GPIO_EN3 (1 << 15) 239d4a17304SKalle Valo #define ADM8211_CSR_GPIO_EN2 (1 << 14) 240d4a17304SKalle Valo #define ADM8211_CSR_GPIO_EN1 (1 << 13) 241d4a17304SKalle Valo #define ADM8211_CSR_GPIO_EN0 (1 << 12) 242d4a17304SKalle Valo #define ADM8211_CSR_GPIO_O5 (1 << 11) 243d4a17304SKalle Valo #define ADM8211_CSR_GPIO_O4 (1 << 10) 244d4a17304SKalle Valo #define ADM8211_CSR_GPIO_O3 (1 << 9) 245d4a17304SKalle Valo #define ADM8211_CSR_GPIO_O2 (1 << 8) 246d4a17304SKalle Valo #define ADM8211_CSR_GPIO_O1 (1 << 7) 247d4a17304SKalle Valo #define ADM8211_CSR_GPIO_O0 (1 << 6) 248d4a17304SKalle Valo #define ADM8211_CSR_GPIO_IN 0x0000003f 249d4a17304SKalle Valo 250d4a17304SKalle Valo /* CSR12 - BBPCTL (BBP Control port) */ 251d4a17304SKalle Valo #define ADM8211_BBPCTL_MMISEL (1 << 31) 252d4a17304SKalle Valo #define ADM8211_BBPCTL_SPICADD (0x7F << 24) 253d4a17304SKalle Valo #define ADM8211_BBPCTL_RF3000 (0x20 << 24) 254d4a17304SKalle Valo #define ADM8211_BBPCTL_TXCE (1 << 23) 255d4a17304SKalle Valo #define ADM8211_BBPCTL_RXCE (1 << 22) 256d4a17304SKalle Valo #define ADM8211_BBPCTL_CCAP (1 << 21) 257d4a17304SKalle Valo #define ADM8211_BBPCTL_TYPE 0x001c0000 258d4a17304SKalle Valo #define ADM8211_BBPCTL_WR (1 << 17) 259d4a17304SKalle Valo #define ADM8211_BBPCTL_RD (1 << 16) 260d4a17304SKalle Valo #define ADM8211_BBPCTL_ADDR 0x0000ff00 261d4a17304SKalle Valo #define ADM8211_BBPCTL_DATA 0x000000ff 262d4a17304SKalle Valo 263d4a17304SKalle Valo /* CSR12A - SYNCTL (Synthesizer Control port) */ 264d4a17304SKalle Valo #define ADM8211_SYNCTL_WR (1 << 31) 265d4a17304SKalle Valo #define ADM8211_SYNCTL_RD (1 << 30) 266d4a17304SKalle Valo #define ADM8211_SYNCTL_CS0 (1 << 29) 267d4a17304SKalle Valo #define ADM8211_SYNCTL_CS1 (1 << 28) 268d4a17304SKalle Valo #define ADM8211_SYNCTL_CAL (1 << 27) 269d4a17304SKalle Valo #define ADM8211_SYNCTL_SELCAL (1 << 26) 270d4a17304SKalle Valo #define ADM8211_SYNCTL_RFtype ((1 << 24) | (1 << 23) | (1 << 22)) 271d4a17304SKalle Valo #define ADM8211_SYNCTL_RFMD (1 << 22) 272d4a17304SKalle Valo #define ADM8211_SYNCTL_GENERAL (0x7 << 22) 273d4a17304SKalle Valo /* SYNCTL 21:0 Data (Si4126: 18-bit data, 4-bit address) */ 274d4a17304SKalle Valo 275d4a17304SKalle Valo /* CSR18 - CMDR (Command Register) */ 276d4a17304SKalle Valo #define ADM8211_CMDR_PM (1 << 19) 277d4a17304SKalle Valo #define ADM8211_CMDR_APM (1 << 18) 278d4a17304SKalle Valo #define ADM8211_CMDR_RTE (1 << 4) 279d4a17304SKalle Valo #define ADM8211_CMDR_DRT ((1 << 3) | (1 << 2)) 280d4a17304SKalle Valo #define ADM8211_CMDR_DRT_8DW (0x0 << 2) 281d4a17304SKalle Valo #define ADM8211_CMDR_DRT_16DW (0x1 << 2) 282d4a17304SKalle Valo #define ADM8211_CMDR_DRT_SF (0x2 << 2) 283d4a17304SKalle Valo 284d4a17304SKalle Valo /* CSR33 - SYNRF (SYNRF direct control) */ 285d4a17304SKalle Valo #define ADM8211_SYNRF_SELSYN (1 << 31) 286d4a17304SKalle Valo #define ADM8211_SYNRF_SELRF (1 << 30) 287d4a17304SKalle Valo #define ADM8211_SYNRF_LERF (1 << 29) 288d4a17304SKalle Valo #define ADM8211_SYNRF_LEIF (1 << 28) 289d4a17304SKalle Valo #define ADM8211_SYNRF_SYNCLK (1 << 27) 290d4a17304SKalle Valo #define ADM8211_SYNRF_SYNDATA (1 << 26) 291d4a17304SKalle Valo #define ADM8211_SYNRF_PE1 (1 << 25) 292d4a17304SKalle Valo #define ADM8211_SYNRF_PE2 (1 << 24) 293d4a17304SKalle Valo #define ADM8211_SYNRF_PA_PE (1 << 23) 294d4a17304SKalle Valo #define ADM8211_SYNRF_TR_SW (1 << 22) 295d4a17304SKalle Valo #define ADM8211_SYNRF_TR_SWN (1 << 21) 296d4a17304SKalle Valo #define ADM8211_SYNRF_RADIO (1 << 20) 297d4a17304SKalle Valo #define ADM8211_SYNRF_CAL_EN (1 << 19) 298d4a17304SKalle Valo #define ADM8211_SYNRF_PHYRST (1 << 18) 299d4a17304SKalle Valo 300d4a17304SKalle Valo #define ADM8211_SYNRF_IF_SELECT_0 (1 << 31) 301d4a17304SKalle Valo #define ADM8211_SYNRF_IF_SELECT_1 ((1 << 31) | (1 << 28)) 302d4a17304SKalle Valo #define ADM8211_SYNRF_WRITE_SYNDATA_0 (1 << 31) 303d4a17304SKalle Valo #define ADM8211_SYNRF_WRITE_SYNDATA_1 ((1 << 31) | (1 << 26)) 304d4a17304SKalle Valo #define ADM8211_SYNRF_WRITE_CLOCK_0 (1 << 31) 305d4a17304SKalle Valo #define ADM8211_SYNRF_WRITE_CLOCK_1 ((1 << 31) | (1 << 27)) 306d4a17304SKalle Valo 307d4a17304SKalle Valo /* CSR44 - WEPCTL (WEP Control) */ 308d4a17304SKalle Valo #define ADM8211_WEPCTL_WEPENABLE (1 << 31) 309d4a17304SKalle Valo #define ADM8211_WEPCTL_WPAENABLE (1 << 30) 310d4a17304SKalle Valo #define ADM8211_WEPCTL_CURRENT_TABLE (1 << 29) 311d4a17304SKalle Valo #define ADM8211_WEPCTL_TABLE_WR (1 << 28) 312d4a17304SKalle Valo #define ADM8211_WEPCTL_TABLE_RD (1 << 27) 313d4a17304SKalle Valo #define ADM8211_WEPCTL_WEPRXBYP (1 << 25) 314d4a17304SKalle Valo #define ADM8211_WEPCTL_SEL_WEPTABLE (1 << 23) 315d4a17304SKalle Valo #define ADM8211_WEPCTL_ADDR (0x000001ff) 316d4a17304SKalle Valo 317d4a17304SKalle Valo /* CSR45 - WESK (Data Entry for Share/Individual Key) */ 318d4a17304SKalle Valo #define ADM8211_WESK_DATA (0x0000ffff) 319d4a17304SKalle Valo 320d4a17304SKalle Valo /* FER (Function Event Register) */ 321d4a17304SKalle Valo #define ADM8211_FER_INTR_EV_ENT (1 << 15) 322d4a17304SKalle Valo 323d4a17304SKalle Valo 324d4a17304SKalle Valo /* Si4126 RF Synthesizer - Control Registers */ 325d4a17304SKalle Valo #define SI4126_MAIN_CONF 0 326d4a17304SKalle Valo #define SI4126_PHASE_DET_GAIN 1 327d4a17304SKalle Valo #define SI4126_POWERDOWN 2 328d4a17304SKalle Valo #define SI4126_RF1_N_DIV 3 /* only Si4136 */ 329d4a17304SKalle Valo #define SI4126_RF2_N_DIV 4 330d4a17304SKalle Valo #define SI4126_IF_N_DIV 5 331d4a17304SKalle Valo #define SI4126_RF1_R_DIV 6 /* only Si4136 */ 332d4a17304SKalle Valo #define SI4126_RF2_R_DIV 7 333d4a17304SKalle Valo #define SI4126_IF_R_DIV 8 334d4a17304SKalle Valo 335d4a17304SKalle Valo /* Main Configuration */ 336d4a17304SKalle Valo #define SI4126_MAIN_XINDIV2 (1 << 6) 337d4a17304SKalle Valo #define SI4126_MAIN_IFDIV ((1 << 11) | (1 << 10)) 338d4a17304SKalle Valo /* Powerdown */ 339d4a17304SKalle Valo #define SI4126_POWERDOWN_PDIB (1 << 1) 340d4a17304SKalle Valo #define SI4126_POWERDOWN_PDRB (1 << 0) 341d4a17304SKalle Valo 342d4a17304SKalle Valo 343d4a17304SKalle Valo /* RF3000 BBP - Control Port Registers */ 344d4a17304SKalle Valo /* 0x00 - reserved */ 345d4a17304SKalle Valo #define RF3000_MODEM_CTRL__RX_STATUS 0x01 346d4a17304SKalle Valo #define RF3000_CCA_CTRL 0x02 347d4a17304SKalle Valo #define RF3000_DIVERSITY__RSSI 0x03 348d4a17304SKalle Valo #define RF3000_RX_SIGNAL_FIELD 0x04 349d4a17304SKalle Valo #define RF3000_RX_LEN_MSB 0x05 350d4a17304SKalle Valo #define RF3000_RX_LEN_LSB 0x06 351d4a17304SKalle Valo #define RF3000_RX_SERVICE_FIELD 0x07 352d4a17304SKalle Valo #define RF3000_TX_VAR_GAIN__TX_LEN_EXT 0x11 353d4a17304SKalle Valo #define RF3000_TX_LEN_MSB 0x12 354d4a17304SKalle Valo #define RF3000_TX_LEN_LSB 0x13 355d4a17304SKalle Valo #define RF3000_LOW_GAIN_CALIB 0x14 356d4a17304SKalle Valo #define RF3000_HIGH_GAIN_CALIB 0x15 357d4a17304SKalle Valo 358d4a17304SKalle Valo /* ADM8211 revisions */ 359d4a17304SKalle Valo #define ADM8211_REV_AB 0x11 360d4a17304SKalle Valo #define ADM8211_REV_AF 0x15 361d4a17304SKalle Valo #define ADM8211_REV_BA 0x20 362d4a17304SKalle Valo #define ADM8211_REV_CA 0x30 363d4a17304SKalle Valo 364d4a17304SKalle Valo struct adm8211_desc { 365d4a17304SKalle Valo __le32 status; 366d4a17304SKalle Valo __le32 length; 367d4a17304SKalle Valo __le32 buffer1; 368d4a17304SKalle Valo __le32 buffer2; 369d4a17304SKalle Valo }; 370d4a17304SKalle Valo 371d4a17304SKalle Valo #define RDES0_STATUS_OWN (1 << 31) 372d4a17304SKalle Valo #define RDES0_STATUS_ES (1 << 30) 373d4a17304SKalle Valo #define RDES0_STATUS_SQL (1 << 29) 374d4a17304SKalle Valo #define RDES0_STATUS_DE (1 << 28) 375d4a17304SKalle Valo #define RDES0_STATUS_FS (1 << 27) 376d4a17304SKalle Valo #define RDES0_STATUS_LS (1 << 26) 377d4a17304SKalle Valo #define RDES0_STATUS_PCF (1 << 25) 378d4a17304SKalle Valo #define RDES0_STATUS_SFDE (1 << 24) 379d4a17304SKalle Valo #define RDES0_STATUS_SIGE (1 << 23) 380d4a17304SKalle Valo #define RDES0_STATUS_CRC16E (1 << 22) 381d4a17304SKalle Valo #define RDES0_STATUS_RXTOE (1 << 21) 382d4a17304SKalle Valo #define RDES0_STATUS_CRC32E (1 << 20) 383d4a17304SKalle Valo #define RDES0_STATUS_ICVE (1 << 19) 384d4a17304SKalle Valo #define RDES0_STATUS_DA1 (1 << 17) 385d4a17304SKalle Valo #define RDES0_STATUS_DA0 (1 << 16) 386d4a17304SKalle Valo #define RDES0_STATUS_RXDR ((1 << 15) | (1 << 14) | (1 << 13) | (1 << 12)) 387d4a17304SKalle Valo #define RDES0_STATUS_FL (0x00000fff) 388d4a17304SKalle Valo 389d4a17304SKalle Valo #define RDES1_CONTROL_RER (1 << 25) 390d4a17304SKalle Valo #define RDES1_CONTROL_RCH (1 << 24) 391d4a17304SKalle Valo #define RDES1_CONTROL_RBS2 (0x00fff000) 392d4a17304SKalle Valo #define RDES1_CONTROL_RBS1 (0x00000fff) 393d4a17304SKalle Valo 394d4a17304SKalle Valo #define RDES1_STATUS_RSSI (0x0000007f) 395d4a17304SKalle Valo 396d4a17304SKalle Valo 397d4a17304SKalle Valo #define TDES0_CONTROL_OWN (1 << 31) 398d4a17304SKalle Valo #define TDES0_CONTROL_DONE (1 << 30) 399d4a17304SKalle Valo #define TDES0_CONTROL_TXDR (0x0ff00000) 400d4a17304SKalle Valo 401d4a17304SKalle Valo #define TDES0_STATUS_OWN (1 << 31) 402d4a17304SKalle Valo #define TDES0_STATUS_DONE (1 << 30) 403d4a17304SKalle Valo #define TDES0_STATUS_ES (1 << 29) 404d4a17304SKalle Valo #define TDES0_STATUS_TLT (1 << 28) 405d4a17304SKalle Valo #define TDES0_STATUS_TRT (1 << 27) 406d4a17304SKalle Valo #define TDES0_STATUS_TUF (1 << 26) 407d4a17304SKalle Valo #define TDES0_STATUS_TRO (1 << 25) 408d4a17304SKalle Valo #define TDES0_STATUS_SOFBR (1 << 24) 409d4a17304SKalle Valo #define TDES0_STATUS_ACR (0x00000fff) 410d4a17304SKalle Valo 411d4a17304SKalle Valo #define TDES1_CONTROL_IC (1 << 31) 412d4a17304SKalle Valo #define TDES1_CONTROL_LS (1 << 30) 413d4a17304SKalle Valo #define TDES1_CONTROL_FS (1 << 29) 414d4a17304SKalle Valo #define TDES1_CONTROL_TER (1 << 25) 415d4a17304SKalle Valo #define TDES1_CONTROL_TCH (1 << 24) 416d4a17304SKalle Valo #define TDES1_CONTROL_RBS2 (0x00fff000) 417d4a17304SKalle Valo #define TDES1_CONTROL_RBS1 (0x00000fff) 418d4a17304SKalle Valo 419d4a17304SKalle Valo /* SRAM offsets */ 420d4a17304SKalle Valo #define ADM8211_SRAM(x) (priv->pdev->revision < ADM8211_REV_BA ? \ 421d4a17304SKalle Valo ADM8211_SRAM_A_ ## x : ADM8211_SRAM_B_ ## x) 422d4a17304SKalle Valo 423d4a17304SKalle Valo #define ADM8211_SRAM_INDIV_KEY 0x0000 424d4a17304SKalle Valo #define ADM8211_SRAM_A_SHARE_KEY 0x0160 425d4a17304SKalle Valo #define ADM8211_SRAM_B_SHARE_KEY 0x00c0 426d4a17304SKalle Valo 427d4a17304SKalle Valo #define ADM8211_SRAM_A_SSID 0x0180 428d4a17304SKalle Valo #define ADM8211_SRAM_B_SSID 0x00d4 429d4a17304SKalle Valo #define ADM8211_SRAM_SSID ADM8211_SRAM(SSID) 430d4a17304SKalle Valo 431d4a17304SKalle Valo #define ADM8211_SRAM_A_SUPP_RATE 0x0191 432d4a17304SKalle Valo #define ADM8211_SRAM_B_SUPP_RATE 0x00dd 433d4a17304SKalle Valo #define ADM8211_SRAM_SUPP_RATE ADM8211_SRAM(SUPP_RATE) 434d4a17304SKalle Valo 435d4a17304SKalle Valo #define ADM8211_SRAM_A_SIZE 0x0200 436d4a17304SKalle Valo #define ADM8211_SRAM_B_SIZE 0x01c0 437d4a17304SKalle Valo #define ADM8211_SRAM_SIZE ADM8211_SRAM(SIZE) 438d4a17304SKalle Valo 439d4a17304SKalle Valo struct adm8211_rx_ring_info { 440d4a17304SKalle Valo struct sk_buff *skb; 441d4a17304SKalle Valo dma_addr_t mapping; 442d4a17304SKalle Valo }; 443d4a17304SKalle Valo 444d4a17304SKalle Valo struct adm8211_tx_ring_info { 445d4a17304SKalle Valo struct sk_buff *skb; 446d4a17304SKalle Valo dma_addr_t mapping; 447d4a17304SKalle Valo size_t hdrlen; 448d4a17304SKalle Valo }; 449d4a17304SKalle Valo 450d4a17304SKalle Valo #define PLCP_SIGNAL_1M 0x0a 451d4a17304SKalle Valo #define PLCP_SIGNAL_2M 0x14 452d4a17304SKalle Valo #define PLCP_SIGNAL_5M5 0x37 453d4a17304SKalle Valo #define PLCP_SIGNAL_11M 0x6e 454d4a17304SKalle Valo 455d4a17304SKalle Valo struct adm8211_tx_hdr { 456d4a17304SKalle Valo u8 da[6]; 457d4a17304SKalle Valo u8 signal; /* PLCP signal / TX rate in 100 Kbps */ 458d4a17304SKalle Valo u8 service; 459d4a17304SKalle Valo __le16 frame_body_size; 460d4a17304SKalle Valo __le16 frame_control; 461d4a17304SKalle Valo __le16 plcp_frag_tail_len; 462d4a17304SKalle Valo __le16 plcp_frag_head_len; 463d4a17304SKalle Valo __le16 dur_frag_tail; 464d4a17304SKalle Valo __le16 dur_frag_head; 465d4a17304SKalle Valo u8 addr4[6]; 466d4a17304SKalle Valo 467d4a17304SKalle Valo #define ADM8211_TXHDRCTL_SHORT_PREAMBLE (1 << 0) 468d4a17304SKalle Valo #define ADM8211_TXHDRCTL_MORE_FRAG (1 << 1) 469d4a17304SKalle Valo #define ADM8211_TXHDRCTL_MORE_DATA (1 << 2) 470d4a17304SKalle Valo #define ADM8211_TXHDRCTL_FRAG_NO (1 << 3) /* ? */ 471d4a17304SKalle Valo #define ADM8211_TXHDRCTL_ENABLE_RTS (1 << 4) 472d4a17304SKalle Valo #define ADM8211_TXHDRCTL_ENABLE_WEP_ENGINE (1 << 5) 473d4a17304SKalle Valo #define ADM8211_TXHDRCTL_ENABLE_EXTEND_HEADER (1 << 15) /* ? */ 474d4a17304SKalle Valo __le16 header_control; 475d4a17304SKalle Valo __le16 frag; 476d4a17304SKalle Valo u8 reserved_0; 477d4a17304SKalle Valo u8 retry_limit; 478d4a17304SKalle Valo 479d4a17304SKalle Valo u32 wep2key0; 480d4a17304SKalle Valo u32 wep2key1; 481d4a17304SKalle Valo u32 wep2key2; 482d4a17304SKalle Valo u32 wep2key3; 483d4a17304SKalle Valo 484d4a17304SKalle Valo u8 keyid; 485d4a17304SKalle Valo u8 entry_control; // huh?? 486d4a17304SKalle Valo u16 reserved_1; 487d4a17304SKalle Valo u32 reserved_2; 488d4a17304SKalle Valo } __packed; 489d4a17304SKalle Valo 490d4a17304SKalle Valo 491d4a17304SKalle Valo #define RX_COPY_BREAK 128 492d4a17304SKalle Valo #define RX_PKT_SIZE 2500 493d4a17304SKalle Valo 494d4a17304SKalle Valo struct adm8211_eeprom { 495d4a17304SKalle Valo __le16 signature; /* 0x00 */ 496d4a17304SKalle Valo u8 major_version; /* 0x02 */ 497d4a17304SKalle Valo u8 minor_version; /* 0x03 */ 498d4a17304SKalle Valo u8 reserved_1[4]; /* 0x04 */ 499d4a17304SKalle Valo u8 hwaddr[6]; /* 0x08 */ 500d4a17304SKalle Valo u8 reserved_2[8]; /* 0x1E */ 501d4a17304SKalle Valo __le16 cr49; /* 0x16 */ 502d4a17304SKalle Valo u8 cr03; /* 0x18 */ 503d4a17304SKalle Valo u8 cr28; /* 0x19 */ 504d4a17304SKalle Valo u8 cr29; /* 0x1A */ 505d4a17304SKalle Valo u8 country_code; /* 0x1B */ 506d4a17304SKalle Valo 507d4a17304SKalle Valo /* specific bbp types */ 508d4a17304SKalle Valo #define ADM8211_BBP_RFMD3000 0x00 509d4a17304SKalle Valo #define ADM8211_BBP_RFMD3002 0x01 510d4a17304SKalle Valo #define ADM8211_BBP_ADM8011 0x04 511d4a17304SKalle Valo u8 specific_bbptype; /* 0x1C */ 512d4a17304SKalle Valo u8 specific_rftype; /* 0x1D */ 513d4a17304SKalle Valo u8 reserved_3[2]; /* 0x1E */ 514d4a17304SKalle Valo __le16 device_id; /* 0x20 */ 515d4a17304SKalle Valo __le16 vendor_id; /* 0x22 */ 516d4a17304SKalle Valo __le16 subsystem_id; /* 0x24 */ 517d4a17304SKalle Valo __le16 subsystem_vendor_id; /* 0x26 */ 518d4a17304SKalle Valo u8 maxlat; /* 0x28 */ 519d4a17304SKalle Valo u8 mingnt; /* 0x29 */ 520d4a17304SKalle Valo __le16 cis_pointer_low; /* 0x2A */ 521d4a17304SKalle Valo __le16 cis_pointer_high; /* 0x2C */ 522d4a17304SKalle Valo __le16 csr18; /* 0x2E */ 523d4a17304SKalle Valo u8 reserved_4[16]; /* 0x30 */ 524d4a17304SKalle Valo u8 d1_pwrdara; /* 0x40 */ 525d4a17304SKalle Valo u8 d0_pwrdara; /* 0x41 */ 526d4a17304SKalle Valo u8 d3_pwrdara; /* 0x42 */ 527d4a17304SKalle Valo u8 d2_pwrdara; /* 0x43 */ 528d4a17304SKalle Valo u8 antenna_power[14]; /* 0x44 */ 529d4a17304SKalle Valo __le16 cis_wordcnt; /* 0x52 */ 530d4a17304SKalle Valo u8 tx_power[14]; /* 0x54 */ 531d4a17304SKalle Valo u8 lpf_cutoff[14]; /* 0x62 */ 532d4a17304SKalle Valo u8 lnags_threshold[14]; /* 0x70 */ 533d4a17304SKalle Valo __le16 checksum; /* 0x7E */ 534*98d13639SGustavo A. R. Silva u8 cis_data[]; /* 0x80, 384 bytes */ 535d4a17304SKalle Valo } __packed; 536d4a17304SKalle Valo 537d4a17304SKalle Valo struct adm8211_priv { 538d4a17304SKalle Valo struct pci_dev *pdev; 539d4a17304SKalle Valo spinlock_t lock; 540d4a17304SKalle Valo struct adm8211_csr __iomem *map; 541d4a17304SKalle Valo struct adm8211_desc *rx_ring; 542d4a17304SKalle Valo struct adm8211_desc *tx_ring; 543d4a17304SKalle Valo dma_addr_t rx_ring_dma; 544d4a17304SKalle Valo dma_addr_t tx_ring_dma; 545d4a17304SKalle Valo struct adm8211_rx_ring_info *rx_buffers; 546d4a17304SKalle Valo struct adm8211_tx_ring_info *tx_buffers; 547d4a17304SKalle Valo unsigned int rx_ring_size, tx_ring_size; 548d4a17304SKalle Valo unsigned int cur_tx, dirty_tx, cur_rx; 549d4a17304SKalle Valo 550d4a17304SKalle Valo struct ieee80211_low_level_stats stats; 551d4a17304SKalle Valo struct ieee80211_supported_band band; 552d4a17304SKalle Valo struct ieee80211_channel channels[14]; 553d4a17304SKalle Valo int mode; 554d4a17304SKalle Valo 555d4a17304SKalle Valo int channel; 556d4a17304SKalle Valo u8 bssid[ETH_ALEN]; 557d4a17304SKalle Valo 558d4a17304SKalle Valo u8 soft_rx_crc; 559d4a17304SKalle Valo u8 retry_limit; 560d4a17304SKalle Valo 561d4a17304SKalle Valo u8 ant_power; 562d4a17304SKalle Valo u8 tx_power; 563d4a17304SKalle Valo u8 lpf_cutoff; 564d4a17304SKalle Valo u8 lnags_threshold; 565d4a17304SKalle Valo struct adm8211_eeprom *eeprom; 566d4a17304SKalle Valo size_t eeprom_len; 567d4a17304SKalle Valo 568d4a17304SKalle Valo u32 nar; 569d4a17304SKalle Valo 570d4a17304SKalle Valo #define ADM8211_TYPE_INTERSIL 0x00 571d4a17304SKalle Valo #define ADM8211_TYPE_RFMD 0x01 572d4a17304SKalle Valo #define ADM8211_TYPE_MARVEL 0x02 573d4a17304SKalle Valo #define ADM8211_TYPE_AIROHA 0x03 574d4a17304SKalle Valo #define ADM8211_TYPE_ADMTEK 0x05 575d4a17304SKalle Valo unsigned int rf_type:3; 576d4a17304SKalle Valo unsigned int bbp_type:3; 577d4a17304SKalle Valo 578d4a17304SKalle Valo u8 specific_bbptype; 579d4a17304SKalle Valo enum { 580d4a17304SKalle Valo ADM8211_RFMD2948 = 0x0, 581d4a17304SKalle Valo ADM8211_RFMD2958 = 0x1, 582d4a17304SKalle Valo ADM8211_RFMD2958_RF3000_CONTROL_POWER = 0x2, 583d4a17304SKalle Valo ADM8211_MAX2820 = 0x8, 584d4a17304SKalle Valo ADM8211_AL2210L = 0xC, /* Airoha */ 585d4a17304SKalle Valo } transceiver_type; 586d4a17304SKalle Valo }; 587d4a17304SKalle Valo 588d4a17304SKalle Valo struct ieee80211_chan_range { 589d4a17304SKalle Valo u8 min; 590d4a17304SKalle Valo u8 max; 591d4a17304SKalle Valo }; 592d4a17304SKalle Valo 593d4a17304SKalle Valo static const struct ieee80211_chan_range cranges[] = { 594d4a17304SKalle Valo {1, 11}, /* FCC */ 595d4a17304SKalle Valo {1, 11}, /* IC */ 596d4a17304SKalle Valo {1, 13}, /* ETSI */ 597d4a17304SKalle Valo {10, 11}, /* SPAIN */ 598d4a17304SKalle Valo {10, 13}, /* FRANCE */ 599d4a17304SKalle Valo {14, 14}, /* MMK */ 600d4a17304SKalle Valo {1, 14}, /* MMK2 */ 601d4a17304SKalle Valo }; 602d4a17304SKalle Valo 603d4a17304SKalle Valo #endif /* ADM8211_H */ 604