xref: /OK3568_Linux_fs/kernel/drivers/crypto/ccree/cc_sram_mgr.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #ifndef __CC_SRAM_MGR_H__
5*4882a593Smuzhiyun #define __CC_SRAM_MGR_H__
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef CC_CC_SRAM_SIZE
8*4882a593Smuzhiyun #define CC_CC_SRAM_SIZE 4096
9*4882a593Smuzhiyun #endif
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun struct cc_drvdata;
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #define NULL_SRAM_ADDR ((u32)-1)
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /**
16*4882a593Smuzhiyun  * cc_sram_mgr_init() - Initializes SRAM pool.
17*4882a593Smuzhiyun  * The first X bytes of SRAM are reserved for ROM usage, hence, pool
18*4882a593Smuzhiyun  * starts right after X bytes.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * @drvdata: Associated device driver context
21*4882a593Smuzhiyun  *
22*4882a593Smuzhiyun  * Return:
23*4882a593Smuzhiyun  * Zero for success, negative value otherwise.
24*4882a593Smuzhiyun  */
25*4882a593Smuzhiyun int cc_sram_mgr_init(struct cc_drvdata *drvdata);
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /**
28*4882a593Smuzhiyun  * cc_sram_alloc() - Allocate buffer from SRAM pool.
29*4882a593Smuzhiyun  *
30*4882a593Smuzhiyun  * @drvdata: Associated device driver context
31*4882a593Smuzhiyun  * @size: The requested bytes to allocate
32*4882a593Smuzhiyun  *
33*4882a593Smuzhiyun  * Return:
34*4882a593Smuzhiyun  * Address offset in SRAM or NULL_SRAM_ADDR for failure.
35*4882a593Smuzhiyun  */
36*4882a593Smuzhiyun u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun /**
39*4882a593Smuzhiyun  * cc_set_sram_desc() - Create const descriptors sequence to
40*4882a593Smuzhiyun  *	set values in given array into SRAM.
41*4882a593Smuzhiyun  * Note: each const value can't exceed word size.
42*4882a593Smuzhiyun  *
43*4882a593Smuzhiyun  * @src:	  A pointer to array of words to set as consts.
44*4882a593Smuzhiyun  * @dst:	  The target SRAM buffer to set into
45*4882a593Smuzhiyun  * @nelement:	  The number of words in "src" array
46*4882a593Smuzhiyun  * @seq:	  A pointer to the given IN/OUT descriptor sequence
47*4882a593Smuzhiyun  * @seq_len:	  A pointer to the given IN/OUT sequence length
48*4882a593Smuzhiyun  */
49*4882a593Smuzhiyun void cc_set_sram_desc(const u32 *src, u32 dst, unsigned int nelement,
50*4882a593Smuzhiyun 		      struct cc_hw_desc *seq, unsigned int *seq_len);
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun #endif /*__CC_SRAM_MGR_H__*/
53