Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * AMD Cryptographic Coprocessor (CCP) driver
0004  *
0005  * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
0006  *
0007  * Author: Tom Lendacky <thomas.lendacky@amd.com>
0008  * Author: Gary R Hook <gary.hook@amd.com>
0009  */
0010 
0011 #ifndef __CCP_DEV_H__
0012 #define __CCP_DEV_H__
0013 
0014 #include <linux/device.h>
0015 #include <linux/spinlock.h>
0016 #include <linux/mutex.h>
0017 #include <linux/list.h>
0018 #include <linux/wait.h>
0019 #include <linux/dma-direction.h>
0020 #include <linux/dmapool.h>
0021 #include <linux/hw_random.h>
0022 #include <linux/bitops.h>
0023 #include <linux/interrupt.h>
0024 #include <linux/irqreturn.h>
0025 #include <linux/dmaengine.h>
0026 
0027 #include "sp-dev.h"
0028 
0029 #define MAX_CCP_NAME_LEN        16
0030 #define MAX_DMAPOOL_NAME_LEN        32
0031 
0032 #define MAX_HW_QUEUES           5
0033 #define MAX_CMD_QLEN            100
0034 
0035 #define TRNG_RETRIES            10
0036 
0037 #define CACHE_NONE          0x00
0038 #define CACHE_WB_NO_ALLOC       0xb7
0039 
0040 /****** Register Mappings ******/
0041 #define Q_MASK_REG          0x000
0042 #define TRNG_OUT_REG            0x00c
0043 #define IRQ_MASK_REG            0x040
0044 #define IRQ_STATUS_REG          0x200
0045 
0046 #define DEL_CMD_Q_JOB           0x124
0047 #define DEL_Q_ACTIVE            0x00000200
0048 #define DEL_Q_ID_SHIFT          6
0049 
0050 #define CMD_REQ0            0x180
0051 #define CMD_REQ_INCR            0x04
0052 
0053 #define CMD_Q_STATUS_BASE       0x210
0054 #define CMD_Q_INT_STATUS_BASE       0x214
0055 #define CMD_Q_STATUS_INCR       0x20
0056 
0057 #define CMD_Q_CACHE_BASE        0x228
0058 #define CMD_Q_CACHE_INC         0x20
0059 
0060 #define CMD_Q_ERROR(__qs)       ((__qs) & 0x0000003f)
0061 #define CMD_Q_DEPTH(__qs)       (((__qs) >> 12) & 0x0000000f)
0062 
0063 /* ------------------------ CCP Version 5 Specifics ------------------------ */
0064 #define CMD5_QUEUE_MASK_OFFSET      0x00
0065 #define CMD5_QUEUE_PRIO_OFFSET      0x04
0066 #define CMD5_REQID_CONFIG_OFFSET    0x08
0067 #define CMD5_CMD_TIMEOUT_OFFSET     0x10
0068 #define LSB_PUBLIC_MASK_LO_OFFSET   0x18
0069 #define LSB_PUBLIC_MASK_HI_OFFSET   0x1C
0070 #define LSB_PRIVATE_MASK_LO_OFFSET  0x20
0071 #define LSB_PRIVATE_MASK_HI_OFFSET  0x24
0072 #define CMD5_PSP_CCP_VERSION        0x100
0073 
0074 #define CMD5_Q_CONTROL_BASE     0x0000
0075 #define CMD5_Q_TAIL_LO_BASE     0x0004
0076 #define CMD5_Q_HEAD_LO_BASE     0x0008
0077 #define CMD5_Q_INT_ENABLE_BASE      0x000C
0078 #define CMD5_Q_INTERRUPT_STATUS_BASE    0x0010
0079 
0080 #define CMD5_Q_STATUS_BASE      0x0100
0081 #define CMD5_Q_INT_STATUS_BASE      0x0104
0082 #define CMD5_Q_DMA_STATUS_BASE      0x0108
0083 #define CMD5_Q_DMA_READ_STATUS_BASE 0x010C
0084 #define CMD5_Q_DMA_WRITE_STATUS_BASE    0x0110
0085 #define CMD5_Q_ABORT_BASE       0x0114
0086 #define CMD5_Q_AX_CACHE_BASE        0x0118
0087 
0088 #define CMD5_CONFIG_0_OFFSET        0x6000
0089 #define CMD5_TRNG_CTL_OFFSET        0x6008
0090 #define CMD5_AES_MASK_OFFSET        0x6010
0091 #define CMD5_CLK_GATE_CTL_OFFSET    0x603C
0092 
0093 /* Address offset between two virtual queue registers */
0094 #define CMD5_Q_STATUS_INCR      0x1000
0095 
0096 /* Bit masks */
0097 #define CMD5_Q_RUN          0x1
0098 #define CMD5_Q_HALT         0x2
0099 #define CMD5_Q_MEM_LOCATION     0x4
0100 #define CMD5_Q_SIZE         0x1F
0101 #define CMD5_Q_SHIFT            3
0102 #define COMMANDS_PER_QUEUE      16
0103 #define QUEUE_SIZE_VAL          ((ffs(COMMANDS_PER_QUEUE) - 2) & \
0104                       CMD5_Q_SIZE)
0105 #define Q_PTR_MASK          (2 << (QUEUE_SIZE_VAL + 5) - 1)
0106 #define Q_DESC_SIZE         sizeof(struct ccp5_desc)
0107 #define Q_SIZE(n)           (COMMANDS_PER_QUEUE*(n))
0108 
0109 #define INT_COMPLETION          0x1
0110 #define INT_ERROR           0x2
0111 #define INT_QUEUE_STOPPED       0x4
0112 #define INT_EMPTY_QUEUE         0x8
0113 #define SUPPORTED_INTERRUPTS        (INT_COMPLETION | INT_ERROR)
0114 
0115 #define LSB_REGION_WIDTH        5
0116 #define MAX_LSB_CNT         8
0117 
0118 #define LSB_SIZE            16
0119 #define LSB_ITEM_SIZE           32
0120 #define PLSB_MAP_SIZE           (LSB_SIZE)
0121 #define SLSB_MAP_SIZE           (MAX_LSB_CNT * LSB_SIZE)
0122 
0123 #define LSB_ENTRY_NUMBER(LSB_ADDR)  (LSB_ADDR / LSB_ITEM_SIZE)
0124 
0125 /* ------------------------ CCP Version 3 Specifics ------------------------ */
0126 #define REQ0_WAIT_FOR_WRITE     0x00000004
0127 #define REQ0_INT_ON_COMPLETE        0x00000002
0128 #define REQ0_STOP_ON_COMPLETE       0x00000001
0129 
0130 #define REQ0_CMD_Q_SHIFT        9
0131 #define REQ0_JOBID_SHIFT        3
0132 
0133 /****** REQ1 Related Values ******/
0134 #define REQ1_PROTECT_SHIFT      27
0135 #define REQ1_ENGINE_SHIFT       23
0136 #define REQ1_KEY_KSB_SHIFT      2
0137 
0138 #define REQ1_EOM            0x00000002
0139 #define REQ1_INIT           0x00000001
0140 
0141 /* AES Related Values */
0142 #define REQ1_AES_TYPE_SHIFT     21
0143 #define REQ1_AES_MODE_SHIFT     18
0144 #define REQ1_AES_ACTION_SHIFT       17
0145 #define REQ1_AES_CFB_SIZE_SHIFT     10
0146 
0147 /* XTS-AES Related Values */
0148 #define REQ1_XTS_AES_SIZE_SHIFT     10
0149 
0150 /* SHA Related Values */
0151 #define REQ1_SHA_TYPE_SHIFT     21
0152 
0153 /* RSA Related Values */
0154 #define REQ1_RSA_MOD_SIZE_SHIFT     10
0155 
0156 /* Pass-Through Related Values */
0157 #define REQ1_PT_BW_SHIFT        12
0158 #define REQ1_PT_BS_SHIFT        10
0159 
0160 /* ECC Related Values */
0161 #define REQ1_ECC_AFFINE_CONVERT     0x00200000
0162 #define REQ1_ECC_FUNCTION_SHIFT     18
0163 
0164 /****** REQ4 Related Values ******/
0165 #define REQ4_KSB_SHIFT          18
0166 #define REQ4_MEMTYPE_SHIFT      16
0167 
0168 /****** REQ6 Related Values ******/
0169 #define REQ6_MEMTYPE_SHIFT      16
0170 
0171 /****** Key Storage Block ******/
0172 #define KSB_START           77
0173 #define KSB_END             127
0174 #define KSB_COUNT           (KSB_END - KSB_START + 1)
0175 #define CCP_SB_BITS         256
0176 
0177 #define CCP_JOBID_MASK          0x0000003f
0178 
0179 /* ------------------------ General CCP Defines ------------------------ */
0180 
0181 #define CCP_DMA_DFLT            0x0
0182 #define CCP_DMA_PRIV            0x1
0183 #define CCP_DMA_PUB         0x2
0184 
0185 #define CCP_DMAPOOL_MAX_SIZE        64
0186 #define CCP_DMAPOOL_ALIGN       BIT(5)
0187 
0188 #define CCP_REVERSE_BUF_SIZE        64
0189 
0190 #define CCP_AES_KEY_SB_COUNT        1
0191 #define CCP_AES_CTX_SB_COUNT        1
0192 
0193 #define CCP_XTS_AES_KEY_SB_COUNT    1
0194 #define CCP5_XTS_AES_KEY_SB_COUNT   2
0195 #define CCP_XTS_AES_CTX_SB_COUNT    1
0196 
0197 #define CCP_DES3_KEY_SB_COUNT       1
0198 #define CCP_DES3_CTX_SB_COUNT       1
0199 
0200 #define CCP_SHA_SB_COUNT        1
0201 
0202 #define CCP_RSA_MAX_WIDTH       4096
0203 #define CCP5_RSA_MAX_WIDTH      16384
0204 
0205 #define CCP_PASSTHRU_BLOCKSIZE      256
0206 #define CCP_PASSTHRU_MASKSIZE       32
0207 #define CCP_PASSTHRU_SB_COUNT       1
0208 
0209 #define CCP_ECC_MODULUS_BYTES       48      /* 384-bits */
0210 #define CCP_ECC_MAX_OPERANDS        6
0211 #define CCP_ECC_MAX_OUTPUTS     3
0212 #define CCP_ECC_SRC_BUF_SIZE        448
0213 #define CCP_ECC_DST_BUF_SIZE        192
0214 #define CCP_ECC_OPERAND_SIZE        64
0215 #define CCP_ECC_OUTPUT_SIZE     64
0216 #define CCP_ECC_RESULT_OFFSET       60
0217 #define CCP_ECC_RESULT_SUCCESS      0x0001
0218 
0219 #define CCP_SB_BYTES            32
0220 
0221 struct ccp_op;
0222 struct ccp_device;
0223 struct ccp_cmd;
0224 struct ccp_fns;
0225 
0226 struct ccp_dma_cmd {
0227     struct list_head entry;
0228 
0229     struct ccp_cmd ccp_cmd;
0230 };
0231 
0232 struct ccp_dma_desc {
0233     struct list_head entry;
0234 
0235     struct ccp_device *ccp;
0236 
0237     struct list_head pending;
0238     struct list_head active;
0239 
0240     enum dma_status status;
0241     struct dma_async_tx_descriptor tx_desc;
0242     size_t len;
0243 };
0244 
0245 struct ccp_dma_chan {
0246     struct ccp_device *ccp;
0247 
0248     spinlock_t lock;
0249     struct list_head created;
0250     struct list_head pending;
0251     struct list_head active;
0252     struct list_head complete;
0253 
0254     struct tasklet_struct cleanup_tasklet;
0255 
0256     enum dma_status status;
0257     struct dma_chan dma_chan;
0258 };
0259 
0260 struct ccp_cmd_queue {
0261     struct ccp_device *ccp;
0262 
0263     /* Queue identifier */
0264     u32 id;
0265 
0266     /* Queue dma pool */
0267     struct dma_pool *dma_pool;
0268 
0269     /* Queue base address (not neccessarily aligned)*/
0270     struct ccp5_desc *qbase;
0271 
0272     /* Aligned queue start address (per requirement) */
0273     struct mutex q_mutex ____cacheline_aligned;
0274     unsigned int qidx;
0275 
0276     /* Version 5 has different requirements for queue memory */
0277     unsigned int qsize;
0278     dma_addr_t qbase_dma;
0279     dma_addr_t qdma_tail;
0280 
0281     /* Per-queue reserved storage block(s) */
0282     u32 sb_key;
0283     u32 sb_ctx;
0284 
0285     /* Bitmap of LSBs that can be accessed by this queue */
0286     DECLARE_BITMAP(lsbmask, MAX_LSB_CNT);
0287     /* Private LSB that is assigned to this queue, or -1 if none.
0288      * Bitmap for my private LSB, unused otherwise
0289      */
0290     int lsb;
0291     DECLARE_BITMAP(lsbmap, PLSB_MAP_SIZE);
0292 
0293     /* Queue processing thread */
0294     struct task_struct *kthread;
0295     unsigned int active;
0296     unsigned int suspended;
0297 
0298     /* Number of free command slots available */
0299     unsigned int free_slots;
0300 
0301     /* Interrupt masks */
0302     u32 int_ok;
0303     u32 int_err;
0304 
0305     /* Register addresses for queue */
0306     void __iomem *reg_control;
0307     void __iomem *reg_tail_lo;
0308     void __iomem *reg_head_lo;
0309     void __iomem *reg_int_enable;
0310     void __iomem *reg_interrupt_status;
0311     void __iomem *reg_status;
0312     void __iomem *reg_int_status;
0313     void __iomem *reg_dma_status;
0314     void __iomem *reg_dma_read_status;
0315     void __iomem *reg_dma_write_status;
0316     u32 qcontrol; /* Cached control register */
0317 
0318     /* Status values from job */
0319     u32 int_status;
0320     u32 q_status;
0321     u32 q_int_status;
0322     u32 cmd_error;
0323 
0324     /* Interrupt wait queue */
0325     wait_queue_head_t int_queue;
0326     unsigned int int_rcvd;
0327 
0328     /* Per-queue Statistics */
0329     unsigned long total_ops;
0330     unsigned long total_aes_ops;
0331     unsigned long total_xts_aes_ops;
0332     unsigned long total_3des_ops;
0333     unsigned long total_sha_ops;
0334     unsigned long total_rsa_ops;
0335     unsigned long total_pt_ops;
0336     unsigned long total_ecc_ops;
0337 } ____cacheline_aligned;
0338 
0339 struct ccp_device {
0340     struct list_head entry;
0341 
0342     struct ccp_vdata *vdata;
0343     unsigned int ord;
0344     char name[MAX_CCP_NAME_LEN];
0345     char rngname[MAX_CCP_NAME_LEN];
0346 
0347     struct device *dev;
0348     struct sp_device *sp;
0349 
0350     /* Bus specific device information
0351      */
0352     void *dev_specific;
0353     unsigned int qim;
0354     unsigned int irq;
0355     bool use_tasklet;
0356     struct tasklet_struct irq_tasklet;
0357 
0358     /* I/O area used for device communication. The register mapping
0359      * starts at an offset into the mapped bar.
0360      *   The CMD_REQx registers and the Delete_Cmd_Queue_Job register
0361      *   need to be protected while a command queue thread is accessing
0362      *   them.
0363      */
0364     struct mutex req_mutex ____cacheline_aligned;
0365     void __iomem *io_regs;
0366 
0367     /* Master lists that all cmds are queued on. Because there can be
0368      * more than one CCP command queue that can process a cmd a separate
0369      * backlog list is needed so that the backlog completion call
0370      * completes before the cmd is available for execution.
0371      */
0372     spinlock_t cmd_lock ____cacheline_aligned;
0373     unsigned int cmd_count;
0374     struct list_head cmd;
0375     struct list_head backlog;
0376 
0377     /* The command queues. These represent the queues available on the
0378      * CCP that are available for processing cmds
0379      */
0380     struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES];
0381     unsigned int cmd_q_count;
0382     unsigned int max_q_count;
0383 
0384     /* Support for the CCP True RNG
0385      */
0386     struct hwrng hwrng;
0387     unsigned int hwrng_retries;
0388 
0389     /* Support for the CCP DMA capabilities
0390      */
0391     struct dma_device dma_dev;
0392     struct ccp_dma_chan *ccp_dma_chan;
0393     struct kmem_cache *dma_cmd_cache;
0394     struct kmem_cache *dma_desc_cache;
0395 
0396     /* A counter used to generate job-ids for cmds submitted to the CCP
0397      */
0398     atomic_t current_id ____cacheline_aligned;
0399 
0400     /* The v3 CCP uses key storage blocks (SB) to maintain context for
0401      * certain operations. To prevent multiple cmds from using the same
0402      * SB range a command queue reserves an SB range for the duration of
0403      * the cmd. Each queue, will however, reserve 2 SB blocks for
0404      * operations that only require single SB entries (eg. AES context/iv
0405      * and key) in order to avoid allocation contention.  This will reserve
0406      * at most 10 SB entries, leaving 40 SB entries available for dynamic
0407      * allocation.
0408      *
0409      * The v5 CCP Local Storage Block (LSB) is broken up into 8
0410      * memrory ranges, each of which can be enabled for access by one
0411      * or more queues. Device initialization takes this into account,
0412      * and attempts to assign one region for exclusive use by each
0413      * available queue; the rest are then aggregated as "public" use.
0414      * If there are fewer regions than queues, all regions are shared
0415      * amongst all queues.
0416      */
0417     struct mutex sb_mutex ____cacheline_aligned;
0418     DECLARE_BITMAP(sb, KSB_COUNT);
0419     wait_queue_head_t sb_queue;
0420     unsigned int sb_avail;
0421     unsigned int sb_count;
0422     u32 sb_start;
0423 
0424     /* Bitmap of shared LSBs, if any */
0425     DECLARE_BITMAP(lsbmap, SLSB_MAP_SIZE);
0426 
0427     /* Suspend support */
0428     unsigned int suspending;
0429     wait_queue_head_t suspend_queue;
0430 
0431     /* DMA caching attribute support */
0432     unsigned int axcache;
0433 
0434     /* Device Statistics */
0435     unsigned long total_interrupts;
0436 
0437     /* DebugFS info */
0438     struct dentry *debugfs_instance;
0439 };
0440 
0441 enum ccp_memtype {
0442     CCP_MEMTYPE_SYSTEM = 0,
0443     CCP_MEMTYPE_SB,
0444     CCP_MEMTYPE_LOCAL,
0445     CCP_MEMTYPE__LAST,
0446 };
0447 #define CCP_MEMTYPE_LSB CCP_MEMTYPE_KSB
0448 
0449 
0450 struct ccp_dma_info {
0451     dma_addr_t address;
0452     unsigned int offset;
0453     unsigned int length;
0454     enum dma_data_direction dir;
0455 } __packed __aligned(4);
0456 
0457 struct ccp_dm_workarea {
0458     struct device *dev;
0459     struct dma_pool *dma_pool;
0460 
0461     u8 *address;
0462     struct ccp_dma_info dma;
0463     unsigned int length;
0464 };
0465 
0466 struct ccp_sg_workarea {
0467     struct scatterlist *sg;
0468     int nents;
0469     unsigned int sg_used;
0470 
0471     struct scatterlist *dma_sg;
0472     struct scatterlist *dma_sg_head;
0473     struct device *dma_dev;
0474     unsigned int dma_count;
0475     enum dma_data_direction dma_dir;
0476 
0477     u64 bytes_left;
0478 };
0479 
0480 struct ccp_data {
0481     struct ccp_sg_workarea sg_wa;
0482     struct ccp_dm_workarea dm_wa;
0483 };
0484 
0485 struct ccp_mem {
0486     enum ccp_memtype type;
0487     union {
0488         struct ccp_dma_info dma;
0489         u32 sb;
0490     } u;
0491 };
0492 
0493 struct ccp_aes_op {
0494     enum ccp_aes_type type;
0495     enum ccp_aes_mode mode;
0496     enum ccp_aes_action action;
0497     unsigned int size;
0498 };
0499 
0500 struct ccp_xts_aes_op {
0501     enum ccp_aes_type type;
0502     enum ccp_aes_action action;
0503     enum ccp_xts_aes_unit_size unit_size;
0504 };
0505 
0506 struct ccp_des3_op {
0507     enum ccp_des3_type type;
0508     enum ccp_des3_mode mode;
0509     enum ccp_des3_action action;
0510 };
0511 
0512 struct ccp_sha_op {
0513     enum ccp_sha_type type;
0514     u64 msg_bits;
0515 };
0516 
0517 struct ccp_rsa_op {
0518     u32 mod_size;
0519     u32 input_len;
0520 };
0521 
0522 struct ccp_passthru_op {
0523     enum ccp_passthru_bitwise bit_mod;
0524     enum ccp_passthru_byteswap byte_swap;
0525 };
0526 
0527 struct ccp_ecc_op {
0528     enum ccp_ecc_function function;
0529 };
0530 
0531 struct ccp_op {
0532     struct ccp_cmd_queue *cmd_q;
0533 
0534     u32 jobid;
0535     u32 ioc;
0536     u32 soc;
0537     u32 sb_key;
0538     u32 sb_ctx;
0539     u32 init;
0540     u32 eom;
0541 
0542     struct ccp_mem src;
0543     struct ccp_mem dst;
0544     struct ccp_mem exp;
0545 
0546     union {
0547         struct ccp_aes_op aes;
0548         struct ccp_xts_aes_op xts;
0549         struct ccp_des3_op des3;
0550         struct ccp_sha_op sha;
0551         struct ccp_rsa_op rsa;
0552         struct ccp_passthru_op passthru;
0553         struct ccp_ecc_op ecc;
0554     } u;
0555 };
0556 
0557 static inline u32 ccp_addr_lo(struct ccp_dma_info *info)
0558 {
0559     return lower_32_bits(info->address + info->offset);
0560 }
0561 
0562 static inline u32 ccp_addr_hi(struct ccp_dma_info *info)
0563 {
0564     return upper_32_bits(info->address + info->offset) & 0x0000ffff;
0565 }
0566 
0567 /**
0568  * descriptor for version 5 CPP commands
0569  * 8 32-bit words:
0570  * word 0: function; engine; control bits
0571  * word 1: length of source data
0572  * word 2: low 32 bits of source pointer
0573  * word 3: upper 16 bits of source pointer; source memory type
0574  * word 4: low 32 bits of destination pointer
0575  * word 5: upper 16 bits of destination pointer; destination memory type
0576  * word 6: low 32 bits of key pointer
0577  * word 7: upper 16 bits of key pointer; key memory type
0578  */
0579 struct dword0 {
0580     unsigned int soc:1;
0581     unsigned int ioc:1;
0582     unsigned int rsvd1:1;
0583     unsigned int init:1;
0584     unsigned int eom:1;     /* AES/SHA only */
0585     unsigned int function:15;
0586     unsigned int engine:4;
0587     unsigned int prot:1;
0588     unsigned int rsvd2:7;
0589 };
0590 
0591 struct dword3 {
0592     unsigned int  src_hi:16;
0593     unsigned int  src_mem:2;
0594     unsigned int  lsb_cxt_id:8;
0595     unsigned int  rsvd1:5;
0596     unsigned int  fixed:1;
0597 };
0598 
0599 union dword4 {
0600     u32 dst_lo;     /* NON-SHA  */
0601     u32 sha_len_lo;     /* SHA      */
0602 };
0603 
0604 union dword5 {
0605     struct {
0606         unsigned int  dst_hi:16;
0607         unsigned int  dst_mem:2;
0608         unsigned int  rsvd1:13;
0609         unsigned int  fixed:1;
0610     } fields;
0611     u32 sha_len_hi;
0612 };
0613 
0614 struct dword7 {
0615     unsigned int  key_hi:16;
0616     unsigned int  key_mem:2;
0617     unsigned int  rsvd1:14;
0618 };
0619 
0620 struct ccp5_desc {
0621     struct dword0 dw0;
0622     u32 length;
0623     u32 src_lo;
0624     struct dword3 dw3;
0625     union dword4 dw4;
0626     union dword5 dw5;
0627     u32 key_lo;
0628     struct dword7 dw7;
0629 };
0630 
0631 void ccp_add_device(struct ccp_device *ccp);
0632 void ccp_del_device(struct ccp_device *ccp);
0633 
0634 extern void ccp_log_error(struct ccp_device *, unsigned int);
0635 
0636 struct ccp_device *ccp_alloc_struct(struct sp_device *sp);
0637 bool ccp_queues_suspended(struct ccp_device *ccp);
0638 int ccp_cmd_queue_thread(void *data);
0639 int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait);
0640 
0641 int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
0642 
0643 int ccp_register_rng(struct ccp_device *ccp);
0644 void ccp_unregister_rng(struct ccp_device *ccp);
0645 int ccp_dmaengine_register(struct ccp_device *ccp);
0646 void ccp_dmaengine_unregister(struct ccp_device *ccp);
0647 
0648 void ccp5_debugfs_setup(struct ccp_device *ccp);
0649 void ccp5_debugfs_destroy(void);
0650 
0651 /* Structure for computation functions that are device-specific */
0652 struct ccp_actions {
0653     int (*aes)(struct ccp_op *);
0654     int (*xts_aes)(struct ccp_op *);
0655     int (*des3)(struct ccp_op *);
0656     int (*sha)(struct ccp_op *);
0657     int (*rsa)(struct ccp_op *);
0658     int (*passthru)(struct ccp_op *);
0659     int (*ecc)(struct ccp_op *);
0660     u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int);
0661     void (*sbfree)(struct ccp_cmd_queue *, unsigned int, unsigned int);
0662     unsigned int (*get_free_slots)(struct ccp_cmd_queue *);
0663     int (*init)(struct ccp_device *);
0664     void (*destroy)(struct ccp_device *);
0665     irqreturn_t (*irqhandler)(int, void *);
0666 };
0667 
0668 extern const struct ccp_vdata ccpv3_platform;
0669 extern const struct ccp_vdata ccpv3;
0670 extern const struct ccp_vdata ccpv5a;
0671 extern const struct ccp_vdata ccpv5b;
0672 
0673 #endif