coh901318.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. *
  3. * include/linux/coh901318.h
  4. *
  5. *
  6. * Copyright (C) 2007-2009 ST-Ericsson
  7. * License terms: GNU General Public License (GPL) version 2
  8. * DMA driver for COH 901 318
  9. * Author: Per Friden <per.friden@stericsson.com>
  10. */
  11. #ifndef COH901318_H
  12. #define COH901318_H
  13. #include <linux/device.h>
  14. #include <linux/dmaengine.h>
  15. #define MAX_DMA_PACKET_SIZE_SHIFT 11
  16. #define MAX_DMA_PACKET_SIZE (1 << MAX_DMA_PACKET_SIZE_SHIFT)
  17. /**
  18. * struct coh901318_lli - linked list item for DMAC
  19. * @control: control settings for DMAC
  20. * @src_addr: transfer source address
  21. * @dst_addr: transfer destination address
  22. * @link_addr: physical address to next lli
  23. * @virt_link_addr: virtual address of next lli (only used by pool_free)
  24. * @phy_this: physical address of current lli (only used by pool_free)
  25. */
  26. struct coh901318_lli {
  27. u32 control;
  28. dma_addr_t src_addr;
  29. dma_addr_t dst_addr;
  30. dma_addr_t link_addr;
  31. void *virt_link_addr;
  32. dma_addr_t phy_this;
  33. };
  34. /**
  35. * struct coh901318_params - parameters for DMAC configuration
  36. * @config: DMA config register
  37. * @ctrl_lli_last: DMA control register for the last lli in the list
  38. * @ctrl_lli: DMA control register for an lli
  39. * @ctrl_lli_chained: DMA control register for a chained lli
  40. */
  41. struct coh901318_params {
  42. u32 config;
  43. u32 ctrl_lli_last;
  44. u32 ctrl_lli;
  45. u32 ctrl_lli_chained;
  46. };
  47. /**
  48. * struct coh_dma_channel - dma channel base
  49. * @name: ascii name of dma channel
  50. * @number: channel id number
  51. * @desc_nbr_max: number of preallocated descriptors
  52. * @priority_high: prio of channel, 0 low otherwise high.
  53. * @param: configuration parameters
  54. * @dev_addr: physical address of periphal connected to channel
  55. */
  56. struct coh_dma_channel {
  57. const char name[32];
  58. const int number;
  59. const int desc_nbr_max;
  60. const int priority_high;
  61. const struct coh901318_params param;
  62. const dma_addr_t dev_addr;
  63. };
  64. /**
  65. * dma_access_memory_state_t - register dma for memory access
  66. *
  67. * @dev: The dma device
  68. * @active: 1 means dma intends to access memory
  69. * 0 means dma wont access memory
  70. */
  71. typedef void (*dma_access_memory_state_t)(struct device *dev,
  72. bool active);
  73. /**
  74. * struct powersave - DMA power save structure
  75. * @lock: lock protecting data in this struct
  76. * @started_channels: bit mask indicating active dma channels
  77. */
  78. struct powersave {
  79. spinlock_t lock;
  80. u64 started_channels;
  81. };
  82. /**
  83. * struct coh901318_platform - platform arch structure
  84. * @chans_slave: specifying dma slave channels
  85. * @chans_memcpy: specifying dma memcpy channels
  86. * @access_memory_state: requesting DMA memory access (on / off)
  87. * @chan_conf: dma channel configurations
  88. * @max_channels: max number of dma chanenls
  89. */
  90. struct coh901318_platform {
  91. const int *chans_slave;
  92. const int *chans_memcpy;
  93. const dma_access_memory_state_t access_memory_state;
  94. const struct coh_dma_channel *chan_conf;
  95. const int max_channels;
  96. };
  97. #ifdef CONFIG_COH901318
  98. /**
  99. * coh901318_filter_id() - DMA channel filter function
  100. * @chan: dma channel handle
  101. * @chan_id: id of dma channel to be filter out
  102. *
  103. * In dma_request_channel() it specifies what channel id to be requested
  104. */
  105. bool coh901318_filter_id(struct dma_chan *chan, void *chan_id);
  106. #else
  107. static inline bool coh901318_filter_id(struct dma_chan *chan, void *chan_id)
  108. {
  109. return false;
  110. }
  111. #endif
  112. /*
  113. * DMA Controller - this access the static mappings of the coh901318 dma.
  114. *
  115. */
  116. #define COH901318_MOD32_MASK (0x1F)
  117. #define COH901318_WORD_MASK (0xFFFFFFFF)
  118. /* INT_STATUS - Interrupt Status Registers 32bit (R/-) */
  119. #define COH901318_INT_STATUS1 (0x0000)
  120. #define COH901318_INT_STATUS2 (0x0004)
  121. /* TC_INT_STATUS - Terminal Count Interrupt Status Registers 32bit (R/-) */
  122. #define COH901318_TC_INT_STATUS1 (0x0008)
  123. #define COH901318_TC_INT_STATUS2 (0x000C)
  124. /* TC_INT_CLEAR - Terminal Count Interrupt Clear Registers 32bit (-/W) */
  125. #define COH901318_TC_INT_CLEAR1 (0x0010)
  126. #define COH901318_TC_INT_CLEAR2 (0x0014)
  127. /* RAW_TC_INT_STATUS - Raw Term Count Interrupt Status Registers 32bit (R/-) */
  128. #define COH901318_RAW_TC_INT_STATUS1 (0x0018)
  129. #define COH901318_RAW_TC_INT_STATUS2 (0x001C)
  130. /* BE_INT_STATUS - Bus Error Interrupt Status Registers 32bit (R/-) */
  131. #define COH901318_BE_INT_STATUS1 (0x0020)
  132. #define COH901318_BE_INT_STATUS2 (0x0024)
  133. /* BE_INT_CLEAR - Bus Error Interrupt Clear Registers 32bit (-/W) */
  134. #define COH901318_BE_INT_CLEAR1 (0x0028)
  135. #define COH901318_BE_INT_CLEAR2 (0x002C)
  136. /* RAW_BE_INT_STATUS - Raw Term Count Interrupt Status Registers 32bit (R/-) */
  137. #define COH901318_RAW_BE_INT_STATUS1 (0x0030)
  138. #define COH901318_RAW_BE_INT_STATUS2 (0x0034)
  139. /*
  140. * CX_CFG - Channel Configuration Registers 32bit (R/W)
  141. */
  142. #define COH901318_CX_CFG (0x0100)
  143. #define COH901318_CX_CFG_SPACING (0x04)
  144. /* Channel enable activates tha dma job */
  145. #define COH901318_CX_CFG_CH_ENABLE (0x00000001)
  146. #define COH901318_CX_CFG_CH_DISABLE (0x00000000)
  147. /* Request Mode */
  148. #define COH901318_CX_CFG_RM_MASK (0x00000006)
  149. #define COH901318_CX_CFG_RM_MEMORY_TO_MEMORY (0x0 << 1)
  150. #define COH901318_CX_CFG_RM_PRIMARY_TO_MEMORY (0x1 << 1)
  151. #define COH901318_CX_CFG_RM_MEMORY_TO_PRIMARY (0x1 << 1)
  152. #define COH901318_CX_CFG_RM_PRIMARY_TO_SECONDARY (0x3 << 1)
  153. #define COH901318_CX_CFG_RM_SECONDARY_TO_PRIMARY (0x3 << 1)
  154. /* Linked channel request field. RM must == 11 */
  155. #define COH901318_CX_CFG_LCRF_SHIFT 3
  156. #define COH901318_CX_CFG_LCRF_MASK (0x000001F8)
  157. #define COH901318_CX_CFG_LCR_DISABLE (0x00000000)
  158. /* Terminal Counter Interrupt Request Mask */
  159. #define COH901318_CX_CFG_TC_IRQ_ENABLE (0x00000200)
  160. #define COH901318_CX_CFG_TC_IRQ_DISABLE (0x00000000)
  161. /* Bus Error interrupt Mask */
  162. #define COH901318_CX_CFG_BE_IRQ_ENABLE (0x00000400)
  163. #define COH901318_CX_CFG_BE_IRQ_DISABLE (0x00000000)
  164. /*
  165. * CX_STAT - Channel Status Registers 32bit (R/-)
  166. */
  167. #define COH901318_CX_STAT (0x0200)
  168. #define COH901318_CX_STAT_SPACING (0x04)
  169. #define COH901318_CX_STAT_RBE_IRQ_IND (0x00000008)
  170. #define COH901318_CX_STAT_RTC_IRQ_IND (0x00000004)
  171. #define COH901318_CX_STAT_ACTIVE (0x00000002)
  172. #define COH901318_CX_STAT_ENABLED (0x00000001)
  173. /*
  174. * CX_CTRL - Channel Control Registers 32bit (R/W)
  175. */
  176. #define COH901318_CX_CTRL (0x0400)
  177. #define COH901318_CX_CTRL_SPACING (0x10)
  178. /* Transfer Count Enable */
  179. #define COH901318_CX_CTRL_TC_ENABLE (0x00001000)
  180. #define COH901318_CX_CTRL_TC_DISABLE (0x00000000)
  181. /* Transfer Count Value 0 - 4095 */
  182. #define COH901318_CX_CTRL_TC_VALUE_MASK (0x00000FFF)
  183. /* Burst count */
  184. #define COH901318_CX_CTRL_BURST_COUNT_MASK (0x0000E000)
  185. #define COH901318_CX_CTRL_BURST_COUNT_64_BYTES (0x7 << 13)
  186. #define COH901318_CX_CTRL_BURST_COUNT_48_BYTES (0x6 << 13)
  187. #define COH901318_CX_CTRL_BURST_COUNT_32_BYTES (0x5 << 13)
  188. #define COH901318_CX_CTRL_BURST_COUNT_16_BYTES (0x4 << 13)
  189. #define COH901318_CX_CTRL_BURST_COUNT_8_BYTES (0x3 << 13)
  190. #define COH901318_CX_CTRL_BURST_COUNT_4_BYTES (0x2 << 13)
  191. #define COH901318_CX_CTRL_BURST_COUNT_2_BYTES (0x1 << 13)
  192. #define COH901318_CX_CTRL_BURST_COUNT_1_BYTE (0x0 << 13)
  193. /* Source bus size */
  194. #define COH901318_CX_CTRL_SRC_BUS_SIZE_MASK (0x00030000)
  195. #define COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS (0x2 << 16)
  196. #define COH901318_CX_CTRL_SRC_BUS_SIZE_16_BITS (0x1 << 16)
  197. #define COH901318_CX_CTRL_SRC_BUS_SIZE_8_BITS (0x0 << 16)
  198. /* Source address increment */
  199. #define COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE (0x00040000)
  200. #define COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE (0x00000000)
  201. /* Destination Bus Size */
  202. #define COH901318_CX_CTRL_DST_BUS_SIZE_MASK (0x00180000)
  203. #define COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS (0x2 << 19)
  204. #define COH901318_CX_CTRL_DST_BUS_SIZE_16_BITS (0x1 << 19)
  205. #define COH901318_CX_CTRL_DST_BUS_SIZE_8_BITS (0x0 << 19)
  206. /* Destination address increment */
  207. #define COH901318_CX_CTRL_DST_ADDR_INC_ENABLE (0x00200000)
  208. #define COH901318_CX_CTRL_DST_ADDR_INC_DISABLE (0x00000000)
  209. /* Master Mode (Master2 is only connected to MSL) */
  210. #define COH901318_CX_CTRL_MASTER_MODE_MASK (0x00C00000)
  211. #define COH901318_CX_CTRL_MASTER_MODE_M2R_M1W (0x3 << 22)
  212. #define COH901318_CX_CTRL_MASTER_MODE_M1R_M2W (0x2 << 22)
  213. #define COH901318_CX_CTRL_MASTER_MODE_M2RW (0x1 << 22)
  214. #define COH901318_CX_CTRL_MASTER_MODE_M1RW (0x0 << 22)
  215. /* Terminal Count flag to PER enable */
  216. #define COH901318_CX_CTRL_TCP_ENABLE (0x01000000)
  217. #define COH901318_CX_CTRL_TCP_DISABLE (0x00000000)
  218. /* Terminal Count flags to CPU enable */
  219. #define COH901318_CX_CTRL_TC_IRQ_ENABLE (0x02000000)
  220. #define COH901318_CX_CTRL_TC_IRQ_DISABLE (0x00000000)
  221. /* Hand shake to peripheral */
  222. #define COH901318_CX_CTRL_HSP_ENABLE (0x04000000)
  223. #define COH901318_CX_CTRL_HSP_DISABLE (0x00000000)
  224. #define COH901318_CX_CTRL_HSS_ENABLE (0x08000000)
  225. #define COH901318_CX_CTRL_HSS_DISABLE (0x00000000)
  226. /* DMA mode */
  227. #define COH901318_CX_CTRL_DDMA_MASK (0x30000000)
  228. #define COH901318_CX_CTRL_DDMA_LEGACY (0x0 << 28)
  229. #define COH901318_CX_CTRL_DDMA_DEMAND_DMA1 (0x1 << 28)
  230. #define COH901318_CX_CTRL_DDMA_DEMAND_DMA2 (0x2 << 28)
  231. /* Primary Request Data Destination */
  232. #define COH901318_CX_CTRL_PRDD_MASK (0x40000000)
  233. #define COH901318_CX_CTRL_PRDD_DEST (0x1 << 30)
  234. #define COH901318_CX_CTRL_PRDD_SOURCE (0x0 << 30)
  235. /*
  236. * CX_SRC_ADDR - Channel Source Address Registers 32bit (R/W)
  237. */
  238. #define COH901318_CX_SRC_ADDR (0x0404)
  239. #define COH901318_CX_SRC_ADDR_SPACING (0x10)
  240. /*
  241. * CX_DST_ADDR - Channel Destination Address Registers 32bit R/W
  242. */
  243. #define COH901318_CX_DST_ADDR (0x0408)
  244. #define COH901318_CX_DST_ADDR_SPACING (0x10)
  245. /*
  246. * CX_LNK_ADDR - Channel Link Address Registers 32bit (R/W)
  247. */
  248. #define COH901318_CX_LNK_ADDR (0x040C)
  249. #define COH901318_CX_LNK_ADDR_SPACING (0x10)
  250. #define COH901318_CX_LNK_LINK_IMMEDIATE (0x00000001)
  251. #endif /* COH901318_H */