regs.h 25 KB

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