2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
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.
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.
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/>.
17 #ifndef __SSI_SRAM_MGR_H__
18 #define __SSI_SRAM_MGR_H__
20 #ifndef SSI_CC_SRAM_SIZE
21 #define SSI_CC_SRAM_SIZE 4096
27 * Address (offset) within CC internal SRAM
30 typedef u64 ssi_sram_addr_t;
32 #define NULL_SRAM_ADDR ((ssi_sram_addr_t)-1)
35 * Initializes SRAM pool.
36 * The first X bytes of SRAM are reserved for ROM usage, hence, pool
37 * starts right after X bytes.
41 * \return int Zero for success, negative value otherwise.
43 int ssi_sram_mgr_init(struct ssi_drvdata *drvdata);
50 void ssi_sram_mgr_fini(struct ssi_drvdata *drvdata);
53 * Allocated buffer from SRAM pool.
54 * Note: Caller is responsible to free the LAST allocated buffer.
55 * This function does not taking care of any fragmentation may occur
56 * by the order of calls to alloc/free.
59 * \param size The requested bytes to allocate
61 ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size);
64 * ssi_sram_mgr_const2sram_desc() - Create const descriptors sequence to
65 * set values in given array into SRAM.
66 * Note: each const value can't exceed word size.
68 * @src: A pointer to array of words to set as consts.
69 * @dst: The target SRAM buffer to set into
70 * @nelements: The number of words in "src" array
71 * @seq: A pointer to the given IN/OUT descriptor sequence
72 * @seq_len: A pointer to the given IN/OUT sequence length
74 void ssi_sram_mgr_const2sram_desc(
75 const u32 *src, ssi_sram_addr_t dst,
76 unsigned int nelement,
77 struct cc_hw_desc *seq, unsigned int *seq_len);
79 #endif /*__SSI_SRAM_MGR_H__*/