162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * sun8i-ce.h - hardware cryptographic offloader for
462306a36Sopenharmony_ci * Allwinner H3/A64/H5/H2+/H6 SoC
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (C) 2016-2019 Corentin LABBE <clabbe.montjoie@gmail.com>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#include <crypto/aes.h>
962306a36Sopenharmony_ci#include <crypto/des.h>
1062306a36Sopenharmony_ci#include <crypto/engine.h>
1162306a36Sopenharmony_ci#include <crypto/skcipher.h>
1262306a36Sopenharmony_ci#include <linux/atomic.h>
1362306a36Sopenharmony_ci#include <linux/debugfs.h>
1462306a36Sopenharmony_ci#include <linux/crypto.h>
1562306a36Sopenharmony_ci#include <linux/hw_random.h>
1662306a36Sopenharmony_ci#include <crypto/internal/hash.h>
1762306a36Sopenharmony_ci#include <crypto/md5.h>
1862306a36Sopenharmony_ci#include <crypto/rng.h>
1962306a36Sopenharmony_ci#include <crypto/sha1.h>
2062306a36Sopenharmony_ci#include <crypto/sha2.h>
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/* CE Registers */
2362306a36Sopenharmony_ci#define CE_TDQ	0x00
2462306a36Sopenharmony_ci#define CE_CTR	0x04
2562306a36Sopenharmony_ci#define CE_ICR	0x08
2662306a36Sopenharmony_ci#define CE_ISR	0x0C
2762306a36Sopenharmony_ci#define CE_TLR	0x10
2862306a36Sopenharmony_ci#define CE_TSR	0x14
2962306a36Sopenharmony_ci#define CE_ESR	0x18
3062306a36Sopenharmony_ci#define CE_CSSGR	0x1C
3162306a36Sopenharmony_ci#define CE_CDSGR	0x20
3262306a36Sopenharmony_ci#define CE_CSAR	0x24
3362306a36Sopenharmony_ci#define CE_CDAR	0x28
3462306a36Sopenharmony_ci#define CE_TPR	0x2C
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci/* Used in struct ce_task */
3762306a36Sopenharmony_ci/* ce_task common */
3862306a36Sopenharmony_ci#define CE_ENCRYPTION		0
3962306a36Sopenharmony_ci#define CE_DECRYPTION		BIT(8)
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define CE_COMM_INT		BIT(31)
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci/* ce_task symmetric */
4462306a36Sopenharmony_ci#define CE_AES_128BITS 0
4562306a36Sopenharmony_ci#define CE_AES_192BITS 1
4662306a36Sopenharmony_ci#define CE_AES_256BITS 2
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define CE_OP_ECB	0
4962306a36Sopenharmony_ci#define CE_OP_CBC	(1 << 8)
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#define CE_ALG_AES		0
5262306a36Sopenharmony_ci#define CE_ALG_DES		1
5362306a36Sopenharmony_ci#define CE_ALG_3DES		2
5462306a36Sopenharmony_ci#define CE_ALG_MD5              16
5562306a36Sopenharmony_ci#define CE_ALG_SHA1             17
5662306a36Sopenharmony_ci#define CE_ALG_SHA224           18
5762306a36Sopenharmony_ci#define CE_ALG_SHA256           19
5862306a36Sopenharmony_ci#define CE_ALG_SHA384           20
5962306a36Sopenharmony_ci#define CE_ALG_SHA512           21
6062306a36Sopenharmony_ci#define CE_ALG_TRNG		48
6162306a36Sopenharmony_ci#define CE_ALG_PRNG		49
6262306a36Sopenharmony_ci#define CE_ALG_TRNG_V2		0x1c
6362306a36Sopenharmony_ci#define CE_ALG_PRNG_V2		0x1d
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci/* Used in ce_variant */
6662306a36Sopenharmony_ci#define CE_ID_NOTSUPP		0xFF
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#define CE_ID_CIPHER_AES	0
6962306a36Sopenharmony_ci#define CE_ID_CIPHER_DES	1
7062306a36Sopenharmony_ci#define CE_ID_CIPHER_DES3	2
7162306a36Sopenharmony_ci#define CE_ID_CIPHER_MAX	3
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#define CE_ID_HASH_MD5		0
7462306a36Sopenharmony_ci#define CE_ID_HASH_SHA1		1
7562306a36Sopenharmony_ci#define CE_ID_HASH_SHA224	2
7662306a36Sopenharmony_ci#define CE_ID_HASH_SHA256	3
7762306a36Sopenharmony_ci#define CE_ID_HASH_SHA384	4
7862306a36Sopenharmony_ci#define CE_ID_HASH_SHA512	5
7962306a36Sopenharmony_ci#define CE_ID_HASH_MAX		6
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#define CE_ID_OP_ECB	0
8262306a36Sopenharmony_ci#define CE_ID_OP_CBC	1
8362306a36Sopenharmony_ci#define CE_ID_OP_MAX	2
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci/* Used in CE registers */
8662306a36Sopenharmony_ci#define CE_ERR_ALGO_NOTSUP	BIT(0)
8762306a36Sopenharmony_ci#define CE_ERR_DATALEN		BIT(1)
8862306a36Sopenharmony_ci#define CE_ERR_KEYSRAM		BIT(2)
8962306a36Sopenharmony_ci#define CE_ERR_ADDR_INVALID	BIT(5)
9062306a36Sopenharmony_ci#define CE_ERR_KEYLADDER	BIT(6)
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#define ESR_H3	0
9362306a36Sopenharmony_ci#define ESR_A64	1
9462306a36Sopenharmony_ci#define ESR_R40	2
9562306a36Sopenharmony_ci#define ESR_H5	3
9662306a36Sopenharmony_ci#define ESR_H6	4
9762306a36Sopenharmony_ci#define ESR_D1	5
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define PRNG_DATA_SIZE (160 / 8)
10062306a36Sopenharmony_ci#define PRNG_SEED_SIZE DIV_ROUND_UP(175, 8)
10162306a36Sopenharmony_ci#define PRNG_LD BIT(17)
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#define CE_DIE_ID_SHIFT	16
10462306a36Sopenharmony_ci#define CE_DIE_ID_MASK	0x07
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#define MAX_SG 8
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci#define CE_MAX_CLOCKS 4
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci#define MAXFLOW 4
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci/*
11362306a36Sopenharmony_ci * struct ce_clock - Describe clocks used by sun8i-ce
11462306a36Sopenharmony_ci * @name:	Name of clock needed by this variant
11562306a36Sopenharmony_ci * @freq:	Frequency to set for each clock
11662306a36Sopenharmony_ci * @max_freq:	Maximum frequency for each clock (generally given by datasheet)
11762306a36Sopenharmony_ci */
11862306a36Sopenharmony_cistruct ce_clock {
11962306a36Sopenharmony_ci	const char *name;
12062306a36Sopenharmony_ci	unsigned long freq;
12162306a36Sopenharmony_ci	unsigned long max_freq;
12262306a36Sopenharmony_ci};
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci/*
12562306a36Sopenharmony_ci * struct ce_variant - Describe CE capability for each variant hardware
12662306a36Sopenharmony_ci * @alg_cipher:	list of supported ciphers. for each CE_ID_ this will give the
12762306a36Sopenharmony_ci *              coresponding CE_ALG_XXX value
12862306a36Sopenharmony_ci * @alg_hash:	list of supported hashes. for each CE_ID_ this will give the
12962306a36Sopenharmony_ci *              corresponding CE_ALG_XXX value
13062306a36Sopenharmony_ci * @op_mode:	list of supported block modes
13162306a36Sopenharmony_ci * @cipher_t_dlen_in_bytes:	Does the request size for cipher is in
13262306a36Sopenharmony_ci *				bytes or words
13362306a36Sopenharmony_ci * @hash_t_dlen_in_bytes:	Does the request size for hash is in
13462306a36Sopenharmony_ci *				bits or words
13562306a36Sopenharmony_ci * @prng_t_dlen_in_bytes:	Does the request size for PRNG is in
13662306a36Sopenharmony_ci *				bytes or words
13762306a36Sopenharmony_ci * @trng_t_dlen_in_bytes:	Does the request size for TRNG is in
13862306a36Sopenharmony_ci *				bytes or words
13962306a36Sopenharmony_ci * @ce_clks:	list of clocks needed by this variant
14062306a36Sopenharmony_ci * @esr:	The type of error register
14162306a36Sopenharmony_ci * @prng:	The CE_ALG_XXX value for the PRNG
14262306a36Sopenharmony_ci * @trng:	The CE_ALG_XXX value for the TRNG
14362306a36Sopenharmony_ci */
14462306a36Sopenharmony_cistruct ce_variant {
14562306a36Sopenharmony_ci	char alg_cipher[CE_ID_CIPHER_MAX];
14662306a36Sopenharmony_ci	char alg_hash[CE_ID_HASH_MAX];
14762306a36Sopenharmony_ci	u32 op_mode[CE_ID_OP_MAX];
14862306a36Sopenharmony_ci	bool cipher_t_dlen_in_bytes;
14962306a36Sopenharmony_ci	bool hash_t_dlen_in_bits;
15062306a36Sopenharmony_ci	bool prng_t_dlen_in_bytes;
15162306a36Sopenharmony_ci	bool trng_t_dlen_in_bytes;
15262306a36Sopenharmony_ci	struct ce_clock ce_clks[CE_MAX_CLOCKS];
15362306a36Sopenharmony_ci	int esr;
15462306a36Sopenharmony_ci	unsigned char prng;
15562306a36Sopenharmony_ci	unsigned char trng;
15662306a36Sopenharmony_ci};
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_cistruct sginfo {
15962306a36Sopenharmony_ci	__le32 addr;
16062306a36Sopenharmony_ci	__le32 len;
16162306a36Sopenharmony_ci} __packed;
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci/*
16462306a36Sopenharmony_ci * struct ce_task - CE Task descriptor
16562306a36Sopenharmony_ci * The structure of this descriptor could be found in the datasheet
16662306a36Sopenharmony_ci */
16762306a36Sopenharmony_cistruct ce_task {
16862306a36Sopenharmony_ci	__le32 t_id;
16962306a36Sopenharmony_ci	__le32 t_common_ctl;
17062306a36Sopenharmony_ci	__le32 t_sym_ctl;
17162306a36Sopenharmony_ci	__le32 t_asym_ctl;
17262306a36Sopenharmony_ci	__le32 t_key;
17362306a36Sopenharmony_ci	__le32 t_iv;
17462306a36Sopenharmony_ci	__le32 t_ctr;
17562306a36Sopenharmony_ci	__le32 t_dlen;
17662306a36Sopenharmony_ci	struct sginfo t_src[MAX_SG];
17762306a36Sopenharmony_ci	struct sginfo t_dst[MAX_SG];
17862306a36Sopenharmony_ci	__le32 next;
17962306a36Sopenharmony_ci	__le32 reserved[3];
18062306a36Sopenharmony_ci} __packed __aligned(8);
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/*
18362306a36Sopenharmony_ci * struct sun8i_ce_flow - Information used by each flow
18462306a36Sopenharmony_ci * @engine:	ptr to the crypto_engine for this flow
18562306a36Sopenharmony_ci * @complete:	completion for the current task on this flow
18662306a36Sopenharmony_ci * @status:	set to 1 by interrupt if task is done
18762306a36Sopenharmony_ci * @t_phy:	Physical address of task
18862306a36Sopenharmony_ci * @tl:		pointer to the current ce_task for this flow
18962306a36Sopenharmony_ci * @backup_iv:		buffer which contain the next IV to store
19062306a36Sopenharmony_ci * @bounce_iv:		buffer which contain the IV
19162306a36Sopenharmony_ci * @stat_req:	number of request done by this flow
19262306a36Sopenharmony_ci */
19362306a36Sopenharmony_cistruct sun8i_ce_flow {
19462306a36Sopenharmony_ci	struct crypto_engine *engine;
19562306a36Sopenharmony_ci	struct completion complete;
19662306a36Sopenharmony_ci	int status;
19762306a36Sopenharmony_ci	dma_addr_t t_phy;
19862306a36Sopenharmony_ci	int timeout;
19962306a36Sopenharmony_ci	struct ce_task *tl;
20062306a36Sopenharmony_ci	void *backup_iv;
20162306a36Sopenharmony_ci	void *bounce_iv;
20262306a36Sopenharmony_ci#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG
20362306a36Sopenharmony_ci	unsigned long stat_req;
20462306a36Sopenharmony_ci#endif
20562306a36Sopenharmony_ci};
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci/*
20862306a36Sopenharmony_ci * struct sun8i_ce_dev - main container for all this driver information
20962306a36Sopenharmony_ci * @base:	base address of CE
21062306a36Sopenharmony_ci * @ceclks:	clocks used by CE
21162306a36Sopenharmony_ci * @reset:	pointer to reset controller
21262306a36Sopenharmony_ci * @dev:	the platform device
21362306a36Sopenharmony_ci * @mlock:	Control access to device registers
21462306a36Sopenharmony_ci * @rnglock:	Control access to the RNG (dedicated channel 3)
21562306a36Sopenharmony_ci * @chanlist:	array of all flow
21662306a36Sopenharmony_ci * @flow:	flow to use in next request
21762306a36Sopenharmony_ci * @variant:	pointer to variant specific data
21862306a36Sopenharmony_ci * @dbgfs_dir:	Debugfs dentry for statistic directory
21962306a36Sopenharmony_ci * @dbgfs_stats: Debugfs dentry for statistic counters
22062306a36Sopenharmony_ci */
22162306a36Sopenharmony_cistruct sun8i_ce_dev {
22262306a36Sopenharmony_ci	void __iomem *base;
22362306a36Sopenharmony_ci	struct clk *ceclks[CE_MAX_CLOCKS];
22462306a36Sopenharmony_ci	struct reset_control *reset;
22562306a36Sopenharmony_ci	struct device *dev;
22662306a36Sopenharmony_ci	struct mutex mlock;
22762306a36Sopenharmony_ci	struct mutex rnglock;
22862306a36Sopenharmony_ci	struct sun8i_ce_flow *chanlist;
22962306a36Sopenharmony_ci	atomic_t flow;
23062306a36Sopenharmony_ci	const struct ce_variant *variant;
23162306a36Sopenharmony_ci#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG
23262306a36Sopenharmony_ci	struct dentry *dbgfs_dir;
23362306a36Sopenharmony_ci	struct dentry *dbgfs_stats;
23462306a36Sopenharmony_ci#endif
23562306a36Sopenharmony_ci#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG
23662306a36Sopenharmony_ci	struct hwrng trng;
23762306a36Sopenharmony_ci#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG
23862306a36Sopenharmony_ci	unsigned long hwrng_stat_req;
23962306a36Sopenharmony_ci	unsigned long hwrng_stat_bytes;
24062306a36Sopenharmony_ci#endif
24162306a36Sopenharmony_ci#endif
24262306a36Sopenharmony_ci};
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci/*
24562306a36Sopenharmony_ci * struct sun8i_cipher_req_ctx - context for a skcipher request
24662306a36Sopenharmony_ci * @op_dir:		direction (encrypt vs decrypt) for this request
24762306a36Sopenharmony_ci * @flow:		the flow to use for this request
24862306a36Sopenharmony_ci * @ivlen:		size of bounce_iv
24962306a36Sopenharmony_ci * @nr_sgs:		The number of source SG (as given by dma_map_sg())
25062306a36Sopenharmony_ci * @nr_sgd:		The number of destination SG (as given by dma_map_sg())
25162306a36Sopenharmony_ci * @addr_iv:		The IV addr returned by dma_map_single, need to unmap later
25262306a36Sopenharmony_ci * @addr_key:		The key addr returned by dma_map_single, need to unmap later
25362306a36Sopenharmony_ci * @fallback_req:	request struct for invoking the fallback skcipher TFM
25462306a36Sopenharmony_ci */
25562306a36Sopenharmony_cistruct sun8i_cipher_req_ctx {
25662306a36Sopenharmony_ci	u32 op_dir;
25762306a36Sopenharmony_ci	int flow;
25862306a36Sopenharmony_ci	unsigned int ivlen;
25962306a36Sopenharmony_ci	int nr_sgs;
26062306a36Sopenharmony_ci	int nr_sgd;
26162306a36Sopenharmony_ci	dma_addr_t addr_iv;
26262306a36Sopenharmony_ci	dma_addr_t addr_key;
26362306a36Sopenharmony_ci	struct skcipher_request fallback_req;   // keep at the end
26462306a36Sopenharmony_ci};
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_ci/*
26762306a36Sopenharmony_ci * struct sun8i_cipher_tfm_ctx - context for a skcipher TFM
26862306a36Sopenharmony_ci * @key:		pointer to key data
26962306a36Sopenharmony_ci * @keylen:		len of the key
27062306a36Sopenharmony_ci * @ce:			pointer to the private data of driver handling this TFM
27162306a36Sopenharmony_ci * @fallback_tfm:	pointer to the fallback TFM
27262306a36Sopenharmony_ci */
27362306a36Sopenharmony_cistruct sun8i_cipher_tfm_ctx {
27462306a36Sopenharmony_ci	u32 *key;
27562306a36Sopenharmony_ci	u32 keylen;
27662306a36Sopenharmony_ci	struct sun8i_ce_dev *ce;
27762306a36Sopenharmony_ci	struct crypto_skcipher *fallback_tfm;
27862306a36Sopenharmony_ci};
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci/*
28162306a36Sopenharmony_ci * struct sun8i_ce_hash_tfm_ctx - context for an ahash TFM
28262306a36Sopenharmony_ci * @ce:			pointer to the private data of driver handling this TFM
28362306a36Sopenharmony_ci * @fallback_tfm:	pointer to the fallback TFM
28462306a36Sopenharmony_ci */
28562306a36Sopenharmony_cistruct sun8i_ce_hash_tfm_ctx {
28662306a36Sopenharmony_ci	struct sun8i_ce_dev *ce;
28762306a36Sopenharmony_ci	struct crypto_ahash *fallback_tfm;
28862306a36Sopenharmony_ci};
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci/*
29162306a36Sopenharmony_ci * struct sun8i_ce_hash_reqctx - context for an ahash request
29262306a36Sopenharmony_ci * @fallback_req:	pre-allocated fallback request
29362306a36Sopenharmony_ci * @flow:	the flow to use for this request
29462306a36Sopenharmony_ci */
29562306a36Sopenharmony_cistruct sun8i_ce_hash_reqctx {
29662306a36Sopenharmony_ci	struct ahash_request fallback_req;
29762306a36Sopenharmony_ci	int flow;
29862306a36Sopenharmony_ci};
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci/*
30162306a36Sopenharmony_ci * struct sun8i_ce_prng_ctx - context for PRNG TFM
30262306a36Sopenharmony_ci * @seed:	The seed to use
30362306a36Sopenharmony_ci * @slen:	The size of the seed
30462306a36Sopenharmony_ci */
30562306a36Sopenharmony_cistruct sun8i_ce_rng_tfm_ctx {
30662306a36Sopenharmony_ci	void *seed;
30762306a36Sopenharmony_ci	unsigned int slen;
30862306a36Sopenharmony_ci};
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ci/*
31162306a36Sopenharmony_ci * struct sun8i_ce_alg_template - crypto_alg template
31262306a36Sopenharmony_ci * @type:		the CRYPTO_ALG_TYPE for this template
31362306a36Sopenharmony_ci * @ce_algo_id:		the CE_ID for this template
31462306a36Sopenharmony_ci * @ce_blockmode:	the type of block operation CE_ID
31562306a36Sopenharmony_ci * @ce:			pointer to the sun8i_ce_dev structure associated with
31662306a36Sopenharmony_ci *			this template
31762306a36Sopenharmony_ci * @alg:		one of sub struct must be used
31862306a36Sopenharmony_ci * @stat_req:		number of request done on this template
31962306a36Sopenharmony_ci * @stat_fb:		number of request which has fallbacked
32062306a36Sopenharmony_ci * @stat_bytes:		total data size done by this template
32162306a36Sopenharmony_ci */
32262306a36Sopenharmony_cistruct sun8i_ce_alg_template {
32362306a36Sopenharmony_ci	u32 type;
32462306a36Sopenharmony_ci	u32 ce_algo_id;
32562306a36Sopenharmony_ci	u32 ce_blockmode;
32662306a36Sopenharmony_ci	struct sun8i_ce_dev *ce;
32762306a36Sopenharmony_ci	union {
32862306a36Sopenharmony_ci		struct skcipher_engine_alg skcipher;
32962306a36Sopenharmony_ci		struct ahash_engine_alg hash;
33062306a36Sopenharmony_ci		struct rng_alg rng;
33162306a36Sopenharmony_ci	} alg;
33262306a36Sopenharmony_ci	unsigned long stat_req;
33362306a36Sopenharmony_ci	unsigned long stat_fb;
33462306a36Sopenharmony_ci	unsigned long stat_bytes;
33562306a36Sopenharmony_ci	unsigned long stat_fb_maxsg;
33662306a36Sopenharmony_ci	unsigned long stat_fb_leniv;
33762306a36Sopenharmony_ci	unsigned long stat_fb_len0;
33862306a36Sopenharmony_ci	unsigned long stat_fb_mod16;
33962306a36Sopenharmony_ci	unsigned long stat_fb_srcali;
34062306a36Sopenharmony_ci	unsigned long stat_fb_srclen;
34162306a36Sopenharmony_ci	unsigned long stat_fb_dstali;
34262306a36Sopenharmony_ci	unsigned long stat_fb_dstlen;
34362306a36Sopenharmony_ci	char fbname[CRYPTO_MAX_ALG_NAME];
34462306a36Sopenharmony_ci};
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ciint sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
34762306a36Sopenharmony_ci			unsigned int keylen);
34862306a36Sopenharmony_ciint sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
34962306a36Sopenharmony_ci			 unsigned int keylen);
35062306a36Sopenharmony_ciint sun8i_ce_cipher_init(struct crypto_tfm *tfm);
35162306a36Sopenharmony_civoid sun8i_ce_cipher_exit(struct crypto_tfm *tfm);
35262306a36Sopenharmony_ciint sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq);
35362306a36Sopenharmony_ciint sun8i_ce_skdecrypt(struct skcipher_request *areq);
35462306a36Sopenharmony_ciint sun8i_ce_skencrypt(struct skcipher_request *areq);
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ciint sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce);
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ciint sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name);
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ciint sun8i_ce_hash_init_tfm(struct crypto_ahash *tfm);
36162306a36Sopenharmony_civoid sun8i_ce_hash_exit_tfm(struct crypto_ahash *tfm);
36262306a36Sopenharmony_ciint sun8i_ce_hash_init(struct ahash_request *areq);
36362306a36Sopenharmony_ciint sun8i_ce_hash_export(struct ahash_request *areq, void *out);
36462306a36Sopenharmony_ciint sun8i_ce_hash_import(struct ahash_request *areq, const void *in);
36562306a36Sopenharmony_ciint sun8i_ce_hash_final(struct ahash_request *areq);
36662306a36Sopenharmony_ciint sun8i_ce_hash_update(struct ahash_request *areq);
36762306a36Sopenharmony_ciint sun8i_ce_hash_finup(struct ahash_request *areq);
36862306a36Sopenharmony_ciint sun8i_ce_hash_digest(struct ahash_request *areq);
36962306a36Sopenharmony_ciint sun8i_ce_hash_run(struct crypto_engine *engine, void *breq);
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ciint sun8i_ce_prng_generate(struct crypto_rng *tfm, const u8 *src,
37262306a36Sopenharmony_ci			   unsigned int slen, u8 *dst, unsigned int dlen);
37362306a36Sopenharmony_ciint sun8i_ce_prng_seed(struct crypto_rng *tfm, const u8 *seed, unsigned int slen);
37462306a36Sopenharmony_civoid sun8i_ce_prng_exit(struct crypto_tfm *tfm);
37562306a36Sopenharmony_ciint sun8i_ce_prng_init(struct crypto_tfm *tfm);
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ciint sun8i_ce_hwrng_register(struct sun8i_ce_dev *ce);
37862306a36Sopenharmony_civoid sun8i_ce_hwrng_unregister(struct sun8i_ce_dev *ce);
379