regs.h 22 KB

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