]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/staging/ccree/cc_lli_defs.h
Merge tag 'renesas-fixes2-for-v4.13' of https://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / ccree / cc_lli_defs.h
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 _CC_LLI_DEFS_H_
18 #define _CC_LLI_DEFS_H_
19
20 #include <linux/types.h>
21
22 /* Max DLLI size
23 * AKA DX_DSCRPTR_QUEUE_WORD1_DIN_SIZE_BIT_SIZE
24 */
25 #define DLLI_SIZE_BIT_SIZE 0x18
26
27 #define CC_MAX_MLLI_ENTRY_SIZE 0xFFFF
28
29 #define LLI_MAX_NUM_OF_DATA_ENTRIES 128
30 #define LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES 4
31 #define MLLI_TABLE_MIN_ALIGNMENT 4 /* 32 bit alignment */
32 #define MAX_NUM_OF_BUFFERS_IN_MLLI 4
33 #define MAX_NUM_OF_TOTAL_MLLI_ENTRIES \
34 (2 * LLI_MAX_NUM_OF_DATA_ENTRIES + \
35 LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)
36
37 /* Size of entry */
38 #define LLI_ENTRY_WORD_SIZE 2
39 #define LLI_ENTRY_BYTE_SIZE (LLI_ENTRY_WORD_SIZE * sizeof(u32))
40
41 /* Word0[31:0] = ADDR[31:0] */
42 #define LLI_WORD0_OFFSET 0
43 #define LLI_LADDR_BIT_OFFSET 0
44 #define LLI_LADDR_BIT_SIZE 32
45 /* Word1[31:16] = ADDR[47:32]; Word1[15:0] = SIZE */
46 #define LLI_WORD1_OFFSET 1
47 #define LLI_SIZE_BIT_OFFSET 0
48 #define LLI_SIZE_BIT_SIZE 16
49 #define LLI_HADDR_BIT_OFFSET 16
50 #define LLI_HADDR_BIT_SIZE 16
51
52 #define LLI_SIZE_MASK GENMASK((LLI_SIZE_BIT_SIZE - 1), LLI_SIZE_BIT_OFFSET)
53 #define LLI_HADDR_MASK GENMASK( \
54 (LLI_HADDR_BIT_OFFSET + LLI_HADDR_BIT_SIZE - 1),\
55 LLI_HADDR_BIT_OFFSET)
56
57 static inline void cc_lli_set_addr(u32 *lli_p, dma_addr_t addr)
58 {
59 lli_p[LLI_WORD0_OFFSET] = (addr & U32_MAX);
60 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
61 lli_p[LLI_WORD1_OFFSET] &= ~LLI_HADDR_MASK;
62 lli_p[LLI_WORD1_OFFSET] |= FIELD_PREP(LLI_HADDR_MASK, (addr >> 16));
63 #endif /* CONFIG_ARCH_DMA_ADDR_T_64BIT */
64 }
65
66 static inline void cc_lli_set_size(u32 *lli_p, u16 size)
67 {
68 lli_p[LLI_WORD1_OFFSET] &= ~LLI_SIZE_MASK;
69 lli_p[LLI_WORD1_OFFSET] |= FIELD_PREP(LLI_SIZE_MASK, size);
70 }
71
72 #endif /*_CC_LLI_DEFS_H_*/