pcie.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* @file mwifiex_pcie.h
  2. *
  3. * @brief This file contains definitions for PCI-E interface.
  4. * driver.
  5. *
  6. * Copyright (C) 2011, Marvell International Ltd.
  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. #ifndef _MWIFIEX_PCIE_H
  22. #define _MWIFIEX_PCIE_H
  23. #include <linux/pci.h>
  24. #include <linux/pcieport_if.h>
  25. #include <linux/interrupt.h>
  26. #include "main.h"
  27. #define PCIE8766_DEFAULT_FW_NAME "mrvl/pcie8766_uapsta.bin"
  28. /* Constants for Buffer Descriptor (BD) rings */
  29. #define MWIFIEX_MAX_TXRX_BD 0x20
  30. #define MWIFIEX_TXBD_MASK 0x3F
  31. #define MWIFIEX_RXBD_MASK 0x3F
  32. #define MWIFIEX_MAX_EVT_BD 0x04
  33. #define MWIFIEX_EVTBD_MASK 0x07
  34. /* PCIE INTERNAL REGISTERS */
  35. #define PCIE_SCRATCH_0_REG 0xC10
  36. #define PCIE_SCRATCH_1_REG 0xC14
  37. #define PCIE_CPU_INT_EVENT 0xC18
  38. #define PCIE_CPU_INT_STATUS 0xC1C
  39. #define PCIE_HOST_INT_STATUS 0xC30
  40. #define PCIE_HOST_INT_MASK 0xC34
  41. #define PCIE_HOST_INT_STATUS_MASK 0xC3C
  42. #define PCIE_SCRATCH_2_REG 0xC40
  43. #define PCIE_SCRATCH_3_REG 0xC44
  44. #define PCIE_SCRATCH_4_REG 0xCD0
  45. #define PCIE_SCRATCH_5_REG 0xCD4
  46. #define PCIE_SCRATCH_6_REG 0xCD8
  47. #define PCIE_SCRATCH_7_REG 0xCDC
  48. #define PCIE_SCRATCH_8_REG 0xCE0
  49. #define PCIE_SCRATCH_9_REG 0xCE4
  50. #define PCIE_SCRATCH_10_REG 0xCE8
  51. #define PCIE_SCRATCH_11_REG 0xCEC
  52. #define PCIE_SCRATCH_12_REG 0xCF0
  53. #define CPU_INTR_DNLD_RDY BIT(0)
  54. #define CPU_INTR_DOOR_BELL BIT(1)
  55. #define CPU_INTR_SLEEP_CFM_DONE BIT(2)
  56. #define CPU_INTR_RESET BIT(3)
  57. #define HOST_INTR_DNLD_DONE BIT(0)
  58. #define HOST_INTR_UPLD_RDY BIT(1)
  59. #define HOST_INTR_CMD_DONE BIT(2)
  60. #define HOST_INTR_EVENT_RDY BIT(3)
  61. #define HOST_INTR_MASK (HOST_INTR_DNLD_DONE | \
  62. HOST_INTR_UPLD_RDY | \
  63. HOST_INTR_CMD_DONE | \
  64. HOST_INTR_EVENT_RDY)
  65. #define MWIFIEX_BD_FLAG_ROLLOVER_IND BIT(7)
  66. #define MWIFIEX_BD_FLAG_FIRST_DESC BIT(0)
  67. #define MWIFIEX_BD_FLAG_LAST_DESC BIT(1)
  68. #define REG_CMD_ADDR_LO PCIE_SCRATCH_0_REG
  69. #define REG_CMD_ADDR_HI PCIE_SCRATCH_1_REG
  70. #define REG_CMD_SIZE PCIE_SCRATCH_2_REG
  71. #define REG_CMDRSP_ADDR_LO PCIE_SCRATCH_4_REG
  72. #define REG_CMDRSP_ADDR_HI PCIE_SCRATCH_5_REG
  73. /* TX buffer description read pointer */
  74. #define REG_TXBD_RDPTR PCIE_SCRATCH_6_REG
  75. /* TX buffer description write pointer */
  76. #define REG_TXBD_WRPTR PCIE_SCRATCH_7_REG
  77. /* RX buffer description read pointer */
  78. #define REG_RXBD_RDPTR PCIE_SCRATCH_8_REG
  79. /* RX buffer description write pointer */
  80. #define REG_RXBD_WRPTR PCIE_SCRATCH_9_REG
  81. /* Event buffer description read pointer */
  82. #define REG_EVTBD_RDPTR PCIE_SCRATCH_10_REG
  83. /* Event buffer description write pointer */
  84. #define REG_EVTBD_WRPTR PCIE_SCRATCH_11_REG
  85. /* Driver ready signature write pointer */
  86. #define REG_DRV_READY PCIE_SCRATCH_12_REG
  87. /* Max retry number of command write */
  88. #define MAX_WRITE_IOMEM_RETRY 2
  89. /* Define PCIE block size for firmware download */
  90. #define MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD 256
  91. /* FW awake cookie after FW ready */
  92. #define FW_AWAKE_COOKIE (0xAA55AA55)
  93. struct mwifiex_pcie_buf_desc {
  94. u64 paddr;
  95. u16 len;
  96. u16 flags;
  97. } __packed;
  98. struct pcie_service_card {
  99. struct pci_dev *dev;
  100. struct mwifiex_adapter *adapter;
  101. u32 txbd_wrptr;
  102. u32 txbd_rdptr;
  103. u32 txbd_ring_size;
  104. u8 *txbd_ring_vbase;
  105. phys_addr_t txbd_ring_pbase;
  106. struct mwifiex_pcie_buf_desc *txbd_ring[MWIFIEX_MAX_TXRX_BD];
  107. struct sk_buff *tx_buf_list[MWIFIEX_MAX_TXRX_BD];
  108. u32 rxbd_wrptr;
  109. u32 rxbd_rdptr;
  110. u32 rxbd_ring_size;
  111. u8 *rxbd_ring_vbase;
  112. phys_addr_t rxbd_ring_pbase;
  113. struct mwifiex_pcie_buf_desc *rxbd_ring[MWIFIEX_MAX_TXRX_BD];
  114. struct sk_buff *rx_buf_list[MWIFIEX_MAX_TXRX_BD];
  115. u32 evtbd_wrptr;
  116. u32 evtbd_rdptr;
  117. u32 evtbd_ring_size;
  118. u8 *evtbd_ring_vbase;
  119. phys_addr_t evtbd_ring_pbase;
  120. struct mwifiex_pcie_buf_desc *evtbd_ring[MWIFIEX_MAX_EVT_BD];
  121. struct sk_buff *evt_buf_list[MWIFIEX_MAX_EVT_BD];
  122. struct sk_buff *cmd_buf;
  123. struct sk_buff *cmdrsp_buf;
  124. struct sk_buff *sleep_cookie;
  125. void __iomem *pci_mmap;
  126. void __iomem *pci_mmap1;
  127. };
  128. #endif /* _MWIFIEX_PCIE_H */