dw_dmac.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. /* bursts size */
  32. enum dw_dma_msize {
  33. DW_DMA_MSIZE_1,
  34. DW_DMA_MSIZE_4,
  35. DW_DMA_MSIZE_8,
  36. DW_DMA_MSIZE_16,
  37. DW_DMA_MSIZE_32,
  38. DW_DMA_MSIZE_64,
  39. DW_DMA_MSIZE_128,
  40. DW_DMA_MSIZE_256,
  41. };
  42. /**
  43. * struct dw_dma_slave - Controller-specific information about a slave
  44. *
  45. * @dma_dev: required DMA master device
  46. * @cfg_hi: Platform-specific initializer for the CFG_HI register
  47. * @cfg_lo: Platform-specific initializer for the CFG_LO register
  48. * @src_master: src master for transfers on allocated channel.
  49. * @dst_master: dest master for transfers on allocated channel.
  50. */
  51. struct dw_dma_slave {
  52. struct device *dma_dev;
  53. u32 cfg_hi;
  54. u32 cfg_lo;
  55. u8 src_master;
  56. u8 dst_master;
  57. };
  58. /* Platform-configurable bits in CFG_HI */
  59. #define DWC_CFGH_FCMODE (1 << 0)
  60. #define DWC_CFGH_FIFO_MODE (1 << 1)
  61. #define DWC_CFGH_PROTCTL(x) ((x) << 2)
  62. #define DWC_CFGH_SRC_PER(x) ((x) << 7)
  63. #define DWC_CFGH_DST_PER(x) ((x) << 11)
  64. /* Platform-configurable bits in CFG_LO */
  65. #define DWC_CFGL_LOCK_CH_XFER (0 << 12) /* scope of LOCK_CH */
  66. #define DWC_CFGL_LOCK_CH_BLOCK (1 << 12)
  67. #define DWC_CFGL_LOCK_CH_XACT (2 << 12)
  68. #define DWC_CFGL_LOCK_BUS_XFER (0 << 14) /* scope of LOCK_BUS */
  69. #define DWC_CFGL_LOCK_BUS_BLOCK (1 << 14)
  70. #define DWC_CFGL_LOCK_BUS_XACT (2 << 14)
  71. #define DWC_CFGL_LOCK_CH (1 << 15) /* channel lockout */
  72. #define DWC_CFGL_LOCK_BUS (1 << 16) /* busmaster lockout */
  73. #define DWC_CFGL_HS_DST_POL (1 << 18) /* dst handshake active low */
  74. #define DWC_CFGL_HS_SRC_POL (1 << 19) /* src handshake active low */
  75. /* DMA API extensions */
  76. struct dw_cyclic_desc {
  77. struct dw_desc **desc;
  78. unsigned long periods;
  79. void (*period_callback)(void *param);
  80. void *period_callback_param;
  81. };
  82. struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,
  83. dma_addr_t buf_addr, size_t buf_len, size_t period_len,
  84. enum dma_transfer_direction direction);
  85. void dw_dma_cyclic_free(struct dma_chan *chan);
  86. int dw_dma_cyclic_start(struct dma_chan *chan);
  87. void dw_dma_cyclic_stop(struct dma_chan *chan);
  88. dma_addr_t dw_dma_get_src_addr(struct dma_chan *chan);
  89. dma_addr_t dw_dma_get_dst_addr(struct dma_chan *chan);
  90. #endif /* DW_DMAC_H */