dma.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* arch/arm/mach-s3c2410/include/mach/dma.h
  2. *
  3. * Copyright (C) 2003,2004,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 <plat/dma.h>
  15. #include <linux/sysdev.h>
  16. #define MAX_DMA_TRANSFER_SIZE 0x100000 /* Data Unit is half word */
  17. /* We use `virtual` dma channels to hide the fact we have only a limited
  18. * number of DMA channels, and not of all of them (dependant on the device)
  19. * can be attached to any DMA source. We therefore let the DMA core handle
  20. * the allocation of hardware channels to clients.
  21. */
  22. enum dma_ch {
  23. DMACH_XD0,
  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_MAX, /* the end entry */
  47. };
  48. #define DMACH_LOW_LEVEL (1<<28) /* use this to specifiy hardware ch no */
  49. /* we have 4 dma channels */
  50. #ifndef CONFIG_CPU_S3C2443
  51. #define S3C_DMA_CHANNELS (4)
  52. #else
  53. #define S3C_DMA_CHANNELS (6)
  54. #endif
  55. /* types */
  56. enum s3c2410_dma_state {
  57. S3C2410_DMA_IDLE,
  58. S3C2410_DMA_RUNNING,
  59. S3C2410_DMA_PAUSED
  60. };
  61. /* enum s3c2410_dma_loadst
  62. *
  63. * This represents the state of the DMA engine, wrt to the loaded / running
  64. * transfers. Since we don't have any way of knowing exactly the state of
  65. * the DMA transfers, we need to know the state to make decisions on wether
  66. * we can
  67. *
  68. * S3C2410_DMA_NONE
  69. *
  70. * There are no buffers loaded (the channel should be inactive)
  71. *
  72. * S3C2410_DMA_1LOADED
  73. *
  74. * There is one buffer loaded, however it has not been confirmed to be
  75. * loaded by the DMA engine. This may be because the channel is not
  76. * yet running, or the DMA driver decided that it was too costly to
  77. * sit and wait for it to happen.
  78. *
  79. * S3C2410_DMA_1RUNNING
  80. *
  81. * The buffer has been confirmed running, and not finisged
  82. *
  83. * S3C2410_DMA_1LOADED_1RUNNING
  84. *
  85. * There is a buffer waiting to be loaded by the DMA engine, and one
  86. * currently running.
  87. */
  88. enum s3c2410_dma_loadst {
  89. S3C2410_DMALOAD_NONE,
  90. S3C2410_DMALOAD_1LOADED,
  91. S3C2410_DMALOAD_1RUNNING,
  92. S3C2410_DMALOAD_1LOADED_1RUNNING,
  93. };
  94. /* flags */
  95. #define S3C2410_DMAF_SLOW (1<<0) /* slow, so don't worry about
  96. * waiting for reloads */
  97. #define S3C2410_DMAF_AUTOSTART (1<<1) /* auto-start if buffer queued */
  98. #define S3C2410_DMAF_CIRCULAR (1 << 2) /* no circular dma support */
  99. /* dma buffer */
  100. struct s3c2410_dma_buf;
  101. /* s3c2410_dma_buf
  102. *
  103. * internally used buffer structure to describe a queued or running
  104. * buffer.
  105. */
  106. struct s3c2410_dma_buf {
  107. struct s3c2410_dma_buf *next;
  108. int magic; /* magic */
  109. int size; /* buffer size in bytes */
  110. dma_addr_t data; /* start of DMA data */
  111. dma_addr_t ptr; /* where the DMA got to [1] */
  112. void *id; /* client's id */
  113. };
  114. /* [1] is this updated for both recv/send modes? */
  115. struct s3c2410_dma_stats {
  116. unsigned long loads;
  117. unsigned long timeout_longest;
  118. unsigned long timeout_shortest;
  119. unsigned long timeout_avg;
  120. unsigned long timeout_failed;
  121. };
  122. struct s3c2410_dma_map;
  123. /* struct s3c2410_dma_chan
  124. *
  125. * full state information for each DMA channel
  126. */
  127. struct s3c2410_dma_chan {
  128. /* channel state flags and information */
  129. unsigned char number; /* number of this dma channel */
  130. unsigned char in_use; /* channel allocated */
  131. unsigned char irq_claimed; /* irq claimed for channel */
  132. unsigned char irq_enabled; /* irq enabled for channel */
  133. unsigned char xfer_unit; /* size of an transfer */
  134. /* channel state */
  135. enum s3c2410_dma_state state;
  136. enum s3c2410_dma_loadst load_state;
  137. struct s3c2410_dma_client *client;
  138. /* channel configuration */
  139. enum s3c2410_dmasrc source;
  140. enum dma_ch req_ch;
  141. unsigned long dev_addr;
  142. unsigned long load_timeout;
  143. unsigned int flags; /* channel flags */
  144. struct s3c24xx_dma_map *map; /* channel hw maps */
  145. /* channel's hardware position and configuration */
  146. void __iomem *regs; /* channels registers */
  147. void __iomem *addr_reg; /* data address register */
  148. unsigned int irq; /* channel irq */
  149. unsigned long dcon; /* default value of DCON */
  150. /* driver handles */
  151. s3c2410_dma_cbfn_t callback_fn; /* buffer done callback */
  152. s3c2410_dma_opfn_t op_fn; /* channel op callback */
  153. /* stats gathering */
  154. struct s3c2410_dma_stats *stats;
  155. struct s3c2410_dma_stats stats_store;
  156. /* buffer list and information */
  157. struct s3c2410_dma_buf *curr; /* current dma buffer */
  158. struct s3c2410_dma_buf *next; /* next buffer to load */
  159. struct s3c2410_dma_buf *end; /* end of queue */
  160. /* system device */
  161. struct sys_device dev;
  162. };
  163. typedef unsigned long dma_device_t;
  164. static inline bool s3c_dma_has_circular(void)
  165. {
  166. return false;
  167. }
  168. #endif /* __ASM_ARCH_DMA_H */