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