aes-7108.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright (C) 2006 Micronas USA
  3. *
  4. * 1. Redistributions of source code must retain the above copyright
  5. * notice, this list of conditions and the following disclaimer.
  6. * 2. Redistributions in binary form must reproduce the above copyright
  7. * notice, this list of conditions and the following disclaimer in the
  8. * documentation and/or other materials provided with the distribution.
  9. * 3. The name of the author may not be used to endorse or promote products
  10. * derived from this software without specific prior written permission.
  11. *
  12. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  13. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * Effort sponsored in part by the Defense Advanced Research Projects
  24. * Agency (DARPA) and Air Force Research Laboratory, Air Force
  25. * Materiel Command, USAF, under agreement number F30602-01-2-0537.
  26. *
  27. */
  28. #ifndef __AES_7108_H__
  29. #define __AES_7108_H__
  30. /* Cypher 7108 AES Controller Hardware */
  31. #define CCU_REG_BASE 0x1b500000
  32. #define CCU_AES_REG_BASE (CCU_REG_BASE + 0x100)
  33. #define C7108_AES_KEY0_LO (0x0000)
  34. #define C7108_AES_KEY0_HI (0x0004)
  35. #define C7108_AES_KEY1_LO (0x0008)
  36. #define C7108_AES_KEY1_HI (0x000c)
  37. #define C7108_AES_KEY2_LO (0x0010)
  38. #define C7108_AES_KEY2_HI (0x0014)
  39. #define C7108_AES_KEY3_LO (0x0018)
  40. #define C7108_AES_KEY3_HI (0x001c)
  41. #define C7108_AES_KEY4_LO (0x0020)
  42. #define C7108_AES_KEY4_HI (0x0024)
  43. #define C7108_AES_KEY5_LO (0x0028)
  44. #define C7108_AES_KEY5_HI (0x002c)
  45. #define C7108_AES_KEY6_LO (0x0030)
  46. #define C7108_AES_KEY6_HI (0x0034)
  47. #define C7108_AES_KEY7_LO (0x0038)
  48. #define C7108_AES_KEY7_HI (0x003c)
  49. #define C7108_AES_IV0_LO (0x0040)
  50. #define C7108_AES_IV0_HI (0x0044)
  51. #define C7108_AES_IV1_LO (0x0048)
  52. #define C7108_AES_IV1_HI (0x004c)
  53. #define C7108_AES_IV2_LO (0x0050)
  54. #define C7108_AES_IV2_HI (0x0054)
  55. #define C7108_AES_IV3_LO (0x0058)
  56. #define C7108_AES_IV3_HI (0x005c)
  57. #define C7108_AES_DMA_SRC0_LO (0x0068) /* Bits 0:15 */
  58. #define C7108_AES_DMA_SRC0_HI (0x006c) /* Bits 27:16 */
  59. #define C7108_AES_DMA_DST0_LO (0x0070) /* Bits 0:15 */
  60. #define C7108_AES_DMA_DST0_HI (0x0074) /* Bits 27:16 */
  61. #define C7108_AES_DMA_LEN (0x0078) /*Bytes:(Count+1)x16 */
  62. /* AES/Copy engine control register */
  63. #define C7108_AES_CTRL (0x007c) /* AES control */
  64. #define C7108_AES_CTRL_RS (1<<0) /* Which set of src/dst to use */
  65. /* AES Cipher mode, controlled by setting Bits 2:0 */
  66. #define C7108_AES_CTRL_MODE_CBC 0
  67. #define C7108_AES_CTRL_MODE_CFB (1<<0)
  68. #define C7108_AES_CTRL_MODE_OFB (1<<1)
  69. #define C7108_AES_CTRL_MODE_CTR ((1<<0)|(1<<1))
  70. #define C7108_AES_CTRL_MODE_ECB (1<<2)
  71. /* AES Key length , Bits 5:4 */
  72. #define C7108_AES_KEY_LEN_128 0 /* 00 */
  73. #define C7108_AES_KEY_LEN_192 (1<<4) /* 01 */
  74. #define C7108_AES_KEY_LEN_256 (1<<5) /* 10 */
  75. /* AES Operation (crypt/decrypt), Bit 3 */
  76. #define C7108_AES_DECRYPT (1<<3) /* Clear for encrypt */
  77. #define C7108_AES_ENCRYPT 0
  78. #define C7108_AES_INTR (1<<13) /* Set on done trans from 0->1*/
  79. #define C7108_AES_GO (1<<14) /* Run */
  80. #define C7108_AES_OP_DONE (1<<15) /* Set when complete */
  81. /* Expanded key registers */
  82. #define C7108_AES_EKEY0_LO (0x0080)
  83. #define C7108_AES_EKEY0_HI (0x0084)
  84. #define C7108_AES_EKEY1_LO (0x0088)
  85. #define C7108_AES_EKEY1_HI (0x008c)
  86. #define C7108_AES_EKEY2_LO (0x0090)
  87. #define C7108_AES_EKEY2_HI (0x0094)
  88. #define C7108_AES_EKEY3_LO (0x0098)
  89. #define C7108_AES_EKEY3_HI (0x009c)
  90. #define C7108_AES_EKEY4_LO (0x00a0)
  91. #define C7108_AES_EKEY4_HI (0x00a4)
  92. #define C7108_AES_EKEY5_LO (0x00a8)
  93. #define C7108_AES_EKEY5_HI (0x00ac)
  94. #define C7108_AES_EKEY6_LO (0x00b0)
  95. #define C7108_AES_EKEY6_HI (0x00b4)
  96. #define C7108_AES_EKEY7_LO (0x00b8)
  97. #define C7108_AES_EKEY7_HI (0x00bc)
  98. #define C7108_AES_OK (0x00fc) /* Reset: "OK" */
  99. #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
  100. /* Software session entry */
  101. #define HW_TYPE_CIPHER 0
  102. #define SW_TYPE_HMAC 1
  103. #define SW_TYPE_AUTH2 2
  104. #define SW_TYPE_HASH 3
  105. #define SW_TYPE_COMP 4
  106. struct cipher_7108 {
  107. int xfm_type;
  108. int cri_alg;
  109. union {
  110. struct {
  111. char sw_key[HMAC_BLOCK_LEN];
  112. int sw_klen;
  113. int sw_authlen;
  114. } hmac;
  115. } u;
  116. struct cipher_7108 *next;
  117. };
  118. #endif /* __C7108_AES_7108_H__ */