mv_cesa.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef __MV_CRYPTO_H__
  2. #define DIGEST_INITIAL_VAL_A 0xdd00
  3. #define DIGEST_INITIAL_VAL_B 0xdd04
  4. #define DIGEST_INITIAL_VAL_C 0xdd08
  5. #define DIGEST_INITIAL_VAL_D 0xdd0c
  6. #define DIGEST_INITIAL_VAL_E 0xdd10
  7. #define DES_CMD_REG 0xdd58
  8. #define SEC_ACCEL_CMD 0xde00
  9. #define SEC_CMD_EN_SEC_ACCL0 (1 << 0)
  10. #define SEC_CMD_EN_SEC_ACCL1 (1 << 1)
  11. #define SEC_CMD_DISABLE_SEC (1 << 2)
  12. #define SEC_ACCEL_DESC_P0 0xde04
  13. #define SEC_DESC_P0_PTR(x) (x)
  14. #define SEC_ACCEL_DESC_P1 0xde14
  15. #define SEC_DESC_P1_PTR(x) (x)
  16. #define SEC_ACCEL_CFG 0xde08
  17. #define SEC_CFG_STOP_DIG_ERR (1 << 0)
  18. #define SEC_CFG_CH0_W_IDMA (1 << 7)
  19. #define SEC_CFG_CH1_W_IDMA (1 << 8)
  20. #define SEC_CFG_ACT_CH0_IDMA (1 << 9)
  21. #define SEC_CFG_ACT_CH1_IDMA (1 << 10)
  22. #define SEC_ACCEL_STATUS 0xde0c
  23. #define SEC_ST_ACT_0 (1 << 0)
  24. #define SEC_ST_ACT_1 (1 << 1)
  25. /*
  26. * FPGA_INT_STATUS looks like a FPGA leftover and is documented only in Errata
  27. * 4.12. It looks like that it was part of an IRQ-controller in FPGA and
  28. * someone forgot to remove it while switching to the core and moving to
  29. * SEC_ACCEL_INT_STATUS.
  30. */
  31. #define FPGA_INT_STATUS 0xdd68
  32. #define SEC_ACCEL_INT_STATUS 0xde20
  33. #define SEC_INT_AUTH_DONE (1 << 0)
  34. #define SEC_INT_DES_E_DONE (1 << 1)
  35. #define SEC_INT_AES_E_DONE (1 << 2)
  36. #define SEC_INT_AES_D_DONE (1 << 3)
  37. #define SEC_INT_ENC_DONE (1 << 4)
  38. #define SEC_INT_ACCEL0_DONE (1 << 5)
  39. #define SEC_INT_ACCEL1_DONE (1 << 6)
  40. #define SEC_INT_ACC0_IDMA_DONE (1 << 7)
  41. #define SEC_INT_ACC1_IDMA_DONE (1 << 8)
  42. #define SEC_ACCEL_INT_MASK 0xde24
  43. #define AES_KEY_LEN (8 * 4)
  44. struct sec_accel_config {
  45. u32 config;
  46. #define CFG_OP_MAC_ONLY 0
  47. #define CFG_OP_CRYPT_ONLY 1
  48. #define CFG_OP_MAC_CRYPT 2
  49. #define CFG_OP_CRYPT_MAC 3
  50. #define CFG_MACM_MD5 (4 << 4)
  51. #define CFG_MACM_SHA1 (5 << 4)
  52. #define CFG_MACM_HMAC_MD5 (6 << 4)
  53. #define CFG_MACM_HMAC_SHA1 (7 << 4)
  54. #define CFG_ENCM_DES (1 << 8)
  55. #define CFG_ENCM_3DES (2 << 8)
  56. #define CFG_ENCM_AES (3 << 8)
  57. #define CFG_DIR_ENC (0 << 12)
  58. #define CFG_DIR_DEC (1 << 12)
  59. #define CFG_ENC_MODE_ECB (0 << 16)
  60. #define CFG_ENC_MODE_CBC (1 << 16)
  61. #define CFG_3DES_EEE (0 << 20)
  62. #define CFG_3DES_EDE (1 << 20)
  63. #define CFG_AES_LEN_128 (0 << 24)
  64. #define CFG_AES_LEN_192 (1 << 24)
  65. #define CFG_AES_LEN_256 (2 << 24)
  66. #define CFG_NOT_FRAG (0 << 30)
  67. #define CFG_FIRST_FRAG (1 << 30)
  68. #define CFG_LAST_FRAG (2 << 30)
  69. #define CFG_MID_FRAG (3 << 30)
  70. u32 enc_p;
  71. #define ENC_P_SRC(x) (x)
  72. #define ENC_P_DST(x) ((x) << 16)
  73. u32 enc_len;
  74. #define ENC_LEN(x) (x)
  75. u32 enc_key_p;
  76. #define ENC_KEY_P(x) (x)
  77. u32 enc_iv;
  78. #define ENC_IV_POINT(x) ((x) << 0)
  79. #define ENC_IV_BUF_POINT(x) ((x) << 16)
  80. u32 mac_src_p;
  81. #define MAC_SRC_DATA_P(x) (x)
  82. #define MAC_SRC_TOTAL_LEN(x) ((x) << 16)
  83. u32 mac_digest;
  84. #define MAC_DIGEST_P(x) (x)
  85. #define MAC_FRAG_LEN(x) ((x) << 16)
  86. u32 mac_iv;
  87. #define MAC_INNER_IV_P(x) (x)
  88. #define MAC_OUTER_IV_P(x) ((x) << 16)
  89. }__attribute__ ((packed));
  90. /*
  91. * /-----------\ 0
  92. * | ACCEL CFG | 4 * 8
  93. * |-----------| 0x20
  94. * | CRYPT KEY | 8 * 4
  95. * |-----------| 0x40
  96. * | IV IN | 4 * 4
  97. * |-----------| 0x40 (inplace)
  98. * | IV BUF | 4 * 4
  99. * |-----------| 0x80
  100. * | DATA IN | 16 * x (max ->max_req_size)
  101. * |-----------| 0x80 (inplace operation)
  102. * | DATA OUT | 16 * x (max ->max_req_size)
  103. * \-----------/ SRAM size
  104. */
  105. /* Hashing memory map:
  106. * /-----------\ 0
  107. * | ACCEL CFG | 4 * 8
  108. * |-----------| 0x20
  109. * | Inner IV | 5 * 4
  110. * |-----------| 0x34
  111. * | Outer IV | 5 * 4
  112. * |-----------| 0x48
  113. * | Output BUF| 5 * 4
  114. * |-----------| 0x80
  115. * | DATA IN | 64 * x (max ->max_req_size)
  116. * \-----------/ SRAM size
  117. */
  118. #define SRAM_CONFIG 0x00
  119. #define SRAM_DATA_KEY_P 0x20
  120. #define SRAM_DATA_IV 0x40
  121. #define SRAM_DATA_IV_BUF 0x40
  122. #define SRAM_DATA_IN_START 0x80
  123. #define SRAM_DATA_OUT_START 0x80
  124. #define SRAM_HMAC_IV_IN 0x20
  125. #define SRAM_HMAC_IV_OUT 0x34
  126. #define SRAM_DIGEST_BUF 0x48
  127. #define SRAM_CFG_SPACE 0x80
  128. #endif