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