regs.h 23 KB

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