linux/drivers/staging/ccree/ssi_sram_mgr.h
<<
>>
Prefs
   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#ifndef SSI_CC_SRAM_SIZE
  21#define SSI_CC_SRAM_SIZE 4096
  22#endif
  23
  24struct ssi_drvdata;
  25
  26/**
  27 * Address (offset) within CC internal SRAM
  28 */
  29
  30typedef u64 ssi_sram_addr_t;
  31
  32#define NULL_SRAM_ADDR ((ssi_sram_addr_t)-1)
  33
  34/*!
  35 * Initializes SRAM pool.
  36 * The first X bytes of SRAM are reserved for ROM usage, hence, pool
  37 * starts right after X bytes.
  38 *
  39 * \param drvdata
  40 *
  41 * \return int Zero for success, negative value otherwise.
  42 */
  43int ssi_sram_mgr_init(struct ssi_drvdata *drvdata);
  44
  45/*!
  46 * Uninits SRAM pool.
  47 *
  48 * \param drvdata
  49 */
  50void ssi_sram_mgr_fini(struct ssi_drvdata *drvdata);
  51
  52/*!
  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.
  57 *
  58 * \param drvdata
  59 * \param size The requested bytes to allocate
  60 */
  61ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size);
  62
  63/**
  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.
  67 *
  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
  73 */
  74void 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);
  78
  79#endif /*__SSI_SRAM_MGR_H__*/
  80