crypto4xx_reg_def.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /**
  2. * AMCC SoC PPC4xx Crypto Driver
  3. *
  4. * Copyright (c) 2008 Applied Micro Circuits Corporation.
  5. * All rights reserved. James Hsiao <jhsiao@amcc.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * This filr defines the register set for Security Subsystem
  18. */
  19. #ifndef __CRYPTO4XX_REG_DEF_H__
  20. #define __CRYPTO4XX_REG_DEF_H__
  21. /* CRYPTO4XX Register offset */
  22. #define CRYPTO4XX_DESCRIPTOR 0x00000000
  23. #define CRYPTO4XX_CTRL_STAT 0x00000000
  24. #define CRYPTO4XX_SOURCE 0x00000004
  25. #define CRYPTO4XX_DEST 0x00000008
  26. #define CRYPTO4XX_SA 0x0000000C
  27. #define CRYPTO4XX_SA_LENGTH 0x00000010
  28. #define CRYPTO4XX_LENGTH 0x00000014
  29. #define CRYPTO4XX_PE_DMA_CFG 0x00000040
  30. #define CRYPTO4XX_PE_DMA_STAT 0x00000044
  31. #define CRYPTO4XX_PDR_BASE 0x00000048
  32. #define CRYPTO4XX_RDR_BASE 0x0000004c
  33. #define CRYPTO4XX_RING_SIZE 0x00000050
  34. #define CRYPTO4XX_RING_CTRL 0x00000054
  35. #define CRYPTO4XX_INT_RING_STAT 0x00000058
  36. #define CRYPTO4XX_EXT_RING_STAT 0x0000005c
  37. #define CRYPTO4XX_IO_THRESHOLD 0x00000060
  38. #define CRYPTO4XX_GATH_RING_BASE 0x00000064
  39. #define CRYPTO4XX_SCAT_RING_BASE 0x00000068
  40. #define CRYPTO4XX_PART_RING_SIZE 0x0000006c
  41. #define CRYPTO4XX_PART_RING_CFG 0x00000070
  42. #define CRYPTO4XX_PDR_BASE_UADDR 0x00000080
  43. #define CRYPTO4XX_RDR_BASE_UADDR 0x00000084
  44. #define CRYPTO4XX_PKT_SRC_UADDR 0x00000088
  45. #define CRYPTO4XX_PKT_DEST_UADDR 0x0000008c
  46. #define CRYPTO4XX_SA_UADDR 0x00000090
  47. #define CRYPTO4XX_GATH_RING_BASE_UADDR 0x000000A0
  48. #define CRYPTO4XX_SCAT_RING_BASE_UADDR 0x000000A4
  49. #define CRYPTO4XX_SEQ_RD 0x00000408
  50. #define CRYPTO4XX_SEQ_MASK_RD 0x0000040C
  51. #define CRYPTO4XX_SA_CMD_0 0x00010600
  52. #define CRYPTO4XX_SA_CMD_1 0x00010604
  53. #define CRYPTO4XX_STATE_PTR 0x000106dc
  54. #define CRYPTO4XX_STATE_IV 0x00010700
  55. #define CRYPTO4XX_STATE_HASH_BYTE_CNT_0 0x00010710
  56. #define CRYPTO4XX_STATE_HASH_BYTE_CNT_1 0x00010714
  57. #define CRYPTO4XX_STATE_IDIGEST_0 0x00010718
  58. #define CRYPTO4XX_STATE_IDIGEST_1 0x0001071c
  59. #define CRYPTO4XX_DATA_IN 0x00018000
  60. #define CRYPTO4XX_DATA_OUT 0x0001c000
  61. #define CRYPTO4XX_INT_UNMASK_STAT 0x000500a0
  62. #define CRYPTO4XX_INT_MASK_STAT 0x000500a4
  63. #define CRYPTO4XX_INT_CLR 0x000500a4
  64. #define CRYPTO4XX_INT_EN 0x000500a8
  65. #define CRYPTO4XX_INT_PKA 0x00000002
  66. #define CRYPTO4XX_INT_PDR_DONE 0x00008000
  67. #define CRYPTO4XX_INT_MA_WR_ERR 0x00020000
  68. #define CRYPTO4XX_INT_MA_RD_ERR 0x00010000
  69. #define CRYPTO4XX_INT_PE_ERR 0x00000200
  70. #define CRYPTO4XX_INT_USER_DMA_ERR 0x00000040
  71. #define CRYPTO4XX_INT_SLAVE_ERR 0x00000010
  72. #define CRYPTO4XX_INT_MASTER_ERR 0x00000008
  73. #define CRYPTO4XX_INT_ERROR 0x00030258
  74. #define CRYPTO4XX_INT_CFG 0x000500ac
  75. #define CRYPTO4XX_INT_DESCR_RD 0x000500b0
  76. #define CRYPTO4XX_INT_DESCR_CNT 0x000500b4
  77. #define CRYPTO4XX_INT_TIMEOUT_CNT 0x000500b8
  78. #define CRYPTO4XX_DEVICE_CTRL 0x00060080
  79. #define CRYPTO4XX_DEVICE_ID 0x00060084
  80. #define CRYPTO4XX_DEVICE_INFO 0x00060088
  81. #define CRYPTO4XX_DMA_USER_SRC 0x00060094
  82. #define CRYPTO4XX_DMA_USER_DEST 0x00060098
  83. #define CRYPTO4XX_DMA_USER_CMD 0x0006009C
  84. #define CRYPTO4XX_DMA_CFG 0x000600d4
  85. #define CRYPTO4XX_BYTE_ORDER_CFG 0x000600d8
  86. #define CRYPTO4XX_ENDIAN_CFG 0x000600d8
  87. #define CRYPTO4XX_PRNG_STAT 0x00070000
  88. #define CRYPTO4XX_PRNG_CTRL 0x00070004
  89. #define CRYPTO4XX_PRNG_SEED_L 0x00070008
  90. #define CRYPTO4XX_PRNG_SEED_H 0x0007000c
  91. #define CRYPTO4XX_PRNG_RES_0 0x00070020
  92. #define CRYPTO4XX_PRNG_RES_1 0x00070024
  93. #define CRYPTO4XX_PRNG_RES_2 0x00070028
  94. #define CRYPTO4XX_PRNG_RES_3 0x0007002C
  95. #define CRYPTO4XX_PRNG_LFSR_L 0x00070030
  96. #define CRYPTO4XX_PRNG_LFSR_H 0x00070034
  97. /**
  98. * Initialize CRYPTO ENGINE registers, and memory bases.
  99. */
  100. #define PPC4XX_PDR_POLL 0x3ff
  101. #define PPC4XX_OUTPUT_THRESHOLD 2
  102. #define PPC4XX_INPUT_THRESHOLD 2
  103. #define PPC4XX_PD_SIZE 6
  104. #define PPC4XX_CTX_DONE_INT 0x2000
  105. #define PPC4XX_PD_DONE_INT 0x8000
  106. #define PPC4XX_TMO_ERR_INT 0x40000
  107. #define PPC4XX_BYTE_ORDER 0x22222
  108. #define PPC4XX_INTERRUPT_CLR 0x3ffff
  109. #define PPC4XX_PRNG_CTRL_AUTO_EN 0x3
  110. #define PPC4XX_DC_3DES_EN 1
  111. #define PPC4XX_TRNG_EN 0x00020000
  112. #define PPC4XX_INT_DESCR_CNT 7
  113. #define PPC4XX_INT_TIMEOUT_CNT 0
  114. #define PPC4XX_INT_TIMEOUT_CNT_REVB 0x3FF
  115. #define PPC4XX_INT_CFG 1
  116. /**
  117. * all follow define are ad hoc
  118. */
  119. #define PPC4XX_RING_RETRY 100
  120. #define PPC4XX_RING_POLL 100
  121. #define PPC4XX_SDR_SIZE PPC4XX_NUM_SD
  122. #define PPC4XX_GDR_SIZE PPC4XX_NUM_GD
  123. /**
  124. * Generic Security Association (SA) with all possible fields. These will
  125. * never likely used except for reference purpose. These structure format
  126. * can be not changed as the hardware expects them to be layout as defined.
  127. * Field can be removed or reduced but ordering can not be changed.
  128. */
  129. #define CRYPTO4XX_DMA_CFG_OFFSET 0x40
  130. union ce_pe_dma_cfg {
  131. struct {
  132. u32 rsv:7;
  133. u32 dir_host:1;
  134. u32 rsv1:2;
  135. u32 bo_td_en:1;
  136. u32 dis_pdr_upd:1;
  137. u32 bo_sgpd_en:1;
  138. u32 bo_data_en:1;
  139. u32 bo_sa_en:1;
  140. u32 bo_pd_en:1;
  141. u32 rsv2:4;
  142. u32 dynamic_sa_en:1;
  143. u32 pdr_mode:2;
  144. u32 pe_mode:1;
  145. u32 rsv3:5;
  146. u32 reset_sg:1;
  147. u32 reset_pdr:1;
  148. u32 reset_pe:1;
  149. } bf;
  150. u32 w;
  151. } __attribute__((packed));
  152. #define CRYPTO4XX_PDR_BASE_OFFSET 0x48
  153. #define CRYPTO4XX_RDR_BASE_OFFSET 0x4c
  154. #define CRYPTO4XX_RING_SIZE_OFFSET 0x50
  155. union ce_ring_size {
  156. struct {
  157. u32 ring_offset:16;
  158. u32 rsv:6;
  159. u32 ring_size:10;
  160. } bf;
  161. u32 w;
  162. } __attribute__((packed));
  163. #define CRYPTO4XX_RING_CONTROL_OFFSET 0x54
  164. union ce_ring_control {
  165. struct {
  166. u32 continuous:1;
  167. u32 rsv:5;
  168. u32 ring_retry_divisor:10;
  169. u32 rsv1:4;
  170. u32 ring_poll_divisor:10;
  171. } bf;
  172. u32 w;
  173. } __attribute__((packed));
  174. #define CRYPTO4XX_IO_THRESHOLD_OFFSET 0x60
  175. union ce_io_threshold {
  176. struct {
  177. u32 rsv:6;
  178. u32 output_threshold:10;
  179. u32 rsv1:6;
  180. u32 input_threshold:10;
  181. } bf;
  182. u32 w;
  183. } __attribute__((packed));
  184. #define CRYPTO4XX_GATHER_RING_BASE_OFFSET 0x64
  185. #define CRYPTO4XX_SCATTER_RING_BASE_OFFSET 0x68
  186. union ce_part_ring_size {
  187. struct {
  188. u32 sdr_size:16;
  189. u32 gdr_size:16;
  190. } bf;
  191. u32 w;
  192. } __attribute__((packed));
  193. #define MAX_BURST_SIZE_32 0
  194. #define MAX_BURST_SIZE_64 1
  195. #define MAX_BURST_SIZE_128 2
  196. #define MAX_BURST_SIZE_256 3
  197. /* gather descriptor control length */
  198. struct gd_ctl_len {
  199. u32 len:16;
  200. u32 rsv:14;
  201. u32 done:1;
  202. u32 ready:1;
  203. } __attribute__((packed));
  204. struct ce_gd {
  205. u32 ptr;
  206. struct gd_ctl_len ctl_len;
  207. } __attribute__((packed));
  208. struct sd_ctl {
  209. u32 ctl:30;
  210. u32 done:1;
  211. u32 rdy:1;
  212. } __attribute__((packed));
  213. struct ce_sd {
  214. u32 ptr;
  215. struct sd_ctl ctl;
  216. } __attribute__((packed));
  217. #define PD_PAD_CTL_32 0x10
  218. #define PD_PAD_CTL_64 0x20
  219. #define PD_PAD_CTL_128 0x40
  220. #define PD_PAD_CTL_256 0x80
  221. union ce_pd_ctl {
  222. struct {
  223. u32 pd_pad_ctl:8;
  224. u32 status:8;
  225. u32 next_hdr:8;
  226. u32 rsv:2;
  227. u32 cached_sa:1;
  228. u32 hash_final:1;
  229. u32 init_arc4:1;
  230. u32 rsv1:1;
  231. u32 pe_done:1;
  232. u32 host_ready:1;
  233. } bf;
  234. u32 w;
  235. } __attribute__((packed));
  236. #define PD_CTL_HASH_FINAL BIT(4)
  237. #define PD_CTL_PE_DONE BIT(1)
  238. #define PD_CTL_HOST_READY BIT(0)
  239. union ce_pd_ctl_len {
  240. struct {
  241. u32 bypass:8;
  242. u32 pe_done:1;
  243. u32 host_ready:1;
  244. u32 rsv:2;
  245. u32 pkt_len:20;
  246. } bf;
  247. u32 w;
  248. } __attribute__((packed));
  249. struct ce_pd {
  250. union ce_pd_ctl pd_ctl;
  251. u32 src;
  252. u32 dest;
  253. u32 sa; /* get from ctx->sa_dma_addr */
  254. u32 sa_len; /* only if dynamic sa is used */
  255. union ce_pd_ctl_len pd_ctl_len;
  256. } __attribute__((packed));
  257. #endif