2 * linux/amba/pl08x.h - ARM PrimeCell DMA Controller driver
4 * Copyright (C) 2005 ARM Ltd
5 * Copyright (C) 2010 ST-Ericsson SA
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.
11 * pl08x information required by platform code
13 * Please credit ARM.com
14 * Documentation: ARM DDI 0196D
20 /* We need sizes of structs from this header */
21 #include <linux/dmaengine.h>
22 #include <linux/interrupt.h>
25 struct pl08x_driver_data
;
27 /* Bitmasks for selecting AHB ports for DMA transfers */
29 PL08X_AHB1
= (1 << 0),
34 * struct pl08x_channel_data - data structure to pass info between
35 * platform and PL08x driver regarding channel configuration
36 * @bus_id: name of this device channel, not just a device name since
37 * devices may have more than one channel e.g. "foo_tx"
38 * @min_signal: the minimum DMA signal number to be muxed in for this
39 * channel (for platforms supporting muxed signals). If you have
40 * static assignments, make sure this is set to the assigned signal
41 * number, PL08x have 16 possible signals in number 0 thru 15 so
42 * when these are not enough they often get muxed (in hardware)
43 * disabling simultaneous use of the same channel for two devices.
44 * @max_signal: the maximum DMA signal number to be muxed in for
45 * the channel. Set to the same as min_signal for
46 * devices with static assignments
47 * @muxval: a number usually used to poke into some mux regiser to
48 * mux in the signal to this channel
49 * @cctl_opt: default options for the channel control register
50 * @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
51 * channels. Fill with 'true' if peripheral should be flow controller. Direction
52 * will be selected at Runtime.
53 * @addr: source/target address in physical memory for this DMA channel,
54 * can be the address of a FIFO register for burst requests for example.
55 * This can be left undefined if the PrimeCell API is used for configuring
57 * @circular_buffer: whether the buffer passed in is circular and
58 * shall simply be looped round round (like a record baby round
60 * @single: the device connected to this channel will request single DMA
61 * transfers, not bursts. (Bursts are default.)
62 * @periph_buses: the device connected to this channel is accessible via
63 * these buses (use PL08X_AHB1 | PL08X_AHB2).
65 struct pl08x_channel_data
{
79 * Struct pl08x_bus_data - information of source or destination
80 * busses for a transfer
81 * @addr: current address
82 * @maxwidth: the maximum width of a transfer on this bus
83 * @buswidth: the width of this bus in bytes: 1, 2 or 4
85 struct pl08x_bus_data
{
92 * struct pl08x_phy_chan - holder for the physical channels
93 * @id: physical index to this channel
94 * @lock: a lock to use when altering an instance of this struct
95 * @signal: the physical signal (aka channel) serving this physical channel
97 * @serving: the virtual channel currently being served by this physical
100 struct pl08x_phy_chan
{
105 struct pl08x_dma_chan
*serving
;
109 * struct pl08x_txd - wrapper for struct dma_async_tx_descriptor
110 * @tx: async tx descriptor
111 * @node: node for txd list for channels
112 * @src_addr: src address of txd
113 * @dst_addr: dst address of txd
114 * @len: transfer len in bytes
115 * @direction: direction of transfer
116 * @llis_bus: DMA memory address (physical) start for the LLIs
117 * @llis_va: virtual memory address start for the LLIs
118 * @cctl: control reg values for current txd
119 * @ccfg: config reg values for current txd
122 struct dma_async_tx_descriptor tx
;
123 struct list_head node
;
124 enum dma_data_direction direction
;
129 struct pl08x_lli
*llis_va
;
130 /* Default cctl value for LLIs */
133 * Settings to be put into the physical channel when we
134 * trigger this txd. Other registers are in llis_va[0].
140 * struct pl08x_dma_chan_state - holds the PL08x specific virtual channel
142 * @PL08X_CHAN_IDLE: the channel is idle
143 * @PL08X_CHAN_RUNNING: the channel has allocated a physical transport
144 * channel and is running a transfer on it
145 * @PL08X_CHAN_PAUSED: the channel has allocated a physical transport
146 * channel, but the transfer is currently paused
147 * @PL08X_CHAN_WAITING: the channel is waiting for a physical transport
148 * channel to become available (only pertains to memcpy channels)
150 enum pl08x_dma_chan_state
{
158 * struct pl08x_dma_chan - this structure wraps a DMA ENGINE channel
159 * @chan: wrappped abstract channel
160 * @phychan: the physical channel utilized by this channel, if there is one
161 * @phychan_hold: if non-zero, hold on to the physical channel even if we
162 * have no pending entries
163 * @tasklet: tasklet scheduled by the IRQ to handle actual work etc
164 * @name: name of channel
165 * @cd: channel platform data
166 * @runtime_addr: address for RX/TX according to the runtime config
167 * @runtime_direction: current direction of this channel according to
169 * @lc: last completed transaction on this channel
170 * @pend_list: queued transactions pending on this channel
171 * @at: active transaction on this channel
172 * @lock: a lock for this channel data
173 * @host: a pointer to the host (internal use)
174 * @state: whether the channel is idle, paused, running etc
175 * @slave: whether this channel is a device (slave) or for memcpy
176 * @waiting: a TX descriptor on this channel which is waiting for a physical
177 * channel to become available
179 struct pl08x_dma_chan
{
180 struct dma_chan chan
;
181 struct pl08x_phy_chan
*phychan
;
183 struct tasklet_struct tasklet
;
185 const struct pl08x_channel_data
*cd
;
190 enum dma_data_direction runtime_direction
;
192 struct list_head pend_list
;
193 struct pl08x_txd
*at
;
195 struct pl08x_driver_data
*host
;
196 enum pl08x_dma_chan_state state
;
198 struct pl08x_txd
*waiting
;
202 * struct pl08x_platform_data - the platform configuration for the PL08x
204 * @slave_channels: the channels defined for the different devices on the
205 * platform, all inclusive, including multiplexed channels. The available
206 * physical channels will be multiplexed around these signals as they are
207 * requested, just enumerate all possible channels.
208 * @get_signal: request a physical signal to be used for a DMA transfer
209 * immediately: if there is some multiplexing or similar blocking the use
210 * of the channel the transfer can be denied by returning less than zero,
211 * else it returns the allocated signal number
212 * @put_signal: indicate to the platform that this physical signal is not
213 * running any DMA transfer and multiplexing can be recycled
214 * @lli_buses: buses which LLIs can be fetched from: PL08X_AHB1 | PL08X_AHB2
215 * @mem_buses: buses which memory can be accessed from: PL08X_AHB1 | PL08X_AHB2
217 struct pl08x_platform_data
{
218 const struct pl08x_channel_data
*slave_channels
;
219 unsigned int num_slave_channels
;
220 struct pl08x_channel_data memcpy_channel
;
221 int (*get_signal
)(struct pl08x_dma_chan
*);
222 void (*put_signal
)(struct pl08x_dma_chan
*);
227 #ifdef CONFIG_AMBA_PL08X
228 bool pl08x_filter_id(struct dma_chan
*chan
, void *chan_id
);
230 static inline bool pl08x_filter_id(struct dma_chan
*chan
, void *chan_id
)
236 #endif /* AMBA_PL08X_H */