edma.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * TI DAVINCI dma definitions
  3. *
  4. * Copyright (C) 2006-2009 Texas Instruments.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  12. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  14. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  15. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  16. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  18. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  20. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. *
  22. * You should have received a copy of the GNU General Public License along
  23. * with this program; if not, write to the Free Software Foundation, Inc.,
  24. * 675 Mass Ave, Cambridge, MA 02139, USA.
  25. *
  26. */
  27. /*
  28. * This EDMA3 programming framework exposes two basic kinds of resource:
  29. *
  30. * Channel Triggers transfers, usually from a hardware event but
  31. * also manually or by "chaining" from DMA completions.
  32. * Each channel is coupled to a Parameter RAM (PaRAM) slot.
  33. *
  34. * Slot Each PaRAM slot holds a DMA transfer descriptor (PaRAM
  35. * "set"), source and destination addresses, a link to a
  36. * next PaRAM slot (if any), options for the transfer, and
  37. * instructions for updating those addresses. There are
  38. * more than twice as many slots as event channels.
  39. *
  40. * Each PaRAM set describes a sequence of transfers, either for one large
  41. * buffer or for several discontiguous smaller buffers. An EDMA transfer
  42. * is driven only from a channel, which performs the transfers specified
  43. * in its PaRAM slot until there are no more transfers. When that last
  44. * transfer completes, the "link" field may be used to reload the channel's
  45. * PaRAM slot with a new transfer descriptor.
  46. *
  47. * The EDMA Channel Controller (CC) maps requests from channels into physical
  48. * Transfer Controller (TC) requests when the channel triggers (by hardware
  49. * or software events, or by chaining). The two physical DMA channels provided
  50. * by the TCs are thus shared by many logical channels.
  51. *
  52. * DaVinci hardware also has a "QDMA" mechanism which is not currently
  53. * supported through this interface. (DSP firmware uses it though.)
  54. */
  55. #ifndef EDMA_H_
  56. #define EDMA_H_
  57. /* PaRAM slots are laid out like this */
  58. struct edmacc_param {
  59. unsigned int opt;
  60. unsigned int src;
  61. unsigned int a_b_cnt;
  62. unsigned int dst;
  63. unsigned int src_dst_bidx;
  64. unsigned int link_bcntrld;
  65. unsigned int src_dst_cidx;
  66. unsigned int ccnt;
  67. };
  68. #define CCINT0_INTERRUPT 16
  69. #define CCERRINT_INTERRUPT 17
  70. #define TCERRINT0_INTERRUPT 18
  71. #define TCERRINT1_INTERRUPT 19
  72. /* fields in edmacc_param.opt */
  73. #define SAM BIT(0)
  74. #define DAM BIT(1)
  75. #define SYNCDIM BIT(2)
  76. #define STATIC BIT(3)
  77. #define EDMA_FWID (0x07 << 8)
  78. #define TCCMODE BIT(11)
  79. #define EDMA_TCC(t) ((t) << 12)
  80. #define TCINTEN BIT(20)
  81. #define ITCINTEN BIT(21)
  82. #define TCCHEN BIT(22)
  83. #define ITCCHEN BIT(23)
  84. #define TRWORD (0x7<<2)
  85. #define PAENTRY (0x1ff<<5)
  86. /* Drivers should avoid using these symbolic names for dm644x
  87. * channels, and use platform_device IORESOURCE_DMA resources
  88. * instead. (Other DaVinci chips have different peripherals
  89. * and thus have different DMA channel mappings.)
  90. */
  91. #define DAVINCI_DMA_MCBSP_TX 2
  92. #define DAVINCI_DMA_MCBSP_RX 3
  93. #define DAVINCI_DMA_VPSS_HIST 4
  94. #define DAVINCI_DMA_VPSS_H3A 5
  95. #define DAVINCI_DMA_VPSS_PRVU 6
  96. #define DAVINCI_DMA_VPSS_RSZ 7
  97. #define DAVINCI_DMA_IMCOP_IMXINT 8
  98. #define DAVINCI_DMA_IMCOP_VLCDINT 9
  99. #define DAVINCI_DMA_IMCO_PASQINT 10
  100. #define DAVINCI_DMA_IMCOP_DSQINT 11
  101. #define DAVINCI_DMA_SPI_SPIX 16
  102. #define DAVINCI_DMA_SPI_SPIR 17
  103. #define DAVINCI_DMA_UART0_URXEVT0 18
  104. #define DAVINCI_DMA_UART0_UTXEVT0 19
  105. #define DAVINCI_DMA_UART1_URXEVT1 20
  106. #define DAVINCI_DMA_UART1_UTXEVT1 21
  107. #define DAVINCI_DMA_UART2_URXEVT2 22
  108. #define DAVINCI_DMA_UART2_UTXEVT2 23
  109. #define DAVINCI_DMA_MEMSTK_MSEVT 24
  110. #define DAVINCI_DMA_MMCRXEVT 26
  111. #define DAVINCI_DMA_MMCTXEVT 27
  112. #define DAVINCI_DMA_I2C_ICREVT 28
  113. #define DAVINCI_DMA_I2C_ICXEVT 29
  114. #define DAVINCI_DMA_GPIO_GPINT0 32
  115. #define DAVINCI_DMA_GPIO_GPINT1 33
  116. #define DAVINCI_DMA_GPIO_GPINT2 34
  117. #define DAVINCI_DMA_GPIO_GPINT3 35
  118. #define DAVINCI_DMA_GPIO_GPINT4 36
  119. #define DAVINCI_DMA_GPIO_GPINT5 37
  120. #define DAVINCI_DMA_GPIO_GPINT6 38
  121. #define DAVINCI_DMA_GPIO_GPINT7 39
  122. #define DAVINCI_DMA_GPIO_GPBNKINT0 40
  123. #define DAVINCI_DMA_GPIO_GPBNKINT1 41
  124. #define DAVINCI_DMA_GPIO_GPBNKINT2 42
  125. #define DAVINCI_DMA_GPIO_GPBNKINT3 43
  126. #define DAVINCI_DMA_GPIO_GPBNKINT4 44
  127. #define DAVINCI_DMA_TIMER0_TINT0 48
  128. #define DAVINCI_DMA_TIMER1_TINT1 49
  129. #define DAVINCI_DMA_TIMER2_TINT2 50
  130. #define DAVINCI_DMA_TIMER3_TINT3 51
  131. #define DAVINCI_DMA_PWM0 52
  132. #define DAVINCI_DMA_PWM1 53
  133. #define DAVINCI_DMA_PWM2 54
  134. /* DA830 specific EDMA3 information */
  135. #define EDMA_DA830_NUM_DMACH 32
  136. #define EDMA_DA830_NUM_TCC 32
  137. #define EDMA_DA830_NUM_PARAMENTRY 128
  138. #define EDMA_DA830_NUM_EVQUE 2
  139. #define EDMA_DA830_NUM_TC 2
  140. #define EDMA_DA830_CHMAP_EXIST 0
  141. #define EDMA_DA830_NUM_REGIONS 4
  142. #define DA830_DMACH2EVENT_MAP0 0x000FC03Fu
  143. #define DA830_DMACH2EVENT_MAP1 0x00000000u
  144. #define DA830_EDMA_ARM_OWN 0x30FFCCFFu
  145. /*ch_status paramater of callback function possible values*/
  146. #define DMA_COMPLETE 1
  147. #define DMA_CC_ERROR 2
  148. #define DMA_TC1_ERROR 3
  149. #define DMA_TC2_ERROR 4
  150. enum address_mode {
  151. INCR = 0,
  152. FIFO = 1
  153. };
  154. enum fifo_width {
  155. W8BIT = 0,
  156. W16BIT = 1,
  157. W32BIT = 2,
  158. W64BIT = 3,
  159. W128BIT = 4,
  160. W256BIT = 5
  161. };
  162. enum dma_event_q {
  163. EVENTQ_0 = 0,
  164. EVENTQ_1 = 1,
  165. EVENTQ_2 = 2,
  166. EVENTQ_3 = 3,
  167. EVENTQ_DEFAULT = -1
  168. };
  169. enum sync_dimension {
  170. ASYNC = 0,
  171. ABSYNC = 1
  172. };
  173. #define EDMA_CTLR_CHAN(ctlr, chan) (((ctlr) << 16) | (chan))
  174. #define EDMA_CTLR(i) ((i) >> 16)
  175. #define EDMA_CHAN_SLOT(i) ((i) & 0xffff)
  176. #define EDMA_CHANNEL_ANY -1 /* for edma_alloc_channel() */
  177. #define EDMA_SLOT_ANY -1 /* for edma_alloc_slot() */
  178. #define EDMA_CONT_PARAMS_ANY 1001
  179. #define EDMA_CONT_PARAMS_FIXED_EXACT 1002
  180. #define EDMA_CONT_PARAMS_FIXED_NOT_EXACT 1003
  181. #define EDMA_MAX_CC 2
  182. /* alloc/free DMA channels and their dedicated parameter RAM slots */
  183. int edma_alloc_channel(int channel,
  184. void (*callback)(unsigned channel, u16 ch_status, void *data),
  185. void *data, enum dma_event_q);
  186. void edma_free_channel(unsigned channel);
  187. /* alloc/free parameter RAM slots */
  188. int edma_alloc_slot(unsigned ctlr, int slot);
  189. void edma_free_slot(unsigned slot);
  190. /* alloc/free a set of contiguous parameter RAM slots */
  191. int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count);
  192. int edma_free_cont_slots(unsigned slot, int count);
  193. /* calls that operate on part of a parameter RAM slot */
  194. void edma_set_src(unsigned slot, dma_addr_t src_port,
  195. enum address_mode mode, enum fifo_width);
  196. void edma_set_dest(unsigned slot, dma_addr_t dest_port,
  197. enum address_mode mode, enum fifo_width);
  198. void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst);
  199. void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx);
  200. void edma_set_dest_index(unsigned slot, s16 dest_bidx, s16 dest_cidx);
  201. void edma_set_transfer_params(unsigned slot, u16 acnt, u16 bcnt, u16 ccnt,
  202. u16 bcnt_rld, enum sync_dimension sync_mode);
  203. void edma_link(unsigned from, unsigned to);
  204. void edma_unlink(unsigned from);
  205. /* calls that operate on an entire parameter RAM slot */
  206. void edma_write_slot(unsigned slot, const struct edmacc_param *params);
  207. void edma_read_slot(unsigned slot, struct edmacc_param *params);
  208. /* channel control operations */
  209. int edma_start(unsigned channel);
  210. void edma_stop(unsigned channel);
  211. void edma_clean_channel(unsigned channel);
  212. void edma_clear_event(unsigned channel);
  213. void edma_pause(unsigned channel);
  214. void edma_resume(unsigned channel);
  215. struct edma_rsv_info {
  216. const s16 (*rsv_chans)[2];
  217. const s16 (*rsv_slots)[2];
  218. };
  219. /* platform_data for EDMA driver */
  220. struct edma_soc_info {
  221. /* how many dma resources of each type */
  222. unsigned n_channel;
  223. unsigned n_region;
  224. unsigned n_slot;
  225. unsigned n_tc;
  226. unsigned n_cc;
  227. /*
  228. * Default queue is expected to be a low-priority queue.
  229. * This way, long transfers on the default queue started
  230. * by the codec engine will not cause audio defects.
  231. */
  232. enum dma_event_q default_queue;
  233. /* Resource reservation for other cores */
  234. struct edma_rsv_info *rsv;
  235. const s8 (*queue_tc_mapping)[2];
  236. const s8 (*queue_priority_mapping)[2];
  237. };
  238. #endif