1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2018-2019 Synopsys, Inc. and/or its affiliates.
4 * Synopsys DesignWare eDMA core driver
6 * Author: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
9 #ifndef _DW_EDMA_CORE_H
10 #define _DW_EDMA_CORE_H
12 #include <linux/msi.h>
13 #include <linux/dma/edma.h>
15 #include "../virt-dma.h"
18 #define EDMA_MAX_WR_CH 8
19 #define EDMA_MAX_RD_CH 8
26 enum dw_edma_map_format {
27 EDMA_MF_EDMA_LEGACY = 0x0,
28 EDMA_MF_EDMA_UNROLL = 0x1,
29 EDMA_MF_HDMA_COMPAT = 0x5
32 enum dw_edma_request {
44 enum dw_edma_xfer_type {
45 EDMA_XFER_SCATTER_GATHER = 0,
53 struct dw_edma_burst {
54 struct list_head list;
60 struct dw_edma_region {
66 struct dw_edma_chunk {
67 struct list_head list;
68 struct dw_edma_chan *chan;
69 struct dw_edma_burst *burst;
74 struct dw_edma_region ll_region; /* Linked list */
78 struct virt_dma_desc vd;
79 struct dw_edma_chan *chan;
80 struct dw_edma_chunk *chunk;
89 struct virt_dma_chan vc;
90 struct dw_edma_chip *chip;
98 enum dw_edma_request request;
99 enum dw_edma_status status;
102 struct dma_slave_config config;
112 struct dw_edma_core_ops {
113 int (*irq_vector)(struct device *dev, unsigned int nr);
119 struct dma_device wr_edma;
122 struct dma_device rd_edma;
125 struct dw_edma_region rg_region; /* Registers */
126 struct dw_edma_region ll_region_wr[EDMA_MAX_WR_CH];
127 struct dw_edma_region ll_region_rd[EDMA_MAX_RD_CH];
128 struct dw_edma_region dt_region_wr[EDMA_MAX_WR_CH];
129 struct dw_edma_region dt_region_rd[EDMA_MAX_RD_CH];
131 struct dw_edma_irq *irq;
134 enum dw_edma_map_format mf;
136 struct dw_edma_chan *chan;
137 const struct dw_edma_core_ops *ops;
139 raw_spinlock_t lock; /* Only for legacy */
140 #ifdef CONFIG_DEBUG_FS
141 struct dentry *debugfs;
142 #endif /* CONFIG_DEBUG_FS */
146 struct scatterlist *sgl;
150 struct dw_edma_cyclic {
156 struct dw_edma_transfer {
157 struct dma_chan *dchan;
159 struct dw_edma_sg sg;
160 struct dw_edma_cyclic cyclic;
161 struct dma_interleaved_template *il;
163 enum dma_transfer_direction direction;
165 enum dw_edma_xfer_type type;
169 struct dw_edma_chan *vc2dw_edma_chan(struct virt_dma_chan *vc)
171 return container_of(vc, struct dw_edma_chan, vc);
175 struct dw_edma_chan *dchan2dw_edma_chan(struct dma_chan *dchan)
177 return vc2dw_edma_chan(to_virt_chan(dchan));
180 #endif /* _DW_EDMA_CORE_H */