18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * AMD Cryptographic Coprocessor (CCP) driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author: Tom Lendacky <thomas.lendacky@amd.com>
88c2ecf20Sopenharmony_ci * Author: Gary R Hook <gary.hook@amd.com>
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef __CCP_DEV_H__
128c2ecf20Sopenharmony_ci#define __CCP_DEV_H__
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/device.h>
158c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
168c2ecf20Sopenharmony_ci#include <linux/mutex.h>
178c2ecf20Sopenharmony_ci#include <linux/list.h>
188c2ecf20Sopenharmony_ci#include <linux/wait.h>
198c2ecf20Sopenharmony_ci#include <linux/dma-direction.h>
208c2ecf20Sopenharmony_ci#include <linux/dmapool.h>
218c2ecf20Sopenharmony_ci#include <linux/hw_random.h>
228c2ecf20Sopenharmony_ci#include <linux/bitops.h>
238c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
248c2ecf20Sopenharmony_ci#include <linux/irqreturn.h>
258c2ecf20Sopenharmony_ci#include <linux/dmaengine.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include "sp-dev.h"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define MAX_CCP_NAME_LEN		16
308c2ecf20Sopenharmony_ci#define MAX_DMAPOOL_NAME_LEN		32
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define MAX_HW_QUEUES			5
338c2ecf20Sopenharmony_ci#define MAX_CMD_QLEN			100
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define TRNG_RETRIES			10
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define CACHE_NONE			0x00
388c2ecf20Sopenharmony_ci#define CACHE_WB_NO_ALLOC		0xb7
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/****** Register Mappings ******/
418c2ecf20Sopenharmony_ci#define Q_MASK_REG			0x000
428c2ecf20Sopenharmony_ci#define TRNG_OUT_REG			0x00c
438c2ecf20Sopenharmony_ci#define IRQ_MASK_REG			0x040
448c2ecf20Sopenharmony_ci#define IRQ_STATUS_REG			0x200
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define DEL_CMD_Q_JOB			0x124
478c2ecf20Sopenharmony_ci#define DEL_Q_ACTIVE			0x00000200
488c2ecf20Sopenharmony_ci#define DEL_Q_ID_SHIFT			6
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define CMD_REQ0			0x180
518c2ecf20Sopenharmony_ci#define CMD_REQ_INCR			0x04
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define CMD_Q_STATUS_BASE		0x210
548c2ecf20Sopenharmony_ci#define CMD_Q_INT_STATUS_BASE		0x214
558c2ecf20Sopenharmony_ci#define CMD_Q_STATUS_INCR		0x20
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define CMD_Q_CACHE_BASE		0x228
588c2ecf20Sopenharmony_ci#define CMD_Q_CACHE_INC			0x20
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#define CMD_Q_ERROR(__qs)		((__qs) & 0x0000003f)
618c2ecf20Sopenharmony_ci#define CMD_Q_DEPTH(__qs)		(((__qs) >> 12) & 0x0000000f)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* ------------------------ CCP Version 5 Specifics ------------------------ */
648c2ecf20Sopenharmony_ci#define CMD5_QUEUE_MASK_OFFSET		0x00
658c2ecf20Sopenharmony_ci#define	CMD5_QUEUE_PRIO_OFFSET		0x04
668c2ecf20Sopenharmony_ci#define CMD5_REQID_CONFIG_OFFSET	0x08
678c2ecf20Sopenharmony_ci#define	CMD5_CMD_TIMEOUT_OFFSET		0x10
688c2ecf20Sopenharmony_ci#define LSB_PUBLIC_MASK_LO_OFFSET	0x18
698c2ecf20Sopenharmony_ci#define LSB_PUBLIC_MASK_HI_OFFSET	0x1C
708c2ecf20Sopenharmony_ci#define LSB_PRIVATE_MASK_LO_OFFSET	0x20
718c2ecf20Sopenharmony_ci#define LSB_PRIVATE_MASK_HI_OFFSET	0x24
728c2ecf20Sopenharmony_ci#define CMD5_PSP_CCP_VERSION		0x100
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define CMD5_Q_CONTROL_BASE		0x0000
758c2ecf20Sopenharmony_ci#define CMD5_Q_TAIL_LO_BASE		0x0004
768c2ecf20Sopenharmony_ci#define CMD5_Q_HEAD_LO_BASE		0x0008
778c2ecf20Sopenharmony_ci#define CMD5_Q_INT_ENABLE_BASE		0x000C
788c2ecf20Sopenharmony_ci#define CMD5_Q_INTERRUPT_STATUS_BASE	0x0010
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define CMD5_Q_STATUS_BASE		0x0100
818c2ecf20Sopenharmony_ci#define CMD5_Q_INT_STATUS_BASE		0x0104
828c2ecf20Sopenharmony_ci#define CMD5_Q_DMA_STATUS_BASE		0x0108
838c2ecf20Sopenharmony_ci#define CMD5_Q_DMA_READ_STATUS_BASE	0x010C
848c2ecf20Sopenharmony_ci#define CMD5_Q_DMA_WRITE_STATUS_BASE	0x0110
858c2ecf20Sopenharmony_ci#define CMD5_Q_ABORT_BASE		0x0114
868c2ecf20Sopenharmony_ci#define CMD5_Q_AX_CACHE_BASE		0x0118
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define	CMD5_CONFIG_0_OFFSET		0x6000
898c2ecf20Sopenharmony_ci#define	CMD5_TRNG_CTL_OFFSET		0x6008
908c2ecf20Sopenharmony_ci#define	CMD5_AES_MASK_OFFSET		0x6010
918c2ecf20Sopenharmony_ci#define	CMD5_CLK_GATE_CTL_OFFSET	0x603C
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* Address offset between two virtual queue registers */
948c2ecf20Sopenharmony_ci#define CMD5_Q_STATUS_INCR		0x1000
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/* Bit masks */
978c2ecf20Sopenharmony_ci#define CMD5_Q_RUN			0x1
988c2ecf20Sopenharmony_ci#define CMD5_Q_HALT			0x2
998c2ecf20Sopenharmony_ci#define CMD5_Q_MEM_LOCATION		0x4
1008c2ecf20Sopenharmony_ci#define CMD5_Q_SIZE			0x1F
1018c2ecf20Sopenharmony_ci#define CMD5_Q_SHIFT			3
1028c2ecf20Sopenharmony_ci#define COMMANDS_PER_QUEUE		16
1038c2ecf20Sopenharmony_ci#define QUEUE_SIZE_VAL			((ffs(COMMANDS_PER_QUEUE) - 2) & \
1048c2ecf20Sopenharmony_ci					  CMD5_Q_SIZE)
1058c2ecf20Sopenharmony_ci#define Q_PTR_MASK			(2 << (QUEUE_SIZE_VAL + 5) - 1)
1068c2ecf20Sopenharmony_ci#define Q_DESC_SIZE			sizeof(struct ccp5_desc)
1078c2ecf20Sopenharmony_ci#define Q_SIZE(n)			(COMMANDS_PER_QUEUE*(n))
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define INT_COMPLETION			0x1
1108c2ecf20Sopenharmony_ci#define INT_ERROR			0x2
1118c2ecf20Sopenharmony_ci#define INT_QUEUE_STOPPED		0x4
1128c2ecf20Sopenharmony_ci#define	INT_EMPTY_QUEUE			0x8
1138c2ecf20Sopenharmony_ci#define SUPPORTED_INTERRUPTS		(INT_COMPLETION | INT_ERROR)
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define LSB_REGION_WIDTH		5
1168c2ecf20Sopenharmony_ci#define MAX_LSB_CNT			8
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#define LSB_SIZE			16
1198c2ecf20Sopenharmony_ci#define LSB_ITEM_SIZE			32
1208c2ecf20Sopenharmony_ci#define PLSB_MAP_SIZE			(LSB_SIZE)
1218c2ecf20Sopenharmony_ci#define SLSB_MAP_SIZE			(MAX_LSB_CNT * LSB_SIZE)
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#define LSB_ENTRY_NUMBER(LSB_ADDR)	(LSB_ADDR / LSB_ITEM_SIZE)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/* ------------------------ CCP Version 3 Specifics ------------------------ */
1268c2ecf20Sopenharmony_ci#define REQ0_WAIT_FOR_WRITE		0x00000004
1278c2ecf20Sopenharmony_ci#define REQ0_INT_ON_COMPLETE		0x00000002
1288c2ecf20Sopenharmony_ci#define REQ0_STOP_ON_COMPLETE		0x00000001
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#define REQ0_CMD_Q_SHIFT		9
1318c2ecf20Sopenharmony_ci#define REQ0_JOBID_SHIFT		3
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci/****** REQ1 Related Values ******/
1348c2ecf20Sopenharmony_ci#define REQ1_PROTECT_SHIFT		27
1358c2ecf20Sopenharmony_ci#define REQ1_ENGINE_SHIFT		23
1368c2ecf20Sopenharmony_ci#define REQ1_KEY_KSB_SHIFT		2
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci#define REQ1_EOM			0x00000002
1398c2ecf20Sopenharmony_ci#define REQ1_INIT			0x00000001
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/* AES Related Values */
1428c2ecf20Sopenharmony_ci#define REQ1_AES_TYPE_SHIFT		21
1438c2ecf20Sopenharmony_ci#define REQ1_AES_MODE_SHIFT		18
1448c2ecf20Sopenharmony_ci#define REQ1_AES_ACTION_SHIFT		17
1458c2ecf20Sopenharmony_ci#define REQ1_AES_CFB_SIZE_SHIFT		10
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci/* XTS-AES Related Values */
1488c2ecf20Sopenharmony_ci#define REQ1_XTS_AES_SIZE_SHIFT		10
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/* SHA Related Values */
1518c2ecf20Sopenharmony_ci#define REQ1_SHA_TYPE_SHIFT		21
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/* RSA Related Values */
1548c2ecf20Sopenharmony_ci#define REQ1_RSA_MOD_SIZE_SHIFT		10
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci/* Pass-Through Related Values */
1578c2ecf20Sopenharmony_ci#define REQ1_PT_BW_SHIFT		12
1588c2ecf20Sopenharmony_ci#define REQ1_PT_BS_SHIFT		10
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci/* ECC Related Values */
1618c2ecf20Sopenharmony_ci#define REQ1_ECC_AFFINE_CONVERT		0x00200000
1628c2ecf20Sopenharmony_ci#define REQ1_ECC_FUNCTION_SHIFT		18
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/****** REQ4 Related Values ******/
1658c2ecf20Sopenharmony_ci#define REQ4_KSB_SHIFT			18
1668c2ecf20Sopenharmony_ci#define REQ4_MEMTYPE_SHIFT		16
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/****** REQ6 Related Values ******/
1698c2ecf20Sopenharmony_ci#define REQ6_MEMTYPE_SHIFT		16
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/****** Key Storage Block ******/
1728c2ecf20Sopenharmony_ci#define KSB_START			77
1738c2ecf20Sopenharmony_ci#define KSB_END				127
1748c2ecf20Sopenharmony_ci#define KSB_COUNT			(KSB_END - KSB_START + 1)
1758c2ecf20Sopenharmony_ci#define CCP_SB_BITS			256
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#define CCP_JOBID_MASK			0x0000003f
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* ------------------------ General CCP Defines ------------------------ */
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci#define	CCP_DMA_DFLT			0x0
1828c2ecf20Sopenharmony_ci#define	CCP_DMA_PRIV			0x1
1838c2ecf20Sopenharmony_ci#define	CCP_DMA_PUB			0x2
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define CCP_DMAPOOL_MAX_SIZE		64
1868c2ecf20Sopenharmony_ci#define CCP_DMAPOOL_ALIGN		BIT(5)
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci#define CCP_REVERSE_BUF_SIZE		64
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci#define CCP_AES_KEY_SB_COUNT		1
1918c2ecf20Sopenharmony_ci#define CCP_AES_CTX_SB_COUNT		1
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci#define CCP_XTS_AES_KEY_SB_COUNT	1
1948c2ecf20Sopenharmony_ci#define CCP5_XTS_AES_KEY_SB_COUNT	2
1958c2ecf20Sopenharmony_ci#define CCP_XTS_AES_CTX_SB_COUNT	1
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci#define CCP_DES3_KEY_SB_COUNT		1
1988c2ecf20Sopenharmony_ci#define CCP_DES3_CTX_SB_COUNT		1
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci#define CCP_SHA_SB_COUNT		1
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci#define CCP_RSA_MAX_WIDTH		4096
2038c2ecf20Sopenharmony_ci#define CCP5_RSA_MAX_WIDTH		16384
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci#define CCP_PASSTHRU_BLOCKSIZE		256
2068c2ecf20Sopenharmony_ci#define CCP_PASSTHRU_MASKSIZE		32
2078c2ecf20Sopenharmony_ci#define CCP_PASSTHRU_SB_COUNT		1
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci#define CCP_ECC_MODULUS_BYTES		48      /* 384-bits */
2108c2ecf20Sopenharmony_ci#define CCP_ECC_MAX_OPERANDS		6
2118c2ecf20Sopenharmony_ci#define CCP_ECC_MAX_OUTPUTS		3
2128c2ecf20Sopenharmony_ci#define CCP_ECC_SRC_BUF_SIZE		448
2138c2ecf20Sopenharmony_ci#define CCP_ECC_DST_BUF_SIZE		192
2148c2ecf20Sopenharmony_ci#define CCP_ECC_OPERAND_SIZE		64
2158c2ecf20Sopenharmony_ci#define CCP_ECC_OUTPUT_SIZE		64
2168c2ecf20Sopenharmony_ci#define CCP_ECC_RESULT_OFFSET		60
2178c2ecf20Sopenharmony_ci#define CCP_ECC_RESULT_SUCCESS		0x0001
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci#define CCP_SB_BYTES			32
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_cistruct ccp_op;
2228c2ecf20Sopenharmony_cistruct ccp_device;
2238c2ecf20Sopenharmony_cistruct ccp_cmd;
2248c2ecf20Sopenharmony_cistruct ccp_fns;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_cistruct ccp_dma_cmd {
2278c2ecf20Sopenharmony_ci	struct list_head entry;
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci	struct ccp_cmd ccp_cmd;
2308c2ecf20Sopenharmony_ci};
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_cistruct ccp_dma_desc {
2338c2ecf20Sopenharmony_ci	struct list_head entry;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	struct ccp_device *ccp;
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	struct list_head pending;
2388c2ecf20Sopenharmony_ci	struct list_head active;
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci	enum dma_status status;
2418c2ecf20Sopenharmony_ci	struct dma_async_tx_descriptor tx_desc;
2428c2ecf20Sopenharmony_ci	size_t len;
2438c2ecf20Sopenharmony_ci};
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_cistruct ccp_dma_chan {
2468c2ecf20Sopenharmony_ci	struct ccp_device *ccp;
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	spinlock_t lock;
2498c2ecf20Sopenharmony_ci	struct list_head created;
2508c2ecf20Sopenharmony_ci	struct list_head pending;
2518c2ecf20Sopenharmony_ci	struct list_head active;
2528c2ecf20Sopenharmony_ci	struct list_head complete;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	struct tasklet_struct cleanup_tasklet;
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci	enum dma_status status;
2578c2ecf20Sopenharmony_ci	struct dma_chan dma_chan;
2588c2ecf20Sopenharmony_ci};
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_cistruct ccp_cmd_queue {
2618c2ecf20Sopenharmony_ci	struct ccp_device *ccp;
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci	/* Queue identifier */
2648c2ecf20Sopenharmony_ci	u32 id;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	/* Queue dma pool */
2678c2ecf20Sopenharmony_ci	struct dma_pool *dma_pool;
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci	/* Queue base address (not neccessarily aligned)*/
2708c2ecf20Sopenharmony_ci	struct ccp5_desc *qbase;
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	/* Aligned queue start address (per requirement) */
2738c2ecf20Sopenharmony_ci	struct mutex q_mutex ____cacheline_aligned;
2748c2ecf20Sopenharmony_ci	unsigned int qidx;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	/* Version 5 has different requirements for queue memory */
2778c2ecf20Sopenharmony_ci	unsigned int qsize;
2788c2ecf20Sopenharmony_ci	dma_addr_t qbase_dma;
2798c2ecf20Sopenharmony_ci	dma_addr_t qdma_tail;
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	/* Per-queue reserved storage block(s) */
2828c2ecf20Sopenharmony_ci	u32 sb_key;
2838c2ecf20Sopenharmony_ci	u32 sb_ctx;
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	/* Bitmap of LSBs that can be accessed by this queue */
2868c2ecf20Sopenharmony_ci	DECLARE_BITMAP(lsbmask, MAX_LSB_CNT);
2878c2ecf20Sopenharmony_ci	/* Private LSB that is assigned to this queue, or -1 if none.
2888c2ecf20Sopenharmony_ci	 * Bitmap for my private LSB, unused otherwise
2898c2ecf20Sopenharmony_ci	 */
2908c2ecf20Sopenharmony_ci	int lsb;
2918c2ecf20Sopenharmony_ci	DECLARE_BITMAP(lsbmap, PLSB_MAP_SIZE);
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	/* Queue processing thread */
2948c2ecf20Sopenharmony_ci	struct task_struct *kthread;
2958c2ecf20Sopenharmony_ci	unsigned int active;
2968c2ecf20Sopenharmony_ci	unsigned int suspended;
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci	/* Number of free command slots available */
2998c2ecf20Sopenharmony_ci	unsigned int free_slots;
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	/* Interrupt masks */
3028c2ecf20Sopenharmony_ci	u32 int_ok;
3038c2ecf20Sopenharmony_ci	u32 int_err;
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	/* Register addresses for queue */
3068c2ecf20Sopenharmony_ci	void __iomem *reg_control;
3078c2ecf20Sopenharmony_ci	void __iomem *reg_tail_lo;
3088c2ecf20Sopenharmony_ci	void __iomem *reg_head_lo;
3098c2ecf20Sopenharmony_ci	void __iomem *reg_int_enable;
3108c2ecf20Sopenharmony_ci	void __iomem *reg_interrupt_status;
3118c2ecf20Sopenharmony_ci	void __iomem *reg_status;
3128c2ecf20Sopenharmony_ci	void __iomem *reg_int_status;
3138c2ecf20Sopenharmony_ci	void __iomem *reg_dma_status;
3148c2ecf20Sopenharmony_ci	void __iomem *reg_dma_read_status;
3158c2ecf20Sopenharmony_ci	void __iomem *reg_dma_write_status;
3168c2ecf20Sopenharmony_ci	u32 qcontrol; /* Cached control register */
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci	/* Status values from job */
3198c2ecf20Sopenharmony_ci	u32 int_status;
3208c2ecf20Sopenharmony_ci	u32 q_status;
3218c2ecf20Sopenharmony_ci	u32 q_int_status;
3228c2ecf20Sopenharmony_ci	u32 cmd_error;
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci	/* Interrupt wait queue */
3258c2ecf20Sopenharmony_ci	wait_queue_head_t int_queue;
3268c2ecf20Sopenharmony_ci	unsigned int int_rcvd;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	/* Per-queue Statistics */
3298c2ecf20Sopenharmony_ci	unsigned long total_ops;
3308c2ecf20Sopenharmony_ci	unsigned long total_aes_ops;
3318c2ecf20Sopenharmony_ci	unsigned long total_xts_aes_ops;
3328c2ecf20Sopenharmony_ci	unsigned long total_3des_ops;
3338c2ecf20Sopenharmony_ci	unsigned long total_sha_ops;
3348c2ecf20Sopenharmony_ci	unsigned long total_rsa_ops;
3358c2ecf20Sopenharmony_ci	unsigned long total_pt_ops;
3368c2ecf20Sopenharmony_ci	unsigned long total_ecc_ops;
3378c2ecf20Sopenharmony_ci} ____cacheline_aligned;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_cistruct ccp_device {
3408c2ecf20Sopenharmony_ci	struct list_head entry;
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci	struct ccp_vdata *vdata;
3438c2ecf20Sopenharmony_ci	unsigned int ord;
3448c2ecf20Sopenharmony_ci	char name[MAX_CCP_NAME_LEN];
3458c2ecf20Sopenharmony_ci	char rngname[MAX_CCP_NAME_LEN];
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci	struct device *dev;
3488c2ecf20Sopenharmony_ci	struct sp_device *sp;
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci	/* Bus specific device information
3518c2ecf20Sopenharmony_ci	 */
3528c2ecf20Sopenharmony_ci	void *dev_specific;
3538c2ecf20Sopenharmony_ci	unsigned int qim;
3548c2ecf20Sopenharmony_ci	unsigned int irq;
3558c2ecf20Sopenharmony_ci	bool use_tasklet;
3568c2ecf20Sopenharmony_ci	struct tasklet_struct irq_tasklet;
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci	/* I/O area used for device communication. The register mapping
3598c2ecf20Sopenharmony_ci	 * starts at an offset into the mapped bar.
3608c2ecf20Sopenharmony_ci	 *   The CMD_REQx registers and the Delete_Cmd_Queue_Job register
3618c2ecf20Sopenharmony_ci	 *   need to be protected while a command queue thread is accessing
3628c2ecf20Sopenharmony_ci	 *   them.
3638c2ecf20Sopenharmony_ci	 */
3648c2ecf20Sopenharmony_ci	struct mutex req_mutex ____cacheline_aligned;
3658c2ecf20Sopenharmony_ci	void __iomem *io_regs;
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_ci	/* Master lists that all cmds are queued on. Because there can be
3688c2ecf20Sopenharmony_ci	 * more than one CCP command queue that can process a cmd a separate
3698c2ecf20Sopenharmony_ci	 * backlog list is neeeded so that the backlog completion call
3708c2ecf20Sopenharmony_ci	 * completes before the cmd is available for execution.
3718c2ecf20Sopenharmony_ci	 */
3728c2ecf20Sopenharmony_ci	spinlock_t cmd_lock ____cacheline_aligned;
3738c2ecf20Sopenharmony_ci	unsigned int cmd_count;
3748c2ecf20Sopenharmony_ci	struct list_head cmd;
3758c2ecf20Sopenharmony_ci	struct list_head backlog;
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci	/* The command queues. These represent the queues available on the
3788c2ecf20Sopenharmony_ci	 * CCP that are available for processing cmds
3798c2ecf20Sopenharmony_ci	 */
3808c2ecf20Sopenharmony_ci	struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES];
3818c2ecf20Sopenharmony_ci	unsigned int cmd_q_count;
3828c2ecf20Sopenharmony_ci	unsigned int max_q_count;
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci	/* Support for the CCP True RNG
3858c2ecf20Sopenharmony_ci	 */
3868c2ecf20Sopenharmony_ci	struct hwrng hwrng;
3878c2ecf20Sopenharmony_ci	unsigned int hwrng_retries;
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci	/* Support for the CCP DMA capabilities
3908c2ecf20Sopenharmony_ci	 */
3918c2ecf20Sopenharmony_ci	struct dma_device dma_dev;
3928c2ecf20Sopenharmony_ci	struct ccp_dma_chan *ccp_dma_chan;
3938c2ecf20Sopenharmony_ci	struct kmem_cache *dma_cmd_cache;
3948c2ecf20Sopenharmony_ci	struct kmem_cache *dma_desc_cache;
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci	/* A counter used to generate job-ids for cmds submitted to the CCP
3978c2ecf20Sopenharmony_ci	 */
3988c2ecf20Sopenharmony_ci	atomic_t current_id ____cacheline_aligned;
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci	/* The v3 CCP uses key storage blocks (SB) to maintain context for
4018c2ecf20Sopenharmony_ci	 * certain operations. To prevent multiple cmds from using the same
4028c2ecf20Sopenharmony_ci	 * SB range a command queue reserves an SB range for the duration of
4038c2ecf20Sopenharmony_ci	 * the cmd. Each queue, will however, reserve 2 SB blocks for
4048c2ecf20Sopenharmony_ci	 * operations that only require single SB entries (eg. AES context/iv
4058c2ecf20Sopenharmony_ci	 * and key) in order to avoid allocation contention.  This will reserve
4068c2ecf20Sopenharmony_ci	 * at most 10 SB entries, leaving 40 SB entries available for dynamic
4078c2ecf20Sopenharmony_ci	 * allocation.
4088c2ecf20Sopenharmony_ci	 *
4098c2ecf20Sopenharmony_ci	 * The v5 CCP Local Storage Block (LSB) is broken up into 8
4108c2ecf20Sopenharmony_ci	 * memrory ranges, each of which can be enabled for access by one
4118c2ecf20Sopenharmony_ci	 * or more queues. Device initialization takes this into account,
4128c2ecf20Sopenharmony_ci	 * and attempts to assign one region for exclusive use by each
4138c2ecf20Sopenharmony_ci	 * available queue; the rest are then aggregated as "public" use.
4148c2ecf20Sopenharmony_ci	 * If there are fewer regions than queues, all regions are shared
4158c2ecf20Sopenharmony_ci	 * amongst all queues.
4168c2ecf20Sopenharmony_ci	 */
4178c2ecf20Sopenharmony_ci	struct mutex sb_mutex ____cacheline_aligned;
4188c2ecf20Sopenharmony_ci	DECLARE_BITMAP(sb, KSB_COUNT);
4198c2ecf20Sopenharmony_ci	wait_queue_head_t sb_queue;
4208c2ecf20Sopenharmony_ci	unsigned int sb_avail;
4218c2ecf20Sopenharmony_ci	unsigned int sb_count;
4228c2ecf20Sopenharmony_ci	u32 sb_start;
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	/* Bitmap of shared LSBs, if any */
4258c2ecf20Sopenharmony_ci	DECLARE_BITMAP(lsbmap, SLSB_MAP_SIZE);
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci	/* Suspend support */
4288c2ecf20Sopenharmony_ci	unsigned int suspending;
4298c2ecf20Sopenharmony_ci	wait_queue_head_t suspend_queue;
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	/* DMA caching attribute support */
4328c2ecf20Sopenharmony_ci	unsigned int axcache;
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci	/* Device Statistics */
4358c2ecf20Sopenharmony_ci	unsigned long total_interrupts;
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci	/* DebugFS info */
4388c2ecf20Sopenharmony_ci	struct dentry *debugfs_instance;
4398c2ecf20Sopenharmony_ci};
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_cienum ccp_memtype {
4428c2ecf20Sopenharmony_ci	CCP_MEMTYPE_SYSTEM = 0,
4438c2ecf20Sopenharmony_ci	CCP_MEMTYPE_SB,
4448c2ecf20Sopenharmony_ci	CCP_MEMTYPE_LOCAL,
4458c2ecf20Sopenharmony_ci	CCP_MEMTYPE__LAST,
4468c2ecf20Sopenharmony_ci};
4478c2ecf20Sopenharmony_ci#define	CCP_MEMTYPE_LSB	CCP_MEMTYPE_KSB
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_cistruct ccp_dma_info {
4518c2ecf20Sopenharmony_ci	dma_addr_t address;
4528c2ecf20Sopenharmony_ci	unsigned int offset;
4538c2ecf20Sopenharmony_ci	unsigned int length;
4548c2ecf20Sopenharmony_ci	enum dma_data_direction dir;
4558c2ecf20Sopenharmony_ci} __packed __aligned(4);
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_cistruct ccp_dm_workarea {
4588c2ecf20Sopenharmony_ci	struct device *dev;
4598c2ecf20Sopenharmony_ci	struct dma_pool *dma_pool;
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci	u8 *address;
4628c2ecf20Sopenharmony_ci	struct ccp_dma_info dma;
4638c2ecf20Sopenharmony_ci	unsigned int length;
4648c2ecf20Sopenharmony_ci};
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_cistruct ccp_sg_workarea {
4678c2ecf20Sopenharmony_ci	struct scatterlist *sg;
4688c2ecf20Sopenharmony_ci	int nents;
4698c2ecf20Sopenharmony_ci	unsigned int sg_used;
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_ci	struct scatterlist *dma_sg;
4728c2ecf20Sopenharmony_ci	struct scatterlist *dma_sg_head;
4738c2ecf20Sopenharmony_ci	struct device *dma_dev;
4748c2ecf20Sopenharmony_ci	unsigned int dma_count;
4758c2ecf20Sopenharmony_ci	enum dma_data_direction dma_dir;
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci	u64 bytes_left;
4788c2ecf20Sopenharmony_ci};
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_cistruct ccp_data {
4818c2ecf20Sopenharmony_ci	struct ccp_sg_workarea sg_wa;
4828c2ecf20Sopenharmony_ci	struct ccp_dm_workarea dm_wa;
4838c2ecf20Sopenharmony_ci};
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_cistruct ccp_mem {
4868c2ecf20Sopenharmony_ci	enum ccp_memtype type;
4878c2ecf20Sopenharmony_ci	union {
4888c2ecf20Sopenharmony_ci		struct ccp_dma_info dma;
4898c2ecf20Sopenharmony_ci		u32 sb;
4908c2ecf20Sopenharmony_ci	} u;
4918c2ecf20Sopenharmony_ci};
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_cistruct ccp_aes_op {
4948c2ecf20Sopenharmony_ci	enum ccp_aes_type type;
4958c2ecf20Sopenharmony_ci	enum ccp_aes_mode mode;
4968c2ecf20Sopenharmony_ci	enum ccp_aes_action action;
4978c2ecf20Sopenharmony_ci	unsigned int size;
4988c2ecf20Sopenharmony_ci};
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_cistruct ccp_xts_aes_op {
5018c2ecf20Sopenharmony_ci	enum ccp_aes_type type;
5028c2ecf20Sopenharmony_ci	enum ccp_aes_action action;
5038c2ecf20Sopenharmony_ci	enum ccp_xts_aes_unit_size unit_size;
5048c2ecf20Sopenharmony_ci};
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_cistruct ccp_des3_op {
5078c2ecf20Sopenharmony_ci	enum ccp_des3_type type;
5088c2ecf20Sopenharmony_ci	enum ccp_des3_mode mode;
5098c2ecf20Sopenharmony_ci	enum ccp_des3_action action;
5108c2ecf20Sopenharmony_ci};
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_cistruct ccp_sha_op {
5138c2ecf20Sopenharmony_ci	enum ccp_sha_type type;
5148c2ecf20Sopenharmony_ci	u64 msg_bits;
5158c2ecf20Sopenharmony_ci};
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_cistruct ccp_rsa_op {
5188c2ecf20Sopenharmony_ci	u32 mod_size;
5198c2ecf20Sopenharmony_ci	u32 input_len;
5208c2ecf20Sopenharmony_ci};
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_cistruct ccp_passthru_op {
5238c2ecf20Sopenharmony_ci	enum ccp_passthru_bitwise bit_mod;
5248c2ecf20Sopenharmony_ci	enum ccp_passthru_byteswap byte_swap;
5258c2ecf20Sopenharmony_ci};
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_cistruct ccp_ecc_op {
5288c2ecf20Sopenharmony_ci	enum ccp_ecc_function function;
5298c2ecf20Sopenharmony_ci};
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_cistruct ccp_op {
5328c2ecf20Sopenharmony_ci	struct ccp_cmd_queue *cmd_q;
5338c2ecf20Sopenharmony_ci
5348c2ecf20Sopenharmony_ci	u32 jobid;
5358c2ecf20Sopenharmony_ci	u32 ioc;
5368c2ecf20Sopenharmony_ci	u32 soc;
5378c2ecf20Sopenharmony_ci	u32 sb_key;
5388c2ecf20Sopenharmony_ci	u32 sb_ctx;
5398c2ecf20Sopenharmony_ci	u32 init;
5408c2ecf20Sopenharmony_ci	u32 eom;
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci	struct ccp_mem src;
5438c2ecf20Sopenharmony_ci	struct ccp_mem dst;
5448c2ecf20Sopenharmony_ci	struct ccp_mem exp;
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci	union {
5478c2ecf20Sopenharmony_ci		struct ccp_aes_op aes;
5488c2ecf20Sopenharmony_ci		struct ccp_xts_aes_op xts;
5498c2ecf20Sopenharmony_ci		struct ccp_des3_op des3;
5508c2ecf20Sopenharmony_ci		struct ccp_sha_op sha;
5518c2ecf20Sopenharmony_ci		struct ccp_rsa_op rsa;
5528c2ecf20Sopenharmony_ci		struct ccp_passthru_op passthru;
5538c2ecf20Sopenharmony_ci		struct ccp_ecc_op ecc;
5548c2ecf20Sopenharmony_ci	} u;
5558c2ecf20Sopenharmony_ci};
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_cistatic inline u32 ccp_addr_lo(struct ccp_dma_info *info)
5588c2ecf20Sopenharmony_ci{
5598c2ecf20Sopenharmony_ci	return lower_32_bits(info->address + info->offset);
5608c2ecf20Sopenharmony_ci}
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_cistatic inline u32 ccp_addr_hi(struct ccp_dma_info *info)
5638c2ecf20Sopenharmony_ci{
5648c2ecf20Sopenharmony_ci	return upper_32_bits(info->address + info->offset) & 0x0000ffff;
5658c2ecf20Sopenharmony_ci}
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci/**
5688c2ecf20Sopenharmony_ci * descriptor for version 5 CPP commands
5698c2ecf20Sopenharmony_ci * 8 32-bit words:
5708c2ecf20Sopenharmony_ci * word 0: function; engine; control bits
5718c2ecf20Sopenharmony_ci * word 1: length of source data
5728c2ecf20Sopenharmony_ci * word 2: low 32 bits of source pointer
5738c2ecf20Sopenharmony_ci * word 3: upper 16 bits of source pointer; source memory type
5748c2ecf20Sopenharmony_ci * word 4: low 32 bits of destination pointer
5758c2ecf20Sopenharmony_ci * word 5: upper 16 bits of destination pointer; destination memory type
5768c2ecf20Sopenharmony_ci * word 6: low 32 bits of key pointer
5778c2ecf20Sopenharmony_ci * word 7: upper 16 bits of key pointer; key memory type
5788c2ecf20Sopenharmony_ci */
5798c2ecf20Sopenharmony_cistruct dword0 {
5808c2ecf20Sopenharmony_ci	unsigned int soc:1;
5818c2ecf20Sopenharmony_ci	unsigned int ioc:1;
5828c2ecf20Sopenharmony_ci	unsigned int rsvd1:1;
5838c2ecf20Sopenharmony_ci	unsigned int init:1;
5848c2ecf20Sopenharmony_ci	unsigned int eom:1;		/* AES/SHA only */
5858c2ecf20Sopenharmony_ci	unsigned int function:15;
5868c2ecf20Sopenharmony_ci	unsigned int engine:4;
5878c2ecf20Sopenharmony_ci	unsigned int prot:1;
5888c2ecf20Sopenharmony_ci	unsigned int rsvd2:7;
5898c2ecf20Sopenharmony_ci};
5908c2ecf20Sopenharmony_ci
5918c2ecf20Sopenharmony_cistruct dword3 {
5928c2ecf20Sopenharmony_ci	unsigned int  src_hi:16;
5938c2ecf20Sopenharmony_ci	unsigned int  src_mem:2;
5948c2ecf20Sopenharmony_ci	unsigned int  lsb_cxt_id:8;
5958c2ecf20Sopenharmony_ci	unsigned int  rsvd1:5;
5968c2ecf20Sopenharmony_ci	unsigned int  fixed:1;
5978c2ecf20Sopenharmony_ci};
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ciunion dword4 {
6008c2ecf20Sopenharmony_ci	u32 dst_lo;		/* NON-SHA	*/
6018c2ecf20Sopenharmony_ci	u32 sha_len_lo;		/* SHA		*/
6028c2ecf20Sopenharmony_ci};
6038c2ecf20Sopenharmony_ci
6048c2ecf20Sopenharmony_ciunion dword5 {
6058c2ecf20Sopenharmony_ci	struct {
6068c2ecf20Sopenharmony_ci		unsigned int  dst_hi:16;
6078c2ecf20Sopenharmony_ci		unsigned int  dst_mem:2;
6088c2ecf20Sopenharmony_ci		unsigned int  rsvd1:13;
6098c2ecf20Sopenharmony_ci		unsigned int  fixed:1;
6108c2ecf20Sopenharmony_ci	} fields;
6118c2ecf20Sopenharmony_ci	u32 sha_len_hi;
6128c2ecf20Sopenharmony_ci};
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_cistruct dword7 {
6158c2ecf20Sopenharmony_ci	unsigned int  key_hi:16;
6168c2ecf20Sopenharmony_ci	unsigned int  key_mem:2;
6178c2ecf20Sopenharmony_ci	unsigned int  rsvd1:14;
6188c2ecf20Sopenharmony_ci};
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_cistruct ccp5_desc {
6218c2ecf20Sopenharmony_ci	struct dword0 dw0;
6228c2ecf20Sopenharmony_ci	u32 length;
6238c2ecf20Sopenharmony_ci	u32 src_lo;
6248c2ecf20Sopenharmony_ci	struct dword3 dw3;
6258c2ecf20Sopenharmony_ci	union dword4 dw4;
6268c2ecf20Sopenharmony_ci	union dword5 dw5;
6278c2ecf20Sopenharmony_ci	u32 key_lo;
6288c2ecf20Sopenharmony_ci	struct dword7 dw7;
6298c2ecf20Sopenharmony_ci};
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_civoid ccp_add_device(struct ccp_device *ccp);
6328c2ecf20Sopenharmony_civoid ccp_del_device(struct ccp_device *ccp);
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ciextern void ccp_log_error(struct ccp_device *, unsigned int);
6358c2ecf20Sopenharmony_ci
6368c2ecf20Sopenharmony_cistruct ccp_device *ccp_alloc_struct(struct sp_device *sp);
6378c2ecf20Sopenharmony_cibool ccp_queues_suspended(struct ccp_device *ccp);
6388c2ecf20Sopenharmony_ciint ccp_cmd_queue_thread(void *data);
6398c2ecf20Sopenharmony_ciint ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait);
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ciint ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ciint ccp_register_rng(struct ccp_device *ccp);
6448c2ecf20Sopenharmony_civoid ccp_unregister_rng(struct ccp_device *ccp);
6458c2ecf20Sopenharmony_ciint ccp_dmaengine_register(struct ccp_device *ccp);
6468c2ecf20Sopenharmony_civoid ccp_dmaengine_unregister(struct ccp_device *ccp);
6478c2ecf20Sopenharmony_ci
6488c2ecf20Sopenharmony_civoid ccp5_debugfs_setup(struct ccp_device *ccp);
6498c2ecf20Sopenharmony_civoid ccp5_debugfs_destroy(void);
6508c2ecf20Sopenharmony_ci
6518c2ecf20Sopenharmony_ci/* Structure for computation functions that are device-specific */
6528c2ecf20Sopenharmony_cistruct ccp_actions {
6538c2ecf20Sopenharmony_ci	int (*aes)(struct ccp_op *);
6548c2ecf20Sopenharmony_ci	int (*xts_aes)(struct ccp_op *);
6558c2ecf20Sopenharmony_ci	int (*des3)(struct ccp_op *);
6568c2ecf20Sopenharmony_ci	int (*sha)(struct ccp_op *);
6578c2ecf20Sopenharmony_ci	int (*rsa)(struct ccp_op *);
6588c2ecf20Sopenharmony_ci	int (*passthru)(struct ccp_op *);
6598c2ecf20Sopenharmony_ci	int (*ecc)(struct ccp_op *);
6608c2ecf20Sopenharmony_ci	u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int);
6618c2ecf20Sopenharmony_ci	void (*sbfree)(struct ccp_cmd_queue *, unsigned int, unsigned int);
6628c2ecf20Sopenharmony_ci	unsigned int (*get_free_slots)(struct ccp_cmd_queue *);
6638c2ecf20Sopenharmony_ci	int (*init)(struct ccp_device *);
6648c2ecf20Sopenharmony_ci	void (*destroy)(struct ccp_device *);
6658c2ecf20Sopenharmony_ci	irqreturn_t (*irqhandler)(int, void *);
6668c2ecf20Sopenharmony_ci};
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_ciextern const struct ccp_vdata ccpv3_platform;
6698c2ecf20Sopenharmony_ciextern const struct ccp_vdata ccpv3;
6708c2ecf20Sopenharmony_ciextern const struct ccp_vdata ccpv5a;
6718c2ecf20Sopenharmony_ciextern const struct ccp_vdata ccpv5b;
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_ci#endif
674