icp_qat_hal.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. This file is provided under a dual BSD/GPLv2 license. When using or
  3. redistributing this file, you may do so under either license.
  4. GPL LICENSE SUMMARY
  5. Copyright(c) 2014 Intel Corporation.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License as
  8. published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. Contact Information:
  14. [email protected]
  15. BSD LICENSE
  16. Copyright(c) 2014 Intel Corporation.
  17. Redistribution and use in source and binary forms, with or without
  18. modification, are permitted provided that the following conditions
  19. are met:
  20. * Redistributions of source code must retain the above copyright
  21. notice, this list of conditions and the following disclaimer.
  22. * Redistributions in binary form must reproduce the above copyright
  23. notice, this list of conditions and the following disclaimer in
  24. the documentation and/or other materials provided with the
  25. distribution.
  26. * Neither the name of Intel Corporation nor the names of its
  27. contributors may be used to endorse or promote products derived
  28. from this software without specific prior written permission.
  29. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. */
  41. #ifndef __ICP_QAT_HAL_H
  42. #define __ICP_QAT_HAL_H
  43. #include "icp_qat_fw_loader_handle.h"
  44. enum hal_global_csr {
  45. MISC_CONTROL = 0x04,
  46. ICP_RESET = 0x0c,
  47. ICP_GLOBAL_CLK_ENABLE = 0x50
  48. };
  49. enum hal_ae_csr {
  50. USTORE_ADDRESS = 0x000,
  51. USTORE_DATA_LOWER = 0x004,
  52. USTORE_DATA_UPPER = 0x008,
  53. ALU_OUT = 0x010,
  54. CTX_ARB_CNTL = 0x014,
  55. CTX_ENABLES = 0x018,
  56. CC_ENABLE = 0x01c,
  57. CSR_CTX_POINTER = 0x020,
  58. CTX_STS_INDIRECT = 0x040,
  59. ACTIVE_CTX_STATUS = 0x044,
  60. CTX_SIG_EVENTS_INDIRECT = 0x048,
  61. CTX_SIG_EVENTS_ACTIVE = 0x04c,
  62. CTX_WAKEUP_EVENTS_INDIRECT = 0x050,
  63. LM_ADDR_0_INDIRECT = 0x060,
  64. LM_ADDR_1_INDIRECT = 0x068,
  65. INDIRECT_LM_ADDR_0_BYTE_INDEX = 0x0e0,
  66. INDIRECT_LM_ADDR_1_BYTE_INDEX = 0x0e8,
  67. FUTURE_COUNT_SIGNAL_INDIRECT = 0x078,
  68. TIMESTAMP_LOW = 0x0c0,
  69. TIMESTAMP_HIGH = 0x0c4,
  70. PROFILE_COUNT = 0x144,
  71. SIGNATURE_ENABLE = 0x150,
  72. AE_MISC_CONTROL = 0x160,
  73. LOCAL_CSR_STATUS = 0x180,
  74. };
  75. enum fcu_csr {
  76. FCU_CONTROL = 0x8c0,
  77. FCU_STATUS = 0x8c4,
  78. FCU_STATUS1 = 0x8c8,
  79. FCU_DRAM_ADDR_LO = 0x8cc,
  80. FCU_DRAM_ADDR_HI = 0x8d0,
  81. FCU_RAMBASE_ADDR_HI = 0x8d4,
  82. FCU_RAMBASE_ADDR_LO = 0x8d8
  83. };
  84. enum fcu_cmd {
  85. FCU_CTRL_CMD_NOOP = 0,
  86. FCU_CTRL_CMD_AUTH = 1,
  87. FCU_CTRL_CMD_LOAD = 2,
  88. FCU_CTRL_CMD_START = 3
  89. };
  90. enum fcu_sts {
  91. FCU_STS_NO_STS = 0,
  92. FCU_STS_VERI_DONE = 1,
  93. FCU_STS_LOAD_DONE = 2,
  94. FCU_STS_VERI_FAIL = 3,
  95. FCU_STS_LOAD_FAIL = 4,
  96. FCU_STS_BUSY = 5
  97. };
  98. #define UA_ECS (0x1 << 31)
  99. #define ACS_ABO_BITPOS 31
  100. #define ACS_ACNO 0x7
  101. #define CE_ENABLE_BITPOS 0x8
  102. #define CE_LMADDR_0_GLOBAL_BITPOS 16
  103. #define CE_LMADDR_1_GLOBAL_BITPOS 17
  104. #define CE_NN_MODE_BITPOS 20
  105. #define CE_REG_PAR_ERR_BITPOS 25
  106. #define CE_BREAKPOINT_BITPOS 27
  107. #define CE_CNTL_STORE_PARITY_ERROR_BITPOS 29
  108. #define CE_INUSE_CONTEXTS_BITPOS 31
  109. #define CE_NN_MODE (0x1 << CE_NN_MODE_BITPOS)
  110. #define CE_INUSE_CONTEXTS (0x1 << CE_INUSE_CONTEXTS_BITPOS)
  111. #define XCWE_VOLUNTARY (0x1)
  112. #define LCS_STATUS (0x1)
  113. #define MMC_SHARE_CS_BITPOS 2
  114. #define GLOBAL_CSR 0xA00
  115. #define FCU_CTRL_AE_POS 0x8
  116. #define FCU_AUTH_STS_MASK 0x7
  117. #define FCU_STS_DONE_POS 0x9
  118. #define FCU_STS_AUTHFWLD_POS 0X8
  119. #define FCU_LOADED_AE_POS 0x16
  120. #define FW_AUTH_WAIT_PERIOD 10
  121. #define FW_AUTH_MAX_RETRY 300
  122. #define SET_CAP_CSR(handle, csr, val) \
  123. ADF_CSR_WR(handle->hal_cap_g_ctl_csr_addr_v, csr, val)
  124. #define GET_CAP_CSR(handle, csr) \
  125. ADF_CSR_RD(handle->hal_cap_g_ctl_csr_addr_v, csr)
  126. #define SET_GLB_CSR(handle, csr, val) SET_CAP_CSR(handle, csr + GLOBAL_CSR, val)
  127. #define GET_GLB_CSR(handle, csr) GET_CAP_CSR(handle, GLOBAL_CSR + csr)
  128. #define AE_CSR(handle, ae) \
  129. ((char __iomem *)handle->hal_cap_ae_local_csr_addr_v + \
  130. ((ae & handle->hal_handle->ae_mask) << 12))
  131. #define AE_CSR_ADDR(handle, ae, csr) (AE_CSR(handle, ae) + (0x3ff & csr))
  132. #define SET_AE_CSR(handle, ae, csr, val) \
  133. ADF_CSR_WR(AE_CSR_ADDR(handle, ae, csr), 0, val)
  134. #define GET_AE_CSR(handle, ae, csr) ADF_CSR_RD(AE_CSR_ADDR(handle, ae, csr), 0)
  135. #define AE_XFER(handle, ae) \
  136. ((char __iomem *)handle->hal_cap_ae_xfer_csr_addr_v + \
  137. ((ae & handle->hal_handle->ae_mask) << 12))
  138. #define AE_XFER_ADDR(handle, ae, reg) (AE_XFER(handle, ae) + \
  139. ((reg & 0xff) << 2))
  140. #define SET_AE_XFER(handle, ae, reg, val) \
  141. ADF_CSR_WR(AE_XFER_ADDR(handle, ae, reg), 0, val)
  142. #define SRAM_WRITE(handle, addr, val) \
  143. ADF_CSR_WR(handle->hal_sram_addr_v, addr, val)
  144. #endif