regs.h 21 KB

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