pl08x.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * linux/amba/pl08x.h - ARM PrimeCell DMA Controller driver
  3. *
  4. * Copyright (C) 2005 ARM Ltd
  5. * Copyright (C) 2010 ST-Ericsson SA
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * pl08x information required by platform code
  12. *
  13. * Please credit ARM.com
  14. * Documentation: ARM DDI 0196D
  15. *
  16. */
  17. #ifndef AMBA_PL08X_H
  18. #define AMBA_PL08X_H
  19. /* We need sizes of structs from this header */
  20. #include <linux/dmaengine.h>
  21. #include <linux/interrupt.h>
  22. struct pl08x_lli;
  23. struct pl08x_driver_data;
  24. /**
  25. * struct pl08x_channel_data - data structure to pass info between
  26. * platform and PL08x driver regarding channel configuration
  27. * @bus_id: name of this device channel, not just a device name since
  28. * devices may have more than one channel e.g. "foo_tx"
  29. * @min_signal: the minimum DMA signal number to be muxed in for this
  30. * channel (for platforms supporting muxed signals). If you have
  31. * static assignments, make sure this is set to the assigned signal
  32. * number, PL08x have 16 possible signals in number 0 thru 15 so
  33. * when these are not enough they often get muxed (in hardware)
  34. * disabling simultaneous use of the same channel for two devices.
  35. * @max_signal: the maximum DMA signal number to be muxed in for
  36. * the channel. Set to the same as min_signal for
  37. * devices with static assignments
  38. * @muxval: a number usually used to poke into some mux regiser to
  39. * mux in the signal to this channel
  40. * @cctl_opt: default options for the channel control register
  41. * @addr: source/target address in physical memory for this DMA channel,
  42. * can be the address of a FIFO register for burst requests for example.
  43. * This can be left undefined if the PrimeCell API is used for configuring
  44. * this.
  45. * @circular_buffer: whether the buffer passed in is circular and
  46. * shall simply be looped round round (like a record baby round
  47. * round round round)
  48. * @single: the device connected to this channel will request single
  49. * DMA transfers, not bursts. (Bursts are default.)
  50. */
  51. struct pl08x_channel_data {
  52. char *bus_id;
  53. int min_signal;
  54. int max_signal;
  55. u32 muxval;
  56. u32 cctl;
  57. dma_addr_t addr;
  58. bool circular_buffer;
  59. bool single;
  60. };
  61. /**
  62. * Struct pl08x_bus_data - information of source or destination
  63. * busses for a transfer
  64. * @addr: current address
  65. * @maxwidth: the maximum width of a transfer on this bus
  66. * @buswidth: the width of this bus in bytes: 1, 2 or 4
  67. * @fill_bytes: bytes required to fill to the next bus memory
  68. * boundary
  69. */
  70. struct pl08x_bus_data {
  71. dma_addr_t addr;
  72. u8 maxwidth;
  73. u8 buswidth;
  74. size_t fill_bytes;
  75. };
  76. /**
  77. * struct pl08x_phy_chan - holder for the physical channels
  78. * @id: physical index to this channel
  79. * @lock: a lock to use when altering an instance of this struct
  80. * @signal: the physical signal (aka channel) serving this
  81. * physical channel right now
  82. * @serving: the virtual channel currently being served by this
  83. * physical channel
  84. */
  85. struct pl08x_phy_chan {
  86. unsigned int id;
  87. void __iomem *base;
  88. spinlock_t lock;
  89. int signal;
  90. struct pl08x_dma_chan *serving;
  91. };
  92. /**
  93. * struct pl08x_txd - wrapper for struct dma_async_tx_descriptor
  94. * @llis_bus: DMA memory address (physical) start for the LLIs
  95. * @llis_va: virtual memory address start for the LLIs
  96. */
  97. struct pl08x_txd {
  98. struct dma_async_tx_descriptor tx;
  99. struct list_head node;
  100. enum dma_data_direction direction;
  101. struct pl08x_bus_data srcbus;
  102. struct pl08x_bus_data dstbus;
  103. size_t len;
  104. dma_addr_t llis_bus;
  105. void *llis_va;
  106. struct pl08x_channel_data *cd;
  107. bool active;
  108. /*
  109. * Settings to be put into the physical channel when we
  110. * trigger this txd. Other registers are in llis_va[0].
  111. */
  112. u32 ccfg;
  113. };
  114. /**
  115. * struct pl08x_dma_chan_state - holds the PL08x specific virtual
  116. * channel states
  117. * @PL08X_CHAN_IDLE: the channel is idle
  118. * @PL08X_CHAN_RUNNING: the channel has allocated a physical transport
  119. * channel and is running a transfer on it
  120. * @PL08X_CHAN_PAUSED: the channel has allocated a physical transport
  121. * channel, but the transfer is currently paused
  122. * @PL08X_CHAN_WAITING: the channel is waiting for a physical transport
  123. * channel to become available (only pertains to memcpy channels)
  124. */
  125. enum pl08x_dma_chan_state {
  126. PL08X_CHAN_IDLE,
  127. PL08X_CHAN_RUNNING,
  128. PL08X_CHAN_PAUSED,
  129. PL08X_CHAN_WAITING,
  130. };
  131. /**
  132. * struct pl08x_dma_chan - this structure wraps a DMA ENGINE channel
  133. * @chan: wrappped abstract channel
  134. * @phychan: the physical channel utilized by this channel, if there is one
  135. * @tasklet: tasklet scheduled by the IRQ to handle actual work etc
  136. * @name: name of channel
  137. * @cd: channel platform data
  138. * @runtime_addr: address for RX/TX according to the runtime config
  139. * @runtime_direction: current direction of this channel according to
  140. * runtime config
  141. * @lc: last completed transaction on this channel
  142. * @desc_list: queued transactions pending on this channel
  143. * @at: active transaction on this channel
  144. * @lockflags: sometimes we let a lock last between two function calls,
  145. * especially prep/submit, and then we need to store the IRQ flags
  146. * in the channel state, here
  147. * @lock: a lock for this channel data
  148. * @host: a pointer to the host (internal use)
  149. * @state: whether the channel is idle, paused, running etc
  150. * @slave: whether this channel is a device (slave) or for memcpy
  151. * @waiting: a TX descriptor on this channel which is waiting for
  152. * a physical channel to become available
  153. */
  154. struct pl08x_dma_chan {
  155. struct dma_chan chan;
  156. struct pl08x_phy_chan *phychan;
  157. struct tasklet_struct tasklet;
  158. char *name;
  159. struct pl08x_channel_data *cd;
  160. dma_addr_t runtime_addr;
  161. enum dma_data_direction runtime_direction;
  162. dma_cookie_t lc;
  163. struct list_head desc_list;
  164. struct pl08x_txd *at;
  165. unsigned long lockflags;
  166. spinlock_t lock;
  167. struct pl08x_driver_data *host;
  168. enum pl08x_dma_chan_state state;
  169. bool slave;
  170. struct pl08x_txd *waiting;
  171. };
  172. /**
  173. * struct pl08x_platform_data - the platform configuration for the
  174. * PL08x PrimeCells.
  175. * @slave_channels: the channels defined for the different devices on the
  176. * platform, all inclusive, including multiplexed channels. The available
  177. * physical channels will be multiplexed around these signals as they
  178. * are requested, just enumerate all possible channels.
  179. * @get_signal: request a physical signal to be used for a DMA
  180. * transfer immediately: if there is some multiplexing or similar blocking
  181. * the use of the channel the transfer can be denied by returning
  182. * less than zero, else it returns the allocated signal number
  183. * @put_signal: indicate to the platform that this physical signal is not
  184. * running any DMA transfer and multiplexing can be recycled
  185. * @bus_bit_lli: Bit[0] of the address indicated which AHB bus master the
  186. * LLI addresses are on 0/1 Master 1/2.
  187. */
  188. struct pl08x_platform_data {
  189. struct pl08x_channel_data *slave_channels;
  190. unsigned int num_slave_channels;
  191. struct pl08x_channel_data memcpy_channel;
  192. int (*get_signal)(struct pl08x_dma_chan *);
  193. void (*put_signal)(struct pl08x_dma_chan *);
  194. };
  195. #ifdef CONFIG_AMBA_PL08X
  196. bool pl08x_filter_id(struct dma_chan *chan, void *chan_id);
  197. #else
  198. static inline bool pl08x_filter_id(struct dma_chan *chan, void *chan_id)
  199. {
  200. return false;
  201. }
  202. #endif
  203. #endif /* AMBA_PL08X_H */