xref: /OK3568_Linux_fs/kernel/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * sun8i-ce.h - hardware cryptographic offloader for
4*4882a593Smuzhiyun  * Allwinner H3/A64/H5/H2+/H6 SoC
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Copyright (C) 2016-2019 Corentin LABBE <clabbe.montjoie@gmail.com>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun #include <crypto/aes.h>
9*4882a593Smuzhiyun #include <crypto/des.h>
10*4882a593Smuzhiyun #include <crypto/engine.h>
11*4882a593Smuzhiyun #include <crypto/skcipher.h>
12*4882a593Smuzhiyun #include <linux/atomic.h>
13*4882a593Smuzhiyun #include <linux/debugfs.h>
14*4882a593Smuzhiyun #include <linux/crypto.h>
15*4882a593Smuzhiyun #include <linux/hw_random.h>
16*4882a593Smuzhiyun #include <crypto/internal/hash.h>
17*4882a593Smuzhiyun #include <crypto/md5.h>
18*4882a593Smuzhiyun #include <crypto/rng.h>
19*4882a593Smuzhiyun #include <crypto/sha.h>
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun /* CE Registers */
22*4882a593Smuzhiyun #define CE_TDQ	0x00
23*4882a593Smuzhiyun #define CE_CTR	0x04
24*4882a593Smuzhiyun #define CE_ICR	0x08
25*4882a593Smuzhiyun #define CE_ISR	0x0C
26*4882a593Smuzhiyun #define CE_TLR	0x10
27*4882a593Smuzhiyun #define CE_TSR	0x14
28*4882a593Smuzhiyun #define CE_ESR	0x18
29*4882a593Smuzhiyun #define CE_CSSGR	0x1C
30*4882a593Smuzhiyun #define CE_CDSGR	0x20
31*4882a593Smuzhiyun #define CE_CSAR	0x24
32*4882a593Smuzhiyun #define CE_CDAR	0x28
33*4882a593Smuzhiyun #define CE_TPR	0x2C
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /* Used in struct ce_task */
36*4882a593Smuzhiyun /* ce_task common */
37*4882a593Smuzhiyun #define CE_ENCRYPTION		0
38*4882a593Smuzhiyun #define CE_DECRYPTION		BIT(8)
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun #define CE_COMM_INT		BIT(31)
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /* ce_task symmetric */
43*4882a593Smuzhiyun #define CE_AES_128BITS 0
44*4882a593Smuzhiyun #define CE_AES_192BITS 1
45*4882a593Smuzhiyun #define CE_AES_256BITS 2
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #define CE_OP_ECB	0
48*4882a593Smuzhiyun #define CE_OP_CBC	(1 << 8)
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun #define CE_ALG_AES		0
51*4882a593Smuzhiyun #define CE_ALG_DES		1
52*4882a593Smuzhiyun #define CE_ALG_3DES		2
53*4882a593Smuzhiyun #define CE_ALG_MD5              16
54*4882a593Smuzhiyun #define CE_ALG_SHA1             17
55*4882a593Smuzhiyun #define CE_ALG_SHA224           18
56*4882a593Smuzhiyun #define CE_ALG_SHA256           19
57*4882a593Smuzhiyun #define CE_ALG_SHA384           20
58*4882a593Smuzhiyun #define CE_ALG_SHA512           21
59*4882a593Smuzhiyun #define CE_ALG_TRNG		48
60*4882a593Smuzhiyun #define CE_ALG_PRNG		49
61*4882a593Smuzhiyun #define CE_ALG_TRNG_V2		0x1c
62*4882a593Smuzhiyun #define CE_ALG_PRNG_V2		0x1d
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun /* Used in ce_variant */
65*4882a593Smuzhiyun #define CE_ID_NOTSUPP		0xFF
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #define CE_ID_CIPHER_AES	0
68*4882a593Smuzhiyun #define CE_ID_CIPHER_DES	1
69*4882a593Smuzhiyun #define CE_ID_CIPHER_DES3	2
70*4882a593Smuzhiyun #define CE_ID_CIPHER_MAX	3
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun #define CE_ID_HASH_MD5		0
73*4882a593Smuzhiyun #define CE_ID_HASH_SHA1		1
74*4882a593Smuzhiyun #define CE_ID_HASH_SHA224	2
75*4882a593Smuzhiyun #define CE_ID_HASH_SHA256	3
76*4882a593Smuzhiyun #define CE_ID_HASH_SHA384	4
77*4882a593Smuzhiyun #define CE_ID_HASH_SHA512	5
78*4882a593Smuzhiyun #define CE_ID_HASH_MAX		6
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun #define CE_ID_OP_ECB	0
81*4882a593Smuzhiyun #define CE_ID_OP_CBC	1
82*4882a593Smuzhiyun #define CE_ID_OP_MAX	2
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun /* Used in CE registers */
85*4882a593Smuzhiyun #define CE_ERR_ALGO_NOTSUP	BIT(0)
86*4882a593Smuzhiyun #define CE_ERR_DATALEN		BIT(1)
87*4882a593Smuzhiyun #define CE_ERR_KEYSRAM		BIT(2)
88*4882a593Smuzhiyun #define CE_ERR_ADDR_INVALID	BIT(5)
89*4882a593Smuzhiyun #define CE_ERR_KEYLADDER	BIT(6)
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun #define ESR_H3	0
92*4882a593Smuzhiyun #define ESR_A64	1
93*4882a593Smuzhiyun #define ESR_R40	2
94*4882a593Smuzhiyun #define ESR_H5	3
95*4882a593Smuzhiyun #define ESR_H6	4
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun #define PRNG_DATA_SIZE (160 / 8)
98*4882a593Smuzhiyun #define PRNG_SEED_SIZE DIV_ROUND_UP(175, 8)
99*4882a593Smuzhiyun #define PRNG_LD BIT(17)
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun #define CE_DIE_ID_SHIFT	16
102*4882a593Smuzhiyun #define CE_DIE_ID_MASK	0x07
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun #define MAX_SG 8
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun #define CE_MAX_CLOCKS 3
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun #define MAXFLOW 4
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun /*
111*4882a593Smuzhiyun  * struct ce_clock - Describe clocks used by sun8i-ce
112*4882a593Smuzhiyun  * @name:	Name of clock needed by this variant
113*4882a593Smuzhiyun  * @freq:	Frequency to set for each clock
114*4882a593Smuzhiyun  * @max_freq:	Maximum frequency for each clock (generally given by datasheet)
115*4882a593Smuzhiyun  */
116*4882a593Smuzhiyun struct ce_clock {
117*4882a593Smuzhiyun 	const char *name;
118*4882a593Smuzhiyun 	unsigned long freq;
119*4882a593Smuzhiyun 	unsigned long max_freq;
120*4882a593Smuzhiyun };
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun /*
123*4882a593Smuzhiyun  * struct ce_variant - Describe CE capability for each variant hardware
124*4882a593Smuzhiyun  * @alg_cipher:	list of supported ciphers. for each CE_ID_ this will give the
125*4882a593Smuzhiyun  *              coresponding CE_ALG_XXX value
126*4882a593Smuzhiyun  * @alg_hash:	list of supported hashes. for each CE_ID_ this will give the
127*4882a593Smuzhiyun  *              corresponding CE_ALG_XXX value
128*4882a593Smuzhiyun  * @op_mode:	list of supported block modes
129*4882a593Smuzhiyun  * @cipher_t_dlen_in_bytes:	Does the request size for cipher is in
130*4882a593Smuzhiyun  *				bytes or words
131*4882a593Smuzhiyun  * @hash_t_dlen_in_bytes:	Does the request size for hash is in
132*4882a593Smuzhiyun  *				bits or words
133*4882a593Smuzhiyun  * @prng_t_dlen_in_bytes:	Does the request size for PRNG is in
134*4882a593Smuzhiyun  *				bytes or words
135*4882a593Smuzhiyun  * @trng_t_dlen_in_bytes:	Does the request size for TRNG is in
136*4882a593Smuzhiyun  *				bytes or words
137*4882a593Smuzhiyun  * @ce_clks:	list of clocks needed by this variant
138*4882a593Smuzhiyun  * @esr:	The type of error register
139*4882a593Smuzhiyun  * @prng:	The CE_ALG_XXX value for the PRNG
140*4882a593Smuzhiyun  * @trng:	The CE_ALG_XXX value for the TRNG
141*4882a593Smuzhiyun  */
142*4882a593Smuzhiyun struct ce_variant {
143*4882a593Smuzhiyun 	char alg_cipher[CE_ID_CIPHER_MAX];
144*4882a593Smuzhiyun 	char alg_hash[CE_ID_HASH_MAX];
145*4882a593Smuzhiyun 	u32 op_mode[CE_ID_OP_MAX];
146*4882a593Smuzhiyun 	bool cipher_t_dlen_in_bytes;
147*4882a593Smuzhiyun 	bool hash_t_dlen_in_bits;
148*4882a593Smuzhiyun 	bool prng_t_dlen_in_bytes;
149*4882a593Smuzhiyun 	bool trng_t_dlen_in_bytes;
150*4882a593Smuzhiyun 	struct ce_clock ce_clks[CE_MAX_CLOCKS];
151*4882a593Smuzhiyun 	int esr;
152*4882a593Smuzhiyun 	unsigned char prng;
153*4882a593Smuzhiyun 	unsigned char trng;
154*4882a593Smuzhiyun };
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun struct sginfo {
157*4882a593Smuzhiyun 	__le32 addr;
158*4882a593Smuzhiyun 	__le32 len;
159*4882a593Smuzhiyun } __packed;
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun /*
162*4882a593Smuzhiyun  * struct ce_task - CE Task descriptor
163*4882a593Smuzhiyun  * The structure of this descriptor could be found in the datasheet
164*4882a593Smuzhiyun  */
165*4882a593Smuzhiyun struct ce_task {
166*4882a593Smuzhiyun 	__le32 t_id;
167*4882a593Smuzhiyun 	__le32 t_common_ctl;
168*4882a593Smuzhiyun 	__le32 t_sym_ctl;
169*4882a593Smuzhiyun 	__le32 t_asym_ctl;
170*4882a593Smuzhiyun 	__le32 t_key;
171*4882a593Smuzhiyun 	__le32 t_iv;
172*4882a593Smuzhiyun 	__le32 t_ctr;
173*4882a593Smuzhiyun 	__le32 t_dlen;
174*4882a593Smuzhiyun 	struct sginfo t_src[MAX_SG];
175*4882a593Smuzhiyun 	struct sginfo t_dst[MAX_SG];
176*4882a593Smuzhiyun 	__le32 next;
177*4882a593Smuzhiyun 	__le32 reserved[3];
178*4882a593Smuzhiyun } __packed __aligned(8);
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun /*
181*4882a593Smuzhiyun  * struct sun8i_ce_flow - Information used by each flow
182*4882a593Smuzhiyun  * @engine:	ptr to the crypto_engine for this flow
183*4882a593Smuzhiyun  * @complete:	completion for the current task on this flow
184*4882a593Smuzhiyun  * @status:	set to 1 by interrupt if task is done
185*4882a593Smuzhiyun  * @t_phy:	Physical address of task
186*4882a593Smuzhiyun  * @tl:		pointer to the current ce_task for this flow
187*4882a593Smuzhiyun  * @stat_req:	number of request done by this flow
188*4882a593Smuzhiyun  */
189*4882a593Smuzhiyun struct sun8i_ce_flow {
190*4882a593Smuzhiyun 	struct crypto_engine *engine;
191*4882a593Smuzhiyun 	struct completion complete;
192*4882a593Smuzhiyun 	int status;
193*4882a593Smuzhiyun 	dma_addr_t t_phy;
194*4882a593Smuzhiyun 	int timeout;
195*4882a593Smuzhiyun 	struct ce_task *tl;
196*4882a593Smuzhiyun #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG
197*4882a593Smuzhiyun 	unsigned long stat_req;
198*4882a593Smuzhiyun #endif
199*4882a593Smuzhiyun };
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun /*
202*4882a593Smuzhiyun  * struct sun8i_ce_dev - main container for all this driver information
203*4882a593Smuzhiyun  * @base:	base address of CE
204*4882a593Smuzhiyun  * @ceclks:	clocks used by CE
205*4882a593Smuzhiyun  * @reset:	pointer to reset controller
206*4882a593Smuzhiyun  * @dev:	the platform device
207*4882a593Smuzhiyun  * @mlock:	Control access to device registers
208*4882a593Smuzhiyun  * @rnglock:	Control access to the RNG (dedicated channel 3)
209*4882a593Smuzhiyun  * @chanlist:	array of all flow
210*4882a593Smuzhiyun  * @flow:	flow to use in next request
211*4882a593Smuzhiyun  * @variant:	pointer to variant specific data
212*4882a593Smuzhiyun  * @dbgfs_dir:	Debugfs dentry for statistic directory
213*4882a593Smuzhiyun  * @dbgfs_stats: Debugfs dentry for statistic counters
214*4882a593Smuzhiyun  */
215*4882a593Smuzhiyun struct sun8i_ce_dev {
216*4882a593Smuzhiyun 	void __iomem *base;
217*4882a593Smuzhiyun 	struct clk *ceclks[CE_MAX_CLOCKS];
218*4882a593Smuzhiyun 	struct reset_control *reset;
219*4882a593Smuzhiyun 	struct device *dev;
220*4882a593Smuzhiyun 	struct mutex mlock;
221*4882a593Smuzhiyun 	struct mutex rnglock;
222*4882a593Smuzhiyun 	struct sun8i_ce_flow *chanlist;
223*4882a593Smuzhiyun 	atomic_t flow;
224*4882a593Smuzhiyun 	const struct ce_variant *variant;
225*4882a593Smuzhiyun #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG
226*4882a593Smuzhiyun 	struct dentry *dbgfs_dir;
227*4882a593Smuzhiyun 	struct dentry *dbgfs_stats;
228*4882a593Smuzhiyun #endif
229*4882a593Smuzhiyun #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG
230*4882a593Smuzhiyun 	struct hwrng trng;
231*4882a593Smuzhiyun #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG
232*4882a593Smuzhiyun 	unsigned long hwrng_stat_req;
233*4882a593Smuzhiyun 	unsigned long hwrng_stat_bytes;
234*4882a593Smuzhiyun #endif
235*4882a593Smuzhiyun #endif
236*4882a593Smuzhiyun };
237*4882a593Smuzhiyun 
238*4882a593Smuzhiyun /*
239*4882a593Smuzhiyun  * struct sun8i_cipher_req_ctx - context for a skcipher request
240*4882a593Smuzhiyun  * @op_dir:		direction (encrypt vs decrypt) for this request
241*4882a593Smuzhiyun  * @flow:		the flow to use for this request
242*4882a593Smuzhiyun  * @backup_iv:		buffer which contain the next IV to store
243*4882a593Smuzhiyun  * @bounce_iv:		buffer which contain the IV
244*4882a593Smuzhiyun  * @ivlen:		size of bounce_iv
245*4882a593Smuzhiyun  * @nr_sgs:		The number of source SG (as given by dma_map_sg())
246*4882a593Smuzhiyun  * @nr_sgd:		The number of destination SG (as given by dma_map_sg())
247*4882a593Smuzhiyun  * @addr_iv:		The IV addr returned by dma_map_single, need to unmap later
248*4882a593Smuzhiyun  * @addr_key:		The key addr returned by dma_map_single, need to unmap later
249*4882a593Smuzhiyun  * @fallback_req:	request struct for invoking the fallback skcipher TFM
250*4882a593Smuzhiyun  */
251*4882a593Smuzhiyun struct sun8i_cipher_req_ctx {
252*4882a593Smuzhiyun 	u32 op_dir;
253*4882a593Smuzhiyun 	int flow;
254*4882a593Smuzhiyun 	void *backup_iv;
255*4882a593Smuzhiyun 	void *bounce_iv;
256*4882a593Smuzhiyun 	unsigned int ivlen;
257*4882a593Smuzhiyun 	int nr_sgs;
258*4882a593Smuzhiyun 	int nr_sgd;
259*4882a593Smuzhiyun 	dma_addr_t addr_iv;
260*4882a593Smuzhiyun 	dma_addr_t addr_key;
261*4882a593Smuzhiyun 	struct skcipher_request fallback_req;   // keep at the end
262*4882a593Smuzhiyun };
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun /*
265*4882a593Smuzhiyun  * struct sun8i_cipher_tfm_ctx - context for a skcipher TFM
266*4882a593Smuzhiyun  * @enginectx:		crypto_engine used by this TFM
267*4882a593Smuzhiyun  * @key:		pointer to key data
268*4882a593Smuzhiyun  * @keylen:		len of the key
269*4882a593Smuzhiyun  * @ce:			pointer to the private data of driver handling this TFM
270*4882a593Smuzhiyun  * @fallback_tfm:	pointer to the fallback TFM
271*4882a593Smuzhiyun  */
272*4882a593Smuzhiyun struct sun8i_cipher_tfm_ctx {
273*4882a593Smuzhiyun 	struct crypto_engine_ctx enginectx;
274*4882a593Smuzhiyun 	u32 *key;
275*4882a593Smuzhiyun 	u32 keylen;
276*4882a593Smuzhiyun 	struct sun8i_ce_dev *ce;
277*4882a593Smuzhiyun 	struct crypto_skcipher *fallback_tfm;
278*4882a593Smuzhiyun };
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun /*
281*4882a593Smuzhiyun  * struct sun8i_ce_hash_tfm_ctx - context for an ahash TFM
282*4882a593Smuzhiyun  * @enginectx:		crypto_engine used by this TFM
283*4882a593Smuzhiyun  * @ce:			pointer to the private data of driver handling this TFM
284*4882a593Smuzhiyun  * @fallback_tfm:	pointer to the fallback TFM
285*4882a593Smuzhiyun  */
286*4882a593Smuzhiyun struct sun8i_ce_hash_tfm_ctx {
287*4882a593Smuzhiyun 	struct crypto_engine_ctx enginectx;
288*4882a593Smuzhiyun 	struct sun8i_ce_dev *ce;
289*4882a593Smuzhiyun 	struct crypto_ahash *fallback_tfm;
290*4882a593Smuzhiyun };
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun /*
293*4882a593Smuzhiyun  * struct sun8i_ce_hash_reqctx - context for an ahash request
294*4882a593Smuzhiyun  * @fallback_req:	pre-allocated fallback request
295*4882a593Smuzhiyun  * @flow:	the flow to use for this request
296*4882a593Smuzhiyun  */
297*4882a593Smuzhiyun struct sun8i_ce_hash_reqctx {
298*4882a593Smuzhiyun 	struct ahash_request fallback_req;
299*4882a593Smuzhiyun 	int flow;
300*4882a593Smuzhiyun };
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun /*
303*4882a593Smuzhiyun  * struct sun8i_ce_prng_ctx - context for PRNG TFM
304*4882a593Smuzhiyun  * @seed:	The seed to use
305*4882a593Smuzhiyun  * @slen:	The size of the seed
306*4882a593Smuzhiyun  */
307*4882a593Smuzhiyun struct sun8i_ce_rng_tfm_ctx {
308*4882a593Smuzhiyun 	void *seed;
309*4882a593Smuzhiyun 	unsigned int slen;
310*4882a593Smuzhiyun };
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun /*
313*4882a593Smuzhiyun  * struct sun8i_ce_alg_template - crypto_alg template
314*4882a593Smuzhiyun  * @type:		the CRYPTO_ALG_TYPE for this template
315*4882a593Smuzhiyun  * @ce_algo_id:		the CE_ID for this template
316*4882a593Smuzhiyun  * @ce_blockmode:	the type of block operation CE_ID
317*4882a593Smuzhiyun  * @ce:			pointer to the sun8i_ce_dev structure associated with
318*4882a593Smuzhiyun  *			this template
319*4882a593Smuzhiyun  * @alg:		one of sub struct must be used
320*4882a593Smuzhiyun  * @stat_req:		number of request done on this template
321*4882a593Smuzhiyun  * @stat_fb:		number of request which has fallbacked
322*4882a593Smuzhiyun  * @stat_bytes:		total data size done by this template
323*4882a593Smuzhiyun  */
324*4882a593Smuzhiyun struct sun8i_ce_alg_template {
325*4882a593Smuzhiyun 	u32 type;
326*4882a593Smuzhiyun 	u32 ce_algo_id;
327*4882a593Smuzhiyun 	u32 ce_blockmode;
328*4882a593Smuzhiyun 	struct sun8i_ce_dev *ce;
329*4882a593Smuzhiyun 	union {
330*4882a593Smuzhiyun 		struct skcipher_alg skcipher;
331*4882a593Smuzhiyun 		struct ahash_alg hash;
332*4882a593Smuzhiyun 		struct rng_alg rng;
333*4882a593Smuzhiyun 	} alg;
334*4882a593Smuzhiyun #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG
335*4882a593Smuzhiyun 	unsigned long stat_req;
336*4882a593Smuzhiyun 	unsigned long stat_fb;
337*4882a593Smuzhiyun 	unsigned long stat_bytes;
338*4882a593Smuzhiyun #endif
339*4882a593Smuzhiyun };
340*4882a593Smuzhiyun 
341*4882a593Smuzhiyun int sun8i_ce_enqueue(struct crypto_async_request *areq, u32 type);
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
344*4882a593Smuzhiyun 			unsigned int keylen);
345*4882a593Smuzhiyun int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
346*4882a593Smuzhiyun 			 unsigned int keylen);
347*4882a593Smuzhiyun int sun8i_ce_cipher_init(struct crypto_tfm *tfm);
348*4882a593Smuzhiyun void sun8i_ce_cipher_exit(struct crypto_tfm *tfm);
349*4882a593Smuzhiyun int sun8i_ce_skdecrypt(struct skcipher_request *areq);
350*4882a593Smuzhiyun int sun8i_ce_skencrypt(struct skcipher_request *areq);
351*4882a593Smuzhiyun 
352*4882a593Smuzhiyun int sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce);
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name);
355*4882a593Smuzhiyun 
356*4882a593Smuzhiyun int sun8i_ce_hash_crainit(struct crypto_tfm *tfm);
357*4882a593Smuzhiyun void sun8i_ce_hash_craexit(struct crypto_tfm *tfm);
358*4882a593Smuzhiyun int sun8i_ce_hash_init(struct ahash_request *areq);
359*4882a593Smuzhiyun int sun8i_ce_hash_export(struct ahash_request *areq, void *out);
360*4882a593Smuzhiyun int sun8i_ce_hash_import(struct ahash_request *areq, const void *in);
361*4882a593Smuzhiyun int sun8i_ce_hash(struct ahash_request *areq);
362*4882a593Smuzhiyun int sun8i_ce_hash_final(struct ahash_request *areq);
363*4882a593Smuzhiyun int sun8i_ce_hash_update(struct ahash_request *areq);
364*4882a593Smuzhiyun int sun8i_ce_hash_finup(struct ahash_request *areq);
365*4882a593Smuzhiyun int sun8i_ce_hash_digest(struct ahash_request *areq);
366*4882a593Smuzhiyun int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq);
367*4882a593Smuzhiyun 
368*4882a593Smuzhiyun int sun8i_ce_prng_generate(struct crypto_rng *tfm, const u8 *src,
369*4882a593Smuzhiyun 			   unsigned int slen, u8 *dst, unsigned int dlen);
370*4882a593Smuzhiyun int sun8i_ce_prng_seed(struct crypto_rng *tfm, const u8 *seed, unsigned int slen);
371*4882a593Smuzhiyun void sun8i_ce_prng_exit(struct crypto_tfm *tfm);
372*4882a593Smuzhiyun int sun8i_ce_prng_init(struct crypto_tfm *tfm);
373*4882a593Smuzhiyun 
374*4882a593Smuzhiyun int sun8i_ce_hwrng_register(struct sun8i_ce_dev *ce);
375*4882a593Smuzhiyun void sun8i_ce_hwrng_unregister(struct sun8i_ce_dev *ce);
376