dw_dmac.h 4.1 KB

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