edma.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2018-2019 Synopsys, Inc. and/or its affiliates.
  4. * Synopsys DesignWare eDMA core driver
  5. *
  6. * Author: Gustavo Pimentel <[email protected]>
  7. */
  8. #ifndef _DW_EDMA_H
  9. #define _DW_EDMA_H
  10. #include <linux/device.h>
  11. #include <linux/dmaengine.h>
  12. #define EDMA_MAX_WR_CH 8
  13. #define EDMA_MAX_RD_CH 8
  14. struct dw_edma;
  15. struct dw_edma_region {
  16. phys_addr_t paddr;
  17. void __iomem *vaddr;
  18. size_t sz;
  19. };
  20. struct dw_edma_core_ops {
  21. int (*irq_vector)(struct device *dev, unsigned int nr);
  22. };
  23. enum dw_edma_map_format {
  24. EDMA_MF_EDMA_LEGACY = 0x0,
  25. EDMA_MF_EDMA_UNROLL = 0x1,
  26. EDMA_MF_HDMA_COMPAT = 0x5
  27. };
  28. /**
  29. * enum dw_edma_chip_flags - Flags specific to an eDMA chip
  30. * @DW_EDMA_CHIP_LOCAL: eDMA is used locally by an endpoint
  31. */
  32. enum dw_edma_chip_flags {
  33. DW_EDMA_CHIP_LOCAL = BIT(0),
  34. };
  35. /**
  36. * struct dw_edma_chip - representation of DesignWare eDMA controller hardware
  37. * @dev: struct device of the eDMA controller
  38. * @id: instance ID
  39. * @nr_irqs: total number of DMA IRQs
  40. * @ops DMA channel to IRQ number mapping
  41. * @flags dw_edma_chip_flags
  42. * @reg_base DMA register base address
  43. * @ll_wr_cnt DMA write link list count
  44. * @ll_rd_cnt DMA read link list count
  45. * @rg_region DMA register region
  46. * @ll_region_wr DMA descriptor link list memory for write channel
  47. * @ll_region_rd DMA descriptor link list memory for read channel
  48. * @dt_region_wr DMA data memory for write channel
  49. * @dt_region_rd DMA data memory for read channel
  50. * @mf DMA register map format
  51. * @dw: struct dw_edma that is filled by dw_edma_probe()
  52. */
  53. struct dw_edma_chip {
  54. struct device *dev;
  55. int id;
  56. int nr_irqs;
  57. const struct dw_edma_core_ops *ops;
  58. u32 flags;
  59. void __iomem *reg_base;
  60. u16 ll_wr_cnt;
  61. u16 ll_rd_cnt;
  62. /* link list address */
  63. struct dw_edma_region ll_region_wr[EDMA_MAX_WR_CH];
  64. struct dw_edma_region ll_region_rd[EDMA_MAX_RD_CH];
  65. /* data region */
  66. struct dw_edma_region dt_region_wr[EDMA_MAX_WR_CH];
  67. struct dw_edma_region dt_region_rd[EDMA_MAX_RD_CH];
  68. enum dw_edma_map_format mf;
  69. struct dw_edma *dw;
  70. };
  71. /* Export to the platform drivers */
  72. #if IS_ENABLED(CONFIG_DW_EDMA)
  73. int dw_edma_probe(struct dw_edma_chip *chip);
  74. int dw_edma_remove(struct dw_edma_chip *chip);
  75. #else
  76. static inline int dw_edma_probe(struct dw_edma_chip *chip)
  77. {
  78. return -ENODEV;
  79. }
  80. static inline int dw_edma_remove(struct dw_edma_chip *chip)
  81. {
  82. return 0;
  83. }
  84. #endif /* CONFIG_DW_EDMA */
  85. #endif /* _DW_EDMA_H */