blob: 7bb898d2e699c36d5bdb785b06ecb81ee8332fd7 [file] [log] [blame]
Kim Phillips8e8ec592011-03-13 16:54:26 +08001/*
2 * CAAM hardware register-level view
3 *
4 * Copyright 2008-2011 Freescale Semiconductor, Inc.
5 */
6
7#ifndef REGS_H
8#define REGS_H
9
10#include <linux/types.h>
11#include <linux/io.h>
12
13/*
14 * Architecture-specific register access methods
15 *
16 * CAAM's bus-addressable registers are 64 bits internally.
17 * They have been wired to be safely accessible on 32-bit
18 * architectures, however. Registers were organized such
19 * that (a) they can be contained in 32 bits, (b) if not, then they
20 * can be treated as two 32-bit entities, or finally (c) if they
21 * must be treated as a single 64-bit value, then this can safely
22 * be done with two 32-bit cycles.
23 *
24 * For 32-bit operations on 64-bit values, CAAM follows the same
25 * 64-bit register access conventions as it's predecessors, in that
26 * writes are "triggered" by a write to the register at the numerically
27 * higher address, thus, a full 64-bit write cycle requires a write
28 * to the lower address, followed by a write to the higher address,
29 * which will latch/execute the write cycle.
30 *
31 * For example, let's assume a SW reset of CAAM through the master
32 * configuration register.
33 * - SWRST is in bit 31 of MCFG.
34 * - MCFG begins at base+0x0000.
35 * - Bits 63-32 are a 32-bit word at base+0x0000 (numerically-lower)
36 * - Bits 31-0 are a 32-bit word at base+0x0004 (numerically-higher)
37 *
38 * (and on Power, the convention is 0-31, 32-63, I know...)
39 *
40 * Assuming a 64-bit write to this MCFG to perform a software reset
41 * would then require a write of 0 to base+0x0000, followed by a
42 * write of 0x80000000 to base+0x0004, which would "execute" the
43 * reset.
44 *
45 * Of course, since MCFG 63-32 is all zero, we could cheat and simply
46 * write 0x8000000 to base+0x0004, and the reset would work fine.
47 * However, since CAAM does contain some write-and-read-intended
48 * 64-bit registers, this code defines 64-bit access methods for
49 * the sake of internal consistency and simplicity, and so that a
50 * clean transition to 64-bit is possible when it becomes necessary.
51 *
52 * There are limitations to this that the developer must recognize.
53 * 32-bit architectures cannot enforce an atomic-64 operation,
54 * Therefore:
55 *
56 * - On writes, since the HW is assumed to latch the cycle on the
57 * write of the higher-numeric-address word, then ordered
58 * writes work OK.
59 *
60 * - For reads, where a register contains a relevant value of more
61 * that 32 bits, the hardware employs logic to latch the other
62 * "half" of the data until read, ensuring an accurate value.
63 * This is of particular relevance when dealing with CAAM's
64 * performance counters.
65 *
66 */
67
68#ifdef __BIG_ENDIAN
69#define wr_reg32(reg, data) out_be32(reg, data)
70#define rd_reg32(reg) in_be32(reg)
71#ifdef CONFIG_64BIT
72#define wr_reg64(reg, data) out_be64(reg, data)
73#define rd_reg64(reg) in_be64(reg)
74#endif
75#else
76#ifdef __LITTLE_ENDIAN
Dan Carpenterf829e7a2014-02-21 11:51:31 +030077#define wr_reg32(reg, data) __raw_writel(data, reg)
Kim Phillips8e8ec592011-03-13 16:54:26 +080078#define rd_reg32(reg) __raw_readl(reg)
79#ifdef CONFIG_64BIT
Dan Carpenterf829e7a2014-02-21 11:51:31 +030080#define wr_reg64(reg, data) __raw_writeq(data, reg)
Kim Phillips8e8ec592011-03-13 16:54:26 +080081#define rd_reg64(reg) __raw_readq(reg)
82#endif
83#endif
84#endif
85
86#ifndef CONFIG_64BIT
87static inline void wr_reg64(u64 __iomem *reg, u64 data)
88{
89 wr_reg32((u32 __iomem *)reg, (data & 0xffffffff00000000ull) >> 32);
90 wr_reg32((u32 __iomem *)reg + 1, data & 0x00000000ffffffffull);
91}
92
93static inline u64 rd_reg64(u64 __iomem *reg)
94{
95 return (((u64)rd_reg32((u32 __iomem *)reg)) << 32) |
96 ((u64)rd_reg32((u32 __iomem *)reg + 1));
97}
98#endif
99
100/*
101 * jr_outentry
102 * Represents each entry in a JobR output ring
103 */
104struct jr_outentry {
105 dma_addr_t desc;/* Pointer to completed descriptor */
106 u32 jrstatus; /* Status for completed descriptor */
107} __packed;
108
109/*
110 * caam_perfmon - Performance Monitor/Secure Memory Status/
111 * CAAM Global Status/Component Version IDs
112 *
113 * Spans f00-fff wherever instantiated
114 */
115
116/* Number of DECOs */
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530117#define CHA_NUM_MS_DECONUM_SHIFT 24
118#define CHA_NUM_MS_DECONUM_MASK (0xfull << CHA_NUM_MS_DECONUM_SHIFT)
Kim Phillips8e8ec592011-03-13 16:54:26 +0800119
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530120/* CHA Version IDs */
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530121#define CHA_ID_LS_AES_SHIFT 0
122#define CHA_ID_LS_AES_MASK (0xfull << CHA_ID_LS_AES_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530123
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530124#define CHA_ID_LS_DES_SHIFT 4
125#define CHA_ID_LS_DES_MASK (0xfull << CHA_ID_LS_DES_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530126
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530127#define CHA_ID_LS_ARC4_SHIFT 8
128#define CHA_ID_LS_ARC4_MASK (0xfull << CHA_ID_LS_ARC4_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530129
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530130#define CHA_ID_LS_MD_SHIFT 12
131#define CHA_ID_LS_MD_MASK (0xfull << CHA_ID_LS_MD_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530132
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530133#define CHA_ID_LS_RNG_SHIFT 16
134#define CHA_ID_LS_RNG_MASK (0xfull << CHA_ID_LS_RNG_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530135
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530136#define CHA_ID_LS_SNW8_SHIFT 20
137#define CHA_ID_LS_SNW8_MASK (0xfull << CHA_ID_LS_SNW8_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530138
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530139#define CHA_ID_LS_KAS_SHIFT 24
140#define CHA_ID_LS_KAS_MASK (0xfull << CHA_ID_LS_KAS_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530141
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530142#define CHA_ID_LS_PK_SHIFT 28
143#define CHA_ID_LS_PK_MASK (0xfull << CHA_ID_LS_PK_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530144
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530145#define CHA_ID_MS_CRC_SHIFT 0
146#define CHA_ID_MS_CRC_MASK (0xfull << CHA_ID_MS_CRC_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530147
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530148#define CHA_ID_MS_SNW9_SHIFT 4
149#define CHA_ID_MS_SNW9_MASK (0xfull << CHA_ID_MS_SNW9_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530150
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530151#define CHA_ID_MS_DECO_SHIFT 24
152#define CHA_ID_MS_DECO_MASK (0xfull << CHA_ID_MS_DECO_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530153
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530154#define CHA_ID_MS_JR_SHIFT 28
155#define CHA_ID_MS_JR_MASK (0xfull << CHA_ID_MS_JR_SHIFT)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530156
Alex Porosanu82c2f962012-07-11 11:06:11 +0800157struct sec_vid {
158 u16 ip_id;
159 u8 maj_rev;
160 u8 min_rev;
161};
162
Kim Phillips8e8ec592011-03-13 16:54:26 +0800163struct caam_perfmon {
164 /* Performance Monitor Registers f00-f9f */
165 u64 req_dequeued; /* PC_REQ_DEQ - Dequeued Requests */
166 u64 ob_enc_req; /* PC_OB_ENC_REQ - Outbound Encrypt Requests */
167 u64 ib_dec_req; /* PC_IB_DEC_REQ - Inbound Decrypt Requests */
168 u64 ob_enc_bytes; /* PC_OB_ENCRYPT - Outbound Bytes Encrypted */
169 u64 ob_prot_bytes; /* PC_OB_PROTECT - Outbound Bytes Protected */
170 u64 ib_dec_bytes; /* PC_IB_DECRYPT - Inbound Bytes Decrypted */
171 u64 ib_valid_bytes; /* PC_IB_VALIDATED Inbound Bytes Validated */
172 u64 rsvd[13];
173
174 /* CAAM Hardware Instantiation Parameters fa0-fbf */
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530175 u32 cha_rev_ms; /* CRNR - CHA Rev No. Most significant half*/
176 u32 cha_rev_ls; /* CRNR - CHA Rev No. Least significant half*/
177#define CTPR_MS_QI_SHIFT 25
178#define CTPR_MS_QI_MASK (0x1ull << CTPR_MS_QI_SHIFT)
179 u32 comp_parms_ms; /* CTPR - Compile Parameters Register */
180 u32 comp_parms_ls; /* CTPR - Compile Parameters Register */
Kim Phillips8e8ec592011-03-13 16:54:26 +0800181 u64 rsvd1[2];
182
183 /* CAAM Global Status fc0-fdf */
184 u64 faultaddr; /* FAR - Fault Address */
185 u32 faultliodn; /* FALR - Fault Address LIODN */
186 u32 faultdetail; /* FADR - Fault Addr Detail */
187 u32 rsvd2;
188 u32 status; /* CSTA - CAAM Status */
189 u64 rsvd3;
190
191 /* Component Instantiation Parameters fe0-fff */
192 u32 rtic_id; /* RVID - RTIC Version ID */
193 u32 ccb_id; /* CCBVID - CCB Version ID */
Ruchika Guptaeb1139c2014-06-23 15:08:28 +0530194 u32 cha_id_ms; /* CHAVID - CHA Version ID Most Significant*/
195 u32 cha_id_ls; /* CHAVID - CHA Version ID Least Significant*/
196 u32 cha_num_ms; /* CHANUM - CHA Number Most Significant */
197 u32 cha_num_ls; /* CHANUM - CHA Number Least Significant*/
198 u32 caam_id_ms; /* CAAMVID - CAAM Version ID MS */
199 u32 caam_id_ls; /* CAAMVID - CAAM Version ID LS */
Kim Phillips8e8ec592011-03-13 16:54:26 +0800200};
201
202/* LIODN programming for DMA configuration */
203#define MSTRID_LOCK_LIODN 0x80000000
204#define MSTRID_LOCK_MAKETRUSTED 0x00010000 /* only for JR masterid */
205
206#define MSTRID_LIODN_MASK 0x0fff
207struct masterid {
208 u32 liodn_ms; /* lock and make-trusted control bits */
209 u32 liodn_ls; /* LIODN for non-sequence and seq access */
210};
211
212/* Partition ID for DMA configuration */
213struct partid {
214 u32 rsvd1;
215 u32 pidr; /* partition ID, DECO */
216};
217
Kim Phillips281922a2012-06-22 19:48:52 -0500218/* RNGB test mode (replicated twice in some configurations) */
Kim Phillips8e8ec592011-03-13 16:54:26 +0800219/* Padded out to 0x100 */
220struct rngtst {
221 u32 mode; /* RTSTMODEx - Test mode */
222 u32 rsvd1[3];
223 u32 reset; /* RTSTRESETx - Test reset control */
224 u32 rsvd2[3];
225 u32 status; /* RTSTSSTATUSx - Test status */
226 u32 rsvd3;
227 u32 errstat; /* RTSTERRSTATx - Test error status */
228 u32 rsvd4;
229 u32 errctl; /* RTSTERRCTLx - Test error control */
230 u32 rsvd5;
231 u32 entropy; /* RTSTENTROPYx - Test entropy */
232 u32 rsvd6[15];
233 u32 verifctl; /* RTSTVERIFCTLx - Test verification control */
234 u32 rsvd7;
235 u32 verifstat; /* RTSTVERIFSTATx - Test verification status */
236 u32 rsvd8;
237 u32 verifdata; /* RTSTVERIFDx - Test verification data */
238 u32 rsvd9;
239 u32 xkey; /* RTSTXKEYx - Test XKEY */
240 u32 rsvd10;
241 u32 oscctctl; /* RTSTOSCCTCTLx - Test osc. counter control */
242 u32 rsvd11;
243 u32 oscct; /* RTSTOSCCTx - Test oscillator counter */
244 u32 rsvd12;
245 u32 oscctstat; /* RTSTODCCTSTATx - Test osc counter status */
246 u32 rsvd13[2];
247 u32 ofifo[4]; /* RTSTOFIFOx - Test output FIFO */
248 u32 rsvd14[15];
249};
250
Kim Phillips281922a2012-06-22 19:48:52 -0500251/* RNG4 TRNG test registers */
252struct rng4tst {
Alex Porosanu1005bcc2013-09-09 18:56:34 +0300253#define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */
Kim Phillips281922a2012-06-22 19:48:52 -0500254 u32 rtmctl; /* misc. control register */
255 u32 rtscmisc; /* statistical check misc. register */
256 u32 rtpkrrng; /* poker range register */
257 union {
258 u32 rtpkrmax; /* PRGM=1: poker max. limit register */
259 u32 rtpkrsq; /* PRGM=0: poker square calc. result register */
260 };
261#define RTSDCTL_ENT_DLY_SHIFT 16
262#define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
Alex Porosanu84cf4822013-09-09 18:56:30 +0300263#define RTSDCTL_ENT_DLY_MIN 1200
264#define RTSDCTL_ENT_DLY_MAX 12800
Kim Phillips281922a2012-06-22 19:48:52 -0500265 u32 rtsdctl; /* seed control register */
266 union {
267 u32 rtsblim; /* PRGM=1: sparse bit limit register */
268 u32 rttotsam; /* PRGM=0: total samples register */
269 };
270 u32 rtfrqmin; /* frequency count min. limit register */
271 union {
272 u32 rtfrqmax; /* PRGM=1: freq. count max. limit register */
273 u32 rtfrqcnt; /* PRGM=0: freq. count register */
274 };
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530275 u32 rsvd1[40];
Alex Porosanu1005bcc2013-09-09 18:56:34 +0300276#define RDSTA_SKVT 0x80000000
277#define RDSTA_SKVN 0x40000000
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530278#define RDSTA_IF0 0x00000001
Alex Porosanu1005bcc2013-09-09 18:56:34 +0300279#define RDSTA_IF1 0x00000002
280#define RDSTA_IFMASK (RDSTA_IF1 | RDSTA_IF0)
Ruchika Gupta986dfbc2013-04-26 15:44:54 +0530281 u32 rdsta;
282 u32 rsvd2[15];
Kim Phillips281922a2012-06-22 19:48:52 -0500283};
284
Kim Phillips8e8ec592011-03-13 16:54:26 +0800285/*
286 * caam_ctrl - basic core configuration
287 * starts base + 0x0000 padded out to 0x1000
288 */
289
290#define KEK_KEY_SIZE 8
291#define TKEK_KEY_SIZE 8
292#define TDSK_KEY_SIZE 8
293
294#define DECO_RESET 1 /* Use with DECO reset/availability regs */
295#define DECO_RESET_0 (DECO_RESET << 0)
296#define DECO_RESET_1 (DECO_RESET << 1)
297#define DECO_RESET_2 (DECO_RESET << 2)
298#define DECO_RESET_3 (DECO_RESET << 3)
299#define DECO_RESET_4 (DECO_RESET << 4)
300
301struct caam_ctrl {
302 /* Basic Configuration Section 000-01f */
303 /* Read/Writable */
304 u32 rsvd1;
305 u32 mcr; /* MCFG Master Config Register */
Vakul Garg575c1bd2013-03-12 13:55:21 +0530306 u32 rsvd2;
307 u32 scfgr; /* SCFGR, Security Config Register */
Kim Phillips8e8ec592011-03-13 16:54:26 +0800308
309 /* Bus Access Configuration Section 010-11f */
310 /* Read/Writable */
311 struct masterid jr_mid[4]; /* JRxLIODNR - JobR LIODN setup */
312 u32 rsvd3[12];
313 struct masterid rtic_mid[4]; /* RTICxLIODNR - RTIC LIODN setup */
314 u32 rsvd4[7];
315 u32 deco_rq; /* DECORR - DECO Request */
316 struct partid deco_mid[5]; /* DECOxLIODNR - 1 per DECO */
317 u32 rsvd5[22];
318
319 /* DECO Availability/Reset Section 120-3ff */
320 u32 deco_avail; /* DAR - DECO availability */
321 u32 deco_reset; /* DRR - DECO reset */
322 u32 rsvd6[182];
323
324 /* Key Encryption/Decryption Configuration 400-5ff */
325 /* Read/Writable only while in Non-secure mode */
326 u32 kek[KEK_KEY_SIZE]; /* JDKEKR - Key Encryption Key */
327 u32 tkek[TKEK_KEY_SIZE]; /* TDKEKR - Trusted Desc KEK */
328 u32 tdsk[TDSK_KEY_SIZE]; /* TDSKR - Trusted Desc Signing Key */
329 u32 rsvd7[32];
330 u64 sknonce; /* SKNR - Secure Key Nonce */
331 u32 rsvd8[70];
332
333 /* RNG Test/Verification/Debug Access 600-7ff */
334 /* (Useful in Test/Debug modes only...) */
Kim Phillips281922a2012-06-22 19:48:52 -0500335 union {
336 struct rngtst rtst[2];
337 struct rng4tst r4tst[2];
338 };
Kim Phillips8e8ec592011-03-13 16:54:26 +0800339
340 u32 rsvd9[448];
341
342 /* Performance Monitor f00-fff */
343 struct caam_perfmon perfmon;
344};
345
346/*
347 * Controller master config register defs
348 */
349#define MCFGR_SWRESET 0x80000000 /* software reset */
350#define MCFGR_WDENABLE 0x40000000 /* DECO watchdog enable */
351#define MCFGR_WDFAIL 0x20000000 /* DECO watchdog force-fail */
352#define MCFGR_DMA_RESET 0x10000000
353#define MCFGR_LONG_PTR 0x00010000 /* Use >32-bit desc addressing */
Vakul Garg575c1bd2013-03-12 13:55:21 +0530354#define SCFGR_RDBENABLE 0x00000400
Ruchika Gupta997ad292013-07-04 11:26:03 +0530355#define DECORR_RQD0ENABLE 0x00000001 /* Enable DECO0 for direct access */
356#define DECORR_DEN0 0x00010000 /* DECO0 available for access*/
Kim Phillips8e8ec592011-03-13 16:54:26 +0800357
358/* AXI read cache control */
359#define MCFGR_ARCACHE_SHIFT 12
360#define MCFGR_ARCACHE_MASK (0xf << MCFGR_ARCACHE_SHIFT)
361
362/* AXI write cache control */
363#define MCFGR_AWCACHE_SHIFT 8
364#define MCFGR_AWCACHE_MASK (0xf << MCFGR_AWCACHE_SHIFT)
365
366/* AXI pipeline depth */
367#define MCFGR_AXIPIPE_SHIFT 4
368#define MCFGR_AXIPIPE_MASK (0xf << MCFGR_AXIPIPE_SHIFT)
369
370#define MCFGR_AXIPRI 0x00000008 /* Assert AXI priority sideband */
371#define MCFGR_BURST_64 0x00000001 /* Max burst size */
372
373/*
374 * caam_job_ring - direct job ring setup
375 * 1-4 possible per instantiation, base + 1000/2000/3000/4000
376 * Padded out to 0x1000
377 */
378struct caam_job_ring {
379 /* Input ring */
380 u64 inpring_base; /* IRBAx - Input desc ring baseaddr */
381 u32 rsvd1;
382 u32 inpring_size; /* IRSx - Input ring size */
383 u32 rsvd2;
384 u32 inpring_avail; /* IRSAx - Input ring room remaining */
385 u32 rsvd3;
386 u32 inpring_jobadd; /* IRJAx - Input ring jobs added */
387
388 /* Output Ring */
389 u64 outring_base; /* ORBAx - Output status ring base addr */
390 u32 rsvd4;
391 u32 outring_size; /* ORSx - Output ring size */
392 u32 rsvd5;
393 u32 outring_rmvd; /* ORJRx - Output ring jobs removed */
394 u32 rsvd6;
395 u32 outring_used; /* ORSFx - Output ring slots full */
396
397 /* Status/Configuration */
398 u32 rsvd7;
399 u32 jroutstatus; /* JRSTAx - JobR output status */
400 u32 rsvd8;
401 u32 jrintstatus; /* JRINTx - JobR interrupt status */
402 u32 rconfig_hi; /* JRxCFG - Ring configuration */
403 u32 rconfig_lo;
404
405 /* Indices. CAAM maintains as "heads" of each queue */
406 u32 rsvd9;
407 u32 inp_rdidx; /* IRRIx - Input ring read index */
408 u32 rsvd10;
409 u32 out_wtidx; /* ORWIx - Output ring write index */
410
411 /* Command/control */
412 u32 rsvd11;
413 u32 jrcommand; /* JRCRx - JobR command */
414
415 u32 rsvd12[932];
416
417 /* Performance Monitor f00-fff */
418 struct caam_perfmon perfmon;
419};
420
421#define JR_RINGSIZE_MASK 0x03ff
422/*
423 * jrstatus - Job Ring Output Status
424 * All values in lo word
425 * Also note, same values written out as status through QI
426 * in the command/status field of a frame descriptor
427 */
428#define JRSTA_SSRC_SHIFT 28
429#define JRSTA_SSRC_MASK 0xf0000000
430
431#define JRSTA_SSRC_NONE 0x00000000
432#define JRSTA_SSRC_CCB_ERROR 0x20000000
433#define JRSTA_SSRC_JUMP_HALT_USER 0x30000000
434#define JRSTA_SSRC_DECO 0x40000000
435#define JRSTA_SSRC_JRERROR 0x60000000
436#define JRSTA_SSRC_JUMP_HALT_CC 0x70000000
437
438#define JRSTA_DECOERR_JUMP 0x08000000
439#define JRSTA_DECOERR_INDEX_SHIFT 8
440#define JRSTA_DECOERR_INDEX_MASK 0xff00
441#define JRSTA_DECOERR_ERROR_MASK 0x00ff
442
443#define JRSTA_DECOERR_NONE 0x00
444#define JRSTA_DECOERR_LINKLEN 0x01
445#define JRSTA_DECOERR_LINKPTR 0x02
446#define JRSTA_DECOERR_JRCTRL 0x03
447#define JRSTA_DECOERR_DESCCMD 0x04
448#define JRSTA_DECOERR_ORDER 0x05
449#define JRSTA_DECOERR_KEYCMD 0x06
450#define JRSTA_DECOERR_LOADCMD 0x07
451#define JRSTA_DECOERR_STORECMD 0x08
452#define JRSTA_DECOERR_OPCMD 0x09
453#define JRSTA_DECOERR_FIFOLDCMD 0x0a
454#define JRSTA_DECOERR_FIFOSTCMD 0x0b
455#define JRSTA_DECOERR_MOVECMD 0x0c
456#define JRSTA_DECOERR_JUMPCMD 0x0d
457#define JRSTA_DECOERR_MATHCMD 0x0e
458#define JRSTA_DECOERR_SHASHCMD 0x0f
459#define JRSTA_DECOERR_SEQCMD 0x10
460#define JRSTA_DECOERR_DECOINTERNAL 0x11
461#define JRSTA_DECOERR_SHDESCHDR 0x12
462#define JRSTA_DECOERR_HDRLEN 0x13
463#define JRSTA_DECOERR_BURSTER 0x14
464#define JRSTA_DECOERR_DESCSIGNATURE 0x15
465#define JRSTA_DECOERR_DMA 0x16
466#define JRSTA_DECOERR_BURSTFIFO 0x17
467#define JRSTA_DECOERR_JRRESET 0x1a
468#define JRSTA_DECOERR_JOBFAIL 0x1b
469#define JRSTA_DECOERR_DNRERR 0x80
470#define JRSTA_DECOERR_UNDEFPCL 0x81
471#define JRSTA_DECOERR_PDBERR 0x82
472#define JRSTA_DECOERR_ANRPLY_LATE 0x83
473#define JRSTA_DECOERR_ANRPLY_REPLAY 0x84
474#define JRSTA_DECOERR_SEQOVF 0x85
475#define JRSTA_DECOERR_INVSIGN 0x86
476#define JRSTA_DECOERR_DSASIGN 0x87
477
478#define JRSTA_CCBERR_JUMP 0x08000000
479#define JRSTA_CCBERR_INDEX_MASK 0xff00
480#define JRSTA_CCBERR_INDEX_SHIFT 8
481#define JRSTA_CCBERR_CHAID_MASK 0x00f0
482#define JRSTA_CCBERR_CHAID_SHIFT 4
483#define JRSTA_CCBERR_ERRID_MASK 0x000f
484
485#define JRSTA_CCBERR_CHAID_AES (0x01 << JRSTA_CCBERR_CHAID_SHIFT)
486#define JRSTA_CCBERR_CHAID_DES (0x02 << JRSTA_CCBERR_CHAID_SHIFT)
487#define JRSTA_CCBERR_CHAID_ARC4 (0x03 << JRSTA_CCBERR_CHAID_SHIFT)
488#define JRSTA_CCBERR_CHAID_MD (0x04 << JRSTA_CCBERR_CHAID_SHIFT)
489#define JRSTA_CCBERR_CHAID_RNG (0x05 << JRSTA_CCBERR_CHAID_SHIFT)
490#define JRSTA_CCBERR_CHAID_SNOW (0x06 << JRSTA_CCBERR_CHAID_SHIFT)
491#define JRSTA_CCBERR_CHAID_KASUMI (0x07 << JRSTA_CCBERR_CHAID_SHIFT)
492#define JRSTA_CCBERR_CHAID_PK (0x08 << JRSTA_CCBERR_CHAID_SHIFT)
493#define JRSTA_CCBERR_CHAID_CRC (0x09 << JRSTA_CCBERR_CHAID_SHIFT)
494
495#define JRSTA_CCBERR_ERRID_NONE 0x00
496#define JRSTA_CCBERR_ERRID_MODE 0x01
497#define JRSTA_CCBERR_ERRID_DATASIZ 0x02
498#define JRSTA_CCBERR_ERRID_KEYSIZ 0x03
499#define JRSTA_CCBERR_ERRID_PKAMEMSZ 0x04
500#define JRSTA_CCBERR_ERRID_PKBMEMSZ 0x05
501#define JRSTA_CCBERR_ERRID_SEQUENCE 0x06
502#define JRSTA_CCBERR_ERRID_PKDIVZRO 0x07
503#define JRSTA_CCBERR_ERRID_PKMODEVN 0x08
504#define JRSTA_CCBERR_ERRID_KEYPARIT 0x09
505#define JRSTA_CCBERR_ERRID_ICVCHK 0x0a
506#define JRSTA_CCBERR_ERRID_HARDWARE 0x0b
507#define JRSTA_CCBERR_ERRID_CCMAAD 0x0c
508#define JRSTA_CCBERR_ERRID_INVCHA 0x0f
509
510#define JRINT_ERR_INDEX_MASK 0x3fff0000
511#define JRINT_ERR_INDEX_SHIFT 16
512#define JRINT_ERR_TYPE_MASK 0xf00
513#define JRINT_ERR_TYPE_SHIFT 8
514#define JRINT_ERR_HALT_MASK 0xc
515#define JRINT_ERR_HALT_SHIFT 2
516#define JRINT_ERR_HALT_INPROGRESS 0x4
517#define JRINT_ERR_HALT_COMPLETE 0x8
518#define JRINT_JR_ERROR 0x02
519#define JRINT_JR_INT 0x01
520
521#define JRINT_ERR_TYPE_WRITE 1
522#define JRINT_ERR_TYPE_BAD_INPADDR 3
523#define JRINT_ERR_TYPE_BAD_OUTADDR 4
524#define JRINT_ERR_TYPE_INV_INPWRT 5
525#define JRINT_ERR_TYPE_INV_OUTWRT 6
526#define JRINT_ERR_TYPE_RESET 7
527#define JRINT_ERR_TYPE_REMOVE_OFL 8
528#define JRINT_ERR_TYPE_ADD_OFL 9
529
530#define JRCFG_SOE 0x04
531#define JRCFG_ICEN 0x02
532#define JRCFG_IMSK 0x01
533#define JRCFG_ICDCT_SHIFT 8
534#define JRCFG_ICTT_SHIFT 16
535
536#define JRCR_RESET 0x01
537
538/*
539 * caam_assurance - Assurance Controller View
540 * base + 0x6000 padded out to 0x1000
541 */
542
543struct rtic_element {
544 u64 address;
545 u32 rsvd;
546 u32 length;
547};
548
549struct rtic_block {
550 struct rtic_element element[2];
551};
552
553struct rtic_memhash {
554 u32 memhash_be[32];
555 u32 memhash_le[32];
556};
557
558struct caam_assurance {
559 /* Status/Command/Watchdog */
560 u32 rsvd1;
561 u32 status; /* RSTA - Status */
562 u32 rsvd2;
563 u32 cmd; /* RCMD - Command */
564 u32 rsvd3;
565 u32 ctrl; /* RCTL - Control */
566 u32 rsvd4;
567 u32 throttle; /* RTHR - Throttle */
568 u32 rsvd5[2];
569 u64 watchdog; /* RWDOG - Watchdog Timer */
570 u32 rsvd6;
571 u32 rend; /* REND - Endian corrections */
572 u32 rsvd7[50];
573
574 /* Block access/configuration @ 100/110/120/130 */
575 struct rtic_block memblk[4]; /* Memory Blocks A-D */
576 u32 rsvd8[32];
577
578 /* Block hashes @ 200/300/400/500 */
579 struct rtic_memhash hash[4]; /* Block hash values A-D */
580 u32 rsvd_3[640];
581};
582
583/*
584 * caam_queue_if - QI configuration and control
585 * starts base + 0x7000, padded out to 0x1000 long
586 */
587
588struct caam_queue_if {
589 u32 qi_control_hi; /* QICTL - QI Control */
590 u32 qi_control_lo;
591 u32 rsvd1;
592 u32 qi_status; /* QISTA - QI Status */
593 u32 qi_deq_cfg_hi; /* QIDQC - QI Dequeue Configuration */
594 u32 qi_deq_cfg_lo;
595 u32 qi_enq_cfg_hi; /* QISEQC - QI Enqueue Command */
596 u32 qi_enq_cfg_lo;
597 u32 rsvd2[1016];
598};
599
600/* QI control bits - low word */
601#define QICTL_DQEN 0x01 /* Enable frame pop */
602#define QICTL_STOP 0x02 /* Stop dequeue/enqueue */
603#define QICTL_SOE 0x04 /* Stop on error */
604
605/* QI control bits - high word */
606#define QICTL_MBSI 0x01
607#define QICTL_MHWSI 0x02
608#define QICTL_MWSI 0x04
609#define QICTL_MDWSI 0x08
610#define QICTL_CBSI 0x10 /* CtrlDataByteSwapInput */
611#define QICTL_CHWSI 0x20 /* CtrlDataHalfSwapInput */
612#define QICTL_CWSI 0x40 /* CtrlDataWordSwapInput */
613#define QICTL_CDWSI 0x80 /* CtrlDataDWordSwapInput */
614#define QICTL_MBSO 0x0100
615#define QICTL_MHWSO 0x0200
616#define QICTL_MWSO 0x0400
617#define QICTL_MDWSO 0x0800
618#define QICTL_CBSO 0x1000 /* CtrlDataByteSwapOutput */
619#define QICTL_CHWSO 0x2000 /* CtrlDataHalfSwapOutput */
620#define QICTL_CWSO 0x4000 /* CtrlDataWordSwapOutput */
621#define QICTL_CDWSO 0x8000 /* CtrlDataDWordSwapOutput */
622#define QICTL_DMBS 0x010000
623#define QICTL_EPO 0x020000
624
625/* QI status bits */
626#define QISTA_PHRDERR 0x01 /* PreHeader Read Error */
627#define QISTA_CFRDERR 0x02 /* Compound Frame Read Error */
628#define QISTA_OFWRERR 0x04 /* Output Frame Read Error */
629#define QISTA_BPDERR 0x08 /* Buffer Pool Depleted */
630#define QISTA_BTSERR 0x10 /* Buffer Undersize */
631#define QISTA_CFWRERR 0x20 /* Compound Frame Write Err */
632#define QISTA_STOPD 0x80000000 /* QI Stopped (see QICTL) */
633
634/* deco_sg_table - DECO view of scatter/gather table */
635struct deco_sg_table {
636 u64 addr; /* Segment Address */
637 u32 elen; /* E, F bits + 30-bit length */
638 u32 bpid_offset; /* Buffer Pool ID + 16-bit length */
639};
640
641/*
642 * caam_deco - descriptor controller - CHA cluster block
643 *
644 * Only accessible when direct DECO access is turned on
645 * (done in DECORR, via MID programmed in DECOxMID
646 *
647 * 5 typical, base + 0x8000/9000/a000/b000
648 * Padded out to 0x1000 long
649 */
650struct caam_deco {
651 u32 rsvd1;
652 u32 cls1_mode; /* CxC1MR - Class 1 Mode */
653 u32 rsvd2;
654 u32 cls1_keysize; /* CxC1KSR - Class 1 Key Size */
655 u32 cls1_datasize_hi; /* CxC1DSR - Class 1 Data Size */
656 u32 cls1_datasize_lo;
657 u32 rsvd3;
658 u32 cls1_icvsize; /* CxC1ICVSR - Class 1 ICV size */
659 u32 rsvd4[5];
660 u32 cha_ctrl; /* CCTLR - CHA control */
661 u32 rsvd5;
662 u32 irq_crtl; /* CxCIRQ - CCB interrupt done/error/clear */
663 u32 rsvd6;
664 u32 clr_written; /* CxCWR - Clear-Written */
665 u32 ccb_status_hi; /* CxCSTA - CCB Status/Error */
666 u32 ccb_status_lo;
667 u32 rsvd7[3];
668 u32 aad_size; /* CxAADSZR - Current AAD Size */
669 u32 rsvd8;
670 u32 cls1_iv_size; /* CxC1IVSZR - Current Class 1 IV Size */
671 u32 rsvd9[7];
672 u32 pkha_a_size; /* PKASZRx - Size of PKHA A */
673 u32 rsvd10;
674 u32 pkha_b_size; /* PKBSZRx - Size of PKHA B */
675 u32 rsvd11;
676 u32 pkha_n_size; /* PKNSZRx - Size of PKHA N */
677 u32 rsvd12;
678 u32 pkha_e_size; /* PKESZRx - Size of PKHA E */
679 u32 rsvd13[24];
680 u32 cls1_ctx[16]; /* CxC1CTXR - Class 1 Context @100 */
681 u32 rsvd14[48];
682 u32 cls1_key[8]; /* CxC1KEYR - Class 1 Key @200 */
683 u32 rsvd15[121];
684 u32 cls2_mode; /* CxC2MR - Class 2 Mode */
685 u32 rsvd16;
686 u32 cls2_keysize; /* CxX2KSR - Class 2 Key Size */
687 u32 cls2_datasize_hi; /* CxC2DSR - Class 2 Data Size */
688 u32 cls2_datasize_lo;
689 u32 rsvd17;
690 u32 cls2_icvsize; /* CxC2ICVSZR - Class 2 ICV Size */
691 u32 rsvd18[56];
692 u32 cls2_ctx[18]; /* CxC2CTXR - Class 2 Context @500 */
693 u32 rsvd19[46];
694 u32 cls2_key[32]; /* CxC2KEYR - Class2 Key @600 */
695 u32 rsvd20[84];
696 u32 inp_infofifo_hi; /* CxIFIFO - Input Info FIFO @7d0 */
697 u32 inp_infofifo_lo;
698 u32 rsvd21[2];
699 u64 inp_datafifo; /* CxDFIFO - Input Data FIFO */
700 u32 rsvd22[2];
701 u64 out_datafifo; /* CxOFIFO - Output Data FIFO */
702 u32 rsvd23[2];
703 u32 jr_ctl_hi; /* CxJRR - JobR Control Register @800 */
704 u32 jr_ctl_lo;
705 u64 jr_descaddr; /* CxDADR - JobR Descriptor Address */
Alex Porosanu1005bcc2013-09-09 18:56:34 +0300706#define DECO_OP_STATUS_HI_ERR_MASK 0xF00000FF
Kim Phillips8e8ec592011-03-13 16:54:26 +0800707 u32 op_status_hi; /* DxOPSTA - DECO Operation Status */
708 u32 op_status_lo;
709 u32 rsvd24[2];
710 u32 liodn; /* DxLSR - DECO LIODN Status - non-seq */
711 u32 td_liodn; /* DxLSR - DECO LIODN Status - trustdesc */
712 u32 rsvd26[6];
713 u64 math[4]; /* DxMTH - Math register */
714 u32 rsvd27[8];
715 struct deco_sg_table gthr_tbl[4]; /* DxGTR - Gather Tables */
716 u32 rsvd28[16];
717 struct deco_sg_table sctr_tbl[4]; /* DxSTR - Scatter Tables */
718 u32 rsvd29[48];
719 u32 descbuf[64]; /* DxDESB - Descriptor buffer */
Ruchika Gupta997ad292013-07-04 11:26:03 +0530720 u32 rscvd30[193];
Alex Porosanu84cf4822013-09-09 18:56:30 +0300721#define DESC_DBG_DECO_STAT_HOST_ERR 0x00D00000
722#define DESC_DBG_DECO_STAT_VALID 0x80000000
723#define DESC_DBG_DECO_STAT_MASK 0x00F00000
Ruchika Gupta997ad292013-07-04 11:26:03 +0530724 u32 desc_dbg; /* DxDDR - DECO Debug Register */
725 u32 rsvd31[126];
Kim Phillips8e8ec592011-03-13 16:54:26 +0800726};
727
Ruchika Gupta997ad292013-07-04 11:26:03 +0530728#define DECO_JQCR_WHL 0x20000000
729#define DECO_JQCR_FOUR 0x10000000
730
Kim Phillips8e8ec592011-03-13 16:54:26 +0800731/*
732 * Current top-level view of memory map is:
733 *
734 * 0x0000 - 0x0fff - CAAM Top-Level Control
735 * 0x1000 - 0x1fff - Job Ring 0
736 * 0x2000 - 0x2fff - Job Ring 1
737 * 0x3000 - 0x3fff - Job Ring 2
738 * 0x4000 - 0x4fff - Job Ring 3
739 * 0x5000 - 0x5fff - (unused)
740 * 0x6000 - 0x6fff - Assurance Controller
741 * 0x7000 - 0x7fff - Queue Interface
742 * 0x8000 - 0x8fff - DECO-CCB 0
743 * 0x9000 - 0x9fff - DECO-CCB 1
744 * 0xa000 - 0xafff - DECO-CCB 2
745 * 0xb000 - 0xbfff - DECO-CCB 3
746 * 0xc000 - 0xcfff - DECO-CCB 4
747 *
748 * caam_full describes the full register view of CAAM if useful,
749 * although many configurations may choose to implement parts of
750 * the register map separately, in differing privilege regions
751 */
752struct caam_full {
753 struct caam_ctrl __iomem ctrl;
754 struct caam_job_ring jr[4];
755 u64 rsvd[512];
756 struct caam_assurance assure;
757 struct caam_queue_if qi;
Ruchika Gupta997ad292013-07-04 11:26:03 +0530758 struct caam_deco deco;
Kim Phillips8e8ec592011-03-13 16:54:26 +0800759};
760
761#endif /* REGS_H */