dma.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * DOC: EP93xx DMA M2P memory to peripheral and peripheral to memory engine
  3. *
  4. * The EP93xx DMA M2P subsystem handles DMA transfers between memory and
  5. * peripherals. DMA M2P channels are available for audio, UARTs and IrDA.
  6. * See chapter 10 of the EP93xx users guide for full details on the DMA M2P
  7. * engine.
  8. *
  9. * See sound/soc/ep93xx/ep93xx-pcm.c for an example use of the DMA M2P code.
  10. *
  11. */
  12. #ifndef __ASM_ARCH_DMA_H
  13. #define __ASM_ARCH_DMA_H
  14. #include <linux/list.h>
  15. #include <linux/types.h>
  16. /**
  17. * struct ep93xx_dma_buffer - Information about a buffer to be transferred
  18. * using the DMA M2P engine
  19. *
  20. * @list: Entry in DMA buffer list
  21. * @bus_addr: Physical address of the buffer
  22. * @size: Size of the buffer in bytes
  23. */
  24. struct ep93xx_dma_buffer {
  25. struct list_head list;
  26. u32 bus_addr;
  27. u16 size;
  28. };
  29. /**
  30. * struct ep93xx_dma_m2p_client - Information about a DMA M2P client
  31. *
  32. * @name: Unique name for this client
  33. * @flags: Client flags
  34. * @cookie: User data to pass to callback functions
  35. * @buffer_started: Non NULL function to call when a transfer is started.
  36. * The arguments are the user data cookie and the DMA
  37. * buffer which is starting.
  38. * @buffer_finished: Non NULL function to call when a transfer is completed.
  39. * The arguments are the user data cookie, the DMA buffer
  40. * which has completed, and a boolean flag indicating if
  41. * the transfer had an error.
  42. */
  43. struct ep93xx_dma_m2p_client {
  44. char *name;
  45. u8 flags;
  46. void *cookie;
  47. void (*buffer_started)(void *cookie,
  48. struct ep93xx_dma_buffer *buf);
  49. void (*buffer_finished)(void *cookie,
  50. struct ep93xx_dma_buffer *buf,
  51. int bytes, int error);
  52. /* private: Internal use only */
  53. void *channel;
  54. };
  55. /* DMA M2P ports */
  56. #define EP93XX_DMA_M2P_PORT_I2S1 0x00
  57. #define EP93XX_DMA_M2P_PORT_I2S2 0x01
  58. #define EP93XX_DMA_M2P_PORT_AAC1 0x02
  59. #define EP93XX_DMA_M2P_PORT_AAC2 0x03
  60. #define EP93XX_DMA_M2P_PORT_AAC3 0x04
  61. #define EP93XX_DMA_M2P_PORT_I2S3 0x05
  62. #define EP93XX_DMA_M2P_PORT_UART1 0x06
  63. #define EP93XX_DMA_M2P_PORT_UART2 0x07
  64. #define EP93XX_DMA_M2P_PORT_UART3 0x08
  65. #define EP93XX_DMA_M2P_PORT_IRDA 0x09
  66. #define EP93XX_DMA_M2P_PORT_MASK 0x0f
  67. /* DMA M2P client flags */
  68. #define EP93XX_DMA_M2P_TX 0x00 /* Memory to peripheral */
  69. #define EP93XX_DMA_M2P_RX 0x10 /* Peripheral to memory */
  70. /*
  71. * DMA M2P client error handling flags. See the EP93xx users guide
  72. * documentation on the DMA M2P CONTROL register for more details
  73. */
  74. #define EP93XX_DMA_M2P_ABORT_ON_ERROR 0x20 /* Abort on peripheral error */
  75. #define EP93XX_DMA_M2P_IGNORE_ERROR 0x40 /* Ignore peripheral errors */
  76. #define EP93XX_DMA_M2P_ERROR_MASK 0x60 /* Mask of error bits */
  77. /**
  78. * ep93xx_dma_m2p_client_register - Register a client with the DMA M2P
  79. * subsystem
  80. *
  81. * @m2p: Client information to register
  82. * returns 0 on success
  83. *
  84. * The DMA M2P subsystem allocates a channel and an interrupt line for the DMA
  85. * client
  86. */
  87. int ep93xx_dma_m2p_client_register(struct ep93xx_dma_m2p_client *m2p);
  88. /**
  89. * ep93xx_dma_m2p_client_unregister - Unregister a client from the DMA M2P
  90. * subsystem
  91. *
  92. * @m2p: Client to unregister
  93. *
  94. * Any transfers currently in progress will be completed in hardware, but
  95. * ignored in software.
  96. */
  97. void ep93xx_dma_m2p_client_unregister(struct ep93xx_dma_m2p_client *m2p);
  98. /**
  99. * ep93xx_dma_m2p_submit - Submit a DMA M2P transfer
  100. *
  101. * @m2p: DMA Client to submit the transfer on
  102. * @buf: DMA Buffer to submit
  103. *
  104. * If the current or next transfer positions are free on the M2P client then
  105. * the transfer is started immediately. If not, the transfer is added to the
  106. * list of pending transfers. This function must not be called from the
  107. * buffer_finished callback for an M2P channel.
  108. *
  109. */
  110. void ep93xx_dma_m2p_submit(struct ep93xx_dma_m2p_client *m2p,
  111. struct ep93xx_dma_buffer *buf);
  112. /**
  113. * ep93xx_dma_m2p_submit_recursive - Put a DMA transfer on the pending list
  114. * for an M2P channel
  115. *
  116. * @m2p: DMA Client to submit the transfer on
  117. * @buf: DMA Buffer to submit
  118. *
  119. * This function must only be called from the buffer_finished callback for an
  120. * M2P channel. It is commonly used to add the next transfer in a chained list
  121. * of DMA transfers.
  122. */
  123. void ep93xx_dma_m2p_submit_recursive(struct ep93xx_dma_m2p_client *m2p,
  124. struct ep93xx_dma_buffer *buf);
  125. /**
  126. * ep93xx_dma_m2p_flush - Flush all pending transfers on a DMA M2P client
  127. *
  128. * @m2p: DMA client to flush transfers on
  129. *
  130. * Any transfers currently in progress will be completed in hardware, but
  131. * ignored in software.
  132. *
  133. */
  134. void ep93xx_dma_m2p_flush(struct ep93xx_dma_m2p_client *m2p);
  135. #endif /* __ASM_ARCH_DMA_H */