ccp-dev.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * AMD Cryptographic Coprocessor (CCP) driver
  4. *
  5. * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
  6. *
  7. * Author: Tom Lendacky <thomas.lendacky@amd.com>
  8. * Author: Gary R Hook <gary.hook@amd.com>
  9. */
  10. #ifndef __CCP_DEV_H__
  11. #define __CCP_DEV_H__
  12. #include <linux/device.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/mutex.h>
  15. #include <linux/list.h>
  16. #include <linux/wait.h>
  17. #include <linux/dma-direction.h>
  18. #include <linux/dmapool.h>
  19. #include <linux/hw_random.h>
  20. #include <linux/bitops.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/irqreturn.h>
  23. #include <linux/dmaengine.h>
  24. #include "sp-dev.h"
  25. #define MAX_CCP_NAME_LEN 16
  26. #define MAX_DMAPOOL_NAME_LEN 32
  27. #define MAX_HW_QUEUES 5
  28. #define MAX_CMD_QLEN 100
  29. #define TRNG_RETRIES 10
  30. #define CACHE_NONE 0x00
  31. #define CACHE_WB_NO_ALLOC 0xb7
  32. /****** Register Mappings ******/
  33. #define Q_MASK_REG 0x000
  34. #define TRNG_OUT_REG 0x00c
  35. #define IRQ_MASK_REG 0x040
  36. #define IRQ_STATUS_REG 0x200
  37. #define DEL_CMD_Q_JOB 0x124
  38. #define DEL_Q_ACTIVE 0x00000200
  39. #define DEL_Q_ID_SHIFT 6
  40. #define CMD_REQ0 0x180
  41. #define CMD_REQ_INCR 0x04
  42. #define CMD_Q_STATUS_BASE 0x210
  43. #define CMD_Q_INT_STATUS_BASE 0x214
  44. #define CMD_Q_STATUS_INCR 0x20
  45. #define CMD_Q_CACHE_BASE 0x228
  46. #define CMD_Q_CACHE_INC 0x20
  47. #define CMD_Q_ERROR(__qs) ((__qs) & 0x0000003f)
  48. #define CMD_Q_DEPTH(__qs) (((__qs) >> 12) & 0x0000000f)
  49. /* ------------------------ CCP Version 5 Specifics ------------------------ */
  50. #define CMD5_QUEUE_MASK_OFFSET 0x00
  51. #define CMD5_QUEUE_PRIO_OFFSET 0x04
  52. #define CMD5_REQID_CONFIG_OFFSET 0x08
  53. #define CMD5_CMD_TIMEOUT_OFFSET 0x10
  54. #define LSB_PUBLIC_MASK_LO_OFFSET 0x18
  55. #define LSB_PUBLIC_MASK_HI_OFFSET 0x1C
  56. #define LSB_PRIVATE_MASK_LO_OFFSET 0x20
  57. #define LSB_PRIVATE_MASK_HI_OFFSET 0x24
  58. #define CMD5_PSP_CCP_VERSION 0x100
  59. #define CMD5_Q_CONTROL_BASE 0x0000
  60. #define CMD5_Q_TAIL_LO_BASE 0x0004
  61. #define CMD5_Q_HEAD_LO_BASE 0x0008
  62. #define CMD5_Q_INT_ENABLE_BASE 0x000C
  63. #define CMD5_Q_INTERRUPT_STATUS_BASE 0x0010
  64. #define CMD5_Q_STATUS_BASE 0x0100
  65. #define CMD5_Q_INT_STATUS_BASE 0x0104
  66. #define CMD5_Q_DMA_STATUS_BASE 0x0108
  67. #define CMD5_Q_DMA_READ_STATUS_BASE 0x010C
  68. #define CMD5_Q_DMA_WRITE_STATUS_BASE 0x0110
  69. #define CMD5_Q_ABORT_BASE 0x0114
  70. #define CMD5_Q_AX_CACHE_BASE 0x0118
  71. #define CMD5_CONFIG_0_OFFSET 0x6000
  72. #define CMD5_TRNG_CTL_OFFSET 0x6008
  73. #define CMD5_AES_MASK_OFFSET 0x6010
  74. #define CMD5_CLK_GATE_CTL_OFFSET 0x603C
  75. /* Address offset between two virtual queue registers */
  76. #define CMD5_Q_STATUS_INCR 0x1000
  77. /* Bit masks */
  78. #define CMD5_Q_RUN 0x1
  79. #define CMD5_Q_HALT 0x2
  80. #define CMD5_Q_MEM_LOCATION 0x4
  81. #define CMD5_Q_SIZE 0x1F
  82. #define CMD5_Q_SHIFT 3
  83. #define COMMANDS_PER_QUEUE 16
  84. #define QUEUE_SIZE_VAL ((ffs(COMMANDS_PER_QUEUE) - 2) & \
  85. CMD5_Q_SIZE)
  86. #define Q_PTR_MASK (2 << (QUEUE_SIZE_VAL + 5) - 1)
  87. #define Q_DESC_SIZE sizeof(struct ccp5_desc)
  88. #define Q_SIZE(n) (COMMANDS_PER_QUEUE*(n))
  89. #define INT_COMPLETION 0x1
  90. #define INT_ERROR 0x2
  91. #define INT_QUEUE_STOPPED 0x4
  92. #define INT_EMPTY_QUEUE 0x8
  93. #define SUPPORTED_INTERRUPTS (INT_COMPLETION | INT_ERROR)
  94. #define LSB_REGION_WIDTH 5
  95. #define MAX_LSB_CNT 8
  96. #define LSB_SIZE 16
  97. #define LSB_ITEM_SIZE 32
  98. #define PLSB_MAP_SIZE (LSB_SIZE)
  99. #define SLSB_MAP_SIZE (MAX_LSB_CNT * LSB_SIZE)
  100. #define LSB_ENTRY_NUMBER(LSB_ADDR) (LSB_ADDR / LSB_ITEM_SIZE)
  101. /* ------------------------ CCP Version 3 Specifics ------------------------ */
  102. #define REQ0_WAIT_FOR_WRITE 0x00000004
  103. #define REQ0_INT_ON_COMPLETE 0x00000002
  104. #define REQ0_STOP_ON_COMPLETE 0x00000001
  105. #define REQ0_CMD_Q_SHIFT 9
  106. #define REQ0_JOBID_SHIFT 3
  107. /****** REQ1 Related Values ******/
  108. #define REQ1_PROTECT_SHIFT 27
  109. #define REQ1_ENGINE_SHIFT 23
  110. #define REQ1_KEY_KSB_SHIFT 2
  111. #define REQ1_EOM 0x00000002
  112. #define REQ1_INIT 0x00000001
  113. /* AES Related Values */
  114. #define REQ1_AES_TYPE_SHIFT 21
  115. #define REQ1_AES_MODE_SHIFT 18
  116. #define REQ1_AES_ACTION_SHIFT 17
  117. #define REQ1_AES_CFB_SIZE_SHIFT 10
  118. /* XTS-AES Related Values */
  119. #define REQ1_XTS_AES_SIZE_SHIFT 10
  120. /* SHA Related Values */
  121. #define REQ1_SHA_TYPE_SHIFT 21
  122. /* RSA Related Values */
  123. #define REQ1_RSA_MOD_SIZE_SHIFT 10
  124. /* Pass-Through Related Values */
  125. #define REQ1_PT_BW_SHIFT 12
  126. #define REQ1_PT_BS_SHIFT 10
  127. /* ECC Related Values */
  128. #define REQ1_ECC_AFFINE_CONVERT 0x00200000
  129. #define REQ1_ECC_FUNCTION_SHIFT 18
  130. /****** REQ4 Related Values ******/
  131. #define REQ4_KSB_SHIFT 18
  132. #define REQ4_MEMTYPE_SHIFT 16
  133. /****** REQ6 Related Values ******/
  134. #define REQ6_MEMTYPE_SHIFT 16
  135. /****** Key Storage Block ******/
  136. #define KSB_START 77
  137. #define KSB_END 127
  138. #define KSB_COUNT (KSB_END - KSB_START + 1)
  139. #define CCP_SB_BITS 256
  140. #define CCP_JOBID_MASK 0x0000003f
  141. /* ------------------------ General CCP Defines ------------------------ */
  142. #define CCP_DMA_DFLT 0x0
  143. #define CCP_DMA_PRIV 0x1
  144. #define CCP_DMA_PUB 0x2
  145. #define CCP_DMAPOOL_MAX_SIZE 64
  146. #define CCP_DMAPOOL_ALIGN BIT(5)
  147. #define CCP_REVERSE_BUF_SIZE 64
  148. #define CCP_AES_KEY_SB_COUNT 1
  149. #define CCP_AES_CTX_SB_COUNT 1
  150. #define CCP_XTS_AES_KEY_SB_COUNT 1
  151. #define CCP5_XTS_AES_KEY_SB_COUNT 2
  152. #define CCP_XTS_AES_CTX_SB_COUNT 1
  153. #define CCP_DES3_KEY_SB_COUNT 1
  154. #define CCP_DES3_CTX_SB_COUNT 1
  155. #define CCP_SHA_SB_COUNT 1
  156. #define CCP_RSA_MAX_WIDTH 4096
  157. #define CCP5_RSA_MAX_WIDTH 16384
  158. #define CCP_PASSTHRU_BLOCKSIZE 256
  159. #define CCP_PASSTHRU_MASKSIZE 32
  160. #define CCP_PASSTHRU_SB_COUNT 1
  161. #define CCP_ECC_MODULUS_BYTES 48 /* 384-bits */
  162. #define CCP_ECC_MAX_OPERANDS 6
  163. #define CCP_ECC_MAX_OUTPUTS 3
  164. #define CCP_ECC_SRC_BUF_SIZE 448
  165. #define CCP_ECC_DST_BUF_SIZE 192
  166. #define CCP_ECC_OPERAND_SIZE 64
  167. #define CCP_ECC_OUTPUT_SIZE 64
  168. #define CCP_ECC_RESULT_OFFSET 60
  169. #define CCP_ECC_RESULT_SUCCESS 0x0001
  170. #define CCP_SB_BYTES 32
  171. struct ccp_op;
  172. struct ccp_device;
  173. struct ccp_cmd;
  174. struct ccp_fns;
  175. struct ccp_dma_cmd {
  176. struct list_head entry;
  177. struct ccp_cmd ccp_cmd;
  178. };
  179. struct ccp_dma_desc {
  180. struct list_head entry;
  181. struct ccp_device *ccp;
  182. struct list_head pending;
  183. struct list_head active;
  184. enum dma_status status;
  185. struct dma_async_tx_descriptor tx_desc;
  186. size_t len;
  187. };
  188. struct ccp_dma_chan {
  189. struct ccp_device *ccp;
  190. spinlock_t lock;
  191. struct list_head created;
  192. struct list_head pending;
  193. struct list_head active;
  194. struct list_head complete;
  195. struct tasklet_struct cleanup_tasklet;
  196. enum dma_status status;
  197. struct dma_chan dma_chan;
  198. };
  199. struct ccp_cmd_queue {
  200. struct ccp_device *ccp;
  201. /* Queue identifier */
  202. u32 id;
  203. /* Queue dma pool */
  204. struct dma_pool *dma_pool;
  205. /* Queue base address (not neccessarily aligned)*/
  206. struct ccp5_desc *qbase;
  207. /* Aligned queue start address (per requirement) */
  208. struct mutex q_mutex ____cacheline_aligned;
  209. unsigned int qidx;
  210. /* Version 5 has different requirements for queue memory */
  211. unsigned int qsize;
  212. dma_addr_t qbase_dma;
  213. dma_addr_t qdma_tail;
  214. /* Per-queue reserved storage block(s) */
  215. u32 sb_key;
  216. u32 sb_ctx;
  217. /* Bitmap of LSBs that can be accessed by this queue */
  218. DECLARE_BITMAP(lsbmask, MAX_LSB_CNT);
  219. /* Private LSB that is assigned to this queue, or -1 if none.
  220. * Bitmap for my private LSB, unused otherwise
  221. */
  222. int lsb;
  223. DECLARE_BITMAP(lsbmap, PLSB_MAP_SIZE);
  224. /* Queue processing thread */
  225. struct task_struct *kthread;
  226. unsigned int active;
  227. unsigned int suspended;
  228. /* Number of free command slots available */
  229. unsigned int free_slots;
  230. /* Interrupt masks */
  231. u32 int_ok;
  232. u32 int_err;
  233. /* Register addresses for queue */
  234. void __iomem *reg_control;
  235. void __iomem *reg_tail_lo;
  236. void __iomem *reg_head_lo;
  237. void __iomem *reg_int_enable;
  238. void __iomem *reg_interrupt_status;
  239. void __iomem *reg_status;
  240. void __iomem *reg_int_status;
  241. void __iomem *reg_dma_status;
  242. void __iomem *reg_dma_read_status;
  243. void __iomem *reg_dma_write_status;
  244. u32 qcontrol; /* Cached control register */
  245. /* Status values from job */
  246. u32 int_status;
  247. u32 q_status;
  248. u32 q_int_status;
  249. u32 cmd_error;
  250. /* Interrupt wait queue */
  251. wait_queue_head_t int_queue;
  252. unsigned int int_rcvd;
  253. /* Per-queue Statistics */
  254. unsigned long total_ops;
  255. unsigned long total_aes_ops;
  256. unsigned long total_xts_aes_ops;
  257. unsigned long total_3des_ops;
  258. unsigned long total_sha_ops;
  259. unsigned long total_rsa_ops;
  260. unsigned long total_pt_ops;
  261. unsigned long total_ecc_ops;
  262. } ____cacheline_aligned;
  263. struct ccp_device {
  264. struct list_head entry;
  265. struct ccp_vdata *vdata;
  266. unsigned int ord;
  267. char name[MAX_CCP_NAME_LEN];
  268. char rngname[MAX_CCP_NAME_LEN];
  269. struct device *dev;
  270. struct sp_device *sp;
  271. /* Bus specific device information
  272. */
  273. void *dev_specific;
  274. unsigned int qim;
  275. unsigned int irq;
  276. bool use_tasklet;
  277. struct tasklet_struct irq_tasklet;
  278. /* I/O area used for device communication. The register mapping
  279. * starts at an offset into the mapped bar.
  280. * The CMD_REQx registers and the Delete_Cmd_Queue_Job register
  281. * need to be protected while a command queue thread is accessing
  282. * them.
  283. */
  284. struct mutex req_mutex ____cacheline_aligned;
  285. void __iomem *io_regs;
  286. /* Master lists that all cmds are queued on. Because there can be
  287. * more than one CCP command queue that can process a cmd a separate
  288. * backlog list is neeeded so that the backlog completion call
  289. * completes before the cmd is available for execution.
  290. */
  291. spinlock_t cmd_lock ____cacheline_aligned;
  292. unsigned int cmd_count;
  293. struct list_head cmd;
  294. struct list_head backlog;
  295. /* The command queues. These represent the queues available on the
  296. * CCP that are available for processing cmds
  297. */
  298. struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES];
  299. unsigned int cmd_q_count;
  300. unsigned int max_q_count;
  301. /* Support for the CCP True RNG
  302. */
  303. struct hwrng hwrng;
  304. unsigned int hwrng_retries;
  305. /* Support for the CCP DMA capabilities
  306. */
  307. struct dma_device dma_dev;
  308. struct ccp_dma_chan *ccp_dma_chan;
  309. struct kmem_cache *dma_cmd_cache;
  310. struct kmem_cache *dma_desc_cache;
  311. /* A counter used to generate job-ids for cmds submitted to the CCP
  312. */
  313. atomic_t current_id ____cacheline_aligned;
  314. /* The v3 CCP uses key storage blocks (SB) to maintain context for
  315. * certain operations. To prevent multiple cmds from using the same
  316. * SB range a command queue reserves an SB range for the duration of
  317. * the cmd. Each queue, will however, reserve 2 SB blocks for
  318. * operations that only require single SB entries (eg. AES context/iv
  319. * and key) in order to avoid allocation contention. This will reserve
  320. * at most 10 SB entries, leaving 40 SB entries available for dynamic
  321. * allocation.
  322. *
  323. * The v5 CCP Local Storage Block (LSB) is broken up into 8
  324. * memrory ranges, each of which can be enabled for access by one
  325. * or more queues. Device initialization takes this into account,
  326. * and attempts to assign one region for exclusive use by each
  327. * available queue; the rest are then aggregated as "public" use.
  328. * If there are fewer regions than queues, all regions are shared
  329. * amongst all queues.
  330. */
  331. struct mutex sb_mutex ____cacheline_aligned;
  332. DECLARE_BITMAP(sb, KSB_COUNT);
  333. wait_queue_head_t sb_queue;
  334. unsigned int sb_avail;
  335. unsigned int sb_count;
  336. u32 sb_start;
  337. /* Bitmap of shared LSBs, if any */
  338. DECLARE_BITMAP(lsbmap, SLSB_MAP_SIZE);
  339. /* Suspend support */
  340. unsigned int suspending;
  341. wait_queue_head_t suspend_queue;
  342. /* DMA caching attribute support */
  343. unsigned int axcache;
  344. /* Device Statistics */
  345. unsigned long total_interrupts;
  346. /* DebugFS info */
  347. struct dentry *debugfs_instance;
  348. };
  349. enum ccp_memtype {
  350. CCP_MEMTYPE_SYSTEM = 0,
  351. CCP_MEMTYPE_SB,
  352. CCP_MEMTYPE_LOCAL,
  353. CCP_MEMTYPE__LAST,
  354. };
  355. #define CCP_MEMTYPE_LSB CCP_MEMTYPE_KSB
  356. struct ccp_dma_info {
  357. dma_addr_t address;
  358. unsigned int offset;
  359. unsigned int length;
  360. enum dma_data_direction dir;
  361. } __packed __aligned(4);
  362. struct ccp_dm_workarea {
  363. struct device *dev;
  364. struct dma_pool *dma_pool;
  365. u8 *address;
  366. struct ccp_dma_info dma;
  367. unsigned int length;
  368. };
  369. struct ccp_sg_workarea {
  370. struct scatterlist *sg;
  371. int nents;
  372. unsigned int sg_used;
  373. struct scatterlist *dma_sg;
  374. struct scatterlist *dma_sg_head;
  375. struct device *dma_dev;
  376. unsigned int dma_count;
  377. enum dma_data_direction dma_dir;
  378. u64 bytes_left;
  379. };
  380. struct ccp_data {
  381. struct ccp_sg_workarea sg_wa;
  382. struct ccp_dm_workarea dm_wa;
  383. };
  384. struct ccp_mem {
  385. enum ccp_memtype type;
  386. union {
  387. struct ccp_dma_info dma;
  388. u32 sb;
  389. } u;
  390. };
  391. struct ccp_aes_op {
  392. enum ccp_aes_type type;
  393. enum ccp_aes_mode mode;
  394. enum ccp_aes_action action;
  395. unsigned int size;
  396. };
  397. struct ccp_xts_aes_op {
  398. enum ccp_aes_type type;
  399. enum ccp_aes_action action;
  400. enum ccp_xts_aes_unit_size unit_size;
  401. };
  402. struct ccp_des3_op {
  403. enum ccp_des3_type type;
  404. enum ccp_des3_mode mode;
  405. enum ccp_des3_action action;
  406. };
  407. struct ccp_sha_op {
  408. enum ccp_sha_type type;
  409. u64 msg_bits;
  410. };
  411. struct ccp_rsa_op {
  412. u32 mod_size;
  413. u32 input_len;
  414. };
  415. struct ccp_passthru_op {
  416. enum ccp_passthru_bitwise bit_mod;
  417. enum ccp_passthru_byteswap byte_swap;
  418. };
  419. struct ccp_ecc_op {
  420. enum ccp_ecc_function function;
  421. };
  422. struct ccp_op {
  423. struct ccp_cmd_queue *cmd_q;
  424. u32 jobid;
  425. u32 ioc;
  426. u32 soc;
  427. u32 sb_key;
  428. u32 sb_ctx;
  429. u32 init;
  430. u32 eom;
  431. struct ccp_mem src;
  432. struct ccp_mem dst;
  433. struct ccp_mem exp;
  434. union {
  435. struct ccp_aes_op aes;
  436. struct ccp_xts_aes_op xts;
  437. struct ccp_des3_op des3;
  438. struct ccp_sha_op sha;
  439. struct ccp_rsa_op rsa;
  440. struct ccp_passthru_op passthru;
  441. struct ccp_ecc_op ecc;
  442. } u;
  443. };
  444. static inline u32 ccp_addr_lo(struct ccp_dma_info *info)
  445. {
  446. return lower_32_bits(info->address + info->offset);
  447. }
  448. static inline u32 ccp_addr_hi(struct ccp_dma_info *info)
  449. {
  450. return upper_32_bits(info->address + info->offset) & 0x0000ffff;
  451. }
  452. /**
  453. * descriptor for version 5 CPP commands
  454. * 8 32-bit words:
  455. * word 0: function; engine; control bits
  456. * word 1: length of source data
  457. * word 2: low 32 bits of source pointer
  458. * word 3: upper 16 bits of source pointer; source memory type
  459. * word 4: low 32 bits of destination pointer
  460. * word 5: upper 16 bits of destination pointer; destination memory type
  461. * word 6: low 32 bits of key pointer
  462. * word 7: upper 16 bits of key pointer; key memory type
  463. */
  464. struct dword0 {
  465. unsigned int soc:1;
  466. unsigned int ioc:1;
  467. unsigned int rsvd1:1;
  468. unsigned int init:1;
  469. unsigned int eom:1; /* AES/SHA only */
  470. unsigned int function:15;
  471. unsigned int engine:4;
  472. unsigned int prot:1;
  473. unsigned int rsvd2:7;
  474. };
  475. struct dword3 {
  476. unsigned int src_hi:16;
  477. unsigned int src_mem:2;
  478. unsigned int lsb_cxt_id:8;
  479. unsigned int rsvd1:5;
  480. unsigned int fixed:1;
  481. };
  482. union dword4 {
  483. __le32 dst_lo; /* NON-SHA */
  484. __le32 sha_len_lo; /* SHA */
  485. };
  486. union dword5 {
  487. struct {
  488. unsigned int dst_hi:16;
  489. unsigned int dst_mem:2;
  490. unsigned int rsvd1:13;
  491. unsigned int fixed:1;
  492. } fields;
  493. __le32 sha_len_hi;
  494. };
  495. struct dword7 {
  496. unsigned int key_hi:16;
  497. unsigned int key_mem:2;
  498. unsigned int rsvd1:14;
  499. };
  500. struct ccp5_desc {
  501. struct dword0 dw0;
  502. __le32 length;
  503. __le32 src_lo;
  504. struct dword3 dw3;
  505. union dword4 dw4;
  506. union dword5 dw5;
  507. __le32 key_lo;
  508. struct dword7 dw7;
  509. };
  510. void ccp_add_device(struct ccp_device *ccp);
  511. void ccp_del_device(struct ccp_device *ccp);
  512. extern void ccp_log_error(struct ccp_device *, unsigned int);
  513. struct ccp_device *ccp_alloc_struct(struct sp_device *sp);
  514. bool ccp_queues_suspended(struct ccp_device *ccp);
  515. int ccp_cmd_queue_thread(void *data);
  516. int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait);
  517. int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
  518. int ccp_register_rng(struct ccp_device *ccp);
  519. void ccp_unregister_rng(struct ccp_device *ccp);
  520. int ccp_dmaengine_register(struct ccp_device *ccp);
  521. void ccp_dmaengine_unregister(struct ccp_device *ccp);
  522. void ccp5_debugfs_setup(struct ccp_device *ccp);
  523. void ccp5_debugfs_destroy(void);
  524. /* Structure for computation functions that are device-specific */
  525. struct ccp_actions {
  526. int (*aes)(struct ccp_op *);
  527. int (*xts_aes)(struct ccp_op *);
  528. int (*des3)(struct ccp_op *);
  529. int (*sha)(struct ccp_op *);
  530. int (*rsa)(struct ccp_op *);
  531. int (*passthru)(struct ccp_op *);
  532. int (*ecc)(struct ccp_op *);
  533. u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int);
  534. void (*sbfree)(struct ccp_cmd_queue *, unsigned int, unsigned int);
  535. unsigned int (*get_free_slots)(struct ccp_cmd_queue *);
  536. int (*init)(struct ccp_device *);
  537. void (*destroy)(struct ccp_device *);
  538. irqreturn_t (*irqhandler)(int, void *);
  539. };
  540. extern const struct ccp_vdata ccpv3_platform;
  541. extern const struct ccp_vdata ccpv3;
  542. extern const struct ccp_vdata ccpv5a;
  543. extern const struct ccp_vdata ccpv5b;
  544. #endif