dw_dmac.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
  3. * AVR32 systems.)
  4. *
  5. * Copyright (C) 2007 Atmel Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef DW_DMAC_H
  12. #define DW_DMAC_H
  13. #include <linux/dmaengine.h>
  14. /**
  15. * struct dw_dma_platform_data - Controller configuration parameters
  16. * @nr_channels: Number of channels supported by hardware (max 8)
  17. * @is_private: The device channels should be marked as private and not for
  18. * by the general purpose DMA channel allocator.
  19. */
  20. struct dw_dma_platform_data {
  21. unsigned int nr_channels;
  22. bool is_private;
  23. #define CHAN_ALLOCATION_ASCENDING 0 /* zero to seven */
  24. #define CHAN_ALLOCATION_DESCENDING 1 /* seven to zero */
  25. unsigned char chan_allocation_order;
  26. #define CHAN_PRIORITY_ASCENDING 0 /* chan0 highest */
  27. #define CHAN_PRIORITY_DESCENDING 1 /* chan7 highest */
  28. unsigned char chan_priority;
  29. };
  30. /**
  31. * enum dw_dma_slave_width - DMA slave register access width.
  32. * @DMA_SLAVE_WIDTH_8BIT: Do 8-bit slave register accesses
  33. * @DMA_SLAVE_WIDTH_16BIT: Do 16-bit slave register accesses
  34. * @DMA_SLAVE_WIDTH_32BIT: Do 32-bit slave register accesses
  35. */
  36. enum dw_dma_slave_width {
  37. DW_DMA_SLAVE_WIDTH_8BIT,
  38. DW_DMA_SLAVE_WIDTH_16BIT,
  39. DW_DMA_SLAVE_WIDTH_32BIT,
  40. };
  41. /* bursts size */
  42. enum dw_dma_msize {
  43. DW_DMA_MSIZE_1,
  44. DW_DMA_MSIZE_4,
  45. DW_DMA_MSIZE_8,
  46. DW_DMA_MSIZE_16,
  47. DW_DMA_MSIZE_32,
  48. DW_DMA_MSIZE_64,
  49. DW_DMA_MSIZE_128,
  50. DW_DMA_MSIZE_256,
  51. };
  52. /* flow controller */
  53. enum dw_dma_fc {
  54. DW_DMA_FC_D_M2M,
  55. DW_DMA_FC_D_M2P,
  56. DW_DMA_FC_D_P2M,
  57. DW_DMA_FC_D_P2P,
  58. DW_DMA_FC_P_P2M,
  59. DW_DMA_FC_SP_P2P,
  60. DW_DMA_FC_P_M2P,
  61. DW_DMA_FC_DP_P2P,
  62. };
  63. /**
  64. * struct dw_dma_slave - Controller-specific information about a slave
  65. *
  66. * @dma_dev: required DMA master device
  67. * @tx_reg: physical address of data register used for
  68. * memory-to-peripheral transfers
  69. * @rx_reg: physical address of data register used for
  70. * peripheral-to-memory transfers
  71. * @reg_width: peripheral register width
  72. * @cfg_hi: Platform-specific initializer for the CFG_HI register
  73. * @cfg_lo: Platform-specific initializer for the CFG_LO register
  74. * @src_master: src master for transfers on allocated channel.
  75. * @dst_master: dest master for transfers on allocated channel.
  76. * @src_msize: src burst size.
  77. * @dst_msize: dest burst size.
  78. * @fc: flow controller for DMA transfer
  79. */
  80. struct dw_dma_slave {
  81. struct device *dma_dev;
  82. dma_addr_t tx_reg;
  83. dma_addr_t rx_reg;
  84. enum dw_dma_slave_width reg_width;
  85. u32 cfg_hi;
  86. u32 cfg_lo;
  87. u8 src_master;
  88. u8 dst_master;
  89. u8 src_msize;
  90. u8 dst_msize;
  91. u8 fc;
  92. };
  93. /* Platform-configurable bits in CFG_HI */
  94. #define DWC_CFGH_FCMODE (1 << 0)
  95. #define DWC_CFGH_FIFO_MODE (1 << 1)
  96. #define DWC_CFGH_PROTCTL(x) ((x) << 2)
  97. #define DWC_CFGH_SRC_PER(x) ((x) << 7)
  98. #define DWC_CFGH_DST_PER(x) ((x) << 11)
  99. /* Platform-configurable bits in CFG_LO */
  100. #define DWC_CFGL_LOCK_CH_XFER (0 << 12) /* scope of LOCK_CH */
  101. #define DWC_CFGL_LOCK_CH_BLOCK (1 << 12)
  102. #define DWC_CFGL_LOCK_CH_XACT (2 << 12)
  103. #define DWC_CFGL_LOCK_BUS_XFER (0 << 14) /* scope of LOCK_BUS */
  104. #define DWC_CFGL_LOCK_BUS_BLOCK (1 << 14)
  105. #define DWC_CFGL_LOCK_BUS_XACT (2 << 14)
  106. #define DWC_CFGL_LOCK_CH (1 << 15) /* channel lockout */
  107. #define DWC_CFGL_LOCK_BUS (1 << 16) /* busmaster lockout */
  108. #define DWC_CFGL_HS_DST_POL (1 << 18) /* dst handshake active low */
  109. #define DWC_CFGL_HS_SRC_POL (1 << 19) /* src handshake active low */
  110. /* DMA API extensions */
  111. struct dw_cyclic_desc {
  112. struct dw_desc **desc;
  113. unsigned long periods;
  114. void (*period_callback)(void *param);
  115. void *period_callback_param;
  116. };
  117. struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,
  118. dma_addr_t buf_addr, size_t buf_len, size_t period_len,
  119. enum dma_data_direction direction);
  120. void dw_dma_cyclic_free(struct dma_chan *chan);
  121. int dw_dma_cyclic_start(struct dma_chan *chan);
  122. void dw_dma_cyclic_stop(struct dma_chan *chan);
  123. dma_addr_t dw_dma_get_src_addr(struct dma_chan *chan);
  124. dma_addr_t dw_dma_get_dst_addr(struct dma_chan *chan);
  125. #endif /* DW_DMAC_H */