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