2 * CAAM hardware register-level view
4 * Copyright 2008-2011 Freescale Semiconductor, Inc.
10 #include <linux/types.h>
14 * Architecture-specific register access methods
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.
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.
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)
38 * (and on Power, the convention is 0-31, 32-63, I know...)
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
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.
52 * There are limitations to this that the developer must recognize.
53 * 32-bit architectures cannot enforce an atomic-64 operation,
56 * - On writes, since the HW is assumed to latch the cycle on the
57 * write of the higher-numeric-address word, then ordered
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.
69 #define wr_reg32(reg, data) out_be32(reg, data)
70 #define rd_reg32(reg) in_be32(reg)
72 #define wr_reg64(reg, data) out_be64(reg, data)
73 #define rd_reg64(reg) in_be64(reg)
76 #ifdef __LITTLE_ENDIAN
77 #define wr_reg32(reg, data) __raw_writel(reg, data)
78 #define rd_reg32(reg) __raw_readl(reg)
80 #define wr_reg64(reg, data) __raw_writeq(reg, data)
81 #define rd_reg64(reg) __raw_readq(reg)
87 static inline void wr_reg64(u64 __iomem
*reg
, u64 data
)
89 wr_reg32((u32 __iomem
*)reg
, (data
& 0xffffffff00000000ull
) >> 32);
90 wr_reg32((u32 __iomem
*)reg
+ 1, data
& 0x00000000ffffffffull
);
93 static inline u64
rd_reg64(u64 __iomem
*reg
)
95 return (((u64
)rd_reg32((u32 __iomem
*)reg
)) << 32) |
96 ((u64
)rd_reg32((u32 __iomem
*)reg
+ 1));
102 * Represents each entry in a JobR output ring
105 dma_addr_t desc
;/* Pointer to completed descriptor */
106 u32 jrstatus
; /* Status for completed descriptor */
110 * caam_perfmon - Performance Monitor/Secure Memory Status/
111 * CAAM Global Status/Component Version IDs
113 * Spans f00-fff wherever instantiated
116 /* Number of DECOs */
117 #define CHA_NUM_DECONUM_SHIFT 56
118 #define CHA_NUM_DECONUM_MASK (0xfull << CHA_NUM_DECONUM_SHIFT)
120 /* CHA Version IDs */
121 #define CHA_ID_AES_SHIFT 0
122 #define CHA_ID_AES_MASK (0xfull << CHA_ID_AES_SHIFT)
124 #define CHA_ID_DES_SHIFT 4
125 #define CHA_ID_DES_MASK (0xfull << CHA_ID_DES_SHIFT)
127 #define CHA_ID_ARC4_SHIFT 8
128 #define CHA_ID_ARC4_MASK (0xfull << CHA_ID_ARC4_SHIFT)
130 #define CHA_ID_MD_SHIFT 12
131 #define CHA_ID_MD_MASK (0xfull << CHA_ID_MD_SHIFT)
133 #define CHA_ID_RNG_SHIFT 16
134 #define CHA_ID_RNG_MASK (0xfull << CHA_ID_RNG_SHIFT)
136 #define CHA_ID_SNW8_SHIFT 20
137 #define CHA_ID_SNW8_MASK (0xfull << CHA_ID_SNW8_SHIFT)
139 #define CHA_ID_KAS_SHIFT 24
140 #define CHA_ID_KAS_MASK (0xfull << CHA_ID_KAS_SHIFT)
142 #define CHA_ID_PK_SHIFT 28
143 #define CHA_ID_PK_MASK (0xfull << CHA_ID_PK_SHIFT)
145 #define CHA_ID_CRC_SHIFT 32
146 #define CHA_ID_CRC_MASK (0xfull << CHA_ID_CRC_SHIFT)
148 #define CHA_ID_SNW9_SHIFT 36
149 #define CHA_ID_SNW9_MASK (0xfull << CHA_ID_SNW9_SHIFT)
151 #define CHA_ID_DECO_SHIFT 56
152 #define CHA_ID_DECO_MASK (0xfull << CHA_ID_DECO_SHIFT)
154 #define CHA_ID_JR_SHIFT 60
155 #define CHA_ID_JR_MASK (0xfull << CHA_ID_JR_SHIFT)
163 struct 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 */
174 /* CAAM Hardware Instantiation Parameters fa0-fbf */
175 u64 cha_rev
; /* CRNR - CHA Revision Number */
176 #define CTPR_QI_SHIFT 57
177 #define CTPR_QI_MASK (0x1ull << CTPR_QI_SHIFT)
178 u64 comp_parms
; /* CTPR - Compile Parameters Register */
181 /* CAAM Global Status fc0-fdf */
182 u64 faultaddr
; /* FAR - Fault Address */
183 u32 faultliodn
; /* FALR - Fault Address LIODN */
184 u32 faultdetail
; /* FADR - Fault Addr Detail */
186 u32 status
; /* CSTA - CAAM Status */
189 /* Component Instantiation Parameters fe0-fff */
190 u32 rtic_id
; /* RVID - RTIC Version ID */
191 u32 ccb_id
; /* CCBVID - CCB Version ID */
192 u64 cha_id
; /* CHAVID - CHA Version ID */
193 u64 cha_num
; /* CHANUM - CHA Number */
194 u64 caam_id
; /* CAAMVID - CAAM Version ID */
197 /* LIODN programming for DMA configuration */
198 #define MSTRID_LOCK_LIODN 0x80000000
199 #define MSTRID_LOCK_MAKETRUSTED 0x00010000 /* only for JR masterid */
201 #define MSTRID_LIODN_MASK 0x0fff
203 u32 liodn_ms
; /* lock and make-trusted control bits */
204 u32 liodn_ls
; /* LIODN for non-sequence and seq access */
207 /* Partition ID for DMA configuration */
210 u32 pidr
; /* partition ID, DECO */
213 /* RNGB test mode (replicated twice in some configurations) */
214 /* Padded out to 0x100 */
216 u32 mode
; /* RTSTMODEx - Test mode */
218 u32 reset
; /* RTSTRESETx - Test reset control */
220 u32 status
; /* RTSTSSTATUSx - Test status */
222 u32 errstat
; /* RTSTERRSTATx - Test error status */
224 u32 errctl
; /* RTSTERRCTLx - Test error control */
226 u32 entropy
; /* RTSTENTROPYx - Test entropy */
228 u32 verifctl
; /* RTSTVERIFCTLx - Test verification control */
230 u32 verifstat
; /* RTSTVERIFSTATx - Test verification status */
232 u32 verifdata
; /* RTSTVERIFDx - Test verification data */
234 u32 xkey
; /* RTSTXKEYx - Test XKEY */
236 u32 oscctctl
; /* RTSTOSCCTCTLx - Test osc. counter control */
238 u32 oscct
; /* RTSTOSCCTx - Test oscillator counter */
240 u32 oscctstat
; /* RTSTODCCTSTATx - Test osc counter status */
242 u32 ofifo
[4]; /* RTSTOFIFOx - Test output FIFO */
246 /* RNG4 TRNG test registers */
248 #define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */
249 u32 rtmctl
; /* misc. control register */
250 u32 rtscmisc
; /* statistical check misc. register */
251 u32 rtpkrrng
; /* poker range register */
253 u32 rtpkrmax
; /* PRGM=1: poker max. limit register */
254 u32 rtpkrsq
; /* PRGM=0: poker square calc. result register */
256 #define RTSDCTL_ENT_DLY_SHIFT 16
257 #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
258 u32 rtsdctl
; /* seed control register */
260 u32 rtsblim
; /* PRGM=1: sparse bit limit register */
261 u32 rttotsam
; /* PRGM=0: total samples register */
263 u32 rtfrqmin
; /* frequency count min. limit register */
265 u32 rtfrqmax
; /* PRGM=1: freq. count max. limit register */
266 u32 rtfrqcnt
; /* PRGM=0: freq. count register */
269 #define RDSTA_IF0 0x00000001
275 * caam_ctrl - basic core configuration
276 * starts base + 0x0000 padded out to 0x1000
279 #define KEK_KEY_SIZE 8
280 #define TKEK_KEY_SIZE 8
281 #define TDSK_KEY_SIZE 8
283 #define DECO_RESET 1 /* Use with DECO reset/availability regs */
284 #define DECO_RESET_0 (DECO_RESET << 0)
285 #define DECO_RESET_1 (DECO_RESET << 1)
286 #define DECO_RESET_2 (DECO_RESET << 2)
287 #define DECO_RESET_3 (DECO_RESET << 3)
288 #define DECO_RESET_4 (DECO_RESET << 4)
291 /* Basic Configuration Section 000-01f */
294 u32 mcr
; /* MCFG Master Config Register */
296 u32 scfgr
; /* SCFGR, Security Config Register */
298 /* Bus Access Configuration Section 010-11f */
300 struct masterid jr_mid
[4]; /* JRxLIODNR - JobR LIODN setup */
302 struct masterid rtic_mid
[4]; /* RTICxLIODNR - RTIC LIODN setup */
304 u32 deco_rq
; /* DECORR - DECO Request */
305 struct partid deco_mid
[5]; /* DECOxLIODNR - 1 per DECO */
308 /* DECO Availability/Reset Section 120-3ff */
309 u32 deco_avail
; /* DAR - DECO availability */
310 u32 deco_reset
; /* DRR - DECO reset */
313 /* Key Encryption/Decryption Configuration 400-5ff */
314 /* Read/Writable only while in Non-secure mode */
315 u32 kek
[KEK_KEY_SIZE
]; /* JDKEKR - Key Encryption Key */
316 u32 tkek
[TKEK_KEY_SIZE
]; /* TDKEKR - Trusted Desc KEK */
317 u32 tdsk
[TDSK_KEY_SIZE
]; /* TDSKR - Trusted Desc Signing Key */
319 u64 sknonce
; /* SKNR - Secure Key Nonce */
322 /* RNG Test/Verification/Debug Access 600-7ff */
323 /* (Useful in Test/Debug modes only...) */
325 struct rngtst rtst
[2];
326 struct rng4tst r4tst
[2];
331 /* Performance Monitor f00-fff */
332 struct caam_perfmon perfmon
;
336 * Controller master config register defs
338 #define MCFGR_SWRESET 0x80000000 /* software reset */
339 #define MCFGR_WDENABLE 0x40000000 /* DECO watchdog enable */
340 #define MCFGR_WDFAIL 0x20000000 /* DECO watchdog force-fail */
341 #define MCFGR_DMA_RESET 0x10000000
342 #define MCFGR_LONG_PTR 0x00010000 /* Use >32-bit desc addressing */
343 #define SCFGR_RDBENABLE 0x00000400
344 #define DECORR_RQD0ENABLE 0x00000001 /* Enable DECO0 for direct access */
345 #define DECORR_DEN0 0x00010000 /* DECO0 available for access*/
347 /* AXI read cache control */
348 #define MCFGR_ARCACHE_SHIFT 12
349 #define MCFGR_ARCACHE_MASK (0xf << MCFGR_ARCACHE_SHIFT)
351 /* AXI write cache control */
352 #define MCFGR_AWCACHE_SHIFT 8
353 #define MCFGR_AWCACHE_MASK (0xf << MCFGR_AWCACHE_SHIFT)
355 /* AXI pipeline depth */
356 #define MCFGR_AXIPIPE_SHIFT 4
357 #define MCFGR_AXIPIPE_MASK (0xf << MCFGR_AXIPIPE_SHIFT)
359 #define MCFGR_AXIPRI 0x00000008 /* Assert AXI priority sideband */
360 #define MCFGR_BURST_64 0x00000001 /* Max burst size */
363 * caam_job_ring - direct job ring setup
364 * 1-4 possible per instantiation, base + 1000/2000/3000/4000
365 * Padded out to 0x1000
367 struct caam_job_ring
{
369 u64 inpring_base
; /* IRBAx - Input desc ring baseaddr */
371 u32 inpring_size
; /* IRSx - Input ring size */
373 u32 inpring_avail
; /* IRSAx - Input ring room remaining */
375 u32 inpring_jobadd
; /* IRJAx - Input ring jobs added */
378 u64 outring_base
; /* ORBAx - Output status ring base addr */
380 u32 outring_size
; /* ORSx - Output ring size */
382 u32 outring_rmvd
; /* ORJRx - Output ring jobs removed */
384 u32 outring_used
; /* ORSFx - Output ring slots full */
386 /* Status/Configuration */
388 u32 jroutstatus
; /* JRSTAx - JobR output status */
390 u32 jrintstatus
; /* JRINTx - JobR interrupt status */
391 u32 rconfig_hi
; /* JRxCFG - Ring configuration */
394 /* Indices. CAAM maintains as "heads" of each queue */
396 u32 inp_rdidx
; /* IRRIx - Input ring read index */
398 u32 out_wtidx
; /* ORWIx - Output ring write index */
400 /* Command/control */
402 u32 jrcommand
; /* JRCRx - JobR command */
406 /* Performance Monitor f00-fff */
407 struct caam_perfmon perfmon
;
410 #define JR_RINGSIZE_MASK 0x03ff
412 * jrstatus - Job Ring Output Status
413 * All values in lo word
414 * Also note, same values written out as status through QI
415 * in the command/status field of a frame descriptor
417 #define JRSTA_SSRC_SHIFT 28
418 #define JRSTA_SSRC_MASK 0xf0000000
420 #define JRSTA_SSRC_NONE 0x00000000
421 #define JRSTA_SSRC_CCB_ERROR 0x20000000
422 #define JRSTA_SSRC_JUMP_HALT_USER 0x30000000
423 #define JRSTA_SSRC_DECO 0x40000000
424 #define JRSTA_SSRC_JRERROR 0x60000000
425 #define JRSTA_SSRC_JUMP_HALT_CC 0x70000000
427 #define JRSTA_DECOERR_JUMP 0x08000000
428 #define JRSTA_DECOERR_INDEX_SHIFT 8
429 #define JRSTA_DECOERR_INDEX_MASK 0xff00
430 #define JRSTA_DECOERR_ERROR_MASK 0x00ff
432 #define JRSTA_DECOERR_NONE 0x00
433 #define JRSTA_DECOERR_LINKLEN 0x01
434 #define JRSTA_DECOERR_LINKPTR 0x02
435 #define JRSTA_DECOERR_JRCTRL 0x03
436 #define JRSTA_DECOERR_DESCCMD 0x04
437 #define JRSTA_DECOERR_ORDER 0x05
438 #define JRSTA_DECOERR_KEYCMD 0x06
439 #define JRSTA_DECOERR_LOADCMD 0x07
440 #define JRSTA_DECOERR_STORECMD 0x08
441 #define JRSTA_DECOERR_OPCMD 0x09
442 #define JRSTA_DECOERR_FIFOLDCMD 0x0a
443 #define JRSTA_DECOERR_FIFOSTCMD 0x0b
444 #define JRSTA_DECOERR_MOVECMD 0x0c
445 #define JRSTA_DECOERR_JUMPCMD 0x0d
446 #define JRSTA_DECOERR_MATHCMD 0x0e
447 #define JRSTA_DECOERR_SHASHCMD 0x0f
448 #define JRSTA_DECOERR_SEQCMD 0x10
449 #define JRSTA_DECOERR_DECOINTERNAL 0x11
450 #define JRSTA_DECOERR_SHDESCHDR 0x12
451 #define JRSTA_DECOERR_HDRLEN 0x13
452 #define JRSTA_DECOERR_BURSTER 0x14
453 #define JRSTA_DECOERR_DESCSIGNATURE 0x15
454 #define JRSTA_DECOERR_DMA 0x16
455 #define JRSTA_DECOERR_BURSTFIFO 0x17
456 #define JRSTA_DECOERR_JRRESET 0x1a
457 #define JRSTA_DECOERR_JOBFAIL 0x1b
458 #define JRSTA_DECOERR_DNRERR 0x80
459 #define JRSTA_DECOERR_UNDEFPCL 0x81
460 #define JRSTA_DECOERR_PDBERR 0x82
461 #define JRSTA_DECOERR_ANRPLY_LATE 0x83
462 #define JRSTA_DECOERR_ANRPLY_REPLAY 0x84
463 #define JRSTA_DECOERR_SEQOVF 0x85
464 #define JRSTA_DECOERR_INVSIGN 0x86
465 #define JRSTA_DECOERR_DSASIGN 0x87
467 #define JRSTA_CCBERR_JUMP 0x08000000
468 #define JRSTA_CCBERR_INDEX_MASK 0xff00
469 #define JRSTA_CCBERR_INDEX_SHIFT 8
470 #define JRSTA_CCBERR_CHAID_MASK 0x00f0
471 #define JRSTA_CCBERR_CHAID_SHIFT 4
472 #define JRSTA_CCBERR_ERRID_MASK 0x000f
474 #define JRSTA_CCBERR_CHAID_AES (0x01 << JRSTA_CCBERR_CHAID_SHIFT)
475 #define JRSTA_CCBERR_CHAID_DES (0x02 << JRSTA_CCBERR_CHAID_SHIFT)
476 #define JRSTA_CCBERR_CHAID_ARC4 (0x03 << JRSTA_CCBERR_CHAID_SHIFT)
477 #define JRSTA_CCBERR_CHAID_MD (0x04 << JRSTA_CCBERR_CHAID_SHIFT)
478 #define JRSTA_CCBERR_CHAID_RNG (0x05 << JRSTA_CCBERR_CHAID_SHIFT)
479 #define JRSTA_CCBERR_CHAID_SNOW (0x06 << JRSTA_CCBERR_CHAID_SHIFT)
480 #define JRSTA_CCBERR_CHAID_KASUMI (0x07 << JRSTA_CCBERR_CHAID_SHIFT)
481 #define JRSTA_CCBERR_CHAID_PK (0x08 << JRSTA_CCBERR_CHAID_SHIFT)
482 #define JRSTA_CCBERR_CHAID_CRC (0x09 << JRSTA_CCBERR_CHAID_SHIFT)
484 #define JRSTA_CCBERR_ERRID_NONE 0x00
485 #define JRSTA_CCBERR_ERRID_MODE 0x01
486 #define JRSTA_CCBERR_ERRID_DATASIZ 0x02
487 #define JRSTA_CCBERR_ERRID_KEYSIZ 0x03
488 #define JRSTA_CCBERR_ERRID_PKAMEMSZ 0x04
489 #define JRSTA_CCBERR_ERRID_PKBMEMSZ 0x05
490 #define JRSTA_CCBERR_ERRID_SEQUENCE 0x06
491 #define JRSTA_CCBERR_ERRID_PKDIVZRO 0x07
492 #define JRSTA_CCBERR_ERRID_PKMODEVN 0x08
493 #define JRSTA_CCBERR_ERRID_KEYPARIT 0x09
494 #define JRSTA_CCBERR_ERRID_ICVCHK 0x0a
495 #define JRSTA_CCBERR_ERRID_HARDWARE 0x0b
496 #define JRSTA_CCBERR_ERRID_CCMAAD 0x0c
497 #define JRSTA_CCBERR_ERRID_INVCHA 0x0f
499 #define JRINT_ERR_INDEX_MASK 0x3fff0000
500 #define JRINT_ERR_INDEX_SHIFT 16
501 #define JRINT_ERR_TYPE_MASK 0xf00
502 #define JRINT_ERR_TYPE_SHIFT 8
503 #define JRINT_ERR_HALT_MASK 0xc
504 #define JRINT_ERR_HALT_SHIFT 2
505 #define JRINT_ERR_HALT_INPROGRESS 0x4
506 #define JRINT_ERR_HALT_COMPLETE 0x8
507 #define JRINT_JR_ERROR 0x02
508 #define JRINT_JR_INT 0x01
510 #define JRINT_ERR_TYPE_WRITE 1
511 #define JRINT_ERR_TYPE_BAD_INPADDR 3
512 #define JRINT_ERR_TYPE_BAD_OUTADDR 4
513 #define JRINT_ERR_TYPE_INV_INPWRT 5
514 #define JRINT_ERR_TYPE_INV_OUTWRT 6
515 #define JRINT_ERR_TYPE_RESET 7
516 #define JRINT_ERR_TYPE_REMOVE_OFL 8
517 #define JRINT_ERR_TYPE_ADD_OFL 9
519 #define JRCFG_SOE 0x04
520 #define JRCFG_ICEN 0x02
521 #define JRCFG_IMSK 0x01
522 #define JRCFG_ICDCT_SHIFT 8
523 #define JRCFG_ICTT_SHIFT 16
525 #define JRCR_RESET 0x01
528 * caam_assurance - Assurance Controller View
529 * base + 0x6000 padded out to 0x1000
532 struct rtic_element
{
539 struct rtic_element element
[2];
542 struct rtic_memhash
{
547 struct caam_assurance
{
548 /* Status/Command/Watchdog */
550 u32 status
; /* RSTA - Status */
552 u32 cmd
; /* RCMD - Command */
554 u32 ctrl
; /* RCTL - Control */
556 u32 throttle
; /* RTHR - Throttle */
558 u64 watchdog
; /* RWDOG - Watchdog Timer */
560 u32 rend
; /* REND - Endian corrections */
563 /* Block access/configuration @ 100/110/120/130 */
564 struct rtic_block memblk
[4]; /* Memory Blocks A-D */
567 /* Block hashes @ 200/300/400/500 */
568 struct rtic_memhash hash
[4]; /* Block hash values A-D */
573 * caam_queue_if - QI configuration and control
574 * starts base + 0x7000, padded out to 0x1000 long
577 struct caam_queue_if
{
578 u32 qi_control_hi
; /* QICTL - QI Control */
581 u32 qi_status
; /* QISTA - QI Status */
582 u32 qi_deq_cfg_hi
; /* QIDQC - QI Dequeue Configuration */
584 u32 qi_enq_cfg_hi
; /* QISEQC - QI Enqueue Command */
589 /* QI control bits - low word */
590 #define QICTL_DQEN 0x01 /* Enable frame pop */
591 #define QICTL_STOP 0x02 /* Stop dequeue/enqueue */
592 #define QICTL_SOE 0x04 /* Stop on error */
594 /* QI control bits - high word */
595 #define QICTL_MBSI 0x01
596 #define QICTL_MHWSI 0x02
597 #define QICTL_MWSI 0x04
598 #define QICTL_MDWSI 0x08
599 #define QICTL_CBSI 0x10 /* CtrlDataByteSwapInput */
600 #define QICTL_CHWSI 0x20 /* CtrlDataHalfSwapInput */
601 #define QICTL_CWSI 0x40 /* CtrlDataWordSwapInput */
602 #define QICTL_CDWSI 0x80 /* CtrlDataDWordSwapInput */
603 #define QICTL_MBSO 0x0100
604 #define QICTL_MHWSO 0x0200
605 #define QICTL_MWSO 0x0400
606 #define QICTL_MDWSO 0x0800
607 #define QICTL_CBSO 0x1000 /* CtrlDataByteSwapOutput */
608 #define QICTL_CHWSO 0x2000 /* CtrlDataHalfSwapOutput */
609 #define QICTL_CWSO 0x4000 /* CtrlDataWordSwapOutput */
610 #define QICTL_CDWSO 0x8000 /* CtrlDataDWordSwapOutput */
611 #define QICTL_DMBS 0x010000
612 #define QICTL_EPO 0x020000
615 #define QISTA_PHRDERR 0x01 /* PreHeader Read Error */
616 #define QISTA_CFRDERR 0x02 /* Compound Frame Read Error */
617 #define QISTA_OFWRERR 0x04 /* Output Frame Read Error */
618 #define QISTA_BPDERR 0x08 /* Buffer Pool Depleted */
619 #define QISTA_BTSERR 0x10 /* Buffer Undersize */
620 #define QISTA_CFWRERR 0x20 /* Compound Frame Write Err */
621 #define QISTA_STOPD 0x80000000 /* QI Stopped (see QICTL) */
623 /* deco_sg_table - DECO view of scatter/gather table */
624 struct deco_sg_table
{
625 u64 addr
; /* Segment Address */
626 u32 elen
; /* E, F bits + 30-bit length */
627 u32 bpid_offset
; /* Buffer Pool ID + 16-bit length */
631 * caam_deco - descriptor controller - CHA cluster block
633 * Only accessible when direct DECO access is turned on
634 * (done in DECORR, via MID programmed in DECOxMID
636 * 5 typical, base + 0x8000/9000/a000/b000
637 * Padded out to 0x1000 long
641 u32 cls1_mode
; /* CxC1MR - Class 1 Mode */
643 u32 cls1_keysize
; /* CxC1KSR - Class 1 Key Size */
644 u32 cls1_datasize_hi
; /* CxC1DSR - Class 1 Data Size */
645 u32 cls1_datasize_lo
;
647 u32 cls1_icvsize
; /* CxC1ICVSR - Class 1 ICV size */
649 u32 cha_ctrl
; /* CCTLR - CHA control */
651 u32 irq_crtl
; /* CxCIRQ - CCB interrupt done/error/clear */
653 u32 clr_written
; /* CxCWR - Clear-Written */
654 u32 ccb_status_hi
; /* CxCSTA - CCB Status/Error */
657 u32 aad_size
; /* CxAADSZR - Current AAD Size */
659 u32 cls1_iv_size
; /* CxC1IVSZR - Current Class 1 IV Size */
661 u32 pkha_a_size
; /* PKASZRx - Size of PKHA A */
663 u32 pkha_b_size
; /* PKBSZRx - Size of PKHA B */
665 u32 pkha_n_size
; /* PKNSZRx - Size of PKHA N */
667 u32 pkha_e_size
; /* PKESZRx - Size of PKHA E */
669 u32 cls1_ctx
[16]; /* CxC1CTXR - Class 1 Context @100 */
671 u32 cls1_key
[8]; /* CxC1KEYR - Class 1 Key @200 */
673 u32 cls2_mode
; /* CxC2MR - Class 2 Mode */
675 u32 cls2_keysize
; /* CxX2KSR - Class 2 Key Size */
676 u32 cls2_datasize_hi
; /* CxC2DSR - Class 2 Data Size */
677 u32 cls2_datasize_lo
;
679 u32 cls2_icvsize
; /* CxC2ICVSZR - Class 2 ICV Size */
681 u32 cls2_ctx
[18]; /* CxC2CTXR - Class 2 Context @500 */
683 u32 cls2_key
[32]; /* CxC2KEYR - Class2 Key @600 */
685 u32 inp_infofifo_hi
; /* CxIFIFO - Input Info FIFO @7d0 */
688 u64 inp_datafifo
; /* CxDFIFO - Input Data FIFO */
690 u64 out_datafifo
; /* CxOFIFO - Output Data FIFO */
692 u32 jr_ctl_hi
; /* CxJRR - JobR Control Register @800 */
694 u64 jr_descaddr
; /* CxDADR - JobR Descriptor Address */
695 u32 op_status_hi
; /* DxOPSTA - DECO Operation Status */
698 u32 liodn
; /* DxLSR - DECO LIODN Status - non-seq */
699 u32 td_liodn
; /* DxLSR - DECO LIODN Status - trustdesc */
701 u64 math
[4]; /* DxMTH - Math register */
703 struct deco_sg_table gthr_tbl
[4]; /* DxGTR - Gather Tables */
705 struct deco_sg_table sctr_tbl
[4]; /* DxSTR - Scatter Tables */
707 u32 descbuf
[64]; /* DxDESB - Descriptor buffer */
709 u32 desc_dbg
; /* DxDDR - DECO Debug Register */
713 /* DECO DBG Register Valid Bit*/
714 #define DECO_DBG_VALID 0x80000000
715 #define DECO_JQCR_WHL 0x20000000
716 #define DECO_JQCR_FOUR 0x10000000
719 * Current top-level view of memory map is:
721 * 0x0000 - 0x0fff - CAAM Top-Level Control
722 * 0x1000 - 0x1fff - Job Ring 0
723 * 0x2000 - 0x2fff - Job Ring 1
724 * 0x3000 - 0x3fff - Job Ring 2
725 * 0x4000 - 0x4fff - Job Ring 3
726 * 0x5000 - 0x5fff - (unused)
727 * 0x6000 - 0x6fff - Assurance Controller
728 * 0x7000 - 0x7fff - Queue Interface
729 * 0x8000 - 0x8fff - DECO-CCB 0
730 * 0x9000 - 0x9fff - DECO-CCB 1
731 * 0xa000 - 0xafff - DECO-CCB 2
732 * 0xb000 - 0xbfff - DECO-CCB 3
733 * 0xc000 - 0xcfff - DECO-CCB 4
735 * caam_full describes the full register view of CAAM if useful,
736 * although many configurations may choose to implement parts of
737 * the register map separately, in differing privilege regions
740 struct caam_ctrl __iomem ctrl
;
741 struct caam_job_ring jr
[4];
743 struct caam_assurance assure
;
744 struct caam_queue_if qi
;
745 struct caam_deco deco
;