1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2018-2019 Synopsys, Inc. and/or its affiliates.
4 * Synopsys DesignWare eDMA core driver
12 #include <linux/device.h>
13 #include <linux/dmaengine.h>
15 #define EDMA_MAX_WR_CH 8
16 #define EDMA_MAX_RD_CH 8
20 struct dw_edma_region {
30 * struct dw_edma_core_ops - platform-specific eDMA methods
31 * @irq_vector: Get IRQ number of the passed eDMA channel. Note the
32 * method accepts the channel id in the end-to-end
33 * numbering with the eDMA write channels being placed
35 * @pci_address: Get PCIe bus address corresponding to the passed CPU
36 * address. Note there is no need in specifying this
37 * function if the address translation is performed by
38 * the DW PCIe RP/EP controller with the DW eDMA device in
39 * subject and DMA_BYPASS isn't set for all the outbound
40 * iATU windows. That will be done by the controller
43 struct dw_edma_core_ops {
44 int (*irq_vector)(struct device *dev, unsigned int nr);
45 u64 (*pci_address)(struct device *dev, phys_addr_t cpu_addr);
48 enum dw_edma_map_format {
49 EDMA_MF_EDMA_LEGACY = 0x0,
50 EDMA_MF_EDMA_UNROLL = 0x1,
51 EDMA_MF_HDMA_COMPAT = 0x5
55 * enum dw_edma_chip_flags - Flags specific to an eDMA chip
56 * @DW_EDMA_CHIP_LOCAL: eDMA is used locally by an endpoint
58 enum dw_edma_chip_flags {
59 DW_EDMA_CHIP_LOCAL = BIT(0),
63 * struct dw_edma_chip - representation of DesignWare eDMA controller hardware
64 * @dev: struct device of the eDMA controller
66 * @nr_irqs: total number of DMA IRQs
67 * @ops DMA channel to IRQ number mapping
68 * @flags dw_edma_chip_flags
69 * @reg_base DMA register base address
70 * @ll_wr_cnt DMA write link list count
71 * @ll_rd_cnt DMA read link list count
72 * @rg_region DMA register region
73 * @ll_region_wr DMA descriptor link list memory for write channel
74 * @ll_region_rd DMA descriptor link list memory for read channel
75 * @dt_region_wr DMA data memory for write channel
76 * @dt_region_rd DMA data memory for read channel
77 * @mf DMA register map format
78 * @dw: struct dw_edma that is filled by dw_edma_probe()
83 const struct dw_edma_core_ops *ops;
86 void __iomem *reg_base;
90 /* link list address */
91 struct dw_edma_region ll_region_wr[EDMA_MAX_WR_CH];
92 struct dw_edma_region ll_region_rd[EDMA_MAX_RD_CH];
95 struct dw_edma_region dt_region_wr[EDMA_MAX_WR_CH];
96 struct dw_edma_region dt_region_rd[EDMA_MAX_RD_CH];
98 enum dw_edma_map_format mf;
103 /* Export to the platform drivers */
104 #if IS_REACHABLE(CONFIG_DW_EDMA)
105 int dw_edma_probe(struct dw_edma_chip *chip);
106 int dw_edma_remove(struct dw_edma_chip *chip);
108 static inline int dw_edma_probe(struct dw_edma_chip *chip)
113 static inline int dw_edma_remove(struct dw_edma_chip *chip)
117 #endif /* CONFIG_DW_EDMA */
119 #endif /* _DW_EDMA_H */