cc_lli_defs.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2012-2018 ARM Limited or its affiliates. */
  3. #ifndef _CC_LLI_DEFS_H_
  4. #define _CC_LLI_DEFS_H_
  5. #include <linux/types.h>
  6. /* Max DLLI size
  7. * AKA CC_DSCRPTR_QUEUE_WORD1_DIN_SIZE_BIT_SIZE
  8. */
  9. #define DLLI_SIZE_BIT_SIZE 0x18
  10. #define CC_MAX_MLLI_ENTRY_SIZE 0xFFFF
  11. #define LLI_MAX_NUM_OF_DATA_ENTRIES 128
  12. #define LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES 4
  13. #define MLLI_TABLE_MIN_ALIGNMENT 4 /* 32 bit alignment */
  14. #define MAX_NUM_OF_BUFFERS_IN_MLLI 4
  15. #define MAX_NUM_OF_TOTAL_MLLI_ENTRIES \
  16. (2 * LLI_MAX_NUM_OF_DATA_ENTRIES + \
  17. LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)
  18. /* Size of entry */
  19. #define LLI_ENTRY_WORD_SIZE 2
  20. #define LLI_ENTRY_BYTE_SIZE (LLI_ENTRY_WORD_SIZE * sizeof(u32))
  21. /* Word0[31:0] = ADDR[31:0] */
  22. #define LLI_WORD0_OFFSET 0
  23. #define LLI_LADDR_BIT_OFFSET 0
  24. #define LLI_LADDR_BIT_SIZE 32
  25. /* Word1[31:16] = ADDR[47:32]; Word1[15:0] = SIZE */
  26. #define LLI_WORD1_OFFSET 1
  27. #define LLI_SIZE_BIT_OFFSET 0
  28. #define LLI_SIZE_BIT_SIZE 16
  29. #define LLI_HADDR_BIT_OFFSET 16
  30. #define LLI_HADDR_BIT_SIZE 16
  31. #define LLI_SIZE_MASK GENMASK((LLI_SIZE_BIT_SIZE - 1), LLI_SIZE_BIT_OFFSET)
  32. #define LLI_HADDR_MASK GENMASK( \
  33. (LLI_HADDR_BIT_OFFSET + LLI_HADDR_BIT_SIZE - 1),\
  34. LLI_HADDR_BIT_OFFSET)
  35. static inline void cc_lli_set_addr(u32 *lli_p, dma_addr_t addr)
  36. {
  37. lli_p[LLI_WORD0_OFFSET] = (addr & U32_MAX);
  38. #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
  39. lli_p[LLI_WORD1_OFFSET] &= ~LLI_HADDR_MASK;
  40. lli_p[LLI_WORD1_OFFSET] |= FIELD_PREP(LLI_HADDR_MASK, (addr >> 32));
  41. #endif /* CONFIG_ARCH_DMA_ADDR_T_64BIT */
  42. }
  43. static inline void cc_lli_set_size(u32 *lli_p, u16 size)
  44. {
  45. lli_p[LLI_WORD1_OFFSET] &= ~LLI_SIZE_MASK;
  46. lli_p[LLI_WORD1_OFFSET] |= FIELD_PREP(LLI_SIZE_MASK, size);
  47. }
  48. #endif /*_CC_LLI_DEFS_H_*/