2 * DOC: EP93xx DMA M2P memory to peripheral and peripheral to memory engine
4 * The EP93xx DMA M2P subsystem handles DMA transfers between memory and
5 * peripherals. DMA M2P channels are available for audio, UARTs and IrDA.
6 * See chapter 10 of the EP93xx users guide for full details on the DMA M2P
9 * See sound/soc/ep93xx/ep93xx-pcm.c for an example use of the DMA M2P code.
13 #ifndef __ASM_ARCH_DMA_H
14 #define __ASM_ARCH_DMA_H
16 #include <linux/list.h>
17 #include <linux/types.h>
18 #include <linux/dmaengine.h>
19 #include <linux/dma-mapping.h>
22 * struct ep93xx_dma_buffer - Information about a buffer to be transferred
23 * using the DMA M2P engine
25 * @list: Entry in DMA buffer list
26 * @bus_addr: Physical address of the buffer
27 * @size: Size of the buffer in bytes
29 struct ep93xx_dma_buffer {
30 struct list_head list;
36 * struct ep93xx_dma_m2p_client - Information about a DMA M2P client
38 * @name: Unique name for this client
39 * @flags: Client flags
40 * @cookie: User data to pass to callback functions
41 * @buffer_started: Non NULL function to call when a transfer is started.
42 * The arguments are the user data cookie and the DMA
43 * buffer which is starting.
44 * @buffer_finished: Non NULL function to call when a transfer is completed.
45 * The arguments are the user data cookie, the DMA buffer
46 * which has completed, and a boolean flag indicating if
47 * the transfer had an error.
49 struct ep93xx_dma_m2p_client {
53 void (*buffer_started)(void *cookie,
54 struct ep93xx_dma_buffer *buf);
55 void (*buffer_finished)(void *cookie,
56 struct ep93xx_dma_buffer *buf,
57 int bytes, int error);
59 /* private: Internal use only */
64 #define EP93XX_DMA_M2P_PORT_I2S1 0x00
65 #define EP93XX_DMA_M2P_PORT_I2S2 0x01
66 #define EP93XX_DMA_M2P_PORT_AAC1 0x02
67 #define EP93XX_DMA_M2P_PORT_AAC2 0x03
68 #define EP93XX_DMA_M2P_PORT_AAC3 0x04
69 #define EP93XX_DMA_M2P_PORT_I2S3 0x05
70 #define EP93XX_DMA_M2P_PORT_UART1 0x06
71 #define EP93XX_DMA_M2P_PORT_UART2 0x07
72 #define EP93XX_DMA_M2P_PORT_UART3 0x08
73 #define EP93XX_DMA_M2P_PORT_IRDA 0x09
74 #define EP93XX_DMA_M2P_PORT_MASK 0x0f
76 /* DMA M2P client flags */
77 #define EP93XX_DMA_M2P_TX 0x00 /* Memory to peripheral */
78 #define EP93XX_DMA_M2P_RX 0x10 /* Peripheral to memory */
81 * DMA M2P client error handling flags. See the EP93xx users guide
82 * documentation on the DMA M2P CONTROL register for more details
84 #define EP93XX_DMA_M2P_ABORT_ON_ERROR 0x20 /* Abort on peripheral error */
85 #define EP93XX_DMA_M2P_IGNORE_ERROR 0x40 /* Ignore peripheral errors */
86 #define EP93XX_DMA_M2P_ERROR_MASK 0x60 /* Mask of error bits */
89 * ep93xx_dma_m2p_client_register - Register a client with the DMA M2P
92 * @m2p: Client information to register
93 * returns 0 on success
95 * The DMA M2P subsystem allocates a channel and an interrupt line for the DMA
98 int ep93xx_dma_m2p_client_register(struct ep93xx_dma_m2p_client *m2p);
101 * ep93xx_dma_m2p_client_unregister - Unregister a client from the DMA M2P
104 * @m2p: Client to unregister
106 * Any transfers currently in progress will be completed in hardware, but
107 * ignored in software.
109 void ep93xx_dma_m2p_client_unregister(struct ep93xx_dma_m2p_client *m2p);
112 * ep93xx_dma_m2p_submit - Submit a DMA M2P transfer
114 * @m2p: DMA Client to submit the transfer on
115 * @buf: DMA Buffer to submit
117 * If the current or next transfer positions are free on the M2P client then
118 * the transfer is started immediately. If not, the transfer is added to the
119 * list of pending transfers. This function must not be called from the
120 * buffer_finished callback for an M2P channel.
123 void ep93xx_dma_m2p_submit(struct ep93xx_dma_m2p_client *m2p,
124 struct ep93xx_dma_buffer *buf);
127 * ep93xx_dma_m2p_submit_recursive - Put a DMA transfer on the pending list
130 * @m2p: DMA Client to submit the transfer on
131 * @buf: DMA Buffer to submit
133 * This function must only be called from the buffer_finished callback for an
134 * M2P channel. It is commonly used to add the next transfer in a chained list
137 void ep93xx_dma_m2p_submit_recursive(struct ep93xx_dma_m2p_client *m2p,
138 struct ep93xx_dma_buffer *buf);
141 * ep93xx_dma_m2p_flush - Flush all pending transfers on a DMA M2P client
143 * @m2p: DMA client to flush transfers on
145 * Any transfers currently in progress will be completed in hardware, but
146 * ignored in software.
149 void ep93xx_dma_m2p_flush(struct ep93xx_dma_m2p_client *m2p);
154 * Note that these values are also directly used for setting the PPALLOC
157 #define EP93XX_DMA_I2S1 0
158 #define EP93XX_DMA_I2S2 1
159 #define EP93XX_DMA_AAC1 2
160 #define EP93XX_DMA_AAC2 3
161 #define EP93XX_DMA_AAC3 4
162 #define EP93XX_DMA_I2S3 5
163 #define EP93XX_DMA_UART1 6
164 #define EP93XX_DMA_UART2 7
165 #define EP93XX_DMA_UART3 8
166 #define EP93XX_DMA_IRDA 9
168 #define EP93XX_DMA_SSP 10
169 #define EP93XX_DMA_IDE 11
172 * struct ep93xx_dma_data - configuration data for the EP93xx dmaengine
173 * @port: peripheral which is requesting the channel
174 * @direction: TX/RX channel
175 * @name: optional name for the channel, this is displayed in /proc/interrupts
177 * This information is passed as private channel parameter in a filter
178 * function. Note that this is only needed for slave/cyclic channels. For
179 * memcpy channels %NULL data should be passed.
181 struct ep93xx_dma_data {
183 enum dma_data_direction direction;
188 * struct ep93xx_dma_chan_data - platform specific data for a DMA channel
189 * @name: name of the channel, used for getting the right clock for the channel
190 * @base: mapped registers
191 * @irq: interrupt number used by this channel
193 struct ep93xx_dma_chan_data {
200 * struct ep93xx_dma_platform_data - platform data for the dmaengine driver
201 * @channels: array of channels which are passed to the driver
202 * @num_channels: number of channels in the array
204 * This structure is passed to the DMA engine driver via platform data. For
205 * M2P channels, contract is that even channels are for TX and odd for RX.
206 * There is no requirement for the M2M channels.
208 struct ep93xx_dma_platform_data {
209 struct ep93xx_dma_chan_data *channels;
213 static inline bool ep93xx_dma_chan_is_m2p(struct dma_chan *chan)
215 return !strcmp(dev_name(chan->device->dev), "ep93xx-dma-m2p");
219 * ep93xx_dma_chan_direction - returns direction the channel can be used
222 * This function can be used in filter functions to find out whether the
223 * channel supports given DMA direction. Only M2P channels have such
224 * limitation, for M2M channels the direction is configurable.
226 static inline enum dma_data_direction
227 ep93xx_dma_chan_direction(struct dma_chan *chan)
229 if (!ep93xx_dma_chan_is_m2p(chan))
232 /* even channels are for TX, odd for RX */
233 return (chan->chan_id % 2 == 0) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
236 #endif /* __ASM_ARCH_DMA_H */