pcie_ipc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright (c) 2015-2016 Quantenna Communications, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef _QTN_FMAC_PCIE_IPC_H_
  17. #define _QTN_FMAC_PCIE_IPC_H_
  18. #include <linux/types.h>
  19. #include "shm_ipc_defs.h"
  20. /* bitmap for EP status and flags: updated by EP, read by RC */
  21. #define QTN_EP_HAS_UBOOT BIT(0)
  22. #define QTN_EP_HAS_FIRMWARE BIT(1)
  23. #define QTN_EP_REQ_UBOOT BIT(2)
  24. #define QTN_EP_REQ_FIRMWARE BIT(3)
  25. #define QTN_EP_ERROR_UBOOT BIT(4)
  26. #define QTN_EP_ERROR_FIRMWARE BIT(5)
  27. #define QTN_EP_FW_LOADRDY BIT(8)
  28. #define QTN_EP_FW_SYNC BIT(9)
  29. #define QTN_EP_FW_RETRY BIT(10)
  30. #define QTN_EP_FW_QLINK_DONE BIT(15)
  31. #define QTN_EP_FW_DONE BIT(16)
  32. /* bitmap for RC status and flags: updated by RC, read by EP */
  33. #define QTN_RC_PCIE_LINK BIT(0)
  34. #define QTN_RC_NET_LINK BIT(1)
  35. #define QTN_RC_FW_FLASHBOOT BIT(5)
  36. #define QTN_RC_FW_QLINK BIT(7)
  37. #define QTN_RC_FW_LOADRDY BIT(8)
  38. #define QTN_RC_FW_SYNC BIT(9)
  39. /* state transition timeouts */
  40. #define QTN_FW_DL_TIMEOUT_MS 3000
  41. #define QTN_FW_QLINK_TIMEOUT_MS 30000
  42. #define QTN_EP_RESET_WAIT_MS 1000
  43. #define PCIE_HDP_INT_RX_BITS (0 \
  44. | PCIE_HDP_INT_EP_TXDMA \
  45. | PCIE_HDP_INT_EP_TXEMPTY \
  46. | PCIE_HDP_INT_HHBM_UF \
  47. )
  48. #define PCIE_HDP_INT_TX_BITS (0 \
  49. | PCIE_HDP_INT_EP_RXDMA \
  50. )
  51. #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
  52. #define QTN_HOST_HI32(a) ((u32)(((u64)a) >> 32))
  53. #define QTN_HOST_LO32(a) ((u32)(((u64)a) & 0xffffffffUL))
  54. #define QTN_HOST_ADDR(h, l) ((((u64)h) << 32) | ((u64)l))
  55. #else
  56. #define QTN_HOST_HI32(a) 0
  57. #define QTN_HOST_LO32(a) ((u32)(((u32)a) & 0xffffffffUL))
  58. #define QTN_HOST_ADDR(h, l) ((u32)l)
  59. #endif
  60. #define QTN_SYSCTL_BAR 0
  61. #define QTN_SHMEM_BAR 2
  62. #define QTN_DMA_BAR 3
  63. #define QTN_PCIE_BDA_VERSION 0x1002
  64. #define PCIE_BDA_NAMELEN 32
  65. #define PCIE_HHBM_MAX_SIZE 2048
  66. #define SKB_BUF_SIZE 2048
  67. #define QTN_PCIE_BOARDFLG "PCIEQTN"
  68. #define QTN_PCIE_FW_DLMASK 0xF
  69. #define QTN_PCIE_FW_BUFSZ 2048
  70. #define QTN_ENET_ADDR_LENGTH 6
  71. #define QTN_TXDONE_MASK ((u32)0x80000000)
  72. #define QTN_GET_LEN(x) ((x) & 0xFFFF)
  73. #define QTN_PCIE_TX_DESC_LEN_MASK 0xFFFF
  74. #define QTN_PCIE_TX_DESC_LEN_SHIFT 0
  75. #define QTN_PCIE_TX_DESC_PORT_MASK 0xF
  76. #define QTN_PCIE_TX_DESC_PORT_SHIFT 16
  77. #define QTN_PCIE_TX_DESC_TQE_BIT BIT(24)
  78. #define QTN_EP_LHOST_TQE_PORT 4
  79. enum qtnf_pcie_bda_ipc_flags {
  80. QTN_PCIE_IPC_FLAG_HBM_MAGIC = BIT(0),
  81. QTN_PCIE_IPC_FLAG_SHM_PIO = BIT(1),
  82. };
  83. struct qtnf_pcie_bda {
  84. __le16 bda_len;
  85. __le16 bda_version;
  86. __le32 bda_pci_endian;
  87. __le32 bda_ep_state;
  88. __le32 bda_rc_state;
  89. __le32 bda_dma_mask;
  90. __le32 bda_msi_addr;
  91. __le32 bda_flashsz;
  92. u8 bda_boardname[PCIE_BDA_NAMELEN];
  93. __le32 bda_rc_msi_enabled;
  94. u8 bda_hhbm_list[PCIE_HHBM_MAX_SIZE];
  95. __le32 bda_dsbw_start_index;
  96. __le32 bda_dsbw_end_index;
  97. __le32 bda_dsbw_total_bytes;
  98. __le32 bda_rc_tx_bd_base;
  99. __le32 bda_rc_tx_bd_num;
  100. u8 bda_pcie_mac[QTN_ENET_ADDR_LENGTH];
  101. struct qtnf_shm_ipc_region bda_shm_reg1 __aligned(4096); /* host TX */
  102. struct qtnf_shm_ipc_region bda_shm_reg2 __aligned(4096); /* host RX */
  103. } __packed;
  104. struct qtnf_tx_bd {
  105. __le32 addr;
  106. __le32 addr_h;
  107. __le32 info;
  108. __le32 info_h;
  109. } __packed;
  110. struct qtnf_rx_bd {
  111. __le32 addr;
  112. __le32 addr_h;
  113. __le32 info;
  114. __le32 info_h;
  115. __le32 next_ptr;
  116. __le32 next_ptr_h;
  117. } __packed;
  118. enum qtnf_fw_loadtype {
  119. QTN_FW_DBEGIN,
  120. QTN_FW_DSUB,
  121. QTN_FW_DEND,
  122. QTN_FW_CTRL
  123. };
  124. struct qtnf_pcie_fw_hdr {
  125. u8 boardflg[8];
  126. __le32 fwsize;
  127. __le32 seqnum;
  128. __le32 type;
  129. __le32 pktlen;
  130. __le32 crc;
  131. } __packed;
  132. #endif /* _QTN_FMAC_PCIE_IPC_H_ */