1d0c50e91SJohannes Hofmann /* $FreeBSD$ */ 24db7dd1bSJoe Talbott 34db7dd1bSJoe Talbott /*- 44db7dd1bSJoe Talbott * Copyright (c) 2006,2007 54db7dd1bSJoe Talbott * Damien Bergamini <damien.bergamini@free.fr> 64db7dd1bSJoe Talbott * 74db7dd1bSJoe Talbott * Permission to use, copy, modify, and distribute this software for any 84db7dd1bSJoe Talbott * purpose with or without fee is hereby granted, provided that the above 94db7dd1bSJoe Talbott * copyright notice and this permission notice appear in all copies. 104db7dd1bSJoe Talbott * 114db7dd1bSJoe Talbott * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 124db7dd1bSJoe Talbott * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 134db7dd1bSJoe Talbott * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 144db7dd1bSJoe Talbott * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 154db7dd1bSJoe Talbott * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 164db7dd1bSJoe Talbott * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 174db7dd1bSJoe Talbott * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 184db7dd1bSJoe Talbott */ 194db7dd1bSJoe Talbott 204db7dd1bSJoe Talbott #define WPI_TX_RING_COUNT 256 21*7370bffcSMatthew Dillon #define WPI_TX_RING_LOMARK 192 22*7370bffcSMatthew Dillon #define WPI_TX_RING_HIMARK 224 23*7370bffcSMatthew Dillon 24*7370bffcSMatthew Dillon #ifdef DIAGNOSTIC 25*7370bffcSMatthew Dillon #define WPI_RX_RING_COUNT_LOG 8 26*7370bffcSMatthew Dillon #else 27*7370bffcSMatthew Dillon #define WPI_RX_RING_COUNT_LOG 6 28*7370bffcSMatthew Dillon #endif 29*7370bffcSMatthew Dillon 30*7370bffcSMatthew Dillon #define WPI_RX_RING_COUNT (1 << WPI_RX_RING_COUNT_LOG) 31*7370bffcSMatthew Dillon 32*7370bffcSMatthew Dillon #define WPI_NTXQUEUES 8 33*7370bffcSMatthew Dillon #define WPI_DRV_NTXQUEUES 5 34*7370bffcSMatthew Dillon #define WPI_CMD_QUEUE_NUM 4 35*7370bffcSMatthew Dillon 36*7370bffcSMatthew Dillon #define WPI_NDMACHNLS 6 37*7370bffcSMatthew Dillon 38*7370bffcSMatthew Dillon /* Maximum scatter/gather. */ 39*7370bffcSMatthew Dillon #define WPI_MAX_SCATTER 4 404db7dd1bSJoe Talbott 414db7dd1bSJoe Talbott /* 424db7dd1bSJoe Talbott * Rings must be aligned on a 16K boundary. 434db7dd1bSJoe Talbott */ 444db7dd1bSJoe Talbott #define WPI_RING_DMA_ALIGN 0x4000 454db7dd1bSJoe Talbott 46*7370bffcSMatthew Dillon /* Maximum Rx buffer size. */ 474db7dd1bSJoe Talbott #define WPI_RBUF_SIZE ( 3 * 1024 ) /* XXX 3000 but must be aligned */ 484db7dd1bSJoe Talbott 494db7dd1bSJoe Talbott /* 504db7dd1bSJoe Talbott * Control and status registers. 514db7dd1bSJoe Talbott */ 52*7370bffcSMatthew Dillon #define WPI_HW_IF_CONFIG 0x000 53*7370bffcSMatthew Dillon #define WPI_INT 0x008 54*7370bffcSMatthew Dillon #define WPI_INT_MASK 0x00c 55*7370bffcSMatthew Dillon #define WPI_FH_INT 0x010 56*7370bffcSMatthew Dillon #define WPI_GPIO_IN 0x018 574db7dd1bSJoe Talbott #define WPI_RESET 0x020 58*7370bffcSMatthew Dillon #define WPI_GP_CNTRL 0x024 59*7370bffcSMatthew Dillon #define WPI_EEPROM 0x02c 60*7370bffcSMatthew Dillon #define WPI_EEPROM_GP 0x030 61*7370bffcSMatthew Dillon #define WPI_GIO 0x03c 62*7370bffcSMatthew Dillon #define WPI_UCODE_GP1 0x054 63*7370bffcSMatthew Dillon #define WPI_UCODE_GP1_SET 0x058 64*7370bffcSMatthew Dillon #define WPI_UCODE_GP1_CLR 0x05c 65*7370bffcSMatthew Dillon #define WPI_UCODE_GP2 0x060 66*7370bffcSMatthew Dillon #define WPI_GIO_CHICKEN 0x100 67*7370bffcSMatthew Dillon #define WPI_ANA_PLL 0x20c 68*7370bffcSMatthew Dillon #define WPI_DBG_HPET_MEM 0x240 69*7370bffcSMatthew Dillon #define WPI_MEM_RADDR 0x40c 70*7370bffcSMatthew Dillon #define WPI_MEM_WADDR 0x410 71*7370bffcSMatthew Dillon #define WPI_MEM_WDATA 0x418 72*7370bffcSMatthew Dillon #define WPI_MEM_RDATA 0x41c 73*7370bffcSMatthew Dillon #define WPI_PRPH_WADDR 0x444 74*7370bffcSMatthew Dillon #define WPI_PRPH_RADDR 0x448 75*7370bffcSMatthew Dillon #define WPI_PRPH_WDATA 0x44c 76*7370bffcSMatthew Dillon #define WPI_PRPH_RDATA 0x450 77*7370bffcSMatthew Dillon #define WPI_HBUS_TARG_WRPTR 0x460 78*7370bffcSMatthew Dillon 79*7370bffcSMatthew Dillon /* 80*7370bffcSMatthew Dillon * Flow-Handler registers. 81*7370bffcSMatthew Dillon */ 82*7370bffcSMatthew Dillon #define WPI_FH_CBBC_CTRL(qid) (0x940 + (qid) * 8) 83*7370bffcSMatthew Dillon #define WPI_FH_CBBC_BASE(qid) (0x944 + (qid) * 8) 84*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG 0xc00 85*7370bffcSMatthew Dillon #define WPI_FH_RX_BASE 0xc04 86*7370bffcSMatthew Dillon #define WPI_FH_RX_WPTR 0xc20 87*7370bffcSMatthew Dillon #define WPI_FH_RX_RPTR_ADDR 0xc24 88*7370bffcSMatthew Dillon #define WPI_FH_RSSR_TBL 0xcc0 89*7370bffcSMatthew Dillon #define WPI_FH_RX_STATUS 0xcc4 90*7370bffcSMatthew Dillon #define WPI_FH_TX_CONFIG(qid) (0xd00 + (qid) * 32) 91*7370bffcSMatthew Dillon #define WPI_FH_TX_BASE 0xe80 92*7370bffcSMatthew Dillon #define WPI_FH_MSG_CONFIG 0xe88 93*7370bffcSMatthew Dillon #define WPI_FH_TX_STATUS 0xe90 944db7dd1bSJoe Talbott 954db7dd1bSJoe Talbott 964db7dd1bSJoe Talbott /* 974db7dd1bSJoe Talbott * NIC internal memory offsets. 984db7dd1bSJoe Talbott */ 99*7370bffcSMatthew Dillon #define WPI_ALM_SCHED_MODE 0x2e00 100*7370bffcSMatthew Dillon #define WPI_ALM_SCHED_ARASTAT 0x2e04 101*7370bffcSMatthew Dillon #define WPI_ALM_SCHED_TXFACT 0x2e10 102*7370bffcSMatthew Dillon #define WPI_ALM_SCHED_TXF4MF 0x2e14 103*7370bffcSMatthew Dillon #define WPI_ALM_SCHED_TXF5MF 0x2e20 104*7370bffcSMatthew Dillon #define WPI_ALM_SCHED_SBYPASS_MODE1 0x2e2c 105*7370bffcSMatthew Dillon #define WPI_ALM_SCHED_SBYPASS_MODE2 0x2e30 106*7370bffcSMatthew Dillon #define WPI_APMG_CLK_CTRL 0x3000 107*7370bffcSMatthew Dillon #define WPI_APMG_CLK_EN 0x3004 108*7370bffcSMatthew Dillon #define WPI_APMG_CLK_DIS 0x3008 109*7370bffcSMatthew Dillon #define WPI_APMG_PS 0x300c 110*7370bffcSMatthew Dillon #define WPI_APMG_PCI_STT 0x3010 111*7370bffcSMatthew Dillon #define WPI_APMG_RFKILL 0x3014 112*7370bffcSMatthew Dillon #define WPI_BSM_WR_CTRL 0x3400 113*7370bffcSMatthew Dillon #define WPI_BSM_WR_MEM_SRC 0x3404 114*7370bffcSMatthew Dillon #define WPI_BSM_WR_MEM_DST 0x3408 115*7370bffcSMatthew Dillon #define WPI_BSM_WR_DWCOUNT 0x340c 116*7370bffcSMatthew Dillon #define WPI_BSM_DRAM_TEXT_ADDR 0x3490 117*7370bffcSMatthew Dillon #define WPI_BSM_DRAM_TEXT_SIZE 0x3494 118*7370bffcSMatthew Dillon #define WPI_BSM_DRAM_DATA_ADDR 0x3498 119*7370bffcSMatthew Dillon #define WPI_BSM_DRAM_DATA_SIZE 0x349c 120*7370bffcSMatthew Dillon #define WPI_BSM_SRAM_BASE 0x3800 1214db7dd1bSJoe Talbott 1224db7dd1bSJoe Talbott 123*7370bffcSMatthew Dillon /* Possible flags for register WPI_HW_IF_CONFIG. */ 124*7370bffcSMatthew Dillon #define WPI_HW_IF_CONFIG_ALM_MB (1 << 8) 125*7370bffcSMatthew Dillon #define WPI_HW_IF_CONFIG_ALM_MM (1 << 9) 126*7370bffcSMatthew Dillon #define WPI_HW_IF_CONFIG_SKU_MRC (1 << 10) 127*7370bffcSMatthew Dillon #define WPI_HW_IF_CONFIG_REV_D (1 << 11) 128*7370bffcSMatthew Dillon #define WPI_HW_IF_CONFIG_TYPE_B (1 << 12) 1294db7dd1bSJoe Talbott 130*7370bffcSMatthew Dillon /* Possible flags for registers WPI_PRPH_RADDR/WPI_PRPH_WADDR. */ 131*7370bffcSMatthew Dillon #define WPI_PRPH_DWORD ((sizeof (uint32_t) - 1) << 24) 1324db7dd1bSJoe Talbott 133*7370bffcSMatthew Dillon /* Possible values for WPI_BSM_WR_MEM_DST. */ 134*7370bffcSMatthew Dillon #define WPI_FW_TEXT_BASE 0x00000000 135*7370bffcSMatthew Dillon #define WPI_FW_DATA_BASE 0x00800000 1364db7dd1bSJoe Talbott 137*7370bffcSMatthew Dillon /* Possible flags for WPI_GPIO_IN. */ 138*7370bffcSMatthew Dillon #define WPI_GPIO_IN_VMAIN (1 << 9) 1394db7dd1bSJoe Talbott 140*7370bffcSMatthew Dillon /* Possible flags for register WPI_RESET. */ 141*7370bffcSMatthew Dillon #define WPI_RESET_NEVO (1 << 0) 142*7370bffcSMatthew Dillon #define WPI_RESET_SW (1 << 7) 143*7370bffcSMatthew Dillon #define WPI_RESET_MASTER_DISABLED (1 << 8) 144*7370bffcSMatthew Dillon #define WPI_RESET_STOP_MASTER (1 << 9) 1454db7dd1bSJoe Talbott 146*7370bffcSMatthew Dillon /* Possible flags for register WPI_GP_CNTRL. */ 147*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_MAC_ACCESS_ENA (1 << 0) 148*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_MAC_CLOCK_READY (1 << 0) 149*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_INIT_DONE (1 << 2) 150*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_MAC_ACCESS_REQ (1 << 3) 151*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_SLEEP (1 << 4) 152*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_PS_MASK (7 << 24) 153*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_MAC_PS (4 << 24) 154*7370bffcSMatthew Dillon #define WPI_GP_CNTRL_RFKILL (1 << 27) 1554db7dd1bSJoe Talbott 156*7370bffcSMatthew Dillon /* Possible flags for register WPI_GIO_CHICKEN. */ 157*7370bffcSMatthew Dillon #define WPI_GIO_CHICKEN_L1A_NO_L0S_RX (1 << 23) 158*7370bffcSMatthew Dillon #define WPI_GIO_CHICKEN_DIS_L0S_TIMER (1 << 29) 1594db7dd1bSJoe Talbott 160*7370bffcSMatthew Dillon /* Possible flags for register WPI_GIO. */ 161*7370bffcSMatthew Dillon #define WPI_GIO_L0S_ENA (1 << 1) 1624db7dd1bSJoe Talbott 163*7370bffcSMatthew Dillon /* Possible flags for register WPI_FH_RX_CONFIG. */ 164*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG_DMA_ENA (1U << 31) 165*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG_RDRBD_ENA (1 << 29) 166*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG_WRSTATUS_ENA (1 << 27) 167*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG_MAXFRAG (1 << 24) 168*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG_NRBD(x) ((x) << 20) 169*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG_IRQ_DST_HOST (1 << 12) 170*7370bffcSMatthew Dillon #define WPI_FH_RX_CONFIG_IRQ_TIMEOUT(x) ((x) << 4) 1714db7dd1bSJoe Talbott 172*7370bffcSMatthew Dillon /* Possible flags for register WPI_ANA_PLL. */ 173*7370bffcSMatthew Dillon #define WPI_ANA_PLL_INIT (1 << 24) 1744db7dd1bSJoe Talbott 175*7370bffcSMatthew Dillon /* Possible flags for register WPI_UCODE_GP1*. */ 176*7370bffcSMatthew Dillon #define WPI_UCODE_GP1_MAC_SLEEP (1 << 0) 177*7370bffcSMatthew Dillon #define WPI_UCODE_GP1_RFKILL (1 << 1) 178*7370bffcSMatthew Dillon #define WPI_UCODE_GP1_CMD_BLOCKED (1 << 2) 1794db7dd1bSJoe Talbott 180*7370bffcSMatthew Dillon /* Possible flags for register WPI_FH_RX_STATUS. */ 181*7370bffcSMatthew Dillon #define WPI_FH_RX_STATUS_IDLE (1 << 24) 1824db7dd1bSJoe Talbott 183*7370bffcSMatthew Dillon /* Possible flags for register WPI_BSM_WR_CTRL. */ 184*7370bffcSMatthew Dillon #define WPI_BSM_WR_CTRL_START_EN (1 << 30) 185*7370bffcSMatthew Dillon #define WPI_BSM_WR_CTRL_START (1U << 31) 1864db7dd1bSJoe Talbott 187*7370bffcSMatthew Dillon /* Possible flags for register WPI_INT. */ 188*7370bffcSMatthew Dillon #define WPI_INT_ALIVE (1 << 0) 189*7370bffcSMatthew Dillon #define WPI_INT_WAKEUP (1 << 1) 190*7370bffcSMatthew Dillon #define WPI_INT_SW_RX (1 << 3) 191*7370bffcSMatthew Dillon #define WPI_INT_SW_ERR (1 << 25) 192*7370bffcSMatthew Dillon #define WPI_INT_FH_TX (1 << 27) 193*7370bffcSMatthew Dillon #define WPI_INT_HW_ERR (1 << 29) 194*7370bffcSMatthew Dillon #define WPI_INT_FH_RX (1U << 31) 1954db7dd1bSJoe Talbott 196*7370bffcSMatthew Dillon /* Shortcut. */ 197*7370bffcSMatthew Dillon #define WPI_INT_MASK_DEF \ 198*7370bffcSMatthew Dillon (WPI_INT_SW_ERR | WPI_INT_HW_ERR | WPI_INT_FH_TX | \ 199*7370bffcSMatthew Dillon WPI_INT_FH_RX | WPI_INT_ALIVE | WPI_INT_WAKEUP | \ 200*7370bffcSMatthew Dillon WPI_INT_SW_RX) 2014db7dd1bSJoe Talbott 202*7370bffcSMatthew Dillon /* Possible flags for register WPI_FH_INT. */ 203*7370bffcSMatthew Dillon #define WPI_FH_INT_RX_CHNL(x) (1 << ((x) + 16)) 204*7370bffcSMatthew Dillon #define WPI_FH_INT_HI_PRIOR (1 << 30) 205*7370bffcSMatthew Dillon /* Shortcuts for the above. */ 206*7370bffcSMatthew Dillon #define WPI_FH_INT_RX \ 207*7370bffcSMatthew Dillon (WPI_FH_INT_RX_CHNL(0) | \ 208*7370bffcSMatthew Dillon WPI_FH_INT_RX_CHNL(1) | \ 209*7370bffcSMatthew Dillon WPI_FH_INT_RX_CHNL(2) | \ 210*7370bffcSMatthew Dillon WPI_FH_INT_HI_PRIOR) 211*7370bffcSMatthew Dillon 212*7370bffcSMatthew Dillon /* Possible flags for register WPI_FH_TX_STATUS. */ 213*7370bffcSMatthew Dillon #define WPI_FH_TX_STATUS_IDLE(qid) \ 214*7370bffcSMatthew Dillon (1 << ((qid) + 24) | 1 << ((qid) + 16)) 215*7370bffcSMatthew Dillon 216*7370bffcSMatthew Dillon /* Possible flags for register WPI_EEPROM. */ 217*7370bffcSMatthew Dillon #define WPI_EEPROM_READ_VALID (1 << 0) 218*7370bffcSMatthew Dillon 219*7370bffcSMatthew Dillon /* Possible flags for register WPI_EEPROM_GP. */ 2204db7dd1bSJoe Talbott #define WPI_EEPROM_VERSION 0x00000007 221*7370bffcSMatthew Dillon #define WPI_EEPROM_GP_IF_OWNER 0x00000180 2224db7dd1bSJoe Talbott 223*7370bffcSMatthew Dillon /* Possible flags for register WPI_APMG_PS. */ 224*7370bffcSMatthew Dillon #define WPI_APMG_PS_PWR_SRC_MASK (3 << 24) 225*7370bffcSMatthew Dillon 226*7370bffcSMatthew Dillon /* Possible flags for registers WPI_APMG_CLK_*. */ 227*7370bffcSMatthew Dillon #define WPI_APMG_CLK_CTRL_DMA_CLK_RQT (1 << 9) 228*7370bffcSMatthew Dillon #define WPI_APMG_CLK_CTRL_BSM_CLK_RQT (1 << 11) 229*7370bffcSMatthew Dillon 230*7370bffcSMatthew Dillon /* Possible flags for register WPI_APMG_PCI_STT. */ 231*7370bffcSMatthew Dillon #define WPI_APMG_PCI_STT_L1A_DIS (1 << 11) 2324db7dd1bSJoe Talbott 2334db7dd1bSJoe Talbott struct wpi_shared { 234*7370bffcSMatthew Dillon uint32_t txbase[WPI_NTXQUEUES]; 2354db7dd1bSJoe Talbott uint32_t next; 2364db7dd1bSJoe Talbott uint32_t reserved[2]; 2374db7dd1bSJoe Talbott } __packed; 2384db7dd1bSJoe Talbott 2394db7dd1bSJoe Talbott #define WPI_MAX_SEG_LEN 65520 2404db7dd1bSJoe Talbott struct wpi_tx_desc { 241*7370bffcSMatthew Dillon uint8_t reserved1[3]; 242*7370bffcSMatthew Dillon uint8_t nsegs; 2434db7dd1bSJoe Talbott #define WPI_PAD32(x) (roundup2(x, 4) - (x)) 2444db7dd1bSJoe Talbott 2454db7dd1bSJoe Talbott struct { 2464db7dd1bSJoe Talbott uint32_t addr; 2474db7dd1bSJoe Talbott uint32_t len; 248*7370bffcSMatthew Dillon } __packed segs[WPI_MAX_SCATTER]; 249*7370bffcSMatthew Dillon uint8_t reserved2[28]; 2504db7dd1bSJoe Talbott } __packed; 2514db7dd1bSJoe Talbott 2524db7dd1bSJoe Talbott struct wpi_tx_stat { 253*7370bffcSMatthew Dillon uint8_t rtsfailcnt; 254*7370bffcSMatthew Dillon uint8_t ackfailcnt; 255*7370bffcSMatthew Dillon uint8_t btkillcnt; 2564db7dd1bSJoe Talbott uint8_t rate; 2574db7dd1bSJoe Talbott uint32_t duration; 2584db7dd1bSJoe Talbott uint32_t status; 259*7370bffcSMatthew Dillon #define WPI_TX_STATUS_SUCCESS 0x01 260*7370bffcSMatthew Dillon #define WPI_TX_STATUS_DIRECT_DONE 0x02 261*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL 0x80 262*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_SHORT_LIMIT 0x82 263*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_LONG_LIMIT 0x83 264*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_FIFO_UNDERRUN 0x84 265*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_MGMNT_ABORT 0x85 266*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_NEXT_FRAG 0x86 267*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_LIFE_EXPIRE 0x87 268*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_NODE_PS 0x88 269*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_ABORTED 0x89 270*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_BT_RETRY 0x8a 271*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_NODE_INVALID 0x8b 272*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_FRAG_DROPPED 0x8c 273*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_TID_DISABLE 0x8d 274*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_FRAME_FLUSHED 0x8e 275*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_INSUFFICIENT_CF_POLL 0x8f 276*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_TX_LOCKED 0x90 277*7370bffcSMatthew Dillon #define WPI_TX_STATUS_FAIL_NO_BEACON_ON_RADAR 0x91 278*7370bffcSMatthew Dillon 2794db7dd1bSJoe Talbott } __packed; 2804db7dd1bSJoe Talbott 2814db7dd1bSJoe Talbott struct wpi_rx_desc { 2824db7dd1bSJoe Talbott uint32_t len; 2834db7dd1bSJoe Talbott uint8_t type; 2844db7dd1bSJoe Talbott #define WPI_UC_READY 1 2854db7dd1bSJoe Talbott #define WPI_RX_DONE 27 2864db7dd1bSJoe Talbott #define WPI_TX_DONE 28 2874db7dd1bSJoe Talbott #define WPI_START_SCAN 130 2884db7dd1bSJoe Talbott #define WPI_SCAN_RESULTS 131 2894db7dd1bSJoe Talbott #define WPI_STOP_SCAN 132 290*7370bffcSMatthew Dillon #define WPI_BEACON_SENT 144 291*7370bffcSMatthew Dillon #define WPI_RX_STATISTICS 156 292*7370bffcSMatthew Dillon #define WPI_BEACON_STATISTICS 157 2934db7dd1bSJoe Talbott #define WPI_STATE_CHANGED 161 294*7370bffcSMatthew Dillon #define WPI_BEACON_MISSED 162 2954db7dd1bSJoe Talbott 2964db7dd1bSJoe Talbott uint8_t flags; 2974db7dd1bSJoe Talbott uint8_t idx; 2984db7dd1bSJoe Talbott uint8_t qid; 2994db7dd1bSJoe Talbott } __packed; 3004db7dd1bSJoe Talbott 301*7370bffcSMatthew Dillon #define WPI_RX_DESC_QID_MSK 0x07 302*7370bffcSMatthew Dillon #define WPI_UNSOLICITED_RX_NOTIF 0x80 303*7370bffcSMatthew Dillon 3044db7dd1bSJoe Talbott struct wpi_rx_stat { 3054db7dd1bSJoe Talbott uint8_t len; 3064db7dd1bSJoe Talbott #define WPI_STAT_MAXLEN 20 3074db7dd1bSJoe Talbott 3084db7dd1bSJoe Talbott uint8_t id; 3094db7dd1bSJoe Talbott uint8_t rssi; /* received signal strength */ 310*7370bffcSMatthew Dillon #define WPI_RSSI_OFFSET -95 3114db7dd1bSJoe Talbott 3124db7dd1bSJoe Talbott uint8_t agc; /* access gain control */ 3134db7dd1bSJoe Talbott uint16_t signal; 3144db7dd1bSJoe Talbott uint16_t noise; 3154db7dd1bSJoe Talbott } __packed; 3164db7dd1bSJoe Talbott 3174db7dd1bSJoe Talbott struct wpi_rx_head { 3184db7dd1bSJoe Talbott uint16_t chan; 3194db7dd1bSJoe Talbott uint16_t flags; 320*7370bffcSMatthew Dillon #define WPI_STAT_FLAG_SHPREAMBLE (1 << 2) 321*7370bffcSMatthew Dillon 3224db7dd1bSJoe Talbott uint8_t reserved; 323*7370bffcSMatthew Dillon uint8_t plcp; 3244db7dd1bSJoe Talbott uint16_t len; 3254db7dd1bSJoe Talbott } __packed; 3264db7dd1bSJoe Talbott 3274db7dd1bSJoe Talbott struct wpi_rx_tail { 3284db7dd1bSJoe Talbott uint32_t flags; 3294db7dd1bSJoe Talbott #define WPI_RX_NO_CRC_ERR (1 << 0) 3304db7dd1bSJoe Talbott #define WPI_RX_NO_OVFL_ERR (1 << 1) 3314db7dd1bSJoe Talbott /* shortcut for the above */ 3324db7dd1bSJoe Talbott #define WPI_RX_NOERROR (WPI_RX_NO_CRC_ERR | WPI_RX_NO_OVFL_ERR) 333*7370bffcSMatthew Dillon #define WPI_RX_CIPHER_MASK (7 << 8) 334*7370bffcSMatthew Dillon #define WPI_RX_CIPHER_CCMP (2 << 8) 335*7370bffcSMatthew Dillon #define WPI_RX_DECRYPT_MASK (3 << 11) 336*7370bffcSMatthew Dillon #define WPI_RX_DECRYPT_OK (3 << 11) 337*7370bffcSMatthew Dillon 3384db7dd1bSJoe Talbott uint64_t tstamp; 3394db7dd1bSJoe Talbott uint32_t tbeacon; 3404db7dd1bSJoe Talbott } __packed; 3414db7dd1bSJoe Talbott 3424db7dd1bSJoe Talbott struct wpi_tx_cmd { 3434db7dd1bSJoe Talbott uint8_t code; 344*7370bffcSMatthew Dillon #define WPI_CMD_RXON 16 345*7370bffcSMatthew Dillon #define WPI_CMD_RXON_ASSOC 17 346*7370bffcSMatthew Dillon #define WPI_CMD_EDCA_PARAMS 19 347*7370bffcSMatthew Dillon #define WPI_CMD_TIMING 20 3484db7dd1bSJoe Talbott #define WPI_CMD_ADD_NODE 24 349*7370bffcSMatthew Dillon #define WPI_CMD_DEL_NODE 25 3504db7dd1bSJoe Talbott #define WPI_CMD_TX_DATA 28 3514db7dd1bSJoe Talbott #define WPI_CMD_MRR_SETUP 71 3524db7dd1bSJoe Talbott #define WPI_CMD_SET_LED 72 3534db7dd1bSJoe Talbott #define WPI_CMD_SET_POWER_MODE 119 3544db7dd1bSJoe Talbott #define WPI_CMD_SCAN 128 355*7370bffcSMatthew Dillon #define WPI_CMD_SCAN_ABORT 129 3564db7dd1bSJoe Talbott #define WPI_CMD_SET_BEACON 145 3574db7dd1bSJoe Talbott #define WPI_CMD_TXPOWER 151 358*7370bffcSMatthew Dillon #define WPI_CMD_BT_COEX 155 359*7370bffcSMatthew Dillon #define WPI_CMD_GET_STATISTICS 156 3604db7dd1bSJoe Talbott 3614db7dd1bSJoe Talbott uint8_t flags; 3624db7dd1bSJoe Talbott uint8_t idx; 3634db7dd1bSJoe Talbott uint8_t qid; 364*7370bffcSMatthew Dillon uint8_t data[124]; 3654db7dd1bSJoe Talbott } __packed; 3664db7dd1bSJoe Talbott 367*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_RXON. */ 368*7370bffcSMatthew Dillon struct wpi_rxon { 3694db7dd1bSJoe Talbott uint8_t myaddr[IEEE80211_ADDR_LEN]; 3704db7dd1bSJoe Talbott uint16_t reserved1; 3714db7dd1bSJoe Talbott uint8_t bssid[IEEE80211_ADDR_LEN]; 3724db7dd1bSJoe Talbott uint16_t reserved2; 373*7370bffcSMatthew Dillon uint8_t wlap[IEEE80211_ADDR_LEN]; 3744db7dd1bSJoe Talbott uint16_t reserved3; 3754db7dd1bSJoe Talbott uint8_t mode; 3764db7dd1bSJoe Talbott #define WPI_MODE_HOSTAP 1 3774db7dd1bSJoe Talbott #define WPI_MODE_STA 3 3784db7dd1bSJoe Talbott #define WPI_MODE_IBSS 4 3794db7dd1bSJoe Talbott #define WPI_MODE_MONITOR 6 3804db7dd1bSJoe Talbott 381*7370bffcSMatthew Dillon uint8_t air; 3824db7dd1bSJoe Talbott uint16_t reserved4; 3834db7dd1bSJoe Talbott uint8_t ofdm_mask; 3844db7dd1bSJoe Talbott uint8_t cck_mask; 3854db7dd1bSJoe Talbott uint16_t associd; 3864db7dd1bSJoe Talbott uint32_t flags; 387*7370bffcSMatthew Dillon #define WPI_RXON_24GHZ (1 << 0) 388*7370bffcSMatthew Dillon #define WPI_RXON_CCK (1 << 1) 389*7370bffcSMatthew Dillon #define WPI_RXON_AUTO (1 << 2) 390*7370bffcSMatthew Dillon #define WPI_RXON_SHSLOT (1 << 4) 391*7370bffcSMatthew Dillon #define WPI_RXON_SHPREAMBLE (1 << 5) 392*7370bffcSMatthew Dillon #define WPI_RXON_NODIVERSITY (1 << 7) 393*7370bffcSMatthew Dillon #define WPI_RXON_ANTENNA_A (1 << 8) 394*7370bffcSMatthew Dillon #define WPI_RXON_ANTENNA_B (1 << 9) 395*7370bffcSMatthew Dillon #define WPI_RXON_TSF (1 << 15) 396*7370bffcSMatthew Dillon #define WPI_RXON_CTS_TO_SELF (1 << 30) 3974db7dd1bSJoe Talbott 3984db7dd1bSJoe Talbott uint32_t filter; 3994db7dd1bSJoe Talbott #define WPI_FILTER_PROMISC (1 << 0) 4004db7dd1bSJoe Talbott #define WPI_FILTER_CTL (1 << 1) 4014db7dd1bSJoe Talbott #define WPI_FILTER_MULTICAST (1 << 2) 4024db7dd1bSJoe Talbott #define WPI_FILTER_NODECRYPT (1 << 3) 4034db7dd1bSJoe Talbott #define WPI_FILTER_BSS (1 << 5) 4044db7dd1bSJoe Talbott #define WPI_FILTER_BEACON (1 << 6) 405*7370bffcSMatthew Dillon #define WPI_FILTER_ASSOC (1 << 7) /* Accept associaton requests. */ 4064db7dd1bSJoe Talbott 4074db7dd1bSJoe Talbott uint8_t chan; 408*7370bffcSMatthew Dillon uint16_t reserved5; 4094db7dd1bSJoe Talbott } __packed; 4104db7dd1bSJoe Talbott 411*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_RXON_ASSOC. */ 4124db7dd1bSJoe Talbott struct wpi_assoc { 4134db7dd1bSJoe Talbott uint32_t flags; 4144db7dd1bSJoe Talbott uint32_t filter; 4154db7dd1bSJoe Talbott uint8_t ofdm_mask; 4164db7dd1bSJoe Talbott uint8_t cck_mask; 4174db7dd1bSJoe Talbott uint16_t reserved; 4184db7dd1bSJoe Talbott } __packed; 4194db7dd1bSJoe Talbott 420*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_EDCA_PARAMS. */ 421*7370bffcSMatthew Dillon struct wpi_edca_params { 4224db7dd1bSJoe Talbott uint32_t flags; 423*7370bffcSMatthew Dillon #define WPI_EDCA_UPDATE (1 << 0) 424*7370bffcSMatthew Dillon 4254db7dd1bSJoe Talbott struct { 4264db7dd1bSJoe Talbott uint16_t cwmin; 4274db7dd1bSJoe Talbott uint16_t cwmax; 4284db7dd1bSJoe Talbott uint8_t aifsn; 4294db7dd1bSJoe Talbott uint8_t reserved; 430*7370bffcSMatthew Dillon uint16_t txoplimit; 4314db7dd1bSJoe Talbott } __packed ac[WME_NUM_AC]; 4324db7dd1bSJoe Talbott } __packed; 4334db7dd1bSJoe Talbott 434*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_TIMING. */ 435*7370bffcSMatthew Dillon struct wpi_cmd_timing { 4364db7dd1bSJoe Talbott uint64_t tstamp; 4374db7dd1bSJoe Talbott uint16_t bintval; 4384db7dd1bSJoe Talbott uint16_t atim; 4394db7dd1bSJoe Talbott uint32_t binitval; 4404db7dd1bSJoe Talbott uint16_t lintval; 4414db7dd1bSJoe Talbott uint16_t reserved; 4424db7dd1bSJoe Talbott } __packed; 4434db7dd1bSJoe Talbott 444*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_ADD_NODE. */ 4454db7dd1bSJoe Talbott struct wpi_node_info { 4464db7dd1bSJoe Talbott uint8_t control; 4474db7dd1bSJoe Talbott #define WPI_NODE_UPDATE (1 << 0) 4484db7dd1bSJoe Talbott 4494db7dd1bSJoe Talbott uint8_t reserved1[3]; 450*7370bffcSMatthew Dillon uint8_t macaddr[IEEE80211_ADDR_LEN]; 4514db7dd1bSJoe Talbott uint16_t reserved2; 4524db7dd1bSJoe Talbott uint8_t id; 4534db7dd1bSJoe Talbott #define WPI_ID_BSS 0 454*7370bffcSMatthew Dillon #define WPI_ID_IBSS_MIN 2 455*7370bffcSMatthew Dillon #define WPI_ID_IBSS_MAX 23 4564db7dd1bSJoe Talbott #define WPI_ID_BROADCAST 24 457*7370bffcSMatthew Dillon #define WPI_ID_UNDEFINED (uint8_t)-1 4584db7dd1bSJoe Talbott 4594db7dd1bSJoe Talbott uint8_t flags; 460*7370bffcSMatthew Dillon #define WPI_FLAG_KEY_SET (1 << 0) 461*7370bffcSMatthew Dillon 4624db7dd1bSJoe Talbott uint16_t reserved3; 463*7370bffcSMatthew Dillon uint16_t kflags; 464*7370bffcSMatthew Dillon #define WPI_KFLAG_CCMP (1 << 1) 465*7370bffcSMatthew Dillon #define WPI_KFLAG_KID(kid) ((kid) << 8) 466*7370bffcSMatthew Dillon #define WPI_KFLAG_MULTICAST (1 << 14) 467*7370bffcSMatthew Dillon 468*7370bffcSMatthew Dillon uint8_t tsc2; 4694db7dd1bSJoe Talbott uint8_t reserved4; 4704db7dd1bSJoe Talbott uint16_t ttak[5]; 4714db7dd1bSJoe Talbott uint16_t reserved5; 4724db7dd1bSJoe Talbott uint8_t key[IEEE80211_KEYBUF_SIZE]; 4734db7dd1bSJoe Talbott uint32_t action; 474*7370bffcSMatthew Dillon #define WPI_ACTION_SET_RATE (1 << 2) 475*7370bffcSMatthew Dillon 4764db7dd1bSJoe Talbott uint32_t mask; 4774db7dd1bSJoe Talbott uint16_t tid; 478*7370bffcSMatthew Dillon uint8_t plcp; 4794db7dd1bSJoe Talbott uint8_t antenna; 4804db7dd1bSJoe Talbott #define WPI_ANTENNA_A (1 << 6) 4814db7dd1bSJoe Talbott #define WPI_ANTENNA_B (1 << 7) 4824db7dd1bSJoe Talbott #define WPI_ANTENNA_BOTH (WPI_ANTENNA_A | WPI_ANTENNA_B) 483*7370bffcSMatthew Dillon 4844db7dd1bSJoe Talbott uint8_t add_imm; 4854db7dd1bSJoe Talbott uint8_t del_imm; 4864db7dd1bSJoe Talbott uint16_t add_imm_start; 4874db7dd1bSJoe Talbott } __packed; 4884db7dd1bSJoe Talbott 489*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_DEL_NODE. */ 490*7370bffcSMatthew Dillon struct wpi_cmd_del_node { 491*7370bffcSMatthew Dillon uint8_t count; 492*7370bffcSMatthew Dillon uint8_t reserved1[3]; 493*7370bffcSMatthew Dillon uint8_t macaddr[IEEE80211_ADDR_LEN]; 494*7370bffcSMatthew Dillon uint16_t reserved2; 495*7370bffcSMatthew Dillon } __packed; 496*7370bffcSMatthew Dillon 497*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_TX_DATA. */ 4984db7dd1bSJoe Talbott struct wpi_cmd_data { 4994db7dd1bSJoe Talbott uint16_t len; 5004db7dd1bSJoe Talbott uint16_t lnext; 5014db7dd1bSJoe Talbott uint32_t flags; 5024db7dd1bSJoe Talbott #define WPI_TX_NEED_RTS (1 << 1) 5034db7dd1bSJoe Talbott #define WPI_TX_NEED_CTS (1 << 2) 5044db7dd1bSJoe Talbott #define WPI_TX_NEED_ACK (1 << 3) 5054db7dd1bSJoe Talbott #define WPI_TX_FULL_TXOP (1 << 7) 5064db7dd1bSJoe Talbott #define WPI_TX_BT_DISABLE (1 << 12) /* bluetooth coexistence */ 5074db7dd1bSJoe Talbott #define WPI_TX_AUTO_SEQ (1 << 13) 508*7370bffcSMatthew Dillon #define WPI_TX_MORE_FRAG (1 << 14) 5094db7dd1bSJoe Talbott #define WPI_TX_INSERT_TSTAMP (1 << 16) 5104db7dd1bSJoe Talbott 511*7370bffcSMatthew Dillon uint8_t plcp; 5124db7dd1bSJoe Talbott uint8_t id; 5134db7dd1bSJoe Talbott uint8_t tid; 5144db7dd1bSJoe Talbott uint8_t security; 515*7370bffcSMatthew Dillon #define WPI_CIPHER_WEP 1 516*7370bffcSMatthew Dillon #define WPI_CIPHER_CCMP 2 517*7370bffcSMatthew Dillon #define WPI_CIPHER_TKIP 3 518*7370bffcSMatthew Dillon #define WPI_CIPHER_WEP104 9 519*7370bffcSMatthew Dillon 5204db7dd1bSJoe Talbott uint8_t key[IEEE80211_KEYBUF_SIZE]; 5214db7dd1bSJoe Talbott uint8_t tkip[IEEE80211_WEP_MICLEN]; 5224db7dd1bSJoe Talbott uint32_t fnext; 523*7370bffcSMatthew Dillon #define WPI_NEXT_STA_ID(id) ((id) << 8) 524*7370bffcSMatthew Dillon 5254db7dd1bSJoe Talbott uint32_t lifetime; 5264db7dd1bSJoe Talbott #define WPI_LIFETIME_INFINITE 0xffffffff 527*7370bffcSMatthew Dillon 5284db7dd1bSJoe Talbott uint8_t ofdm_mask; 5294db7dd1bSJoe Talbott uint8_t cck_mask; 5304db7dd1bSJoe Talbott uint8_t rts_ntries; 5314db7dd1bSJoe Talbott uint8_t data_ntries; 5324db7dd1bSJoe Talbott uint16_t timeout; 5334db7dd1bSJoe Talbott uint16_t txop; 5344db7dd1bSJoe Talbott } __packed; 5354db7dd1bSJoe Talbott 536*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_SET_BEACON. */ 5374db7dd1bSJoe Talbott struct wpi_cmd_beacon { 5384db7dd1bSJoe Talbott uint16_t len; 5394db7dd1bSJoe Talbott uint16_t reserved1; 5404db7dd1bSJoe Talbott uint32_t flags; /* same as wpi_cmd_data */ 541*7370bffcSMatthew Dillon uint8_t plcp; 5424db7dd1bSJoe Talbott uint8_t id; 5434db7dd1bSJoe Talbott uint8_t reserved2[30]; 5444db7dd1bSJoe Talbott uint32_t lifetime; 5454db7dd1bSJoe Talbott uint8_t ofdm_mask; 5464db7dd1bSJoe Talbott uint8_t cck_mask; 5474db7dd1bSJoe Talbott uint16_t reserved3[3]; 5484db7dd1bSJoe Talbott uint16_t tim; 5494db7dd1bSJoe Talbott uint8_t timsz; 5504db7dd1bSJoe Talbott uint8_t reserved4; 5514db7dd1bSJoe Talbott } __packed; 5524db7dd1bSJoe Talbott 553*7370bffcSMatthew Dillon /* Structure for notification WPI_BEACON_MISSED. */ 554*7370bffcSMatthew Dillon struct wpi_beacon_missed { 5554db7dd1bSJoe Talbott uint32_t consecutive; 5564db7dd1bSJoe Talbott uint32_t total; 5574db7dd1bSJoe Talbott uint32_t expected; 5584db7dd1bSJoe Talbott uint32_t received; 5594db7dd1bSJoe Talbott } __packed; 5604db7dd1bSJoe Talbott 5614db7dd1bSJoe Talbott 562*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_MRR_SETUP. */ 563*7370bffcSMatthew Dillon #define WPI_RIDX_MAX 11 5644db7dd1bSJoe Talbott struct wpi_mrr_setup { 565*7370bffcSMatthew Dillon uint32_t which; 5664db7dd1bSJoe Talbott #define WPI_MRR_CTL 0 5674db7dd1bSJoe Talbott #define WPI_MRR_DATA 1 5684db7dd1bSJoe Talbott 5694db7dd1bSJoe Talbott struct { 570*7370bffcSMatthew Dillon uint8_t plcp; 5714db7dd1bSJoe Talbott uint8_t flags; 5724db7dd1bSJoe Talbott uint8_t ntries; 573*7370bffcSMatthew Dillon #define WPI_NTRIES_DEFAULT 2 5744db7dd1bSJoe Talbott 575*7370bffcSMatthew Dillon uint8_t next; 576*7370bffcSMatthew Dillon } __packed rates[WPI_RIDX_MAX + 1]; 5774db7dd1bSJoe Talbott } __packed; 5784db7dd1bSJoe Talbott 579*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_SET_LED. */ 5804db7dd1bSJoe Talbott struct wpi_cmd_led { 5814db7dd1bSJoe Talbott uint32_t unit; /* multiplier (in usecs) */ 5824db7dd1bSJoe Talbott uint8_t which; 5834db7dd1bSJoe Talbott #define WPI_LED_ACTIVITY 1 5844db7dd1bSJoe Talbott #define WPI_LED_LINK 2 5854db7dd1bSJoe Talbott 5864db7dd1bSJoe Talbott uint8_t off; 5874db7dd1bSJoe Talbott uint8_t on; 5884db7dd1bSJoe Talbott uint8_t reserved; 5894db7dd1bSJoe Talbott } __packed; 5904db7dd1bSJoe Talbott 591*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_SET_POWER_MODE. */ 592*7370bffcSMatthew Dillon struct wpi_pmgt_cmd { 593*7370bffcSMatthew Dillon uint16_t flags; 594*7370bffcSMatthew Dillon #define WPI_PS_ALLOW_SLEEP (1 << 0) 595*7370bffcSMatthew Dillon #define WPI_PS_NOTIFY (1 << 1) 596*7370bffcSMatthew Dillon #define WPI_PS_SLEEP_OVER_DTIM (1 << 2) 597*7370bffcSMatthew Dillon #define WPI_PS_PCI_PMGT (1 << 3) 598*7370bffcSMatthew Dillon 599*7370bffcSMatthew Dillon uint8_t reserved[2]; 600*7370bffcSMatthew Dillon uint32_t rxtimeout; 601*7370bffcSMatthew Dillon uint32_t txtimeout; 602*7370bffcSMatthew Dillon uint32_t intval[5]; 6034db7dd1bSJoe Talbott } __packed; 6044db7dd1bSJoe Talbott 605*7370bffcSMatthew Dillon /* Structures for command WPI_CMD_SCAN. */ 606*7370bffcSMatthew Dillon #define WPI_SCAN_MAX_ESSIDS 4 607*7370bffcSMatthew Dillon struct wpi_scan_essid { 608*7370bffcSMatthew Dillon uint8_t id; 609*7370bffcSMatthew Dillon uint8_t len; 610*7370bffcSMatthew Dillon uint8_t data[IEEE80211_NWID_LEN]; 611*7370bffcSMatthew Dillon } __packed; 612*7370bffcSMatthew Dillon 6134db7dd1bSJoe Talbott struct wpi_scan_hdr { 6144db7dd1bSJoe Talbott uint16_t len; 6154db7dd1bSJoe Talbott uint8_t reserved1; 6164db7dd1bSJoe Talbott uint8_t nchan; 617*7370bffcSMatthew Dillon uint16_t quiet_time; /* timeout in milliseconds */ 618*7370bffcSMatthew Dillon #define WPI_QUIET_TIME_DEFAULT 10 619*7370bffcSMatthew Dillon 620*7370bffcSMatthew Dillon uint16_t quiet_threshold; /* min # of packets */ 621*7370bffcSMatthew Dillon uint16_t crc_threshold; 6224db7dd1bSJoe Talbott uint16_t reserved2; 623*7370bffcSMatthew Dillon uint32_t max_svc; /* background scans */ 624*7370bffcSMatthew Dillon uint32_t pause_svc; /* background scans */ 625*7370bffcSMatthew Dillon #define WPI_PAUSE_MAX_TIME ((1 << 20) - 1) 626*7370bffcSMatthew Dillon #define WPI_PAUSE_SCAN(nbeacons, time) ((nbeacons << 24) | time) 627*7370bffcSMatthew Dillon 6284db7dd1bSJoe Talbott uint32_t flags; 6294db7dd1bSJoe Talbott uint32_t filter; 6304db7dd1bSJoe Talbott 631*7370bffcSMatthew Dillon /* Followed by a struct wpi_cmd_data. */ 632*7370bffcSMatthew Dillon /* Followed by an array of 4 structs wpi_scan_essid. */ 633*7370bffcSMatthew Dillon /* Followed by probe request body. */ 634*7370bffcSMatthew Dillon /* Followed by an array of ``nchan'' structs wpi_scan_chan. */ 6354db7dd1bSJoe Talbott } __packed; 6364db7dd1bSJoe Talbott 6374db7dd1bSJoe Talbott struct wpi_scan_chan { 6384db7dd1bSJoe Talbott uint8_t flags; 6394db7dd1bSJoe Talbott #define WPI_CHAN_ACTIVE (1 << 0) 640*7370bffcSMatthew Dillon #define WPI_CHAN_NPBREQS(x) (((1 << (x)) - 1) << 1) 641*7370bffcSMatthew Dillon 642*7370bffcSMatthew Dillon uint8_t chan; 643*7370bffcSMatthew Dillon uint8_t rf_gain; 644*7370bffcSMatthew Dillon uint8_t dsp_gain; 6454db7dd1bSJoe Talbott uint16_t active; /* msecs */ 6464db7dd1bSJoe Talbott uint16_t passive; /* msecs */ 6474db7dd1bSJoe Talbott } __packed; 6484db7dd1bSJoe Talbott 649*7370bffcSMatthew Dillon #define WPI_SCAN_CRC_TH_DEFAULT htole16(1) 650*7370bffcSMatthew Dillon #define WPI_SCAN_CRC_TH_NEVER htole16(0xffff) 651*7370bffcSMatthew Dillon 652*7370bffcSMatthew Dillon /* Maximum size of a scan command. */ 653*7370bffcSMatthew Dillon #define WPI_SCAN_MAXSZ (MCLBYTES - 4) 654*7370bffcSMatthew Dillon 655*7370bffcSMatthew Dillon #define WPI_ACTIVE_DWELL_TIME_2GHZ (30) /* all times in msec */ 656*7370bffcSMatthew Dillon #define WPI_ACTIVE_DWELL_TIME_5GHZ (20) 657*7370bffcSMatthew Dillon #define WPI_ACTIVE_DWELL_FACTOR_2GHZ ( 3) 658*7370bffcSMatthew Dillon #define WPI_ACTIVE_DWELL_FACTOR_5GHZ ( 2) 659*7370bffcSMatthew Dillon 660*7370bffcSMatthew Dillon #define WPI_PASSIVE_DWELL_TIME_2GHZ ( 20) 661*7370bffcSMatthew Dillon #define WPI_PASSIVE_DWELL_TIME_5GHZ ( 10) 662*7370bffcSMatthew Dillon #define WPI_PASSIVE_DWELL_BASE (100) 663*7370bffcSMatthew Dillon #define WPI_CHANNEL_TUNE_TIME ( 6) 664*7370bffcSMatthew Dillon 665*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_TXPOWER. */ 666*7370bffcSMatthew Dillon struct wpi_cmd_txpower { 667*7370bffcSMatthew Dillon uint8_t band; 668*7370bffcSMatthew Dillon #define WPI_BAND_5GHZ 0 669*7370bffcSMatthew Dillon #define WPI_BAND_2GHZ 1 670*7370bffcSMatthew Dillon 671*7370bffcSMatthew Dillon uint8_t reserved; 672*7370bffcSMatthew Dillon uint16_t chan; 673*7370bffcSMatthew Dillon 674*7370bffcSMatthew Dillon struct { 675*7370bffcSMatthew Dillon uint8_t plcp; 676*7370bffcSMatthew Dillon uint8_t rf_gain; 677*7370bffcSMatthew Dillon uint8_t dsp_gain; 678*7370bffcSMatthew Dillon uint8_t reserved; 679*7370bffcSMatthew Dillon } __packed rates[WPI_RIDX_MAX + 1]; 680*7370bffcSMatthew Dillon 681*7370bffcSMatthew Dillon } __packed; 682*7370bffcSMatthew Dillon 683*7370bffcSMatthew Dillon /* Structure for command WPI_CMD_BT_COEX. */ 6844db7dd1bSJoe Talbott struct wpi_bluetooth { 6854db7dd1bSJoe Talbott uint8_t flags; 686*7370bffcSMatthew Dillon #define WPI_BT_COEX_DISABLE 0 687*7370bffcSMatthew Dillon #define WPI_BT_COEX_MODE_2WIRE 1 688*7370bffcSMatthew Dillon #define WPI_BT_COEX_MODE_3WIRE 2 689*7370bffcSMatthew Dillon #define WPI_BT_COEX_MODE_4WIRE 3 690*7370bffcSMatthew Dillon 691*7370bffcSMatthew Dillon uint8_t lead_time; 692*7370bffcSMatthew Dillon #define WPI_BT_LEAD_TIME_DEF 30 693*7370bffcSMatthew Dillon 694*7370bffcSMatthew Dillon uint8_t max_kill; 695*7370bffcSMatthew Dillon #define WPI_BT_MAX_KILL_DEF 5 696*7370bffcSMatthew Dillon 6974db7dd1bSJoe Talbott uint8_t reserved; 698*7370bffcSMatthew Dillon uint32_t kill_ack; 699*7370bffcSMatthew Dillon uint32_t kill_cts; 7004db7dd1bSJoe Talbott } __packed; 7014db7dd1bSJoe Talbott 702*7370bffcSMatthew Dillon /* Structure for WPI_UC_READY notification. */ 7034db7dd1bSJoe Talbott struct wpi_ucode_info { 704*7370bffcSMatthew Dillon uint8_t minor; 705*7370bffcSMatthew Dillon uint8_t major; 706*7370bffcSMatthew Dillon uint16_t reserved1; 7074db7dd1bSJoe Talbott uint8_t revision[8]; 7084db7dd1bSJoe Talbott uint8_t type; 7094db7dd1bSJoe Talbott uint8_t subtype; 710*7370bffcSMatthew Dillon uint16_t reserved2; 7114db7dd1bSJoe Talbott uint32_t logptr; 712*7370bffcSMatthew Dillon uint32_t errptr; 713*7370bffcSMatthew Dillon uint32_t tstamp; 7144db7dd1bSJoe Talbott uint32_t valid; 7154db7dd1bSJoe Talbott } __packed; 7164db7dd1bSJoe Talbott 717*7370bffcSMatthew Dillon /* Structure for WPI_START_SCAN notification. */ 7184db7dd1bSJoe Talbott struct wpi_start_scan { 7194db7dd1bSJoe Talbott uint64_t tstamp; 7204db7dd1bSJoe Talbott uint32_t tbeacon; 7214db7dd1bSJoe Talbott uint8_t chan; 7224db7dd1bSJoe Talbott uint8_t band; 7234db7dd1bSJoe Talbott uint16_t reserved; 7244db7dd1bSJoe Talbott uint32_t status; 7254db7dd1bSJoe Talbott } __packed; 7264db7dd1bSJoe Talbott 727*7370bffcSMatthew Dillon /* Structure for WPI_STOP_SCAN notification. */ 7284db7dd1bSJoe Talbott struct wpi_stop_scan { 7294db7dd1bSJoe Talbott uint8_t nchan; 7304db7dd1bSJoe Talbott uint8_t status; 731*7370bffcSMatthew Dillon #define WPI_SCAN_COMPLETED 1 732*7370bffcSMatthew Dillon #define WPI_SCAN_ABORTED 2 733*7370bffcSMatthew Dillon 7344db7dd1bSJoe Talbott uint8_t reserved; 7354db7dd1bSJoe Talbott uint8_t chan; 7364db7dd1bSJoe Talbott uint64_t tsf; 7374db7dd1bSJoe Talbott } __packed; 7384db7dd1bSJoe Talbott 739*7370bffcSMatthew Dillon /* Structures for WPI_{RX,BEACON}_STATISTICS notification. */ 740*7370bffcSMatthew Dillon struct wpi_rx_phy_stats { 741*7370bffcSMatthew Dillon uint32_t ina; 742*7370bffcSMatthew Dillon uint32_t fina; 743*7370bffcSMatthew Dillon uint32_t bad_plcp; 744*7370bffcSMatthew Dillon uint32_t bad_crc32; 745*7370bffcSMatthew Dillon uint32_t overrun; 746*7370bffcSMatthew Dillon uint32_t eoverrun; 747*7370bffcSMatthew Dillon uint32_t good_crc32; 748*7370bffcSMatthew Dillon uint32_t fa; 749*7370bffcSMatthew Dillon uint32_t bad_fina_sync; 750*7370bffcSMatthew Dillon uint32_t sfd_timeout; 751*7370bffcSMatthew Dillon uint32_t fina_timeout; 752*7370bffcSMatthew Dillon uint32_t no_rts_ack; 753*7370bffcSMatthew Dillon uint32_t rxe_limit; 754*7370bffcSMatthew Dillon uint32_t ack; 755*7370bffcSMatthew Dillon uint32_t cts; 756*7370bffcSMatthew Dillon } __packed; 757*7370bffcSMatthew Dillon 758*7370bffcSMatthew Dillon struct wpi_rx_general_stats { 759*7370bffcSMatthew Dillon uint32_t bad_cts; 760*7370bffcSMatthew Dillon uint32_t bad_ack; 761*7370bffcSMatthew Dillon uint32_t not_bss; 762*7370bffcSMatthew Dillon uint32_t filtered; 763*7370bffcSMatthew Dillon uint32_t bad_chan; 764*7370bffcSMatthew Dillon } __packed; 765*7370bffcSMatthew Dillon 766*7370bffcSMatthew Dillon struct wpi_rx_stats { 767*7370bffcSMatthew Dillon struct wpi_rx_phy_stats ofdm; 768*7370bffcSMatthew Dillon struct wpi_rx_phy_stats cck; 769*7370bffcSMatthew Dillon struct wpi_rx_general_stats general; 770*7370bffcSMatthew Dillon } __packed; 771*7370bffcSMatthew Dillon 772*7370bffcSMatthew Dillon struct wpi_tx_stats { 773*7370bffcSMatthew Dillon uint32_t preamble; 774*7370bffcSMatthew Dillon uint32_t rx_detected; 775*7370bffcSMatthew Dillon uint32_t bt_defer; 776*7370bffcSMatthew Dillon uint32_t bt_kill; 777*7370bffcSMatthew Dillon uint32_t short_len; 778*7370bffcSMatthew Dillon uint32_t cts_timeout; 779*7370bffcSMatthew Dillon uint32_t ack_timeout; 780*7370bffcSMatthew Dillon uint32_t exp_ack; 781*7370bffcSMatthew Dillon uint32_t ack; 782*7370bffcSMatthew Dillon } __packed; 783*7370bffcSMatthew Dillon 784*7370bffcSMatthew Dillon struct wpi_general_stats { 785*7370bffcSMatthew Dillon uint32_t temp; 786*7370bffcSMatthew Dillon uint32_t burst_check; 787*7370bffcSMatthew Dillon uint32_t burst; 788*7370bffcSMatthew Dillon uint32_t reserved[4]; 789*7370bffcSMatthew Dillon uint32_t sleep; 790*7370bffcSMatthew Dillon uint32_t slot_out; 791*7370bffcSMatthew Dillon uint32_t slot_idle; 792*7370bffcSMatthew Dillon uint32_t ttl_tstamp; 793*7370bffcSMatthew Dillon uint32_t tx_ant_a; 794*7370bffcSMatthew Dillon uint32_t tx_ant_b; 795*7370bffcSMatthew Dillon uint32_t exec; 796*7370bffcSMatthew Dillon uint32_t probe; 797*7370bffcSMatthew Dillon } __packed; 798*7370bffcSMatthew Dillon 799*7370bffcSMatthew Dillon struct wpi_stats { 800*7370bffcSMatthew Dillon uint32_t flags; 801*7370bffcSMatthew Dillon struct wpi_rx_stats rx; 802*7370bffcSMatthew Dillon struct wpi_tx_stats tx; 803*7370bffcSMatthew Dillon struct wpi_general_stats general; 804*7370bffcSMatthew Dillon } __packed; 805*7370bffcSMatthew Dillon 806*7370bffcSMatthew Dillon /* Possible flags for command WPI_CMD_GET_STATISTICS. */ 807*7370bffcSMatthew Dillon #define WPI_STATISTICS_BEACON_DISABLE (1 << 1) 808*7370bffcSMatthew Dillon 809*7370bffcSMatthew Dillon 810*7370bffcSMatthew Dillon /* Firmware error dump entry. */ 811*7370bffcSMatthew Dillon struct wpi_fw_dump { 812*7370bffcSMatthew Dillon uint32_t desc; 813*7370bffcSMatthew Dillon uint32_t time; 814*7370bffcSMatthew Dillon uint32_t blink[2]; 815*7370bffcSMatthew Dillon uint32_t ilink[2]; 816*7370bffcSMatthew Dillon uint32_t data; 817*7370bffcSMatthew Dillon } __packed; 818*7370bffcSMatthew Dillon 819*7370bffcSMatthew Dillon /* Firmware image file header. */ 820*7370bffcSMatthew Dillon struct wpi_firmware_hdr { 821*7370bffcSMatthew Dillon 822*7370bffcSMatthew Dillon #define WPI_FW_MINVERSION 2144 823*7370bffcSMatthew Dillon #define WPI_FW_NAME "wpifw" 824*7370bffcSMatthew Dillon 825*7370bffcSMatthew Dillon uint16_t driver; 826*7370bffcSMatthew Dillon uint8_t minor; 827*7370bffcSMatthew Dillon uint8_t major; 828*7370bffcSMatthew Dillon uint32_t rtextsz; 829*7370bffcSMatthew Dillon uint32_t rdatasz; 830*7370bffcSMatthew Dillon uint32_t itextsz; 831*7370bffcSMatthew Dillon uint32_t idatasz; 832*7370bffcSMatthew Dillon uint32_t btextsz; 833*7370bffcSMatthew Dillon } __packed; 834*7370bffcSMatthew Dillon 835*7370bffcSMatthew Dillon #define WPI_FW_TEXT_MAXSZ ( 80 * 1024 ) 836*7370bffcSMatthew Dillon #define WPI_FW_DATA_MAXSZ ( 32 * 1024 ) 837*7370bffcSMatthew Dillon #define WPI_FW_BOOT_TEXT_MAXSZ 1024 838*7370bffcSMatthew Dillon 839*7370bffcSMatthew Dillon #define WPI_FW_UPDATED (1U << 31 ) 840*7370bffcSMatthew Dillon 841*7370bffcSMatthew Dillon /* 842*7370bffcSMatthew Dillon * Offsets into EEPROM. 843*7370bffcSMatthew Dillon */ 8444db7dd1bSJoe Talbott #define WPI_EEPROM_MAC 0x015 8454db7dd1bSJoe Talbott #define WPI_EEPROM_REVISION 0x035 846*7370bffcSMatthew Dillon #define WPI_EEPROM_SKU_CAP 0x045 8474db7dd1bSJoe Talbott #define WPI_EEPROM_TYPE 0x04a 8484db7dd1bSJoe Talbott #define WPI_EEPROM_DOMAIN 0x060 8494db7dd1bSJoe Talbott #define WPI_EEPROM_BAND1 0x063 8504db7dd1bSJoe Talbott #define WPI_EEPROM_BAND2 0x072 8514db7dd1bSJoe Talbott #define WPI_EEPROM_BAND3 0x080 8524db7dd1bSJoe Talbott #define WPI_EEPROM_BAND4 0x08d 8534db7dd1bSJoe Talbott #define WPI_EEPROM_BAND5 0x099 8544db7dd1bSJoe Talbott #define WPI_EEPROM_POWER_GRP 0x100 8554db7dd1bSJoe Talbott 8564db7dd1bSJoe Talbott struct wpi_eeprom_chan { 8574db7dd1bSJoe Talbott uint8_t flags; 8584db7dd1bSJoe Talbott #define WPI_EEPROM_CHAN_VALID (1 << 0) 8594db7dd1bSJoe Talbott #define WPI_EEPROM_CHAN_IBSS (1 << 1) 8604db7dd1bSJoe Talbott #define WPI_EEPROM_CHAN_ACTIVE (1 << 3) 8614db7dd1bSJoe Talbott #define WPI_EEPROM_CHAN_RADAR (1 << 4) 8624db7dd1bSJoe Talbott 8634db7dd1bSJoe Talbott int8_t maxpwr; 8644db7dd1bSJoe Talbott } __packed; 8654db7dd1bSJoe Talbott 8664db7dd1bSJoe Talbott struct wpi_eeprom_sample { 8674db7dd1bSJoe Talbott uint8_t index; 8684db7dd1bSJoe Talbott int8_t power; 8694db7dd1bSJoe Talbott uint16_t volt; 870*7370bffcSMatthew Dillon } __packed; 8714db7dd1bSJoe Talbott 8724db7dd1bSJoe Talbott #define WPI_POWER_GROUPS_COUNT 5 8734db7dd1bSJoe Talbott struct wpi_eeprom_group { 8744db7dd1bSJoe Talbott struct wpi_eeprom_sample samples[5]; 8754db7dd1bSJoe Talbott int32_t coef[5]; 8764db7dd1bSJoe Talbott int32_t corr[5]; 8774db7dd1bSJoe Talbott int8_t maxpwr; 8784db7dd1bSJoe Talbott uint8_t chan; 8794db7dd1bSJoe Talbott int16_t temp; 8804db7dd1bSJoe Talbott } __packed; 8814db7dd1bSJoe Talbott 8824db7dd1bSJoe Talbott #define WPI_CHAN_BANDS_COUNT 5 8834db7dd1bSJoe Talbott #define WPI_MAX_CHAN_PER_BAND 14 8844db7dd1bSJoe Talbott static const struct wpi_chan_band { 8854db7dd1bSJoe Talbott uint32_t addr; /* offset in EEPROM */ 8864db7dd1bSJoe Talbott uint8_t nchan; 8874db7dd1bSJoe Talbott uint8_t chan[WPI_MAX_CHAN_PER_BAND]; 888*7370bffcSMatthew Dillon } wpi_bands[] = { 889*7370bffcSMatthew Dillon /* 20MHz channels, 2GHz band. */ 8904db7dd1bSJoe Talbott { WPI_EEPROM_BAND1, 14, 8914db7dd1bSJoe Talbott { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 } }, 892*7370bffcSMatthew Dillon /* 20MHz channels, 5GHz band. */ 8934db7dd1bSJoe Talbott { WPI_EEPROM_BAND2, 13, 8944db7dd1bSJoe Talbott { 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 } }, 8954db7dd1bSJoe Talbott { WPI_EEPROM_BAND3, 12, 8964db7dd1bSJoe Talbott { 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 } }, 8974db7dd1bSJoe Talbott { WPI_EEPROM_BAND4, 11, 8984db7dd1bSJoe Talbott { 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 } }, 8994db7dd1bSJoe Talbott { WPI_EEPROM_BAND5, 6, 9004db7dd1bSJoe Talbott { 145, 149, 153, 157, 161, 165 } } 9014db7dd1bSJoe Talbott }; 9024db7dd1bSJoe Talbott 903*7370bffcSMatthew Dillon /* HW rate indices. */ 904*7370bffcSMatthew Dillon #define WPI_RIDX_OFDM6 0 905*7370bffcSMatthew Dillon #define WPI_RIDX_OFDM36 5 906*7370bffcSMatthew Dillon #define WPI_RIDX_OFDM48 6 907*7370bffcSMatthew Dillon #define WPI_RIDX_OFDM54 7 908*7370bffcSMatthew Dillon #define WPI_RIDX_CCK1 8 909*7370bffcSMatthew Dillon #define WPI_RIDX_CCK2 9 910*7370bffcSMatthew Dillon #define WPI_RIDX_CCK11 11 911*7370bffcSMatthew Dillon 912*7370bffcSMatthew Dillon static const uint8_t wpi_ridx_to_plcp[] = { 913*7370bffcSMatthew Dillon /* OFDM: IEEE Std 802.11a-1999, pp. 14 Table 80 */ 914*7370bffcSMatthew Dillon /* R1-R4 (ral/ural is R4-R1) */ 915*7370bffcSMatthew Dillon 0xd, 0xf, 0x5, 0x7, 0x9, 0xb, 0x1, 0x3, 916*7370bffcSMatthew Dillon /* CCK: device-dependent */ 917*7370bffcSMatthew Dillon 10, 20, 55, 110 918*7370bffcSMatthew Dillon }; 919*7370bffcSMatthew Dillon 9204db7dd1bSJoe Talbott #define WPI_MAX_PWR_INDEX 77 9214db7dd1bSJoe Talbott 9224db7dd1bSJoe Talbott /* 9234db7dd1bSJoe Talbott * RF Tx gain values from highest to lowest power (values obtained from 9244db7dd1bSJoe Talbott * the reference driver.) 9254db7dd1bSJoe Talbott */ 9264db7dd1bSJoe Talbott static const uint8_t wpi_rf_gain_2ghz[WPI_MAX_PWR_INDEX + 1] = { 9274db7dd1bSJoe Talbott 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xbb, 0xbb, 0xbb, 9284db7dd1bSJoe Talbott 0xbb, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xd3, 0xd3, 0xb3, 0xb3, 0xb3, 9294db7dd1bSJoe Talbott 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x73, 0xeb, 0xeb, 0xeb, 9304db7dd1bSJoe Talbott 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xab, 0xab, 0xab, 0x8b, 9314db7dd1bSJoe Talbott 0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0xc3, 0xc3, 0xc3, 0xc3, 0xa3, 9324db7dd1bSJoe Talbott 0xa3, 0xa3, 0xa3, 0x83, 0x83, 0x83, 0x83, 0x63, 0x63, 0x63, 0x63, 9334db7dd1bSJoe Talbott 0x43, 0x43, 0x43, 0x43, 0x23, 0x23, 0x23, 0x23, 0x03, 0x03, 0x03, 9344db7dd1bSJoe Talbott 0x03 9354db7dd1bSJoe Talbott }; 9364db7dd1bSJoe Talbott 9374db7dd1bSJoe Talbott static const uint8_t wpi_rf_gain_5ghz[WPI_MAX_PWR_INDEX + 1] = { 9384db7dd1bSJoe Talbott 0xfb, 0xfb, 0xfb, 0xdb, 0xdb, 0xbb, 0xbb, 0x9b, 0x9b, 0x7b, 0x7b, 9394db7dd1bSJoe Talbott 0x7b, 0x7b, 0x5b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x1b, 0x1b, 9404db7dd1bSJoe Talbott 0x1b, 0x73, 0x73, 0x73, 0x53, 0x53, 0x53, 0x53, 0x53, 0x33, 0x33, 9414db7dd1bSJoe Talbott 0x33, 0x33, 0x13, 0x13, 0x13, 0x13, 0x13, 0xab, 0xab, 0xab, 0x8b, 9424db7dd1bSJoe Talbott 0x8b, 0x8b, 0x8b, 0x6b, 0x6b, 0x6b, 0x6b, 0x4b, 0x4b, 0x4b, 0x4b, 9434db7dd1bSJoe Talbott 0x2b, 0x2b, 0x2b, 0x2b, 0x0b, 0x0b, 0x0b, 0x0b, 0x83, 0x83, 0x63, 9444db7dd1bSJoe Talbott 0x63, 0x63, 0x63, 0x43, 0x43, 0x43, 0x43, 0x23, 0x23, 0x23, 0x23, 9454db7dd1bSJoe Talbott 0x03 9464db7dd1bSJoe Talbott }; 9474db7dd1bSJoe Talbott 9484db7dd1bSJoe Talbott /* 9494db7dd1bSJoe Talbott * DSP pre-DAC gain values from highest to lowest power (values obtained 9504db7dd1bSJoe Talbott * from the reference driver.) 9514db7dd1bSJoe Talbott */ 9524db7dd1bSJoe Talbott static const uint8_t wpi_dsp_gain_2ghz[WPI_MAX_PWR_INDEX + 1] = { 9534db7dd1bSJoe Talbott 0x7f, 0x7f, 0x7f, 0x7f, 0x7d, 0x6e, 0x69, 0x62, 0x7d, 0x73, 0x6c, 9544db7dd1bSJoe Talbott 0x63, 0x77, 0x6f, 0x69, 0x61, 0x5c, 0x6a, 0x64, 0x78, 0x71, 0x6b, 9554db7dd1bSJoe Talbott 0x7d, 0x77, 0x70, 0x6a, 0x65, 0x61, 0x5b, 0x6b, 0x79, 0x73, 0x6d, 9564db7dd1bSJoe Talbott 0x7f, 0x79, 0x73, 0x6c, 0x66, 0x60, 0x5c, 0x6e, 0x68, 0x62, 0x74, 9574db7dd1bSJoe Talbott 0x7d, 0x77, 0x71, 0x6b, 0x65, 0x60, 0x71, 0x6a, 0x66, 0x5f, 0x71, 9584db7dd1bSJoe Talbott 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 9594db7dd1bSJoe Talbott 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 9604db7dd1bSJoe Talbott 0x5f 9614db7dd1bSJoe Talbott }; 9624db7dd1bSJoe Talbott 9634db7dd1bSJoe Talbott static const uint8_t wpi_dsp_gain_5ghz[WPI_MAX_PWR_INDEX + 1] = { 9644db7dd1bSJoe Talbott 0x7f, 0x78, 0x72, 0x77, 0x65, 0x71, 0x66, 0x72, 0x67, 0x75, 0x6b, 9654db7dd1bSJoe Talbott 0x63, 0x5c, 0x6c, 0x7d, 0x76, 0x6d, 0x66, 0x60, 0x5a, 0x68, 0x62, 9664db7dd1bSJoe Talbott 0x5c, 0x76, 0x6f, 0x68, 0x7e, 0x79, 0x71, 0x69, 0x63, 0x76, 0x6f, 9674db7dd1bSJoe Talbott 0x68, 0x62, 0x74, 0x6d, 0x66, 0x62, 0x5d, 0x71, 0x6b, 0x63, 0x78, 9684db7dd1bSJoe Talbott 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 9694db7dd1bSJoe Talbott 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x6b, 0x63, 0x78, 9704db7dd1bSJoe Talbott 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 9714db7dd1bSJoe Talbott 0x78 9724db7dd1bSJoe Talbott }; 9734db7dd1bSJoe Talbott 974*7370bffcSMatthew Dillon /* 975*7370bffcSMatthew Dillon * Power saving settings (values obtained from the reference driver.) 976*7370bffcSMatthew Dillon */ 977*7370bffcSMatthew Dillon #define WPI_NDTIMRANGES 2 978*7370bffcSMatthew Dillon #define WPI_NPOWERLEVELS 6 979*7370bffcSMatthew Dillon static const struct wpi_pmgt { 980*7370bffcSMatthew Dillon uint32_t rxtimeout; 981*7370bffcSMatthew Dillon uint32_t txtimeout; 982*7370bffcSMatthew Dillon uint32_t intval[5]; 983*7370bffcSMatthew Dillon uint8_t skip_dtim; 984*7370bffcSMatthew Dillon } wpi_pmgt[WPI_NDTIMRANGES][WPI_NPOWERLEVELS] = { 985*7370bffcSMatthew Dillon /* DTIM <= 10 */ 986*7370bffcSMatthew Dillon { 987*7370bffcSMatthew Dillon { 0, 0, { 0, 0, 0, 0, 0 }, 0 }, /* CAM */ 988*7370bffcSMatthew Dillon { 200, 500, { 1, 2, 3, 4, 4 }, 0 }, /* PS level 1 */ 989*7370bffcSMatthew Dillon { 200, 300, { 2, 4, 6, 7, 7 }, 0 }, /* PS level 2 */ 990*7370bffcSMatthew Dillon { 50, 100, { 2, 6, 9, 9, 10 }, 0 }, /* PS level 3 */ 991*7370bffcSMatthew Dillon { 50, 25, { 2, 7, 9, 9, 10 }, 1 }, /* PS level 4 */ 992*7370bffcSMatthew Dillon { 25, 25, { 4, 7, 10, 10, 10 }, 1 } /* PS level 5 */ 993*7370bffcSMatthew Dillon }, 994*7370bffcSMatthew Dillon /* DTIM >= 11 */ 995*7370bffcSMatthew Dillon { 996*7370bffcSMatthew Dillon { 0, 0, { 0, 0, 0, 0, 0 }, 0 }, /* CAM */ 997*7370bffcSMatthew Dillon { 200, 500, { 1, 2, 3, 4, -1 }, 0 }, /* PS level 1 */ 998*7370bffcSMatthew Dillon { 200, 300, { 2, 4, 6, 7, -1 }, 0 }, /* PS level 2 */ 999*7370bffcSMatthew Dillon { 50, 100, { 2, 6, 9, 9, -1 }, 0 }, /* PS level 3 */ 1000*7370bffcSMatthew Dillon { 50, 25, { 2, 7, 9, 9, -1 }, 0 }, /* PS level 4 */ 1001*7370bffcSMatthew Dillon { 25, 25, { 4, 7, 10, 10, -1 }, 0 } /* PS level 5 */ 1002*7370bffcSMatthew Dillon } 1003*7370bffcSMatthew Dillon }; 1004*7370bffcSMatthew Dillon 1005*7370bffcSMatthew Dillon /* Firmware errors. */ 1006*7370bffcSMatthew Dillon static const char * const wpi_fw_errmsg[] = { 1007*7370bffcSMatthew Dillon "OK", 1008*7370bffcSMatthew Dillon "FAIL", 1009*7370bffcSMatthew Dillon "BAD_PARAM", 1010*7370bffcSMatthew Dillon "BAD_CHECKSUM", 1011*7370bffcSMatthew Dillon "NMI_INTERRUPT", 1012*7370bffcSMatthew Dillon "SYSASSERT", 1013*7370bffcSMatthew Dillon "FATAL_ERROR" 1014*7370bffcSMatthew Dillon }; 10154db7dd1bSJoe Talbott 10164db7dd1bSJoe Talbott #define WPI_READ(sc, reg) \ 10174db7dd1bSJoe Talbott bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg)) 10184db7dd1bSJoe Talbott 10194db7dd1bSJoe Talbott #define WPI_WRITE(sc, reg, val) \ 10204db7dd1bSJoe Talbott bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val)) 10214db7dd1bSJoe Talbott 10224db7dd1bSJoe Talbott #define WPI_WRITE_REGION_4(sc, offset, datap, count) \ 10234db7dd1bSJoe Talbott bus_space_write_region_4((sc)->sc_st, (sc)->sc_sh, (offset), \ 10244db7dd1bSJoe Talbott (datap), (count)) 1025*7370bffcSMatthew Dillon 1026*7370bffcSMatthew Dillon #define WPI_SETBITS(sc, reg, mask) \ 1027*7370bffcSMatthew Dillon WPI_WRITE(sc, reg, WPI_READ(sc, reg) | (mask)) 1028*7370bffcSMatthew Dillon 1029*7370bffcSMatthew Dillon #define WPI_CLRBITS(sc, reg, mask) \ 1030*7370bffcSMatthew Dillon WPI_WRITE(sc, reg, WPI_READ(sc, reg) & ~(mask)) 1031*7370bffcSMatthew Dillon 1032*7370bffcSMatthew Dillon #define WPI_BARRIER_WRITE(sc) \ 1033*7370bffcSMatthew Dillon bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \ 1034*7370bffcSMatthew Dillon BUS_SPACE_BARRIER_WRITE) 1035*7370bffcSMatthew Dillon 1036*7370bffcSMatthew Dillon #define WPI_BARRIER_READ_WRITE(sc) \ 1037*7370bffcSMatthew Dillon bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \ 1038*7370bffcSMatthew Dillon BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE) 1039