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