edma.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * TI EDMA definitions
  3. *
  4. * Copyright (C) 2006-2013 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. /*
  12. * This EDMA3 programming framework exposes two basic kinds of resource:
  13. *
  14. * Channel Triggers transfers, usually from a hardware event but
  15. * also manually or by "chaining" from DMA completions.
  16. * Each channel is coupled to a Parameter RAM (PaRAM) slot.
  17. *
  18. * Slot Each PaRAM slot holds a DMA transfer descriptor (PaRAM
  19. * "set"), source and destination addresses, a link to a
  20. * next PaRAM slot (if any), options for the transfer, and
  21. * instructions for updating those addresses. There are
  22. * more than twice as many slots as event channels.
  23. *
  24. * Each PaRAM set describes a sequence of transfers, either for one large
  25. * buffer or for several discontiguous smaller buffers. An EDMA transfer
  26. * is driven only from a channel, which performs the transfers specified
  27. * in its PaRAM slot until there are no more transfers. When that last
  28. * transfer completes, the "link" field may be used to reload the channel's
  29. * PaRAM slot with a new transfer descriptor.
  30. *
  31. * The EDMA Channel Controller (CC) maps requests from channels into physical
  32. * Transfer Controller (TC) requests when the channel triggers (by hardware
  33. * or software events, or by chaining). The two physical DMA channels provided
  34. * by the TCs are thus shared by many logical channels.
  35. *
  36. * DaVinci hardware also has a "QDMA" mechanism which is not currently
  37. * supported through this interface. (DSP firmware uses it though.)
  38. */
  39. #ifndef EDMA_H_
  40. #define EDMA_H_
  41. /* PaRAM slots are laid out like this */
  42. struct edmacc_param {
  43. unsigned int opt;
  44. unsigned int src;
  45. unsigned int a_b_cnt;
  46. unsigned int dst;
  47. unsigned int src_dst_bidx;
  48. unsigned int link_bcntrld;
  49. unsigned int src_dst_cidx;
  50. unsigned int ccnt;
  51. };
  52. /* fields in edmacc_param.opt */
  53. #define SAM BIT(0)
  54. #define DAM BIT(1)
  55. #define SYNCDIM BIT(2)
  56. #define STATIC BIT(3)
  57. #define EDMA_FWID (0x07 << 8)
  58. #define TCCMODE BIT(11)
  59. #define EDMA_TCC(t) ((t) << 12)
  60. #define TCINTEN BIT(20)
  61. #define ITCINTEN BIT(21)
  62. #define TCCHEN BIT(22)
  63. #define ITCCHEN BIT(23)
  64. /*ch_status paramater of callback function possible values*/
  65. #define DMA_COMPLETE 1
  66. #define DMA_CC_ERROR 2
  67. #define DMA_TC1_ERROR 3
  68. #define DMA_TC2_ERROR 4
  69. enum address_mode {
  70. INCR = 0,
  71. FIFO = 1
  72. };
  73. enum fifo_width {
  74. W8BIT = 0,
  75. W16BIT = 1,
  76. W32BIT = 2,
  77. W64BIT = 3,
  78. W128BIT = 4,
  79. W256BIT = 5
  80. };
  81. enum dma_event_q {
  82. EVENTQ_0 = 0,
  83. EVENTQ_1 = 1,
  84. EVENTQ_2 = 2,
  85. EVENTQ_3 = 3,
  86. EVENTQ_DEFAULT = -1
  87. };
  88. enum sync_dimension {
  89. ASYNC = 0,
  90. ABSYNC = 1
  91. };
  92. #define EDMA_CTLR_CHAN(ctlr, chan) (((ctlr) << 16) | (chan))
  93. #define EDMA_CTLR(i) ((i) >> 16)
  94. #define EDMA_CHAN_SLOT(i) ((i) & 0xffff)
  95. #define EDMA_CHANNEL_ANY -1 /* for edma_alloc_channel() */
  96. #define EDMA_SLOT_ANY -1 /* for edma_alloc_slot() */
  97. #define EDMA_CONT_PARAMS_ANY 1001
  98. #define EDMA_CONT_PARAMS_FIXED_EXACT 1002
  99. #define EDMA_CONT_PARAMS_FIXED_NOT_EXACT 1003
  100. #define EDMA_MAX_CC 2
  101. /* alloc/free DMA channels and their dedicated parameter RAM slots */
  102. int edma_alloc_channel(int channel,
  103. void (*callback)(unsigned channel, u16 ch_status, void *data),
  104. void *data, enum dma_event_q);
  105. void edma_free_channel(unsigned channel);
  106. /* alloc/free parameter RAM slots */
  107. int edma_alloc_slot(unsigned ctlr, int slot);
  108. void edma_free_slot(unsigned slot);
  109. /* alloc/free a set of contiguous parameter RAM slots */
  110. int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count);
  111. int edma_free_cont_slots(unsigned slot, int count);
  112. /* calls that operate on part of a parameter RAM slot */
  113. void edma_set_src(unsigned slot, dma_addr_t src_port,
  114. enum address_mode mode, enum fifo_width);
  115. void edma_set_dest(unsigned slot, dma_addr_t dest_port,
  116. enum address_mode mode, enum fifo_width);
  117. void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst);
  118. void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx);
  119. void edma_set_dest_index(unsigned slot, s16 dest_bidx, s16 dest_cidx);
  120. void edma_set_transfer_params(unsigned slot, u16 acnt, u16 bcnt, u16 ccnt,
  121. u16 bcnt_rld, enum sync_dimension sync_mode);
  122. void edma_link(unsigned from, unsigned to);
  123. void edma_unlink(unsigned from);
  124. /* calls that operate on an entire parameter RAM slot */
  125. void edma_write_slot(unsigned slot, const struct edmacc_param *params);
  126. void edma_read_slot(unsigned slot, struct edmacc_param *params);
  127. /* channel control operations */
  128. int edma_start(unsigned channel);
  129. void edma_stop(unsigned channel);
  130. void edma_clean_channel(unsigned channel);
  131. void edma_clear_event(unsigned channel);
  132. void edma_pause(unsigned channel);
  133. void edma_resume(unsigned channel);
  134. struct edma_rsv_info {
  135. const s16 (*rsv_chans)[2];
  136. const s16 (*rsv_slots)[2];
  137. };
  138. /* platform_data for EDMA driver */
  139. struct edma_soc_info {
  140. /* how many dma resources of each type */
  141. unsigned n_channel;
  142. unsigned n_region;
  143. unsigned n_slot;
  144. unsigned n_tc;
  145. unsigned n_cc;
  146. /*
  147. * Default queue is expected to be a low-priority queue.
  148. * This way, long transfers on the default queue started
  149. * by the codec engine will not cause audio defects.
  150. */
  151. enum dma_event_q default_queue;
  152. /* Resource reservation for other cores */
  153. struct edma_rsv_info *rsv;
  154. s8 (*queue_tc_mapping)[2];
  155. s8 (*queue_priority_mapping)[2];
  156. const s16 (*xbar_chans)[2];
  157. };
  158. #endif