btintel_pcie.h 16 KB

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