regs.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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. #define DECORR_RQD0ENABLE 0x00000001 /* Enable DECO0 for direct access */
  303. #define DECORR_DEN0 0x00010000 /* DECO0 available for access*/
  304. /* AXI read cache control */
  305. #define MCFGR_ARCACHE_SHIFT 12
  306. #define MCFGR_ARCACHE_MASK (0xf << MCFGR_ARCACHE_SHIFT)
  307. /* AXI write cache control */
  308. #define MCFGR_AWCACHE_SHIFT 8
  309. #define MCFGR_AWCACHE_MASK (0xf << MCFGR_AWCACHE_SHIFT)
  310. /* AXI pipeline depth */
  311. #define MCFGR_AXIPIPE_SHIFT 4
  312. #define MCFGR_AXIPIPE_MASK (0xf << MCFGR_AXIPIPE_SHIFT)
  313. #define MCFGR_AXIPRI 0x00000008 /* Assert AXI priority sideband */
  314. #define MCFGR_BURST_64 0x00000001 /* Max burst size */
  315. /*
  316. * caam_job_ring - direct job ring setup
  317. * 1-4 possible per instantiation, base + 1000/2000/3000/4000
  318. * Padded out to 0x1000
  319. */
  320. struct caam_job_ring {
  321. /* Input ring */
  322. u64 inpring_base; /* IRBAx - Input desc ring baseaddr */
  323. u32 rsvd1;
  324. u32 inpring_size; /* IRSx - Input ring size */
  325. u32 rsvd2;
  326. u32 inpring_avail; /* IRSAx - Input ring room remaining */
  327. u32 rsvd3;
  328. u32 inpring_jobadd; /* IRJAx - Input ring jobs added */
  329. /* Output Ring */
  330. u64 outring_base; /* ORBAx - Output status ring base addr */
  331. u32 rsvd4;
  332. u32 outring_size; /* ORSx - Output ring size */
  333. u32 rsvd5;
  334. u32 outring_rmvd; /* ORJRx - Output ring jobs removed */
  335. u32 rsvd6;
  336. u32 outring_used; /* ORSFx - Output ring slots full */
  337. /* Status/Configuration */
  338. u32 rsvd7;
  339. u32 jroutstatus; /* JRSTAx - JobR output status */
  340. u32 rsvd8;
  341. u32 jrintstatus; /* JRINTx - JobR interrupt status */
  342. u32 rconfig_hi; /* JRxCFG - Ring configuration */
  343. u32 rconfig_lo;
  344. /* Indices. CAAM maintains as "heads" of each queue */
  345. u32 rsvd9;
  346. u32 inp_rdidx; /* IRRIx - Input ring read index */
  347. u32 rsvd10;
  348. u32 out_wtidx; /* ORWIx - Output ring write index */
  349. /* Command/control */
  350. u32 rsvd11;
  351. u32 jrcommand; /* JRCRx - JobR command */
  352. u32 rsvd12[932];
  353. /* Performance Monitor f00-fff */
  354. struct caam_perfmon perfmon;
  355. };
  356. #define JR_RINGSIZE_MASK 0x03ff
  357. /*
  358. * jrstatus - Job Ring Output Status
  359. * All values in lo word
  360. * Also note, same values written out as status through QI
  361. * in the command/status field of a frame descriptor
  362. */
  363. #define JRSTA_SSRC_SHIFT 28
  364. #define JRSTA_SSRC_MASK 0xf0000000
  365. #define JRSTA_SSRC_NONE 0x00000000
  366. #define JRSTA_SSRC_CCB_ERROR 0x20000000
  367. #define JRSTA_SSRC_JUMP_HALT_USER 0x30000000
  368. #define JRSTA_SSRC_DECO 0x40000000
  369. #define JRSTA_SSRC_JRERROR 0x60000000
  370. #define JRSTA_SSRC_JUMP_HALT_CC 0x70000000
  371. #define JRSTA_DECOERR_JUMP 0x08000000
  372. #define JRSTA_DECOERR_INDEX_SHIFT 8
  373. #define JRSTA_DECOERR_INDEX_MASK 0xff00
  374. #define JRSTA_DECOERR_ERROR_MASK 0x00ff
  375. #define JRSTA_DECOERR_NONE 0x00
  376. #define JRSTA_DECOERR_LINKLEN 0x01
  377. #define JRSTA_DECOERR_LINKPTR 0x02
  378. #define JRSTA_DECOERR_JRCTRL 0x03
  379. #define JRSTA_DECOERR_DESCCMD 0x04
  380. #define JRSTA_DECOERR_ORDER 0x05
  381. #define JRSTA_DECOERR_KEYCMD 0x06
  382. #define JRSTA_DECOERR_LOADCMD 0x07
  383. #define JRSTA_DECOERR_STORECMD 0x08
  384. #define JRSTA_DECOERR_OPCMD 0x09
  385. #define JRSTA_DECOERR_FIFOLDCMD 0x0a
  386. #define JRSTA_DECOERR_FIFOSTCMD 0x0b
  387. #define JRSTA_DECOERR_MOVECMD 0x0c
  388. #define JRSTA_DECOERR_JUMPCMD 0x0d
  389. #define JRSTA_DECOERR_MATHCMD 0x0e
  390. #define JRSTA_DECOERR_SHASHCMD 0x0f
  391. #define JRSTA_DECOERR_SEQCMD 0x10
  392. #define JRSTA_DECOERR_DECOINTERNAL 0x11
  393. #define JRSTA_DECOERR_SHDESCHDR 0x12
  394. #define JRSTA_DECOERR_HDRLEN 0x13
  395. #define JRSTA_DECOERR_BURSTER 0x14
  396. #define JRSTA_DECOERR_DESCSIGNATURE 0x15
  397. #define JRSTA_DECOERR_DMA 0x16
  398. #define JRSTA_DECOERR_BURSTFIFO 0x17
  399. #define JRSTA_DECOERR_JRRESET 0x1a
  400. #define JRSTA_DECOERR_JOBFAIL 0x1b
  401. #define JRSTA_DECOERR_DNRERR 0x80
  402. #define JRSTA_DECOERR_UNDEFPCL 0x81
  403. #define JRSTA_DECOERR_PDBERR 0x82
  404. #define JRSTA_DECOERR_ANRPLY_LATE 0x83
  405. #define JRSTA_DECOERR_ANRPLY_REPLAY 0x84
  406. #define JRSTA_DECOERR_SEQOVF 0x85
  407. #define JRSTA_DECOERR_INVSIGN 0x86
  408. #define JRSTA_DECOERR_DSASIGN 0x87
  409. #define JRSTA_CCBERR_JUMP 0x08000000
  410. #define JRSTA_CCBERR_INDEX_MASK 0xff00
  411. #define JRSTA_CCBERR_INDEX_SHIFT 8
  412. #define JRSTA_CCBERR_CHAID_MASK 0x00f0
  413. #define JRSTA_CCBERR_CHAID_SHIFT 4
  414. #define JRSTA_CCBERR_ERRID_MASK 0x000f
  415. #define JRSTA_CCBERR_CHAID_AES (0x01 << JRSTA_CCBERR_CHAID_SHIFT)
  416. #define JRSTA_CCBERR_CHAID_DES (0x02 << JRSTA_CCBERR_CHAID_SHIFT)
  417. #define JRSTA_CCBERR_CHAID_ARC4 (0x03 << JRSTA_CCBERR_CHAID_SHIFT)
  418. #define JRSTA_CCBERR_CHAID_MD (0x04 << JRSTA_CCBERR_CHAID_SHIFT)
  419. #define JRSTA_CCBERR_CHAID_RNG (0x05 << JRSTA_CCBERR_CHAID_SHIFT)
  420. #define JRSTA_CCBERR_CHAID_SNOW (0x06 << JRSTA_CCBERR_CHAID_SHIFT)
  421. #define JRSTA_CCBERR_CHAID_KASUMI (0x07 << JRSTA_CCBERR_CHAID_SHIFT)
  422. #define JRSTA_CCBERR_CHAID_PK (0x08 << JRSTA_CCBERR_CHAID_SHIFT)
  423. #define JRSTA_CCBERR_CHAID_CRC (0x09 << JRSTA_CCBERR_CHAID_SHIFT)
  424. #define JRSTA_CCBERR_ERRID_NONE 0x00
  425. #define JRSTA_CCBERR_ERRID_MODE 0x01
  426. #define JRSTA_CCBERR_ERRID_DATASIZ 0x02
  427. #define JRSTA_CCBERR_ERRID_KEYSIZ 0x03
  428. #define JRSTA_CCBERR_ERRID_PKAMEMSZ 0x04
  429. #define JRSTA_CCBERR_ERRID_PKBMEMSZ 0x05
  430. #define JRSTA_CCBERR_ERRID_SEQUENCE 0x06
  431. #define JRSTA_CCBERR_ERRID_PKDIVZRO 0x07
  432. #define JRSTA_CCBERR_ERRID_PKMODEVN 0x08
  433. #define JRSTA_CCBERR_ERRID_KEYPARIT 0x09
  434. #define JRSTA_CCBERR_ERRID_ICVCHK 0x0a
  435. #define JRSTA_CCBERR_ERRID_HARDWARE 0x0b
  436. #define JRSTA_CCBERR_ERRID_CCMAAD 0x0c
  437. #define JRSTA_CCBERR_ERRID_INVCHA 0x0f
  438. #define JRINT_ERR_INDEX_MASK 0x3fff0000
  439. #define JRINT_ERR_INDEX_SHIFT 16
  440. #define JRINT_ERR_TYPE_MASK 0xf00
  441. #define JRINT_ERR_TYPE_SHIFT 8
  442. #define JRINT_ERR_HALT_MASK 0xc
  443. #define JRINT_ERR_HALT_SHIFT 2
  444. #define JRINT_ERR_HALT_INPROGRESS 0x4
  445. #define JRINT_ERR_HALT_COMPLETE 0x8
  446. #define JRINT_JR_ERROR 0x02
  447. #define JRINT_JR_INT 0x01
  448. #define JRINT_ERR_TYPE_WRITE 1
  449. #define JRINT_ERR_TYPE_BAD_INPADDR 3
  450. #define JRINT_ERR_TYPE_BAD_OUTADDR 4
  451. #define JRINT_ERR_TYPE_INV_INPWRT 5
  452. #define JRINT_ERR_TYPE_INV_OUTWRT 6
  453. #define JRINT_ERR_TYPE_RESET 7
  454. #define JRINT_ERR_TYPE_REMOVE_OFL 8
  455. #define JRINT_ERR_TYPE_ADD_OFL 9
  456. #define JRCFG_SOE 0x04
  457. #define JRCFG_ICEN 0x02
  458. #define JRCFG_IMSK 0x01
  459. #define JRCFG_ICDCT_SHIFT 8
  460. #define JRCFG_ICTT_SHIFT 16
  461. #define JRCR_RESET 0x01
  462. /*
  463. * caam_assurance - Assurance Controller View
  464. * base + 0x6000 padded out to 0x1000
  465. */
  466. struct rtic_element {
  467. u64 address;
  468. u32 rsvd;
  469. u32 length;
  470. };
  471. struct rtic_block {
  472. struct rtic_element element[2];
  473. };
  474. struct rtic_memhash {
  475. u32 memhash_be[32];
  476. u32 memhash_le[32];
  477. };
  478. struct caam_assurance {
  479. /* Status/Command/Watchdog */
  480. u32 rsvd1;
  481. u32 status; /* RSTA - Status */
  482. u32 rsvd2;
  483. u32 cmd; /* RCMD - Command */
  484. u32 rsvd3;
  485. u32 ctrl; /* RCTL - Control */
  486. u32 rsvd4;
  487. u32 throttle; /* RTHR - Throttle */
  488. u32 rsvd5[2];
  489. u64 watchdog; /* RWDOG - Watchdog Timer */
  490. u32 rsvd6;
  491. u32 rend; /* REND - Endian corrections */
  492. u32 rsvd7[50];
  493. /* Block access/configuration @ 100/110/120/130 */
  494. struct rtic_block memblk[4]; /* Memory Blocks A-D */
  495. u32 rsvd8[32];
  496. /* Block hashes @ 200/300/400/500 */
  497. struct rtic_memhash hash[4]; /* Block hash values A-D */
  498. u32 rsvd_3[640];
  499. };
  500. /*
  501. * caam_queue_if - QI configuration and control
  502. * starts base + 0x7000, padded out to 0x1000 long
  503. */
  504. struct caam_queue_if {
  505. u32 qi_control_hi; /* QICTL - QI Control */
  506. u32 qi_control_lo;
  507. u32 rsvd1;
  508. u32 qi_status; /* QISTA - QI Status */
  509. u32 qi_deq_cfg_hi; /* QIDQC - QI Dequeue Configuration */
  510. u32 qi_deq_cfg_lo;
  511. u32 qi_enq_cfg_hi; /* QISEQC - QI Enqueue Command */
  512. u32 qi_enq_cfg_lo;
  513. u32 rsvd2[1016];
  514. };
  515. /* QI control bits - low word */
  516. #define QICTL_DQEN 0x01 /* Enable frame pop */
  517. #define QICTL_STOP 0x02 /* Stop dequeue/enqueue */
  518. #define QICTL_SOE 0x04 /* Stop on error */
  519. /* QI control bits - high word */
  520. #define QICTL_MBSI 0x01
  521. #define QICTL_MHWSI 0x02
  522. #define QICTL_MWSI 0x04
  523. #define QICTL_MDWSI 0x08
  524. #define QICTL_CBSI 0x10 /* CtrlDataByteSwapInput */
  525. #define QICTL_CHWSI 0x20 /* CtrlDataHalfSwapInput */
  526. #define QICTL_CWSI 0x40 /* CtrlDataWordSwapInput */
  527. #define QICTL_CDWSI 0x80 /* CtrlDataDWordSwapInput */
  528. #define QICTL_MBSO 0x0100
  529. #define QICTL_MHWSO 0x0200
  530. #define QICTL_MWSO 0x0400
  531. #define QICTL_MDWSO 0x0800
  532. #define QICTL_CBSO 0x1000 /* CtrlDataByteSwapOutput */
  533. #define QICTL_CHWSO 0x2000 /* CtrlDataHalfSwapOutput */
  534. #define QICTL_CWSO 0x4000 /* CtrlDataWordSwapOutput */
  535. #define QICTL_CDWSO 0x8000 /* CtrlDataDWordSwapOutput */
  536. #define QICTL_DMBS 0x010000
  537. #define QICTL_EPO 0x020000
  538. /* QI status bits */
  539. #define QISTA_PHRDERR 0x01 /* PreHeader Read Error */
  540. #define QISTA_CFRDERR 0x02 /* Compound Frame Read Error */
  541. #define QISTA_OFWRERR 0x04 /* Output Frame Read Error */
  542. #define QISTA_BPDERR 0x08 /* Buffer Pool Depleted */
  543. #define QISTA_BTSERR 0x10 /* Buffer Undersize */
  544. #define QISTA_CFWRERR 0x20 /* Compound Frame Write Err */
  545. #define QISTA_STOPD 0x80000000 /* QI Stopped (see QICTL) */
  546. /* deco_sg_table - DECO view of scatter/gather table */
  547. struct deco_sg_table {
  548. u64 addr; /* Segment Address */
  549. u32 elen; /* E, F bits + 30-bit length */
  550. u32 bpid_offset; /* Buffer Pool ID + 16-bit length */
  551. };
  552. /*
  553. * caam_deco - descriptor controller - CHA cluster block
  554. *
  555. * Only accessible when direct DECO access is turned on
  556. * (done in DECORR, via MID programmed in DECOxMID
  557. *
  558. * 5 typical, base + 0x8000/9000/a000/b000
  559. * Padded out to 0x1000 long
  560. */
  561. struct caam_deco {
  562. u32 rsvd1;
  563. u32 cls1_mode; /* CxC1MR - Class 1 Mode */
  564. u32 rsvd2;
  565. u32 cls1_keysize; /* CxC1KSR - Class 1 Key Size */
  566. u32 cls1_datasize_hi; /* CxC1DSR - Class 1 Data Size */
  567. u32 cls1_datasize_lo;
  568. u32 rsvd3;
  569. u32 cls1_icvsize; /* CxC1ICVSR - Class 1 ICV size */
  570. u32 rsvd4[5];
  571. u32 cha_ctrl; /* CCTLR - CHA control */
  572. u32 rsvd5;
  573. u32 irq_crtl; /* CxCIRQ - CCB interrupt done/error/clear */
  574. u32 rsvd6;
  575. u32 clr_written; /* CxCWR - Clear-Written */
  576. u32 ccb_status_hi; /* CxCSTA - CCB Status/Error */
  577. u32 ccb_status_lo;
  578. u32 rsvd7[3];
  579. u32 aad_size; /* CxAADSZR - Current AAD Size */
  580. u32 rsvd8;
  581. u32 cls1_iv_size; /* CxC1IVSZR - Current Class 1 IV Size */
  582. u32 rsvd9[7];
  583. u32 pkha_a_size; /* PKASZRx - Size of PKHA A */
  584. u32 rsvd10;
  585. u32 pkha_b_size; /* PKBSZRx - Size of PKHA B */
  586. u32 rsvd11;
  587. u32 pkha_n_size; /* PKNSZRx - Size of PKHA N */
  588. u32 rsvd12;
  589. u32 pkha_e_size; /* PKESZRx - Size of PKHA E */
  590. u32 rsvd13[24];
  591. u32 cls1_ctx[16]; /* CxC1CTXR - Class 1 Context @100 */
  592. u32 rsvd14[48];
  593. u32 cls1_key[8]; /* CxC1KEYR - Class 1 Key @200 */
  594. u32 rsvd15[121];
  595. u32 cls2_mode; /* CxC2MR - Class 2 Mode */
  596. u32 rsvd16;
  597. u32 cls2_keysize; /* CxX2KSR - Class 2 Key Size */
  598. u32 cls2_datasize_hi; /* CxC2DSR - Class 2 Data Size */
  599. u32 cls2_datasize_lo;
  600. u32 rsvd17;
  601. u32 cls2_icvsize; /* CxC2ICVSZR - Class 2 ICV Size */
  602. u32 rsvd18[56];
  603. u32 cls2_ctx[18]; /* CxC2CTXR - Class 2 Context @500 */
  604. u32 rsvd19[46];
  605. u32 cls2_key[32]; /* CxC2KEYR - Class2 Key @600 */
  606. u32 rsvd20[84];
  607. u32 inp_infofifo_hi; /* CxIFIFO - Input Info FIFO @7d0 */
  608. u32 inp_infofifo_lo;
  609. u32 rsvd21[2];
  610. u64 inp_datafifo; /* CxDFIFO - Input Data FIFO */
  611. u32 rsvd22[2];
  612. u64 out_datafifo; /* CxOFIFO - Output Data FIFO */
  613. u32 rsvd23[2];
  614. u32 jr_ctl_hi; /* CxJRR - JobR Control Register @800 */
  615. u32 jr_ctl_lo;
  616. u64 jr_descaddr; /* CxDADR - JobR Descriptor Address */
  617. u32 op_status_hi; /* DxOPSTA - DECO Operation Status */
  618. u32 op_status_lo;
  619. u32 rsvd24[2];
  620. u32 liodn; /* DxLSR - DECO LIODN Status - non-seq */
  621. u32 td_liodn; /* DxLSR - DECO LIODN Status - trustdesc */
  622. u32 rsvd26[6];
  623. u64 math[4]; /* DxMTH - Math register */
  624. u32 rsvd27[8];
  625. struct deco_sg_table gthr_tbl[4]; /* DxGTR - Gather Tables */
  626. u32 rsvd28[16];
  627. struct deco_sg_table sctr_tbl[4]; /* DxSTR - Scatter Tables */
  628. u32 rsvd29[48];
  629. u32 descbuf[64]; /* DxDESB - Descriptor buffer */
  630. u32 rscvd30[193];
  631. u32 desc_dbg; /* DxDDR - DECO Debug Register */
  632. u32 rsvd31[126];
  633. };
  634. /* DECO DBG Register Valid Bit*/
  635. #define DECO_DBG_VALID 0x80000000
  636. #define DECO_JQCR_WHL 0x20000000
  637. #define DECO_JQCR_FOUR 0x10000000
  638. /*
  639. * Current top-level view of memory map is:
  640. *
  641. * 0x0000 - 0x0fff - CAAM Top-Level Control
  642. * 0x1000 - 0x1fff - Job Ring 0
  643. * 0x2000 - 0x2fff - Job Ring 1
  644. * 0x3000 - 0x3fff - Job Ring 2
  645. * 0x4000 - 0x4fff - Job Ring 3
  646. * 0x5000 - 0x5fff - (unused)
  647. * 0x6000 - 0x6fff - Assurance Controller
  648. * 0x7000 - 0x7fff - Queue Interface
  649. * 0x8000 - 0x8fff - DECO-CCB 0
  650. * 0x9000 - 0x9fff - DECO-CCB 1
  651. * 0xa000 - 0xafff - DECO-CCB 2
  652. * 0xb000 - 0xbfff - DECO-CCB 3
  653. * 0xc000 - 0xcfff - DECO-CCB 4
  654. *
  655. * caam_full describes the full register view of CAAM if useful,
  656. * although many configurations may choose to implement parts of
  657. * the register map separately, in differing privilege regions
  658. */
  659. struct caam_full {
  660. struct caam_ctrl __iomem ctrl;
  661. struct caam_job_ring jr[4];
  662. u64 rsvd[512];
  663. struct caam_assurance assure;
  664. struct caam_queue_if qi;
  665. struct caam_deco deco;
  666. };
  667. #endif /* REGS_H */