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