dw_dmac.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. */
  18. struct dw_dma_platform_data {
  19. unsigned int nr_channels;
  20. };
  21. /**
  22. * enum dw_dma_slave_width - DMA slave register access width.
  23. * @DMA_SLAVE_WIDTH_8BIT: Do 8-bit slave register accesses
  24. * @DMA_SLAVE_WIDTH_16BIT: Do 16-bit slave register accesses
  25. * @DMA_SLAVE_WIDTH_32BIT: Do 32-bit slave register accesses
  26. */
  27. enum dw_dma_slave_width {
  28. DW_DMA_SLAVE_WIDTH_8BIT,
  29. DW_DMA_SLAVE_WIDTH_16BIT,
  30. DW_DMA_SLAVE_WIDTH_32BIT,
  31. };
  32. /**
  33. * struct dw_dma_slave - Controller-specific information about a slave
  34. *
  35. * @dma_dev: required DMA master device
  36. * @tx_reg: physical address of data register used for
  37. * memory-to-peripheral transfers
  38. * @rx_reg: physical address of data register used for
  39. * peripheral-to-memory transfers
  40. * @reg_width: peripheral register width
  41. * @cfg_hi: Platform-specific initializer for the CFG_HI register
  42. * @cfg_lo: Platform-specific initializer for the CFG_LO register
  43. */
  44. struct dw_dma_slave {
  45. struct device *dma_dev;
  46. dma_addr_t tx_reg;
  47. dma_addr_t rx_reg;
  48. enum dw_dma_slave_width reg_width;
  49. u32 cfg_hi;
  50. u32 cfg_lo;
  51. };
  52. /* Platform-configurable bits in CFG_HI */
  53. #define DWC_CFGH_FCMODE (1 << 0)
  54. #define DWC_CFGH_FIFO_MODE (1 << 1)
  55. #define DWC_CFGH_PROTCTL(x) ((x) << 2)
  56. #define DWC_CFGH_SRC_PER(x) ((x) << 7)
  57. #define DWC_CFGH_DST_PER(x) ((x) << 11)
  58. /* Platform-configurable bits in CFG_LO */
  59. #define DWC_CFGL_PRIO(x) ((x) << 5) /* priority */
  60. #define DWC_CFGL_LOCK_CH_XFER (0 << 12) /* scope of LOCK_CH */
  61. #define DWC_CFGL_LOCK_CH_BLOCK (1 << 12)
  62. #define DWC_CFGL_LOCK_CH_XACT (2 << 12)
  63. #define DWC_CFGL_LOCK_BUS_XFER (0 << 14) /* scope of LOCK_BUS */
  64. #define DWC_CFGL_LOCK_BUS_BLOCK (1 << 14)
  65. #define DWC_CFGL_LOCK_BUS_XACT (2 << 14)
  66. #define DWC_CFGL_LOCK_CH (1 << 15) /* channel lockout */
  67. #define DWC_CFGL_LOCK_BUS (1 << 16) /* busmaster lockout */
  68. #define DWC_CFGL_HS_DST_POL (1 << 18) /* dst handshake active low */
  69. #define DWC_CFGL_HS_SRC_POL (1 << 19) /* src handshake active low */
  70. /* DMA API extensions */
  71. struct dw_cyclic_desc {
  72. struct dw_desc **desc;
  73. unsigned long periods;
  74. void (*period_callback)(void *param);
  75. void *period_callback_param;
  76. };
  77. struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,
  78. dma_addr_t buf_addr, size_t buf_len, size_t period_len,
  79. enum dma_data_direction direction);
  80. void dw_dma_cyclic_free(struct dma_chan *chan);
  81. int dw_dma_cyclic_start(struct dma_chan *chan);
  82. void dw_dma_cyclic_stop(struct dma_chan *chan);
  83. dma_addr_t dw_dma_get_src_addr(struct dma_chan *chan);
  84. dma_addr_t dw_dma_get_dst_addr(struct dma_chan *chan);
  85. #endif /* DW_DMAC_H */