0c7bfcbb83d11e8cbb5f6620b4a3ac5bbf929c1c
[15.05/openwrt.git] / target / linux / generic / files / crypto / ocf / c7108 / aes-7108.h
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
29 #ifndef __AES_7108_H__
30 #define __AES_7108_H__
31
32 /* Cypher 7108 AES Controller Hardware */
33 #define CCU_REG_BASE       0x1b500000   
34 #define CCU_AES_REG_BASE   (CCU_REG_BASE + 0x100)
35 #define C7108_AES_KEY0_LO        (0x0000) 
36 #define C7108_AES_KEY0_HI        (0x0004) 
37 #define C7108_AES_KEY1_LO        (0x0008) 
38 #define C7108_AES_KEY1_HI        (0x000c) 
39 #define C7108_AES_KEY2_LO        (0x0010) 
40 #define C7108_AES_KEY2_HI        (0x0014) 
41 #define C7108_AES_KEY3_LO        (0x0018) 
42 #define C7108_AES_KEY3_HI        (0x001c) 
43 #define C7108_AES_KEY4_LO        (0x0020) 
44 #define C7108_AES_KEY4_HI        (0x0024) 
45 #define C7108_AES_KEY5_LO        (0x0028) 
46 #define C7108_AES_KEY5_HI        (0x002c) 
47 #define C7108_AES_KEY6_LO        (0x0030) 
48 #define C7108_AES_KEY6_HI        (0x0034) 
49 #define C7108_AES_KEY7_LO        (0x0038) 
50 #define C7108_AES_KEY7_HI        (0x003c) 
51 #define C7108_AES_IV0_LO         (0x0040) 
52 #define C7108_AES_IV0_HI         (0x0044) 
53 #define C7108_AES_IV1_LO         (0x0048) 
54 #define C7108_AES_IV1_HI         (0x004c) 
55 #define C7108_AES_IV2_LO         (0x0050) 
56 #define C7108_AES_IV2_HI         (0x0054) 
57 #define C7108_AES_IV3_LO         (0x0058) 
58 #define C7108_AES_IV3_HI         (0x005c) 
59
60 #define C7108_AES_DMA_SRC0_LO    (0x0068) /* Bits 0:15 */
61 #define C7108_AES_DMA_SRC0_HI    (0x006c) /* Bits 27:16 */
62 #define C7108_AES_DMA_DST0_LO    (0x0070) /* Bits 0:15 */
63 #define C7108_AES_DMA_DST0_HI    (0x0074) /* Bits 27:16 */
64 #define C7108_AES_DMA_LEN        (0x0078)  /*Bytes:(Count+1)x16 */
65
66 /* AES/Copy engine control register */
67 #define C7108_AES_CTRL           (0x007c) /* AES control */
68 #define C7108_AES_CTRL_RS        (1<<0)     /* Which set of src/dst to use */
69
70 /* AES Cipher mode, controlled by setting Bits 2:0 */
71 #define C7108_AES_CTRL_MODE_CBC     0
72 #define C7108_AES_CTRL_MODE_CFB     (1<<0)
73 #define C7108_AES_CTRL_MODE_OFB     (1<<1)
74 #define C7108_AES_CTRL_MODE_CTR     ((1<<0)|(1<<1))
75 #define C7108_AES_CTRL_MODE_ECB     (1<<2)
76
77 /* AES Key length , Bits 5:4 */
78 #define C7108_AES_KEY_LEN_128         0       /* 00 */
79 #define C7108_AES_KEY_LEN_192         (1<<4)  /* 01 */
80 #define C7108_AES_KEY_LEN_256         (1<<5)  /* 10 */
81
82 /* AES Operation (crypt/decrypt), Bit 3 */
83 #define C7108_AES_DECRYPT             (1<<3)   /* Clear for encrypt */
84 #define C7108_AES_ENCRYPT              0       
85 #define C7108_AES_INTR                (1<<13) /* Set on done trans from 0->1*/
86 #define C7108_AES_GO                  (1<<14) /* Run */
87 #define C7108_AES_OP_DONE             (1<<15) /* Set when complete */
88
89
90 /* Expanded key registers */
91 #define C7108_AES_EKEY0_LO            (0x0080)
92 #define C7108_AES_EKEY0_HI            (0x0084)
93 #define C7108_AES_EKEY1_LO            (0x0088)
94 #define C7108_AES_EKEY1_HI            (0x008c)
95 #define C7108_AES_EKEY2_LO            (0x0090)
96 #define C7108_AES_EKEY2_HI            (0x0094)
97 #define C7108_AES_EKEY3_LO            (0x0098)
98 #define C7108_AES_EKEY3_HI            (0x009c)
99 #define C7108_AES_EKEY4_LO            (0x00a0)
100 #define C7108_AES_EKEY4_HI            (0x00a4)
101 #define C7108_AES_EKEY5_LO            (0x00a8)
102 #define C7108_AES_EKEY5_HI            (0x00ac)
103 #define C7108_AES_EKEY6_LO            (0x00b0)
104 #define C7108_AES_EKEY6_HI            (0x00b4)
105 #define C7108_AES_EKEY7_LO            (0x00b8)
106 #define C7108_AES_EKEY7_HI            (0x00bc)
107 #define C7108_AES_OK                  (0x00fc) /* Reset: "OK" */
108
109 #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
110
111 /* Software session entry */
112
113 #define HW_TYPE_CIPHER  0
114 #define SW_TYPE_HMAC    1
115 #define SW_TYPE_AUTH2   2
116 #define SW_TYPE_HASH    3
117 #define SW_TYPE_COMP    4
118
119 struct cipher_7108 {
120         int                     xfm_type;
121         int                     cri_alg;
122         union {
123                 struct {
124                         char sw_key[HMAC_BLOCK_LEN];
125                         int  sw_klen;
126                         int  sw_authlen;
127                 } hmac;
128         } u;
129         struct cipher_7108      *next;
130 };
131
132
133
134 #endif /* __C7108_AES_7108_H__ */