xref: /linux/drivers/bluetooth/btintel_pcie.h (revision f70f7f2512c6b9113dc78f6a25361166afd1412e)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *
4  *  Bluetooth support for Intel PCIe devices
5  *
6  *  Copyright (C) 2024  Intel Corporation
7  */
8 
9 /* Control and Status Register(BTINTEL_PCIE_CSR) */
10 #define BTINTEL_PCIE_CSR_BASE			(0x000)
11 #define BTINTEL_PCIE_CSR_FUNC_CTRL_REG		(BTINTEL_PCIE_CSR_BASE + 0x024)
12 #define BTINTEL_PCIE_CSR_HW_REV_REG		(BTINTEL_PCIE_CSR_BASE + 0x028)
13 #define BTINTEL_PCIE_CSR_RF_ID_REG		(BTINTEL_PCIE_CSR_BASE + 0x09C)
14 #define BTINTEL_PCIE_CSR_BOOT_STAGE_REG		(BTINTEL_PCIE_CSR_BASE + 0x108)
15 #define BTINTEL_PCIE_CSR_IPC_CONTROL_REG	(BTINTEL_PCIE_CSR_BASE + 0x10C)
16 #define BTINTEL_PCIE_CSR_IPC_STATUS_REG		(BTINTEL_PCIE_CSR_BASE + 0x110)
17 #define BTINTEL_PCIE_CSR_IPC_SLEEP_CTL_REG	(BTINTEL_PCIE_CSR_BASE + 0x114)
18 #define BTINTEL_PCIE_CSR_CI_ADDR_LSB_REG	(BTINTEL_PCIE_CSR_BASE + 0x118)
19 #define BTINTEL_PCIE_CSR_CI_ADDR_MSB_REG	(BTINTEL_PCIE_CSR_BASE + 0x11C)
20 #define BTINTEL_PCIE_CSR_IMG_RESPONSE_REG	(BTINTEL_PCIE_CSR_BASE + 0x12C)
21 #define BTINTEL_PCIE_CSR_MBOX_1_REG		(BTINTEL_PCIE_CSR_BASE + 0x170)
22 #define BTINTEL_PCIE_CSR_MBOX_2_REG		(BTINTEL_PCIE_CSR_BASE + 0x174)
23 #define BTINTEL_PCIE_CSR_MBOX_3_REG		(BTINTEL_PCIE_CSR_BASE + 0x178)
24 #define BTINTEL_PCIE_CSR_MBOX_4_REG		(BTINTEL_PCIE_CSR_BASE + 0x17C)
25 #define BTINTEL_PCIE_CSR_MBOX_STATUS_REG	(BTINTEL_PCIE_CSR_BASE + 0x180)
26 #define BTINTEL_PCIE_PRPH_DEV_ADDR_REG		(BTINTEL_PCIE_CSR_BASE + 0x440)
27 #define BTINTEL_PCIE_PRPH_DEV_RD_REG		(BTINTEL_PCIE_CSR_BASE + 0x458)
28 #define BTINTEL_PCIE_CSR_HBUS_TARG_WRPTR	(BTINTEL_PCIE_CSR_BASE + 0x460)
29 
30 /* BTINTEL_PCIE_CSR Function Control Register */
31 #define BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_ENA		(BIT(0))
32 #define BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT		(BIT(6))
33 #define BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_INIT		(BIT(7))
34 #define BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_STS	(BIT(20))
35 
36 #define BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ	(BIT(21))
37 
38 #define BTINTEL_PCIE_CSR_FUNC_CTRL_BUS_MASTER_STS	(BIT(28))
39 #define BTINTEL_PCIE_CSR_FUNC_CTRL_BUS_MASTER_DISCON	(BIT(29))
40 #define BTINTEL_PCIE_CSR_FUNC_CTRL_SW_RESET		(BIT(31))
41 
42 /* Value for BTINTEL_PCIE_CSR_BOOT_STAGE register */
43 #define BTINTEL_PCIE_CSR_BOOT_STAGE_ROM		(BIT(0))
44 #define BTINTEL_PCIE_CSR_BOOT_STAGE_IML		(BIT(1))
45 #define BTINTEL_PCIE_CSR_BOOT_STAGE_OPFW		(BIT(2))
46 #define BTINTEL_PCIE_CSR_BOOT_STAGE_ROM_LOCKDOWN	(BIT(10))
47 #define BTINTEL_PCIE_CSR_BOOT_STAGE_IML_LOCKDOWN	(BIT(11))
48 #define BTINTEL_PCIE_CSR_BOOT_STAGE_DEVICE_WARNING	(BIT(12))
49 #define BTINTEL_PCIE_CSR_BOOT_STAGE_ABORT_HANDLER	(BIT(13))
50 #define BTINTEL_PCIE_CSR_BOOT_STAGE_DEVICE_HALTED	(BIT(14))
51 #define BTINTEL_PCIE_CSR_BOOT_STAGE_MAC_ACCESS_ON	(BIT(16))
52 #define BTINTEL_PCIE_CSR_BOOT_STAGE_ALIVE		(BIT(23))
53 #define BTINTEL_PCIE_CSR_BOOT_STAGE_D3_STATE_READY	(BIT(24))
54 
55 /* Registers for MSI-X */
56 #define BTINTEL_PCIE_CSR_MSIX_BASE		(0x2000)
57 #define BTINTEL_PCIE_CSR_MSIX_FH_INT_CAUSES	(BTINTEL_PCIE_CSR_MSIX_BASE + 0x0800)
58 #define BTINTEL_PCIE_CSR_MSIX_FH_INT_MASK	(BTINTEL_PCIE_CSR_MSIX_BASE + 0x0804)
59 #define BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES	(BTINTEL_PCIE_CSR_MSIX_BASE + 0x0808)
60 #define BTINTEL_PCIE_CSR_MSIX_HW_INT_MASK	(BTINTEL_PCIE_CSR_MSIX_BASE + 0x080C)
61 #define BTINTEL_PCIE_CSR_MSIX_AUTOMASK_ST	(BTINTEL_PCIE_CSR_MSIX_BASE + 0x0810)
62 #define BTINTEL_PCIE_CSR_MSIX_AUTOMASK_EN	(BTINTEL_PCIE_CSR_MSIX_BASE + 0x0814)
63 #define BTINTEL_PCIE_CSR_MSIX_IVAR_BASE		(BTINTEL_PCIE_CSR_MSIX_BASE + 0x0880)
64 #define BTINTEL_PCIE_CSR_MSIX_IVAR(cause)	(BTINTEL_PCIE_CSR_MSIX_IVAR_BASE + (cause))
65 
66 /* IOSF Debug Register */
67 #define BTINTEL_PCIE_DBGC_BASE_ADDR			(0xf3800300)
68 #define BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS		(BTINTEL_PCIE_DBGC_BASE_ADDR + 0x1C)
69 #define BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND		(BTINTEL_PCIE_DBGC_BASE_ADDR + 0x2C)
70 
71 #define BTINTEL_PCIE_DBGC_BASE_ADDR_SCP			(0xf0d5d500)
72 #define BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS_SCP	(BTINTEL_PCIE_DBGC_BASE_ADDR_SCP + 0x1C)
73 #define BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND_SCP		(BTINTEL_PCIE_DBGC_BASE_ADDR_SCP + 0x2C)
74 
75 #define BTINTEL_PCIE_DBG_IDX_BIT_MASK		0x0F
76 #define BTINTEL_PCIE_DBGC_DBG_BUF_IDX(data)	(((data) >> 24) & BTINTEL_PCIE_DBG_IDX_BIT_MASK)
77 #define BTINTEL_PCIE_DBG_OFFSET_BIT_MASK	0xFFFFFF
78 
79 /* The DRAM buffer count, each buffer size, and
80  * fragment buffer size
81  */
82 #define BTINTEL_PCIE_DBGC_BUFFER_COUNT		16
83 #define BTINTEL_PCIE_DBGC_BUFFER_SIZE		(256 * 1024) /* 256 KB */
84 
85 #define BTINTEL_PCIE_DBGC_FRAG_VERSION		1
86 #define BTINTEL_PCIE_DBGC_FRAG_BUFFER_COUNT	BTINTEL_PCIE_DBGC_BUFFER_COUNT
87 
88 /* Magic number(4), version(4), size of payload length(4) */
89 #define BTINTEL_PCIE_DBGC_FRAG_HEADER_SIZE	12
90 
91 /* Num of alloc Dbg buff (4) + (LSB(4), MSB(4), Size(4)) for each buffer */
92 #define BTINTEL_PCIE_DBGC_FRAG_PAYLOAD_SIZE	196
93 
94 /* Causes for the FH register interrupts */
95 enum msix_fh_int_causes {
96 	BTINTEL_PCIE_MSIX_FH_INT_CAUSES_0	= BIT(0),	/* cause 0 */
97 	BTINTEL_PCIE_MSIX_FH_INT_CAUSES_1	= BIT(1),	/* cause 1 */
98 };
99 
100 /* Causes for the HW register interrupts */
101 enum msix_hw_int_causes {
102 	BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0	= BIT(0),	/* cause 32 */
103 	BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP1	= BIT(1),	/* cause 33 */
104 	BTINTEL_PCIE_MSIX_HW_INT_CAUSES_HWEXP	= BIT(3),	/* cause 35 */
105 	BTINTEL_PCIE_MSIX_HW_INT_CAUSES_FWTRIG	= BIT(5),	/* cause 37 */
106 };
107 
108 /* PCIe device states
109  * Host-Device interface is active
110  * Host-Device interface is inactive(as reflected by IPC_SLEEP_CONTROL_CSR_AD)
111  * Host-Device interface is inactive(as reflected by IPC_SLEEP_CONTROL_CSR_AD)
112  */
113 enum {
114 	BTINTEL_PCIE_STATE_D0 = 0,
115 	BTINTEL_PCIE_STATE_D3_HOT = 2,
116 	BTINTEL_PCIE_STATE_D3_COLD = 3,
117 };
118 
119 enum {
120 	BTINTEL_PCIE_CORE_HALTED,
121 	BTINTEL_PCIE_HWEXP_INPROGRESS,
122 	BTINTEL_PCIE_COREDUMP_INPROGRESS,
123 	BTINTEL_PCIE_FWTRIGGER_DUMP_INPROGRESS,
124 	BTINTEL_PCIE_RECOVERY_IN_PROGRESS,
125 	BTINTEL_PCIE_SETUP_DONE
126 };
127 
128 enum btintel_pcie_tlv_type {
129 	BTINTEL_CNVI_BT,
130 	BTINTEL_WRITE_PTR,
131 	BTINTEL_WRAP_CTR,
132 	BTINTEL_TRIGGER_REASON,
133 	BTINTEL_FW_SHA,
134 	BTINTEL_CNVR_TOP,
135 	BTINTEL_CNVI_TOP,
136 	BTINTEL_DUMP_TIME,
137 	BTINTEL_FW_BUILD,
138 	BTINTEL_VENDOR,
139 	BTINTEL_DRIVER,
140 	BTINTEL_EVENT_TYPE,
141 	BTINTEL_EVENT_ID
142 };
143 
144 /* causes for the MBOX interrupts */
145 enum msix_mbox_int_causes {
146 	BTINTEL_PCIE_CSR_MBOX_STATUS_MBOX1 = BIT(0), /* cause MBOX1 */
147 	BTINTEL_PCIE_CSR_MBOX_STATUS_MBOX2 = BIT(1), /* cause MBOX2 */
148 	BTINTEL_PCIE_CSR_MBOX_STATUS_MBOX3 = BIT(2), /* cause MBOX3 */
149 	BTINTEL_PCIE_CSR_MBOX_STATUS_MBOX4 = BIT(3), /* cause MBOX4 */
150 };
151 
152 enum btintel_pcie_reset_type {
153 	BTINTEL_PCIE_IOSF_PRR_FLR = 0,
154 	BTINTEL_PCIE_IOSF_PRR_PLDR = 1,
155 };
156 
157 #define BTINTEL_PCIE_MSIX_NON_AUTO_CLEAR_CAUSE	BIT(7)
158 
159 /* Minimum and Maximum number of MSI-X Vector
160  * Intel Bluetooth PCIe support only 1 vector
161  */
162 #define BTINTEL_PCIE_MSIX_VEC_MAX	1
163 #define BTINTEL_PCIE_MSIX_VEC_MIN	1
164 
165 /* Default poll time for MAC access during init */
166 #define BTINTEL_DEFAULT_MAC_ACCESS_TIMEOUT_US	200000
167 
168 /* Default interrupt timeout in msec */
169 #define BTINTEL_DEFAULT_INTR_TIMEOUT_MS	3000
170 
171 #define BTINTEL_PCIE_DX_TRANSITION_MAX_RETRIES	3
172 
173 /* The number of descriptors in TX queues */
174 #define BTINTEL_PCIE_TX_DESCS_COUNT	32
175 
176 /* The number of descriptors in RX queues */
177 #define BTINTEL_PCIE_RX_DESCS_COUNT	64
178 
179 /* Number of Queue for TX and RX
180  * It indicates the index of the IA(Index Array)
181  */
182 enum {
183 	BTINTEL_PCIE_TXQ_NUM = 0,
184 	BTINTEL_PCIE_RXQ_NUM = 1,
185 	BTINTEL_PCIE_NUM_QUEUES = 2,
186 };
187 
188 /* The size of DMA buffer for TX and RX in bytes */
189 #define BTINTEL_PCIE_BUFFER_SIZE	4096
190 
191 #define BTINTEL_PCIE_TX_WAIT_TIMEOUT_MS		500
192 
193 /* Doorbell vector for TFD */
194 #define BTINTEL_PCIE_TX_DB_VEC	0
195 
196 /* Doorbell vector for FRBD */
197 #define BTINTEL_PCIE_RX_DB_VEC	513
198 
199 /* RBD buffer size mapping */
200 #define BTINTEL_PCIE_RBD_SIZE_4K	0x04
201 
202 /*
203  * Struct for Context Information (v2)
204  *
205  * All members are write-only for host and read-only for device.
206  *
207  * @version: Version of context information
208  * @size: Size of context information
209  * @config: Config with which host wants peripheral to execute
210  *	Subset of capability register published by device
211  * @addr_tr_hia: Address of TR Head Index Array
212  * @addr_tr_tia: Address of TR Tail Index Array
213  * @addr_cr_hia: Address of CR Head Index Array
214  * @addr_cr_tia: Address of CR Tail Index Array
215  * @num_tr_ia: Number of entries in TR Index Arrays
216  * @num_cr_ia: Number of entries in CR Index Arrays
217  * @rbd_siz: RBD Size { 0x4=4K }
218  * @addr_tfdq: Address of TFD Queue(tx)
219  * @addr_urbdq0: Address of URBD Queue(tx)
220  * @num_tfdq: Number of TFD in TFD Queue(tx)
221  * @num_urbdq0: Number of URBD in URBD Queue(tx)
222  * @tfdq_db_vec: Queue number of TFD
223  * @urbdq0_db_vec: Queue number of URBD
224  * @addr_frbdq: Address of FRBD Queue(rx)
225  * @addr_urbdq1: Address of URBD Queue(rx)
226  * @num_frbdq: Number of FRBD in FRBD Queue(rx)
227  * @frbdq_db_vec: Queue number of FRBD
228  * @num_urbdq1: Number of URBD in URBD Queue(rx)
229  * @urbdq_db_vec: Queue number of URBDQ1
230  * @tr_msi_vec: Transfer Ring MSI-X Vector
231  * @cr_msi_vec: Completion Ring MSI-X Vector
232  * @dbgc_addr: DBGC first fragment address
233  * @dbgc_size: DBGC buffer size
234  * @early_enable: Enarly debug enable
235  * @dbg_output_mode: Debug output mode
236  *	Bit[4] DBGC O/P { 0=SRAM, 1=DRAM(not relevant for NPK) }
237  *	Bit[5] DBGC I/P { 0=BDBG, 1=DBGI }
238  *	Bits[6:7] DBGI O/P(relevant if bit[5] = 1)
239  *	 0=BT DBGC, 1=WiFi DBGC, 2=NPK }
240  * @dbg_preset: Debug preset
241  * @ext_addr: Address of context information extension
242  * @ext_size: Size of context information part
243  *
244  * Total 38 DWords
245  */
246 struct ctx_info {
247 	u16	version;
248 	u16	size;
249 	u32	config;
250 	u32	reserved_dw02;
251 	u32	reserved_dw03;
252 	u64	addr_tr_hia;
253 	u64	addr_tr_tia;
254 	u64	addr_cr_hia;
255 	u64	addr_cr_tia;
256 	u16	num_tr_ia;
257 	u16	num_cr_ia;
258 	u32	rbd_size:4,
259 		reserved_dw13:28;
260 	u64	addr_tfdq;
261 	u64	addr_urbdq0;
262 	u16	num_tfdq;
263 	u16	num_urbdq0;
264 	u16	tfdq_db_vec;
265 	u16	urbdq0_db_vec;
266 	u64	addr_frbdq;
267 	u64	addr_urbdq1;
268 	u16	num_frbdq;
269 	u16	frbdq_db_vec;
270 	u16	num_urbdq1;
271 	u16	urbdq_db_vec;
272 	u16	tr_msi_vec;
273 	u16	cr_msi_vec;
274 	u32	reserved_dw27;
275 	u64	dbgc_addr;
276 	u32	dbgc_size;
277 	u32	early_enable:1,
278 		reserved_dw31:3,
279 		dbg_output_mode:4,
280 		dbg_preset:8,
281 		reserved2_dw31:16;
282 	u64	ext_addr;
283 	u32	ext_size;
284 	u32	test_param;
285 	u32	reserved_dw36;
286 	u32	reserved_dw37;
287 } __packed;
288 
289 /* Transfer Descriptor for TX
290  * @type: Not in use. Set to 0x0
291  * @size: Size of data in the buffer
292  * @addr: DMA Address of buffer
293  */
294 struct tfd {
295 	u8	type;
296 	u16	size;
297 	u8	reserved;
298 	u64	addr;
299 	u32	reserved1;
300 } __packed;
301 
302 /* URB Descriptor for TX
303  * @tfd_index: Index of TFD in TFDQ + 1
304  * @num_txq: Queue index of TFD Queue
305  * @cmpl_count: Completion count. Always 0x01
306  * @immediate_cmpl: Immediate completion flag: Always 0x01
307  */
308 struct urbd0 {
309 	u32	tfd_index:16,
310 		num_txq:8,
311 		cmpl_count:4,
312 		reserved:3,
313 		immediate_cmpl:1;
314 } __packed;
315 
316 /* FRB Descriptor for RX
317  * @tag: RX buffer tag (index of RX buffer queue)
318  * @addr: Address of buffer
319  */
320 struct frbd {
321 	u32	tag:16,
322 		reserved:16;
323 	u32	reserved2;
324 	u64	addr;
325 } __packed;
326 
327 /* URB Descriptor for RX
328  * @frbd_tag: Tag from FRBD
329  * @status: Status
330  */
331 struct urbd1 {
332 	u32	frbd_tag:16,
333 		status:1,
334 		reserved:14,
335 		fixed:1;
336 } __packed;
337 
338 /* RFH header in RX packet
339  * @packet_len: Length of the data in the buffer
340  * @rxq: RX Queue number
341  * @cmd_id: Command ID. Not in Use
342  */
343 struct rfh_hdr {
344 	u64	packet_len:16,
345 		rxq:6,
346 		reserved:10,
347 		cmd_id:16,
348 		reserved1:16;
349 } __packed;
350 
351 /* Internal data buffer
352  * @data: pointer to the data buffer
353  * @p_addr: physical address of data buffer
354  */
355 struct data_buf {
356 	u8		*data;
357 	dma_addr_t	data_p_addr;
358 };
359 
360 /* Index Array */
361 struct ia {
362 	dma_addr_t	tr_hia_p_addr;
363 	u16		*tr_hia;
364 	dma_addr_t	tr_tia_p_addr;
365 	u16		*tr_tia;
366 	dma_addr_t	cr_hia_p_addr;
367 	u16		*cr_hia;
368 	dma_addr_t	cr_tia_p_addr;
369 	u16		*cr_tia;
370 };
371 
372 /* Structure for TX Queue
373  * @count: Number of descriptors
374  * @tfds: Array of TFD
375  * @urbd0s: Array of URBD0
376  * @buf: Array of data_buf structure
377  */
378 struct txq {
379 	u16		count;
380 
381 	dma_addr_t	tfds_p_addr;
382 	struct tfd	*tfds;
383 
384 	dma_addr_t	urbd0s_p_addr;
385 	struct urbd0	*urbd0s;
386 
387 	dma_addr_t	buf_p_addr;
388 	void		*buf_v_addr;
389 	struct data_buf	*bufs;
390 };
391 
392 /* Structure for RX Queue
393  * @count: Number of descriptors
394  * @frbds: Array of FRBD
395  * @urbd1s: Array of URBD1
396  * @buf: Array of data_buf structure
397  */
398 struct rxq {
399 	u16		count;
400 
401 	dma_addr_t	frbds_p_addr;
402 	struct frbd	*frbds;
403 
404 	dma_addr_t	urbd1s_p_addr;
405 	struct urbd1	*urbd1s;
406 
407 	dma_addr_t	buf_p_addr;
408 	void		*buf_v_addr;
409 	struct data_buf	*bufs;
410 };
411 
412 /* Structure for DRAM Buffer
413  * @count: Number of descriptors
414  * @buf: Array of data_buf structure
415  */
416 struct btintel_pcie_dbgc {
417 	u16		count;
418 
419 	void		*frag_v_addr;
420 	dma_addr_t	frag_p_addr;
421 	u16		frag_size;
422 
423 	dma_addr_t	buf_p_addr;
424 	void		*buf_v_addr;
425 	struct data_buf *bufs;
426 };
427 
428 struct btintel_pcie_dump_header {
429 	const char	*driver_name;
430 	u32		cnvi_top;
431 	u32		cnvr_top;
432 	u16		fw_timestamp;
433 	u8		fw_build_type;
434 	u32		fw_build_num;
435 	u32		fw_git_sha1;
436 	u32		cnvi_bt;
437 	u32		write_ptr;
438 	u32		wrap_ctr;
439 	u16		trigger_reason;
440 	int		state;
441 	u8		event_type;
442 	u16		event_id;
443 };
444 
445 /* struct btintel_pcie_data
446  * @pdev: pci device
447  * @hdev: hdev device
448  * @flags: driver state
449  * @irq_lock: spinlock for MSI-X
450  * @hci_rx_lock: spinlock for HCI RX flow
451  * @base_addr: pci base address (from BAR)
452  * @msix_entries: array of MSI-X entries
453  * @msix_enabled: true if MSI-X is enabled;
454  * @alloc_vecs: number of interrupt vectors allocated
455  * @def_irq: default irq for all causes
456  * @fh_init_mask: initial unmasked rxq causes
457  * @hw_init_mask: initial unmaksed hw causes
458  * @boot_stage_cache: cached value of boot stage register
459  * @img_resp_cache: cached value of image response register
460  * @cnvi: CNVi register value
461  * @cnvr: CNVr register value
462  * @gp0_received: condition for gp0 interrupt
463  * @gp0_wait_q: wait_q for gp0 interrupt
464  * @tx_wait_done: condition for tx interrupt
465  * @tx_wait_q: wait_q for tx interrupt
466  * @workqueue: workqueue for RX work
467  * @rx_skb_q: SKB queue for RX packet
468  * @rx_work: RX work struct to process the RX packet in @rx_skb_q
469  * @coredump_workqueue: dedicated workqueue for coredump collection
470  * @coredump_work: work struct for coredump trace collection
471  * @dma_pool: DMA pool for descriptors, index array and ci
472  * @dma_p_addr: DMA address for pool
473  * @dma_v_addr: address of pool
474  * @ci_p_addr: DMA address for CI struct
475  * @ci: CI struct
476  * @ia: Index Array struct
477  * @txq: TX Queue struct
478  * @rxq: RX Queue struct
479  * @alive_intr_ctxt: Alive interrupt context
480  * @pm_sx_event: PM event on which system got suspended
481  */
482 struct btintel_pcie_data {
483 	struct pci_dev	*pdev;
484 	struct hci_dev	*hdev;
485 
486 	unsigned long	flags;
487 	/* lock used in MSI-X interrupt */
488 	spinlock_t	irq_lock;
489 	/* lock to serialize rx events */
490 	spinlock_t	hci_rx_lock;
491 
492 	void __iomem	*base_addr;
493 
494 	struct msix_entry	msix_entries[BTINTEL_PCIE_MSIX_VEC_MAX];
495 	bool	msix_enabled;
496 	u32	alloc_vecs;
497 	u32	def_irq;
498 
499 	u32	fh_init_mask;
500 	u32	hw_init_mask;
501 
502 	u32	boot_stage_cache;
503 	u32	img_resp_cache;
504 
505 	u32	cnvi;
506 	u32	cnvr;
507 
508 	bool	gp0_received;
509 	wait_queue_head_t	gp0_wait_q;
510 
511 	bool	tx_wait_done;
512 	wait_queue_head_t	tx_wait_q;
513 
514 	struct workqueue_struct	*workqueue;
515 	struct sk_buff_head	rx_skb_q;
516 	struct work_struct	rx_work;
517 	struct work_struct      reset_work;
518 
519 	struct workqueue_struct	*coredump_workqueue;
520 	struct work_struct	coredump_work;
521 
522 	struct dma_pool	*dma_pool;
523 	dma_addr_t	dma_p_addr;
524 	void		*dma_v_addr;
525 
526 	dma_addr_t	ci_p_addr;
527 	struct ctx_info	*ci;
528 	struct ia	ia;
529 	struct txq	txq;
530 	struct rxq	rxq;
531 	u32	alive_intr_ctxt;
532 	enum btintel_pcie_reset_type	reset_type;
533 	struct btintel_pcie_dbgc	dbgc;
534 	struct btintel_pcie_dump_header dmp_hdr;
535 	u8	pm_sx_event;
536 	u32	debug_evt_addr;
537 	u32	debug_evt_size;
538 };
539 
540 static inline u32 btintel_pcie_rd_reg32(struct btintel_pcie_data *data,
541 					u32 offset)
542 {
543 	return ioread32(data->base_addr + offset);
544 }
545 
546 static inline void btintel_pcie_wr_reg8(struct btintel_pcie_data *data,
547 					u32 offset, u8 val)
548 {
549 	iowrite8(val, data->base_addr + offset);
550 }
551 
552 static inline void btintel_pcie_wr_reg32(struct btintel_pcie_data *data,
553 					 u32 offset, u32 val)
554 {
555 	iowrite32(val, data->base_addr + offset);
556 }
557 
558 static inline void btintel_pcie_set_reg_bits(struct btintel_pcie_data *data,
559 					     u32 offset, u32 bits)
560 {
561 	u32 r;
562 
563 	r = ioread32(data->base_addr + offset);
564 	r |= bits;
565 	iowrite32(r, data->base_addr + offset);
566 }
567 
568 static inline void btintel_pcie_clr_reg_bits(struct btintel_pcie_data *data,
569 					     u32 offset, u32 bits)
570 {
571 	u32 r;
572 
573 	r = ioread32(data->base_addr + offset);
574 	r &= ~bits;
575 	iowrite32(r, data->base_addr + offset);
576 }
577 
578 static inline u32 btintel_pcie_rd_dev_mem(struct btintel_pcie_data *data,
579 					  u32 addr)
580 {
581 	btintel_pcie_wr_reg32(data, BTINTEL_PCIE_PRPH_DEV_ADDR_REG, addr);
582 	return btintel_pcie_rd_reg32(data, BTINTEL_PCIE_PRPH_DEV_RD_REG);
583 }
584 
585