qce40.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _DRIVERS_CRYPTO_MSM_QCE40_H_
  13. #define _DRIVERS_CRYPTO_MSM_QCE40_H_
  14. #define GET_VIRT_ADDR(x) \
  15. ((uint32_t)pce_dev->coh_vmem + \
  16. ((uint32_t)x - pce_dev->coh_pmem))
  17. #define GET_PHYS_ADDR(x) \
  18. (pce_dev->coh_pmem + ((unsigned char *)x - \
  19. pce_dev->coh_vmem))
  20. /* Sets the adddress of a command list in command pointer list */
  21. #define QCE_SET_CMD_PTR(x) \
  22. (uint32_t)(DMOV_CMD_ADDR(GET_PHYS_ADDR((unsigned char *)x)))
  23. /* Sets the adddress of the last command list in command pointer list */
  24. #define SET_LAST_CMD_PTR(x) \
  25. ((DMOV_CMD_ADDR(x)) | CMD_PTR_LP)
  26. /* Get the adddress of the last command list in command pointer list */
  27. #define QCE_SET_LAST_CMD_PTR(x) \
  28. SET_LAST_CMD_PTR((GET_PHYS_ADDR((unsigned char *)x)))
  29. /* MAX Data xfer block size between DM and CE */
  30. #define MAX_ADM_CE_BLOCK_SIZE 64
  31. #define ADM_DESC_LENGTH_MASK 0xffff
  32. #define ADM_DESC_LENGTH(x) (x & ADM_DESC_LENGTH_MASK)
  33. #define ADM_STATUS_OK 0x80000002
  34. /* QCE max number of descriptor in a descriptor list */
  35. #define QCE_MAX_NUM_DESC 128
  36. #define CRYPTO_REG_SIZE 0x4
  37. struct dmov_desc {
  38. uint32_t addr;
  39. uint32_t len;
  40. };
  41. /* State of DM channel */
  42. enum qce_chan_st_enum {
  43. QCE_CHAN_STATE_IDLE = 0,
  44. QCE_CHAN_STATE_IN_PROG = 1,
  45. QCE_CHAN_STATE_COMP = 2,
  46. QCE_CHAN_STATE_LAST
  47. };
  48. /* CE buffers */
  49. struct ce_reg_buffer_addr {
  50. unsigned char *reset_buf_64;
  51. unsigned char *version;
  52. unsigned char *encr_seg_cfg_size_start;
  53. unsigned char *encr_key;
  54. unsigned char *encr_xts_key;
  55. unsigned char *encr_cntr_iv;
  56. unsigned char *encr_mask;
  57. unsigned char *encr_xts_du_size;
  58. unsigned char *auth_seg_cfg_size_start;
  59. unsigned char *auth_key;
  60. unsigned char *auth_iv;
  61. unsigned char *auth_result;
  62. unsigned char *auth_nonce_info;
  63. unsigned char *auth_byte_count;
  64. unsigned char *seg_size;
  65. unsigned char *go_proc;
  66. unsigned char *status;
  67. unsigned char *pad;
  68. unsigned char *ignore_data;
  69. };
  70. /* CE buffers */
  71. struct ce_reg_buffers {
  72. unsigned char reset_buf_64[64];
  73. unsigned char version[CRYPTO_REG_SIZE];
  74. unsigned char encr_seg_cfg_size_start[3 * CRYPTO_REG_SIZE];
  75. unsigned char encr_key[8 * CRYPTO_REG_SIZE];
  76. unsigned char encr_xts_key[8 * CRYPTO_REG_SIZE];
  77. unsigned char encr_cntr_iv[4 * CRYPTO_REG_SIZE];
  78. unsigned char encr_mask[CRYPTO_REG_SIZE];
  79. unsigned char encr_xts_du_size[CRYPTO_REG_SIZE];
  80. unsigned char auth_seg_cfg_size_start[3 * CRYPTO_REG_SIZE];
  81. unsigned char auth_key[16 * CRYPTO_REG_SIZE];
  82. unsigned char auth_iv[16 * CRYPTO_REG_SIZE];
  83. unsigned char auth_result[16 * CRYPTO_REG_SIZE];
  84. unsigned char auth_nonce_info[4 * CRYPTO_REG_SIZE];
  85. unsigned char auth_byte_count[4 * CRYPTO_REG_SIZE];
  86. unsigned char seg_size[CRYPTO_REG_SIZE];
  87. unsigned char go_proc[CRYPTO_REG_SIZE];
  88. unsigned char status[CRYPTO_REG_SIZE];
  89. unsigned char pad[2 * MAX_ADM_CE_BLOCK_SIZE];
  90. };
  91. /* CE Command lists */
  92. struct ce_cmdlists {
  93. dmov_s *get_hw_version;
  94. dmov_s *clear_status;
  95. dmov_s *clear_status_ocb;
  96. dmov_s *get_status_ocu;
  97. dmov_s *set_cipher_cfg;
  98. dmov_s *set_cipher_aes_128_key;
  99. dmov_s *set_cipher_aes_256_key;
  100. dmov_s *set_cipher_des_key;
  101. dmov_s *set_cipher_3des_key;
  102. dmov_s *set_cipher_aes_128_xts_key;
  103. dmov_s *set_cipher_aes_256_xts_key;
  104. dmov_s *set_cipher_xts_du_size;
  105. dmov_s *set_cipher_aes_iv;
  106. dmov_s *set_cipher_aes_xts_iv;
  107. dmov_s *set_cipher_des_iv;
  108. dmov_s *get_cipher_iv;
  109. dmov_s *set_cipher_mask;
  110. dmov_s *set_auth_cfg;
  111. dmov_s *set_auth_key_128;
  112. dmov_s *set_auth_key_256;
  113. dmov_s *set_auth_key_512;
  114. dmov_s *set_auth_iv_16;
  115. dmov_s *get_auth_result_16;
  116. dmov_s *set_auth_iv_20;
  117. dmov_s *get_auth_result_20;
  118. dmov_s *set_auth_iv_32;
  119. dmov_s *get_auth_result_32;
  120. dmov_s *set_auth_byte_count;
  121. dmov_s *get_auth_byte_count;
  122. dmov_s *set_auth_nonce_info;
  123. dmov_s *reset_cipher_key;
  124. dmov_s *reset_cipher_xts_key;
  125. dmov_s *reset_cipher_iv;
  126. dmov_s *reset_cipher_cfg;
  127. dmov_s *reset_auth_key;
  128. dmov_s *reset_auth_iv;
  129. dmov_s *reset_auth_cfg;
  130. dmov_s *reset_auth_byte_count;
  131. dmov_s *set_seg_size;
  132. dmov_s *get_status_wait;
  133. dmov_s *set_go_proc;
  134. dmov_sg *ce_data_in;
  135. dmov_sg *ce_data_out;
  136. };
  137. /* Command pointer lists */
  138. struct ce_cmdptrlists_ops {
  139. uint32_t probe_ce_hw;
  140. uint32_t cipher_aes_128_cbc_ctr;
  141. uint32_t cipher_aes_256_cbc_ctr;
  142. uint32_t cipher_aes_128_ecb;
  143. uint32_t cipher_aes_256_ecb;
  144. uint32_t cipher_aes_128_xts;
  145. uint32_t cipher_aes_256_xts;
  146. uint32_t cipher_des_cbc;
  147. uint32_t cipher_des_ecb;
  148. uint32_t cipher_3des_cbc;
  149. uint32_t cipher_3des_ecb;
  150. uint32_t auth_sha1;
  151. uint32_t auth_sha256;
  152. uint32_t auth_sha1_hmac;
  153. uint32_t auth_sha256_hmac;
  154. uint32_t auth_aes_128_cmac;
  155. uint32_t auth_aes_256_cmac;
  156. uint32_t aead_aes_128_ccm;
  157. uint32_t aead_aes_256_ccm;
  158. uint32_t cipher_ce_out;
  159. uint32_t cipher_ce_out_get_iv;
  160. uint32_t aead_ce_out;
  161. };
  162. /* DM data structure with buffers, commandlists & commmand pointer lists */
  163. struct ce_dm_data {
  164. unsigned int chan_ce_in; /* ADM channel used for CE input
  165. * and auth result if authentication
  166. * only operation. */
  167. unsigned int chan_ce_out; /* ADM channel used for CE output,
  168. * and icv for esp */
  169. unsigned int crci_in; /* CRCI for CE DM IN Channel */
  170. unsigned int crci_out; /* CRCI for CE DM OUT Channel */
  171. enum qce_chan_st_enum chan_ce_in_state; /* chan ce_in state */
  172. enum qce_chan_st_enum chan_ce_out_state; /* chan ce_out state */
  173. int chan_ce_in_status; /* chan ce_in status */
  174. int chan_ce_out_status; /* chan ce_out status */
  175. struct dmov_desc *ce_out_src_desc;
  176. struct dmov_desc *ce_out_dst_desc;
  177. struct dmov_desc *ce_in_src_desc;
  178. struct dmov_desc *ce_in_dst_desc;
  179. int ce_out_src_desc_index;
  180. int ce_out_dst_desc_index;
  181. int ce_in_src_desc_index;
  182. int ce_in_dst_desc_index;
  183. int ce_block_size;
  184. dma_addr_t phy_ce_out_ignore;
  185. dma_addr_t phy_ce_pad;
  186. struct ce_reg_buffer_addr buffer;
  187. struct ce_cmdlists cmdlist;
  188. struct ce_cmdptrlists_ops cmdptrlist;
  189. struct msm_dmov_cmd *chan_ce_in_cmd;
  190. struct msm_dmov_cmd *chan_ce_out_cmd;
  191. };
  192. #endif /* _DRIVERS_CRYPTO_MSM_QCE40_H */