diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/crypto/tegra-se.h | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'drivers/crypto/tegra-se.h')
-rw-r--r-- | drivers/crypto/tegra-se.h | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/drivers/crypto/tegra-se.h b/drivers/crypto/tegra-se.h new file mode 100644 index 00000000000..8c54df8991e --- /dev/null +++ b/drivers/crypto/tegra-se.h | |||
@@ -0,0 +1,235 @@ | |||
1 | /* | ||
2 | * Driver for Tegra Security Engine | ||
3 | * | ||
4 | * Copyright (c) 2011, NVIDIA Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef _CRYPTO_TEGRA_SE_H | ||
22 | #define _CRYPTO_TEGRA_SE_H | ||
23 | |||
24 | #include <crypto/hash.h> | ||
25 | #include <crypto/sha.h> | ||
26 | |||
27 | #define PFX "tegra-se: " | ||
28 | |||
29 | #define TEGRA_SE_CRA_PRIORITY 300 | ||
30 | #define TEGRA_SE_COMPOSITE_PRIORITY 400 | ||
31 | #define TEGRA_SE_CRYPTO_QUEUE_LENGTH 50 | ||
32 | #define SE_MAX_SRC_SG_COUNT 50 | ||
33 | #define SE_MAX_DST_SG_COUNT 50 | ||
34 | |||
35 | #define TEGRA_SE_KEYSLOT_COUNT 16 | ||
36 | |||
37 | /* SE register definitions */ | ||
38 | #define SE_CONFIG_REG_OFFSET 0x014 | ||
39 | #define SE_CONFIG_ENC_ALG_SHIFT 12 | ||
40 | #define SE_CONFIG_DEC_ALG_SHIFT 8 | ||
41 | #define ALG_AES_ENC 1 | ||
42 | #define ALG_RNG 2 | ||
43 | #define ALG_SHA 3 | ||
44 | #define ALG_NOP 0 | ||
45 | #define ALG_AES_DEC 1 | ||
46 | #define SE_CONFIG_ENC_ALG(x) (x << SE_CONFIG_ENC_ALG_SHIFT) | ||
47 | #define SE_CONFIG_DEC_ALG(x) (x << SE_CONFIG_DEC_ALG_SHIFT) | ||
48 | #define SE_CONFIG_DST_SHIFT 2 | ||
49 | #define DST_MEMORY 0 | ||
50 | #define DST_HASHREG 1 | ||
51 | #define DST_KEYTAB 2 | ||
52 | #define DST_SRK 3 | ||
53 | #define SE_CONFIG_DST(x) (x << SE_CONFIG_DST_SHIFT) | ||
54 | #define SE_CONFIG_ENC_MODE_SHIFT 24 | ||
55 | #define SE_CONFIG_DEC_MODE_SHIFT 16 | ||
56 | #define MODE_KEY128 0 | ||
57 | #define MODE_KEY192 1 | ||
58 | #define MODE_KEY256 2 | ||
59 | #define MODE_SHA1 0 | ||
60 | #define MODE_SHA224 4 | ||
61 | #define MODE_SHA256 5 | ||
62 | #define MODE_SHA384 6 | ||
63 | #define MODE_SHA512 7 | ||
64 | #define SE_CONFIG_ENC_MODE(x) (x << SE_CONFIG_ENC_MODE_SHIFT) | ||
65 | #define SE_CONFIG_DEC_MODE(x) (x << SE_CONFIG_DEC_MODE_SHIFT) | ||
66 | |||
67 | #define SE_KEYTABLE_REG_OFFSET 0x31c | ||
68 | #define SE_KEYTABLE_SLOT_SHIFT 4 | ||
69 | #define SE_KEYTABLE_SLOT(x) (x << SE_KEYTABLE_SLOT_SHIFT) | ||
70 | #define SE_KEYTABLE_QUAD_SHIFT 2 | ||
71 | #define QUAD_KEYS_128 0 | ||
72 | #define QUAD_KEYS_192 1 | ||
73 | #define QUAD_KEYS_256 1 | ||
74 | #define QUAD_ORG_IV 2 | ||
75 | #define QUAD_UPDTD_IV 3 | ||
76 | #define SE_KEYTABLE_QUAD(x) (x << SE_KEYTABLE_QUAD_SHIFT) | ||
77 | #define SE_KEYTABLE_OP_TYPE_SHIFT 9 | ||
78 | #define OP_READ 0 | ||
79 | #define OP_WRITE 1 | ||
80 | #define SE_KEYTABLE_OP_TYPE(x) (x << SE_KEYTABLE_OP_TYPE_SHIFT) | ||
81 | #define SE_KEYTABLE_TABLE_SEL_SHIFT 8 | ||
82 | #define TABLE_KEYIV 0 | ||
83 | #define TABLE_SCHEDULE 1 | ||
84 | #define SE_KEYTABLE_TABLE_SEL(x) (x << SE_KEYTABLE_TABLE_SEL_SHIFT) | ||
85 | #define SE_KEYTABLE_PKT_SHIFT 0 | ||
86 | #define SE_KEYTABLE_PKT(x) (x << SE_KEYTABLE_PKT_SHIFT) | ||
87 | |||
88 | #define SE_CRYPTO_REG_OFFSET 0x304 | ||
89 | #define SE_CRYPTO_HASH_SHIFT 0 | ||
90 | #define HASH_DISABLE 0 | ||
91 | #define HASH_ENABLE 1 | ||
92 | #define SE_CRYPTO_HASH(x) (x << SE_CRYPTO_HASH_SHIFT) | ||
93 | #define SE_CRYPTO_XOR_POS_SHIFT 1 | ||
94 | #define XOR_BYPASS 0 | ||
95 | #define XOR_TOP 2 | ||
96 | #define XOR_BOTTOM 3 | ||
97 | #define SE_CRYPTO_XOR_POS(x) (x << SE_CRYPTO_XOR_POS_SHIFT) | ||
98 | #define SE_CRYPTO_INPUT_SEL_SHIFT 3 | ||
99 | #define INPUT_AHB 0 | ||
100 | #define INPUT_LFSR 1 | ||
101 | #define INPUT_AESOUT 2 | ||
102 | #define INPUT_LNR_CTR 3 | ||
103 | #define SE_CRYPTO_INPUT_SEL(x) (x << SE_CRYPTO_INPUT_SEL_SHIFT) | ||
104 | #define SE_CRYPTO_VCTRAM_SEL_SHIFT 5 | ||
105 | #define VCTRAM_AHB 0 | ||
106 | #define VCTRAM_AESOUT 2 | ||
107 | #define VCTRAM_PREVAHB 3 | ||
108 | #define SE_CRYPTO_VCTRAM_SEL(x) (x << SE_CRYPTO_VCTRAM_SEL_SHIFT) | ||
109 | #define SE_CRYPTO_IV_SEL_SHIFT 7 | ||
110 | #define IV_ORIGINAL 0 | ||
111 | #define IV_UPDATED 1 | ||
112 | #define SE_CRYPTO_IV_SEL(x) (x << SE_CRYPTO_IV_SEL_SHIFT) | ||
113 | #define SE_CRYPTO_CORE_SEL_SHIFT 8 | ||
114 | #define CORE_DECRYPT 0 | ||
115 | #define CORE_ENCRYPT 1 | ||
116 | #define SE_CRYPTO_CORE_SEL(x) (x << SE_CRYPTO_CORE_SEL_SHIFT) | ||
117 | #define SE_CRYPTO_CTR_VAL_SHIFT 11 | ||
118 | #define SE_CRYPTO_CTR_VAL(x) (x << SE_CRYPTO_CTR_VAL_SHIFT) | ||
119 | #define SE_CRYPTO_KEY_INDEX_SHIFT 24 | ||
120 | #define SE_CRYPTO_KEY_INDEX(x) (x << SE_CRYPTO_KEY_INDEX_SHIFT) | ||
121 | #define SE_CRYPTO_CTR_CNTN_SHIFT 11 | ||
122 | #define SE_CRYPTO_CTR_CNTN(x) (x << SE_CRYPTO_CTR_CNTN_SHIFT) | ||
123 | |||
124 | #define SE_CRYPTO_CTR_REG_COUNT 4 | ||
125 | #define SE_CRYPTO_CTR_REG_OFFSET 0x308 | ||
126 | |||
127 | #define SE_OPERATION_REG_OFFSET 0x008 | ||
128 | #define SE_OPERATION_SHIFT 0 | ||
129 | #define OP_ABORT 0 | ||
130 | #define OP_SRART 1 | ||
131 | #define OP_RESTART 2 | ||
132 | #define OP_CTX_SAVE 3 | ||
133 | #define SE_OPERATION(x) (x << SE_OPERATION_SHIFT) | ||
134 | |||
135 | #define SE_CONTEXT_SAVE_CONFIG_REG_OFFSET 0x070 | ||
136 | #define SE_CONTEXT_SAVE_WORD_QUAD_SHIFT 0 | ||
137 | #define KEYS_0_3 0 | ||
138 | #define KEYS_4_7 1 | ||
139 | #define ORIG_IV 2 | ||
140 | #define UPD_IV 3 | ||
141 | #define SE_CONTEXT_SAVE_WORD_QUAD(x) (x << SE_CONTEXT_SAVE_WORD_QUAD_SHIFT) | ||
142 | |||
143 | #define SE_CONTEXT_SAVE_KEY_INDEX_SHIFT 8 | ||
144 | #define SE_CONTEXT_SAVE_KEY_INDEX(x) (x << SE_CONTEXT_SAVE_KEY_INDEX_SHIFT) | ||
145 | |||
146 | |||
147 | #define SE_CONTEXT_SAVE_SRC_SHIFT 30 | ||
148 | #define STICKY_BITS 0 | ||
149 | #define KEYTABLE 1 | ||
150 | #define MEM 2 | ||
151 | #define SRK 3 | ||
152 | #define SE_CONTEXT_SAVE_SRC(x) (x << SE_CONTEXT_SAVE_SRC_SHIFT) | ||
153 | |||
154 | #define SE_INT_ENABLE_REG_OFFSET 0x00c | ||
155 | #define SE_INT_STATUS_REG_OFFSET 0x010 | ||
156 | #define INT_DISABLE 0 | ||
157 | #define INT_ENABLE 1 | ||
158 | #define INT_UNSET 0 | ||
159 | #define INT_SET 1 | ||
160 | #define SE_INT_OP_DONE_SHIFT 4 | ||
161 | #define SE_INT_OP_DONE(x) (x << SE_INT_OP_DONE_SHIFT) | ||
162 | #define SE_INT_ERROR_SHIFT 16 | ||
163 | #define SE_INT_ERROR(x) (x << SE_INT_ERROR_SHIFT) | ||
164 | |||
165 | #define SE_CRYPTO_KEYTABLE_DST_REG_OFFSET 0X330 | ||
166 | #define SE_CRYPTO_KEYTABLE_DST_WORD_QUAD_SHIFT 0 | ||
167 | #define SE_CRYPTO_KEYTABLE_DST_WORD_QUAD(x) \ | ||
168 | (x << SE_CRYPTO_KEYTABLE_DST_WORD_QUAD_SHIFT) | ||
169 | |||
170 | #define SE_KEY_INDEX_SHIFT 8 | ||
171 | #define SE_CRYPTO_KEYTABLE_DST_KEY_INDEX(x) (x << SE_KEY_INDEX_SHIFT) | ||
172 | |||
173 | #define SE_IN_LL_ADDR_REG_OFFSET 0x018 | ||
174 | #define SE_OUT_LL_ADDR_REG_OFFSET 0x024 | ||
175 | |||
176 | #define SE_KEYTABLE_DATA0_REG_OFFSET 0x320 | ||
177 | #define SE_KEYTABLE_REG_MAX_DATA 16 | ||
178 | |||
179 | #define SE_BLOCK_COUNT_REG_OFFSET 0x318 | ||
180 | |||
181 | #define SE_SPARE_0_REG_OFFSET 0x80c | ||
182 | |||
183 | #define SE_SHA_CONFIG_REG_OFFSET 0x200 | ||
184 | #define SHA_DISABLE 0 | ||
185 | #define SHA_ENABLE 1 | ||
186 | |||
187 | #define SE_SHA_MSG_LENGTH_REG_OFFSET 0x204 | ||
188 | #define SE_SHA_MSG_LEFT_REG_OFFSET 0x214 | ||
189 | |||
190 | |||
191 | #define SE_HASH_RESULT_REG_COUNT 16 | ||
192 | #define SE_HASH_RESULT_REG_OFFSET 0x030 | ||
193 | |||
194 | |||
195 | #define TEGRA_SE_KEY_256_SIZE 32 | ||
196 | #define TEGRA_SE_KEY_192_SIZE 24 | ||
197 | #define TEGRA_SE_KEY_128_SIZE 16 | ||
198 | #define TEGRA_SE_AES_BLOCK_SIZE 16 | ||
199 | #define TEGRA_SE_AES_MIN_KEY_SIZE 16 | ||
200 | #define TEGRA_SE_AES_MAX_KEY_SIZE 32 | ||
201 | #define TEGRA_SE_AES_IV_SIZE 16 | ||
202 | #define TEGRA_SE_RNG_IV_SIZE 16 | ||
203 | #define TEGRA_SE_RNG_DT_SIZE 16 | ||
204 | #define TEGRA_SE_RNG_KEY_SIZE 16 | ||
205 | #define TEGRA_SE_RNG_SEED_SIZE (TEGRA_SE_RNG_IV_SIZE + \ | ||
206 | TEGRA_SE_RNG_KEY_SIZE + \ | ||
207 | TEGRA_SE_RNG_DT_SIZE) | ||
208 | #define TEGRA_SE_AES_CMAC_DIGEST_SIZE 16 | ||
209 | |||
210 | #define SE_KEY_TABLE_ACCESS_REG_OFFSET 0x284 | ||
211 | #define SE_KEY_READ_DISABLE_SHIFT 0 | ||
212 | |||
213 | #define SE_CONTEXT_BUFER_SIZE 1072 | ||
214 | #define SE_CONTEXT_SAVE_RANDOM_DATA_OFFSET 0 | ||
215 | #define SE_CONTEXT_SAVE_RANDOM_DATA_SIZE 16 | ||
216 | #define SE_CONTEXT_SAVE_STICKY_BITS_OFFSET \ | ||
217 | (SE_CONTEXT_SAVE_RANDOM_DATA_OFFSET + SE_CONTEXT_SAVE_RANDOM_DATA_SIZE) | ||
218 | #define SE_CONTEXT_SAVE_STICKY_BITS_SIZE 16 | ||
219 | #define SE_CONTEXT_SAVE_KEYS_OFFSET (SE_CONTEXT_SAVE_STICKY_BITS_OFFSET + \ | ||
220 | SE_CONTEXT_SAVE_STICKY_BITS_SIZE) | ||
221 | #define SE_CONTEXT_SAVE_KEY_LENGTH 512 | ||
222 | #define SE_CONTEXT_ORIGINAL_IV_OFFSET (SE_CONTEXT_SAVE_KEYS_OFFSET + \ | ||
223 | SE_CONTEXT_SAVE_KEY_LENGTH) | ||
224 | #define SE_CONTEXT_ORIGINAL_IV_LENGTH 256 | ||
225 | |||
226 | #define SE_CONTEXT_UPDATED_IV_OFFSET (SE_CONTEXT_ORIGINAL_IV_OFFSET + \ | ||
227 | SE_CONTEXT_ORIGINAL_IV_LENGTH) | ||
228 | |||
229 | #define SE_CONTEXT_UPDATED_IV_LENGTH 256 | ||
230 | #define SE_CONTEXT_KNOWN_PATTERN_OFFSET (SE_CONTEXT_UPDATED_IV_OFFSET + \ | ||
231 | SE_CONTEXT_UPDATED_IV_LENGTH) | ||
232 | #define SE_CONTEXT_KNOWN_PATTERN_SIZE 16 | ||
233 | |||
234 | |||
235 | #endif /* _CRYPTO_TEGRA_SE_H */ | ||