]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/staging/ccree/ssi_sram_mgr.h
d71fbaf9ac44ffb42381086c101ee45563edbe52
[linux.git] / drivers / staging / ccree / ssi_sram_mgr.h
1 /*
2  * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3  * 
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  * 
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  */
16
17 #ifndef __SSI_SRAM_MGR_H__
18 #define __SSI_SRAM_MGR_H__
19
20
21 #ifndef SSI_CC_SRAM_SIZE
22 #define SSI_CC_SRAM_SIZE 4096
23 #endif
24
25 struct ssi_drvdata;
26
27 /**
28  * Address (offset) within CC internal SRAM
29  */
30
31 typedef uint64_t ssi_sram_addr_t;
32
33 #define NULL_SRAM_ADDR ((ssi_sram_addr_t)-1)
34
35 /*!
36  * Initializes SRAM pool. 
37  * The first X bytes of SRAM are reserved for ROM usage, hence, pool 
38  * starts right after X bytes. 
39  *  
40  * \param drvdata 
41  *  
42  * \return int Zero for success, negative value otherwise.
43  */
44 int ssi_sram_mgr_init(struct ssi_drvdata *drvdata);
45
46 /*!
47  * Uninits SRAM pool.
48  * 
49  * \param drvdata 
50  */
51 void ssi_sram_mgr_fini(struct ssi_drvdata *drvdata);
52
53 /*!
54  * Allocated buffer from SRAM pool. 
55  * Note: Caller is responsible to free the LAST allocated buffer. 
56  * This function does not taking care of any fragmentation may occur 
57  * by the order of calls to alloc/free. 
58  * 
59  * \param drvdata 
60  * \param size The requested bytes to allocate
61  */
62 ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, uint32_t size);
63
64 /**
65  * ssi_sram_mgr_const2sram_desc() - Create const descriptors sequence to
66  *      set values in given array into SRAM. 
67  * Note: each const value can't exceed word size.
68  * 
69  * @src:          A pointer to array of words to set as consts.
70  * @dst:          The target SRAM buffer to set into
71  * @nelements:    The number of words in "src" array
72  * @seq:          A pointer to the given IN/OUT descriptor sequence
73  * @seq_len:      A pointer to the given IN/OUT sequence length
74  */
75 void ssi_sram_mgr_const2sram_desc(
76         const uint32_t *src, ssi_sram_addr_t dst,
77         unsigned int nelement,
78         HwDesc_s *seq, unsigned int *seq_len);
79
80 #endif /*__SSI_SRAM_MGR_H__*/