1*277b024eSKalle Valo /* @file mwifiex_pcie.h 2*277b024eSKalle Valo * 3*277b024eSKalle Valo * @brief This file contains definitions for PCI-E interface. 4*277b024eSKalle Valo * driver. 5*277b024eSKalle Valo * 6*277b024eSKalle Valo * Copyright (C) 2011-2014, Marvell International Ltd. 7*277b024eSKalle Valo * 8*277b024eSKalle Valo * This software file (the "File") is distributed by Marvell International 9*277b024eSKalle Valo * Ltd. under the terms of the GNU General Public License Version 2, June 1991 10*277b024eSKalle Valo * (the "License"). You may use, redistribute and/or modify this File in 11*277b024eSKalle Valo * accordance with the terms and conditions of the License, a copy of which 12*277b024eSKalle Valo * is available by writing to the Free Software Foundation, Inc., 13*277b024eSKalle Valo * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 14*277b024eSKalle Valo * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 15*277b024eSKalle Valo * 16*277b024eSKalle Valo * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 17*277b024eSKalle Valo * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 18*277b024eSKalle Valo * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 19*277b024eSKalle Valo * this warranty disclaimer. 20*277b024eSKalle Valo */ 21*277b024eSKalle Valo 22*277b024eSKalle Valo #ifndef _MWIFIEX_PCIE_H 23*277b024eSKalle Valo #define _MWIFIEX_PCIE_H 24*277b024eSKalle Valo 25*277b024eSKalle Valo #include <linux/pci.h> 26*277b024eSKalle Valo #include <linux/pcieport_if.h> 27*277b024eSKalle Valo #include <linux/interrupt.h> 28*277b024eSKalle Valo 29*277b024eSKalle Valo #include "main.h" 30*277b024eSKalle Valo 31*277b024eSKalle Valo #define PCIE8766_DEFAULT_FW_NAME "mrvl/pcie8766_uapsta.bin" 32*277b024eSKalle Valo #define PCIE8897_DEFAULT_FW_NAME "mrvl/pcie8897_uapsta.bin" 33*277b024eSKalle Valo #define PCIE8997_DEFAULT_FW_NAME "mrvl/pcie8997_uapsta.bin" 34*277b024eSKalle Valo 35*277b024eSKalle Valo #define PCIE_VENDOR_ID_MARVELL (0x11ab) 36*277b024eSKalle Valo #define PCIE_DEVICE_ID_MARVELL_88W8766P (0x2b30) 37*277b024eSKalle Valo #define PCIE_DEVICE_ID_MARVELL_88W8897 (0x2b38) 38*277b024eSKalle Valo #define PCIE_DEVICE_ID_MARVELL_88W8997 (0x2b42) 39*277b024eSKalle Valo 40*277b024eSKalle Valo /* Constants for Buffer Descriptor (BD) rings */ 41*277b024eSKalle Valo #define MWIFIEX_MAX_TXRX_BD 0x20 42*277b024eSKalle Valo #define MWIFIEX_TXBD_MASK 0x3F 43*277b024eSKalle Valo #define MWIFIEX_RXBD_MASK 0x3F 44*277b024eSKalle Valo 45*277b024eSKalle Valo #define MWIFIEX_MAX_EVT_BD 0x08 46*277b024eSKalle Valo #define MWIFIEX_EVTBD_MASK 0x0f 47*277b024eSKalle Valo 48*277b024eSKalle Valo /* PCIE INTERNAL REGISTERS */ 49*277b024eSKalle Valo #define PCIE_SCRATCH_0_REG 0xC10 50*277b024eSKalle Valo #define PCIE_SCRATCH_1_REG 0xC14 51*277b024eSKalle Valo #define PCIE_CPU_INT_EVENT 0xC18 52*277b024eSKalle Valo #define PCIE_CPU_INT_STATUS 0xC1C 53*277b024eSKalle Valo #define PCIE_HOST_INT_STATUS 0xC30 54*277b024eSKalle Valo #define PCIE_HOST_INT_MASK 0xC34 55*277b024eSKalle Valo #define PCIE_HOST_INT_STATUS_MASK 0xC3C 56*277b024eSKalle Valo #define PCIE_SCRATCH_2_REG 0xC40 57*277b024eSKalle Valo #define PCIE_SCRATCH_3_REG 0xC44 58*277b024eSKalle Valo #define PCIE_SCRATCH_4_REG 0xCD0 59*277b024eSKalle Valo #define PCIE_SCRATCH_5_REG 0xCD4 60*277b024eSKalle Valo #define PCIE_SCRATCH_6_REG 0xCD8 61*277b024eSKalle Valo #define PCIE_SCRATCH_7_REG 0xCDC 62*277b024eSKalle Valo #define PCIE_SCRATCH_8_REG 0xCE0 63*277b024eSKalle Valo #define PCIE_SCRATCH_9_REG 0xCE4 64*277b024eSKalle Valo #define PCIE_SCRATCH_10_REG 0xCE8 65*277b024eSKalle Valo #define PCIE_SCRATCH_11_REG 0xCEC 66*277b024eSKalle Valo #define PCIE_SCRATCH_12_REG 0xCF0 67*277b024eSKalle Valo #define PCIE_RD_DATA_PTR_Q0_Q1 0xC08C 68*277b024eSKalle Valo #define PCIE_WR_DATA_PTR_Q0_Q1 0xC05C 69*277b024eSKalle Valo 70*277b024eSKalle Valo #define CPU_INTR_DNLD_RDY BIT(0) 71*277b024eSKalle Valo #define CPU_INTR_DOOR_BELL BIT(1) 72*277b024eSKalle Valo #define CPU_INTR_SLEEP_CFM_DONE BIT(2) 73*277b024eSKalle Valo #define CPU_INTR_RESET BIT(3) 74*277b024eSKalle Valo #define CPU_INTR_EVENT_DONE BIT(5) 75*277b024eSKalle Valo 76*277b024eSKalle Valo #define HOST_INTR_DNLD_DONE BIT(0) 77*277b024eSKalle Valo #define HOST_INTR_UPLD_RDY BIT(1) 78*277b024eSKalle Valo #define HOST_INTR_CMD_DONE BIT(2) 79*277b024eSKalle Valo #define HOST_INTR_EVENT_RDY BIT(3) 80*277b024eSKalle Valo #define HOST_INTR_MASK (HOST_INTR_DNLD_DONE | \ 81*277b024eSKalle Valo HOST_INTR_UPLD_RDY | \ 82*277b024eSKalle Valo HOST_INTR_CMD_DONE | \ 83*277b024eSKalle Valo HOST_INTR_EVENT_RDY) 84*277b024eSKalle Valo 85*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_ROLLOVER_IND BIT(7) 86*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_FIRST_DESC BIT(0) 87*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_LAST_DESC BIT(1) 88*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_SOP BIT(0) 89*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_EOP BIT(1) 90*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_XS_SOP BIT(2) 91*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_XS_EOP BIT(3) 92*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_EVT_ROLLOVER_IND BIT(7) 93*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_RX_ROLLOVER_IND BIT(10) 94*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_TX_START_PTR BIT(16) 95*277b024eSKalle Valo #define MWIFIEX_BD_FLAG_TX_ROLLOVER_IND BIT(26) 96*277b024eSKalle Valo 97*277b024eSKalle Valo /* Max retry number of command write */ 98*277b024eSKalle Valo #define MAX_WRITE_IOMEM_RETRY 2 99*277b024eSKalle Valo /* Define PCIE block size for firmware download */ 100*277b024eSKalle Valo #define MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD 256 101*277b024eSKalle Valo /* FW awake cookie after FW ready */ 102*277b024eSKalle Valo #define FW_AWAKE_COOKIE (0xAA55AA55) 103*277b024eSKalle Valo #define MWIFIEX_DEF_SLEEP_COOKIE 0xBEEFBEEF 104*277b024eSKalle Valo #define MWIFIEX_MAX_DELAY_COUNT 5 105*277b024eSKalle Valo 106*277b024eSKalle Valo struct mwifiex_pcie_card_reg { 107*277b024eSKalle Valo u16 cmd_addr_lo; 108*277b024eSKalle Valo u16 cmd_addr_hi; 109*277b024eSKalle Valo u16 fw_status; 110*277b024eSKalle Valo u16 cmd_size; 111*277b024eSKalle Valo u16 cmdrsp_addr_lo; 112*277b024eSKalle Valo u16 cmdrsp_addr_hi; 113*277b024eSKalle Valo u16 tx_rdptr; 114*277b024eSKalle Valo u16 tx_wrptr; 115*277b024eSKalle Valo u16 rx_rdptr; 116*277b024eSKalle Valo u16 rx_wrptr; 117*277b024eSKalle Valo u16 evt_rdptr; 118*277b024eSKalle Valo u16 evt_wrptr; 119*277b024eSKalle Valo u16 drv_rdy; 120*277b024eSKalle Valo u16 tx_start_ptr; 121*277b024eSKalle Valo u32 tx_mask; 122*277b024eSKalle Valo u32 tx_wrap_mask; 123*277b024eSKalle Valo u32 rx_mask; 124*277b024eSKalle Valo u32 rx_wrap_mask; 125*277b024eSKalle Valo u32 tx_rollover_ind; 126*277b024eSKalle Valo u32 rx_rollover_ind; 127*277b024eSKalle Valo u32 evt_rollover_ind; 128*277b024eSKalle Valo u8 ring_flag_sop; 129*277b024eSKalle Valo u8 ring_flag_eop; 130*277b024eSKalle Valo u8 ring_flag_xs_sop; 131*277b024eSKalle Valo u8 ring_flag_xs_eop; 132*277b024eSKalle Valo u32 ring_tx_start_ptr; 133*277b024eSKalle Valo u8 pfu_enabled; 134*277b024eSKalle Valo u8 sleep_cookie; 135*277b024eSKalle Valo u16 fw_dump_ctrl; 136*277b024eSKalle Valo u16 fw_dump_start; 137*277b024eSKalle Valo u16 fw_dump_end; 138*277b024eSKalle Valo }; 139*277b024eSKalle Valo 140*277b024eSKalle Valo static const struct mwifiex_pcie_card_reg mwifiex_reg_8766 = { 141*277b024eSKalle Valo .cmd_addr_lo = PCIE_SCRATCH_0_REG, 142*277b024eSKalle Valo .cmd_addr_hi = PCIE_SCRATCH_1_REG, 143*277b024eSKalle Valo .cmd_size = PCIE_SCRATCH_2_REG, 144*277b024eSKalle Valo .fw_status = PCIE_SCRATCH_3_REG, 145*277b024eSKalle Valo .cmdrsp_addr_lo = PCIE_SCRATCH_4_REG, 146*277b024eSKalle Valo .cmdrsp_addr_hi = PCIE_SCRATCH_5_REG, 147*277b024eSKalle Valo .tx_rdptr = PCIE_SCRATCH_6_REG, 148*277b024eSKalle Valo .tx_wrptr = PCIE_SCRATCH_7_REG, 149*277b024eSKalle Valo .rx_rdptr = PCIE_SCRATCH_8_REG, 150*277b024eSKalle Valo .rx_wrptr = PCIE_SCRATCH_9_REG, 151*277b024eSKalle Valo .evt_rdptr = PCIE_SCRATCH_10_REG, 152*277b024eSKalle Valo .evt_wrptr = PCIE_SCRATCH_11_REG, 153*277b024eSKalle Valo .drv_rdy = PCIE_SCRATCH_12_REG, 154*277b024eSKalle Valo .tx_start_ptr = 0, 155*277b024eSKalle Valo .tx_mask = MWIFIEX_TXBD_MASK, 156*277b024eSKalle Valo .tx_wrap_mask = 0, 157*277b024eSKalle Valo .rx_mask = MWIFIEX_RXBD_MASK, 158*277b024eSKalle Valo .rx_wrap_mask = 0, 159*277b024eSKalle Valo .tx_rollover_ind = MWIFIEX_BD_FLAG_ROLLOVER_IND, 160*277b024eSKalle Valo .rx_rollover_ind = MWIFIEX_BD_FLAG_ROLLOVER_IND, 161*277b024eSKalle Valo .evt_rollover_ind = MWIFIEX_BD_FLAG_ROLLOVER_IND, 162*277b024eSKalle Valo .ring_flag_sop = 0, 163*277b024eSKalle Valo .ring_flag_eop = 0, 164*277b024eSKalle Valo .ring_flag_xs_sop = 0, 165*277b024eSKalle Valo .ring_flag_xs_eop = 0, 166*277b024eSKalle Valo .ring_tx_start_ptr = 0, 167*277b024eSKalle Valo .pfu_enabled = 0, 168*277b024eSKalle Valo .sleep_cookie = 1, 169*277b024eSKalle Valo }; 170*277b024eSKalle Valo 171*277b024eSKalle Valo static const struct mwifiex_pcie_card_reg mwifiex_reg_8897 = { 172*277b024eSKalle Valo .cmd_addr_lo = PCIE_SCRATCH_0_REG, 173*277b024eSKalle Valo .cmd_addr_hi = PCIE_SCRATCH_1_REG, 174*277b024eSKalle Valo .cmd_size = PCIE_SCRATCH_2_REG, 175*277b024eSKalle Valo .fw_status = PCIE_SCRATCH_3_REG, 176*277b024eSKalle Valo .cmdrsp_addr_lo = PCIE_SCRATCH_4_REG, 177*277b024eSKalle Valo .cmdrsp_addr_hi = PCIE_SCRATCH_5_REG, 178*277b024eSKalle Valo .tx_rdptr = PCIE_RD_DATA_PTR_Q0_Q1, 179*277b024eSKalle Valo .tx_wrptr = PCIE_WR_DATA_PTR_Q0_Q1, 180*277b024eSKalle Valo .rx_rdptr = PCIE_WR_DATA_PTR_Q0_Q1, 181*277b024eSKalle Valo .rx_wrptr = PCIE_RD_DATA_PTR_Q0_Q1, 182*277b024eSKalle Valo .evt_rdptr = PCIE_SCRATCH_10_REG, 183*277b024eSKalle Valo .evt_wrptr = PCIE_SCRATCH_11_REG, 184*277b024eSKalle Valo .drv_rdy = PCIE_SCRATCH_12_REG, 185*277b024eSKalle Valo .tx_start_ptr = 16, 186*277b024eSKalle Valo .tx_mask = 0x03FF0000, 187*277b024eSKalle Valo .tx_wrap_mask = 0x07FF0000, 188*277b024eSKalle Valo .rx_mask = 0x000003FF, 189*277b024eSKalle Valo .rx_wrap_mask = 0x000007FF, 190*277b024eSKalle Valo .tx_rollover_ind = MWIFIEX_BD_FLAG_TX_ROLLOVER_IND, 191*277b024eSKalle Valo .rx_rollover_ind = MWIFIEX_BD_FLAG_RX_ROLLOVER_IND, 192*277b024eSKalle Valo .evt_rollover_ind = MWIFIEX_BD_FLAG_EVT_ROLLOVER_IND, 193*277b024eSKalle Valo .ring_flag_sop = MWIFIEX_BD_FLAG_SOP, 194*277b024eSKalle Valo .ring_flag_eop = MWIFIEX_BD_FLAG_EOP, 195*277b024eSKalle Valo .ring_flag_xs_sop = MWIFIEX_BD_FLAG_XS_SOP, 196*277b024eSKalle Valo .ring_flag_xs_eop = MWIFIEX_BD_FLAG_XS_EOP, 197*277b024eSKalle Valo .ring_tx_start_ptr = MWIFIEX_BD_FLAG_TX_START_PTR, 198*277b024eSKalle Valo .pfu_enabled = 1, 199*277b024eSKalle Valo .sleep_cookie = 0, 200*277b024eSKalle Valo .fw_dump_ctrl = 0xcf4, 201*277b024eSKalle Valo .fw_dump_start = 0xcf8, 202*277b024eSKalle Valo .fw_dump_end = 0xcff, 203*277b024eSKalle Valo }; 204*277b024eSKalle Valo 205*277b024eSKalle Valo static const struct mwifiex_pcie_card_reg mwifiex_reg_8997 = { 206*277b024eSKalle Valo .cmd_addr_lo = PCIE_SCRATCH_0_REG, 207*277b024eSKalle Valo .cmd_addr_hi = PCIE_SCRATCH_1_REG, 208*277b024eSKalle Valo .cmd_size = PCIE_SCRATCH_2_REG, 209*277b024eSKalle Valo .fw_status = PCIE_SCRATCH_3_REG, 210*277b024eSKalle Valo .cmdrsp_addr_lo = PCIE_SCRATCH_4_REG, 211*277b024eSKalle Valo .cmdrsp_addr_hi = PCIE_SCRATCH_5_REG, 212*277b024eSKalle Valo .tx_rdptr = 0xC1A4, 213*277b024eSKalle Valo .tx_wrptr = 0xC1A8, 214*277b024eSKalle Valo .rx_rdptr = 0xC1A8, 215*277b024eSKalle Valo .rx_wrptr = 0xC1A4, 216*277b024eSKalle Valo .evt_rdptr = PCIE_SCRATCH_10_REG, 217*277b024eSKalle Valo .evt_wrptr = PCIE_SCRATCH_11_REG, 218*277b024eSKalle Valo .drv_rdy = PCIE_SCRATCH_12_REG, 219*277b024eSKalle Valo .tx_start_ptr = 16, 220*277b024eSKalle Valo .tx_mask = 0x0FFF0000, 221*277b024eSKalle Valo .tx_wrap_mask = 0x01FF0000, 222*277b024eSKalle Valo .rx_mask = 0x00000FFF, 223*277b024eSKalle Valo .rx_wrap_mask = 0x000001FF, 224*277b024eSKalle Valo .tx_rollover_ind = BIT(28), 225*277b024eSKalle Valo .rx_rollover_ind = BIT(12), 226*277b024eSKalle Valo .evt_rollover_ind = MWIFIEX_BD_FLAG_EVT_ROLLOVER_IND, 227*277b024eSKalle Valo .ring_flag_sop = MWIFIEX_BD_FLAG_SOP, 228*277b024eSKalle Valo .ring_flag_eop = MWIFIEX_BD_FLAG_EOP, 229*277b024eSKalle Valo .ring_flag_xs_sop = MWIFIEX_BD_FLAG_XS_SOP, 230*277b024eSKalle Valo .ring_flag_xs_eop = MWIFIEX_BD_FLAG_XS_EOP, 231*277b024eSKalle Valo .ring_tx_start_ptr = MWIFIEX_BD_FLAG_TX_START_PTR, 232*277b024eSKalle Valo .pfu_enabled = 1, 233*277b024eSKalle Valo .sleep_cookie = 0, 234*277b024eSKalle Valo }; 235*277b024eSKalle Valo 236*277b024eSKalle Valo struct mwifiex_pcie_device { 237*277b024eSKalle Valo const char *firmware; 238*277b024eSKalle Valo const struct mwifiex_pcie_card_reg *reg; 239*277b024eSKalle Valo u16 blksz_fw_dl; 240*277b024eSKalle Valo u16 tx_buf_size; 241*277b024eSKalle Valo bool can_dump_fw; 242*277b024eSKalle Valo bool can_ext_scan; 243*277b024eSKalle Valo }; 244*277b024eSKalle Valo 245*277b024eSKalle Valo static const struct mwifiex_pcie_device mwifiex_pcie8766 = { 246*277b024eSKalle Valo .firmware = PCIE8766_DEFAULT_FW_NAME, 247*277b024eSKalle Valo .reg = &mwifiex_reg_8766, 248*277b024eSKalle Valo .blksz_fw_dl = MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD, 249*277b024eSKalle Valo .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K, 250*277b024eSKalle Valo .can_dump_fw = false, 251*277b024eSKalle Valo .can_ext_scan = true, 252*277b024eSKalle Valo }; 253*277b024eSKalle Valo 254*277b024eSKalle Valo static const struct mwifiex_pcie_device mwifiex_pcie8897 = { 255*277b024eSKalle Valo .firmware = PCIE8897_DEFAULT_FW_NAME, 256*277b024eSKalle Valo .reg = &mwifiex_reg_8897, 257*277b024eSKalle Valo .blksz_fw_dl = MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD, 258*277b024eSKalle Valo .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K, 259*277b024eSKalle Valo .can_dump_fw = true, 260*277b024eSKalle Valo .can_ext_scan = true, 261*277b024eSKalle Valo }; 262*277b024eSKalle Valo 263*277b024eSKalle Valo static const struct mwifiex_pcie_device mwifiex_pcie8997 = { 264*277b024eSKalle Valo .firmware = PCIE8997_DEFAULT_FW_NAME, 265*277b024eSKalle Valo .reg = &mwifiex_reg_8997, 266*277b024eSKalle Valo .blksz_fw_dl = MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD, 267*277b024eSKalle Valo .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K, 268*277b024eSKalle Valo .can_dump_fw = false, 269*277b024eSKalle Valo .can_ext_scan = true, 270*277b024eSKalle Valo }; 271*277b024eSKalle Valo 272*277b024eSKalle Valo struct mwifiex_evt_buf_desc { 273*277b024eSKalle Valo u64 paddr; 274*277b024eSKalle Valo u16 len; 275*277b024eSKalle Valo u16 flags; 276*277b024eSKalle Valo } __packed; 277*277b024eSKalle Valo 278*277b024eSKalle Valo struct mwifiex_pcie_buf_desc { 279*277b024eSKalle Valo u64 paddr; 280*277b024eSKalle Valo u16 len; 281*277b024eSKalle Valo u16 flags; 282*277b024eSKalle Valo } __packed; 283*277b024eSKalle Valo 284*277b024eSKalle Valo struct mwifiex_pfu_buf_desc { 285*277b024eSKalle Valo u16 flags; 286*277b024eSKalle Valo u16 offset; 287*277b024eSKalle Valo u16 frag_len; 288*277b024eSKalle Valo u16 len; 289*277b024eSKalle Valo u64 paddr; 290*277b024eSKalle Valo u32 reserved; 291*277b024eSKalle Valo } __packed; 292*277b024eSKalle Valo 293*277b024eSKalle Valo struct pcie_service_card { 294*277b024eSKalle Valo struct pci_dev *dev; 295*277b024eSKalle Valo struct mwifiex_adapter *adapter; 296*277b024eSKalle Valo struct mwifiex_pcie_device pcie; 297*277b024eSKalle Valo 298*277b024eSKalle Valo u8 txbd_flush; 299*277b024eSKalle Valo u32 txbd_wrptr; 300*277b024eSKalle Valo u32 txbd_rdptr; 301*277b024eSKalle Valo u32 txbd_ring_size; 302*277b024eSKalle Valo u8 *txbd_ring_vbase; 303*277b024eSKalle Valo dma_addr_t txbd_ring_pbase; 304*277b024eSKalle Valo void *txbd_ring[MWIFIEX_MAX_TXRX_BD]; 305*277b024eSKalle Valo struct sk_buff *tx_buf_list[MWIFIEX_MAX_TXRX_BD]; 306*277b024eSKalle Valo 307*277b024eSKalle Valo u32 rxbd_wrptr; 308*277b024eSKalle Valo u32 rxbd_rdptr; 309*277b024eSKalle Valo u32 rxbd_ring_size; 310*277b024eSKalle Valo u8 *rxbd_ring_vbase; 311*277b024eSKalle Valo dma_addr_t rxbd_ring_pbase; 312*277b024eSKalle Valo void *rxbd_ring[MWIFIEX_MAX_TXRX_BD]; 313*277b024eSKalle Valo struct sk_buff *rx_buf_list[MWIFIEX_MAX_TXRX_BD]; 314*277b024eSKalle Valo 315*277b024eSKalle Valo u32 evtbd_wrptr; 316*277b024eSKalle Valo u32 evtbd_rdptr; 317*277b024eSKalle Valo u32 evtbd_ring_size; 318*277b024eSKalle Valo u8 *evtbd_ring_vbase; 319*277b024eSKalle Valo dma_addr_t evtbd_ring_pbase; 320*277b024eSKalle Valo void *evtbd_ring[MWIFIEX_MAX_EVT_BD]; 321*277b024eSKalle Valo struct sk_buff *evt_buf_list[MWIFIEX_MAX_EVT_BD]; 322*277b024eSKalle Valo 323*277b024eSKalle Valo struct sk_buff *cmd_buf; 324*277b024eSKalle Valo struct sk_buff *cmdrsp_buf; 325*277b024eSKalle Valo u8 *sleep_cookie_vbase; 326*277b024eSKalle Valo dma_addr_t sleep_cookie_pbase; 327*277b024eSKalle Valo void __iomem *pci_mmap; 328*277b024eSKalle Valo void __iomem *pci_mmap1; 329*277b024eSKalle Valo }; 330*277b024eSKalle Valo 331*277b024eSKalle Valo static inline int 332*277b024eSKalle Valo mwifiex_pcie_txbd_empty(struct pcie_service_card *card, u32 rdptr) 333*277b024eSKalle Valo { 334*277b024eSKalle Valo const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; 335*277b024eSKalle Valo 336*277b024eSKalle Valo switch (card->dev->device) { 337*277b024eSKalle Valo case PCIE_DEVICE_ID_MARVELL_88W8766P: 338*277b024eSKalle Valo if (((card->txbd_wrptr & reg->tx_mask) == 339*277b024eSKalle Valo (rdptr & reg->tx_mask)) && 340*277b024eSKalle Valo ((card->txbd_wrptr & reg->tx_rollover_ind) != 341*277b024eSKalle Valo (rdptr & reg->tx_rollover_ind))) 342*277b024eSKalle Valo return 1; 343*277b024eSKalle Valo break; 344*277b024eSKalle Valo case PCIE_DEVICE_ID_MARVELL_88W8897: 345*277b024eSKalle Valo if (((card->txbd_wrptr & reg->tx_mask) == 346*277b024eSKalle Valo (rdptr & reg->tx_mask)) && 347*277b024eSKalle Valo ((card->txbd_wrptr & reg->tx_rollover_ind) == 348*277b024eSKalle Valo (rdptr & reg->tx_rollover_ind))) 349*277b024eSKalle Valo return 1; 350*277b024eSKalle Valo break; 351*277b024eSKalle Valo } 352*277b024eSKalle Valo 353*277b024eSKalle Valo return 0; 354*277b024eSKalle Valo } 355*277b024eSKalle Valo 356*277b024eSKalle Valo static inline int 357*277b024eSKalle Valo mwifiex_pcie_txbd_not_full(struct pcie_service_card *card) 358*277b024eSKalle Valo { 359*277b024eSKalle Valo const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; 360*277b024eSKalle Valo 361*277b024eSKalle Valo switch (card->dev->device) { 362*277b024eSKalle Valo case PCIE_DEVICE_ID_MARVELL_88W8766P: 363*277b024eSKalle Valo if (((card->txbd_wrptr & reg->tx_mask) != 364*277b024eSKalle Valo (card->txbd_rdptr & reg->tx_mask)) || 365*277b024eSKalle Valo ((card->txbd_wrptr & reg->tx_rollover_ind) != 366*277b024eSKalle Valo (card->txbd_rdptr & reg->tx_rollover_ind))) 367*277b024eSKalle Valo return 1; 368*277b024eSKalle Valo break; 369*277b024eSKalle Valo case PCIE_DEVICE_ID_MARVELL_88W8897: 370*277b024eSKalle Valo case PCIE_DEVICE_ID_MARVELL_88W8997: 371*277b024eSKalle Valo if (((card->txbd_wrptr & reg->tx_mask) != 372*277b024eSKalle Valo (card->txbd_rdptr & reg->tx_mask)) || 373*277b024eSKalle Valo ((card->txbd_wrptr & reg->tx_rollover_ind) == 374*277b024eSKalle Valo (card->txbd_rdptr & reg->tx_rollover_ind))) 375*277b024eSKalle Valo return 1; 376*277b024eSKalle Valo break; 377*277b024eSKalle Valo } 378*277b024eSKalle Valo 379*277b024eSKalle Valo return 0; 380*277b024eSKalle Valo } 381*277b024eSKalle Valo 382*277b024eSKalle Valo #endif /* _MWIFIEX_PCIE_H */ 383