blob: 1c965ef83002a631b310aaa221a001b80675012c [file] [log] [blame]
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +00001/* SPDX-License-Identifier: GPL-2.0 */
Gilad Ben-Yossef03963ca2019-04-18 16:38:53 +03002/* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +00003
4#ifndef __CC_SRAM_MGR_H__
5#define __CC_SRAM_MGR_H__
6
7#ifndef CC_CC_SRAM_SIZE
8#define CC_CC_SRAM_SIZE 4096
9#endif
10
11struct cc_drvdata;
12
Geert Uytterhoeven1a895f12020-02-11 19:19:07 +010013#define NULL_SRAM_ADDR ((u32)-1)
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000014
Geert Uytterhoeven31568ab2020-02-11 19:19:22 +010015/**
16 * cc_sram_mgr_init() - Initializes SRAM pool.
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000017 * The first X bytes of SRAM are reserved for ROM usage, hence, pool
18 * starts right after X bytes.
19 *
Geert Uytterhoeven31568ab2020-02-11 19:19:22 +010020 * @drvdata: Associated device driver context
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000021 *
Geert Uytterhoeven31568ab2020-02-11 19:19:22 +010022 * Return:
23 * Zero for success, negative value otherwise.
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000024 */
25int cc_sram_mgr_init(struct cc_drvdata *drvdata);
26
Geert Uytterhoeven31568ab2020-02-11 19:19:22 +010027/**
28 * cc_sram_alloc() - Allocate buffer from SRAM pool.
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000029 *
Geert Uytterhoeven31568ab2020-02-11 19:19:22 +010030 * @drvdata: Associated device driver context
31 * @size: The requested bytes to allocate
32 *
33 * Return:
34 * Address offset in SRAM or NULL_SRAM_ADDR for failure.
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000035 */
Geert Uytterhoeven1a895f12020-02-11 19:19:07 +010036u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000037
38/**
39 * cc_set_sram_desc() - Create const descriptors sequence to
40 * set values in given array into SRAM.
41 * Note: each const value can't exceed word size.
42 *
43 * @src: A pointer to array of words to set as consts.
44 * @dst: The target SRAM buffer to set into
Geert Uytterhoeven31568ab2020-02-11 19:19:22 +010045 * @nelement: The number of words in "src" array
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000046 * @seq: A pointer to the given IN/OUT descriptor sequence
47 * @seq_len: A pointer to the given IN/OUT sequence length
48 */
Geert Uytterhoeven1a895f12020-02-11 19:19:07 +010049void cc_set_sram_desc(const u32 *src, u32 dst, unsigned int nelement,
50 struct cc_hw_desc *seq, unsigned int *seq_len);
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000051
52#endif /*__CC_SRAM_MGR_H__*/