dma.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /* arch/arm/mach-s3c2410/include/mach/dma.h
  2. *
  3. * Copyright (C) 2003-2006 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * Samsung S3C24XX DMA support
  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 __ASM_ARCH_DMA_H
  13. #define __ASM_ARCH_DMA_H __FILE__
  14. #include <linux/device.h>
  15. #define MAX_DMA_TRANSFER_SIZE 0x100000 /* Data Unit is half word */
  16. /* We use `virtual` dma channels to hide the fact we have only a limited
  17. * number of DMA channels, and not of all of them (dependent on the device)
  18. * can be attached to any DMA source. We therefore let the DMA core handle
  19. * the allocation of hardware channels to clients.
  20. */
  21. enum dma_ch {
  22. DMACH_DT_PROP = -1, /* not yet supported, do not use */
  23. DMACH_XD0 = 0,
  24. DMACH_XD1,
  25. DMACH_SDI,
  26. DMACH_SPI0,
  27. DMACH_SPI1,
  28. DMACH_UART0,
  29. DMACH_UART1,
  30. DMACH_UART2,
  31. DMACH_TIMER,
  32. DMACH_I2S_IN,
  33. DMACH_I2S_OUT,
  34. DMACH_PCM_IN,
  35. DMACH_PCM_OUT,
  36. DMACH_MIC_IN,
  37. DMACH_USB_EP1,
  38. DMACH_USB_EP2,
  39. DMACH_USB_EP3,
  40. DMACH_USB_EP4,
  41. DMACH_UART0_SRC2, /* s3c2412 second uart sources */
  42. DMACH_UART1_SRC2,
  43. DMACH_UART2_SRC2,
  44. DMACH_UART3, /* s3c2443 has extra uart */
  45. DMACH_UART3_SRC2,
  46. DMACH_SPI0_TX, /* s3c2443/2416/2450 hsspi0 */
  47. DMACH_SPI0_RX, /* s3c2443/2416/2450 hsspi0 */
  48. DMACH_SPI1_TX, /* s3c2443/2450 hsspi1 */
  49. DMACH_SPI1_RX, /* s3c2443/2450 hsspi1 */
  50. DMACH_MAX, /* the end entry */
  51. };
  52. static inline bool samsung_dma_has_circular(void)
  53. {
  54. return false;
  55. }
  56. static inline bool samsung_dma_is_dmadev(void)
  57. {
  58. return false;
  59. }
  60. #include <plat/dma.h>
  61. #define DMACH_LOW_LEVEL (1<<28) /* use this to specifiy hardware ch no */
  62. /* we have 4 dma channels */
  63. #if !defined(CONFIG_CPU_S3C2443) && !defined(CONFIG_CPU_S3C2416)
  64. #define S3C_DMA_CHANNELS (4)
  65. #else
  66. #define S3C_DMA_CHANNELS (6)
  67. #endif
  68. /* types */
  69. enum s3c2410_dma_state {
  70. S3C2410_DMA_IDLE,
  71. S3C2410_DMA_RUNNING,
  72. S3C2410_DMA_PAUSED
  73. };
  74. /* enum s3c2410_dma_loadst
  75. *
  76. * This represents the state of the DMA engine, wrt to the loaded / running
  77. * transfers. Since we don't have any way of knowing exactly the state of
  78. * the DMA transfers, we need to know the state to make decisions on whether
  79. * we can
  80. *
  81. * S3C2410_DMA_NONE
  82. *
  83. * There are no buffers loaded (the channel should be inactive)
  84. *
  85. * S3C2410_DMA_1LOADED
  86. *
  87. * There is one buffer loaded, however it has not been confirmed to be
  88. * loaded by the DMA engine. This may be because the channel is not
  89. * yet running, or the DMA driver decided that it was too costly to
  90. * sit and wait for it to happen.
  91. *
  92. * S3C2410_DMA_1RUNNING
  93. *
  94. * The buffer has been confirmed running, and not finisged
  95. *
  96. * S3C2410_DMA_1LOADED_1RUNNING
  97. *
  98. * There is a buffer waiting to be loaded by the DMA engine, and one
  99. * currently running.
  100. */
  101. enum s3c2410_dma_loadst {
  102. S3C2410_DMALOAD_NONE,
  103. S3C2410_DMALOAD_1LOADED,
  104. S3C2410_DMALOAD_1RUNNING,
  105. S3C2410_DMALOAD_1LOADED_1RUNNING,
  106. };
  107. /* flags */
  108. #define S3C2410_DMAF_SLOW (1<<0) /* slow, so don't worry about
  109. * waiting for reloads */
  110. #define S3C2410_DMAF_AUTOSTART (1<<1) /* auto-start if buffer queued */
  111. #define S3C2410_DMAF_CIRCULAR (1 << 2) /* no circular dma support */
  112. /* dma buffer */
  113. struct s3c2410_dma_buf;
  114. /* s3c2410_dma_buf
  115. *
  116. * internally used buffer structure to describe a queued or running
  117. * buffer.
  118. */
  119. struct s3c2410_dma_buf {
  120. struct s3c2410_dma_buf *next;
  121. int magic; /* magic */
  122. int size; /* buffer size in bytes */
  123. dma_addr_t data; /* start of DMA data */
  124. dma_addr_t ptr; /* where the DMA got to [1] */
  125. void *id; /* client's id */
  126. };
  127. /* [1] is this updated for both recv/send modes? */
  128. struct s3c2410_dma_stats {
  129. unsigned long loads;
  130. unsigned long timeout_longest;
  131. unsigned long timeout_shortest;
  132. unsigned long timeout_avg;
  133. unsigned long timeout_failed;
  134. };
  135. struct s3c2410_dma_map;
  136. /* struct s3c2410_dma_chan
  137. *
  138. * full state information for each DMA channel
  139. */
  140. struct s3c2410_dma_chan {
  141. /* channel state flags and information */
  142. unsigned char number; /* number of this dma channel */
  143. unsigned char in_use; /* channel allocated */
  144. unsigned char irq_claimed; /* irq claimed for channel */
  145. unsigned char irq_enabled; /* irq enabled for channel */
  146. unsigned char xfer_unit; /* size of an transfer */
  147. /* channel state */
  148. enum s3c2410_dma_state state;
  149. enum s3c2410_dma_loadst load_state;
  150. struct s3c2410_dma_client *client;
  151. /* channel configuration */
  152. enum dma_data_direction source;
  153. enum dma_ch req_ch;
  154. unsigned long dev_addr;
  155. unsigned long load_timeout;
  156. unsigned int flags; /* channel flags */
  157. struct s3c24xx_dma_map *map; /* channel hw maps */
  158. /* channel's hardware position and configuration */
  159. void __iomem *regs; /* channels registers */
  160. void __iomem *addr_reg; /* data address register */
  161. unsigned int irq; /* channel irq */
  162. unsigned long dcon; /* default value of DCON */
  163. /* driver handles */
  164. s3c2410_dma_cbfn_t callback_fn; /* buffer done callback */
  165. s3c2410_dma_opfn_t op_fn; /* channel op callback */
  166. /* stats gathering */
  167. struct s3c2410_dma_stats *stats;
  168. struct s3c2410_dma_stats stats_store;
  169. /* buffer list and information */
  170. struct s3c2410_dma_buf *curr; /* current dma buffer */
  171. struct s3c2410_dma_buf *next; /* next buffer to load */
  172. struct s3c2410_dma_buf *end; /* end of queue */
  173. /* system device */
  174. struct device dev;
  175. };
  176. typedef unsigned long dma_device_t;
  177. #endif /* __ASM_ARCH_DMA_H */