cc_sram_mgr.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
  3. #ifndef __CC_SRAM_MGR_H__
  4. #define __CC_SRAM_MGR_H__
  5. #ifndef CC_CC_SRAM_SIZE
  6. #define CC_CC_SRAM_SIZE 4096
  7. #endif
  8. struct cc_drvdata;
  9. /**
  10. * Address (offset) within CC internal SRAM
  11. */
  12. typedef u64 cc_sram_addr_t;
  13. #define NULL_SRAM_ADDR ((cc_sram_addr_t)-1)
  14. /*!
  15. * Initializes SRAM pool.
  16. * The first X bytes of SRAM are reserved for ROM usage, hence, pool
  17. * starts right after X bytes.
  18. *
  19. * \param drvdata
  20. *
  21. * \return int Zero for success, negative value otherwise.
  22. */
  23. int cc_sram_mgr_init(struct cc_drvdata *drvdata);
  24. /*!
  25. * Uninits SRAM pool.
  26. *
  27. * \param drvdata
  28. */
  29. void cc_sram_mgr_fini(struct cc_drvdata *drvdata);
  30. /*!
  31. * Allocated buffer from SRAM pool.
  32. * Note: Caller is responsible to free the LAST allocated buffer.
  33. * This function does not taking care of any fragmentation may occur
  34. * by the order of calls to alloc/free.
  35. *
  36. * \param drvdata
  37. * \param size The requested bytes to allocate
  38. */
  39. cc_sram_addr_t cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
  40. /**
  41. * cc_set_sram_desc() - Create const descriptors sequence to
  42. * set values in given array into SRAM.
  43. * Note: each const value can't exceed word size.
  44. *
  45. * @src: A pointer to array of words to set as consts.
  46. * @dst: The target SRAM buffer to set into
  47. * @nelements: The number of words in "src" array
  48. * @seq: A pointer to the given IN/OUT descriptor sequence
  49. * @seq_len: A pointer to the given IN/OUT sequence length
  50. */
  51. void cc_set_sram_desc(const u32 *src, cc_sram_addr_t dst,
  52. unsigned int nelement, struct cc_hw_desc *seq,
  53. unsigned int *seq_len);
  54. #endif /*__CC_SRAM_MGR_H__*/