dma.h 5.2 KB

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