Blame view

include/linux/amba/pl08x.h 8.01 KB
e8689e63d   Linus Walleij   dmaengine: driver...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  /*
   * linux/amba/pl08x.h - ARM PrimeCell DMA Controller driver
   *
   * Copyright (C) 2005 ARM Ltd
   * Copyright (C) 2010 ST-Ericsson SA
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   *
   * pl08x information required by platform code
   *
   * Please credit ARM.com
   * Documentation: ARM DDI 0196D
e8689e63d   Linus Walleij   dmaengine: driver...
15
16
17
18
19
20
21
22
   */
  
  #ifndef AMBA_PL08X_H
  #define AMBA_PL08X_H
  
  /* We need sizes of structs from this header */
  #include <linux/dmaengine.h>
  #include <linux/interrupt.h>
7cb72ad95   Russell King - ARM Linux   ARM: PL08x: avoid...
23
24
  struct pl08x_lli;
  struct pl08x_driver_data;
30749cb4a   Russell King - ARM Linux   ARM: PL08x: allow...
25
26
27
28
29
  /* Bitmasks for selecting AHB ports for DMA transfers */
  enum {
  	PL08X_AHB1 = (1 << 0),
  	PL08X_AHB2 = (1 << 1)
  };
e8689e63d   Linus Walleij   dmaengine: driver...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  /**
   * struct pl08x_channel_data - data structure to pass info between
   * platform and PL08x driver regarding channel configuration
   * @bus_id: name of this device channel, not just a device name since
   * devices may have more than one channel e.g. "foo_tx"
   * @min_signal: the minimum DMA signal number to be muxed in for this
   * channel (for platforms supporting muxed signals). If you have
   * static assignments, make sure this is set to the assigned signal
   * number, PL08x have 16 possible signals in number 0 thru 15 so
   * when these are not enough they often get muxed (in hardware)
   * disabling simultaneous use of the same channel for two devices.
   * @max_signal: the maximum DMA signal number to be muxed in for
   * the channel. Set to the same as min_signal for
   * devices with static assignments
   * @muxval: a number usually used to poke into some mux regiser to
   * mux in the signal to this channel
   * @cctl_opt: default options for the channel control register
0a2356572   Viresh Kumar   dmaengine/amba-pl...
47
48
49
   * @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
   * channels. Fill with 'true' if peripheral should be flow controller. Direction
   * will be selected at Runtime.
e8689e63d   Linus Walleij   dmaengine: driver...
50
51
52
53
54
55
56
   * @addr: source/target address in physical memory for this DMA channel,
   * can be the address of a FIFO register for burst requests for example.
   * This can be left undefined if the PrimeCell API is used for configuring
   * this.
   * @circular_buffer: whether the buffer passed in is circular and
   * shall simply be looped round round (like a record baby round
   * round round round)
94ae85220   Russell King - ARM Linux   ARM: PL08x: clean...
57
58
   * @single: the device connected to this channel will request single DMA
   * transfers, not bursts. (Bursts are default.)
30749cb4a   Russell King - ARM Linux   ARM: PL08x: allow...
59
60
   * @periph_buses: the device connected to this channel is accessible via
   * these buses (use PL08X_AHB1 | PL08X_AHB2).
e8689e63d   Linus Walleij   dmaengine: driver...
61
62
63
64
65
66
67
   */
  struct pl08x_channel_data {
  	char *bus_id;
  	int min_signal;
  	int max_signal;
  	u32 muxval;
  	u32 cctl;
0a2356572   Viresh Kumar   dmaengine/amba-pl...
68
  	bool device_fc;
e8689e63d   Linus Walleij   dmaengine: driver...
69
70
71
  	dma_addr_t addr;
  	bool circular_buffer;
  	bool single;
30749cb4a   Russell King - ARM Linux   ARM: PL08x: allow...
72
  	u8 periph_buses;
e8689e63d   Linus Walleij   dmaengine: driver...
73
74
75
76
77
78
79
80
  };
  
  /**
   * Struct pl08x_bus_data - information of source or destination
   * busses for a transfer
   * @addr: current address
   * @maxwidth: the maximum width of a transfer on this bus
   * @buswidth: the width of this bus in bytes: 1, 2 or 4
e8689e63d   Linus Walleij   dmaengine: driver...
81
82
83
84
85
   */
  struct pl08x_bus_data {
  	dma_addr_t addr;
  	u8 maxwidth;
  	u8 buswidth;
e8689e63d   Linus Walleij   dmaengine: driver...
86
87
88
89
90
91
  };
  
  /**
   * struct pl08x_phy_chan - holder for the physical channels
   * @id: physical index to this channel
   * @lock: a lock to use when altering an instance of this struct
94ae85220   Russell King - ARM Linux   ARM: PL08x: clean...
92
93
94
95
   * @signal: the physical signal (aka channel) serving this physical channel
   * right now
   * @serving: the virtual channel currently being served by this physical
   * channel
e8689e63d   Linus Walleij   dmaengine: driver...
96
97
98
99
100
101
102
   */
  struct pl08x_phy_chan {
  	unsigned int id;
  	void __iomem *base;
  	spinlock_t lock;
  	int signal;
  	struct pl08x_dma_chan *serving;
e8689e63d   Linus Walleij   dmaengine: driver...
103
104
105
  };
  
  /**
b7f69d9d4   Viresh Kumar   dmaengine/amba-pl...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
   * struct pl08x_sg - structure containing data per sg
   * @src_addr: src address of sg
   * @dst_addr: dst address of sg
   * @len: transfer len in bytes
   * @node: node for txd's dsg_list
   */
  struct pl08x_sg {
  	dma_addr_t src_addr;
  	dma_addr_t dst_addr;
  	size_t len;
  	struct list_head node;
  };
  
  /**
e8689e63d   Linus Walleij   dmaengine: driver...
120
   * struct pl08x_txd - wrapper for struct dma_async_tx_descriptor
5a6123307   Viresh Kumar   dmaengine/amba-pl...
121
122
   * @tx: async tx descriptor
   * @node: node for txd list for channels
b7f69d9d4   Viresh Kumar   dmaengine/amba-pl...
123
   * @dsg_list: list of children sg's
5a6123307   Viresh Kumar   dmaengine/amba-pl...
124
   * @direction: direction of transfer
e8689e63d   Linus Walleij   dmaengine: driver...
125
126
   * @llis_bus: DMA memory address (physical) start for the LLIs
   * @llis_va: virtual memory address start for the LLIs
5a6123307   Viresh Kumar   dmaengine/amba-pl...
127
128
   * @cctl: control reg values for current txd
   * @ccfg: config reg values for current txd
e8689e63d   Linus Walleij   dmaengine: driver...
129
130
131
132
   */
  struct pl08x_txd {
  	struct dma_async_tx_descriptor tx;
  	struct list_head node;
b7f69d9d4   Viresh Kumar   dmaengine/amba-pl...
133
  	struct list_head dsg_list;
e8689e63d   Linus Walleij   dmaengine: driver...
134
  	enum dma_data_direction	direction;
e8689e63d   Linus Walleij   dmaengine: driver...
135
  	dma_addr_t llis_bus;
96a608a4b   Dan Williams   ARM: PL08x: fix a...
136
  	struct pl08x_lli *llis_va;
70b5ed6b6   Russell King - ARM Linux   ARM: PL08x: move ...
137
138
  	/* Default cctl value for LLIs */
  	u32 cctl;
4983a04fd   Russell King - ARM Linux   ARM: PL08x: move ...
139
140
141
142
143
  	/*
  	 * Settings to be put into the physical channel when we
  	 * trigger this txd.  Other registers are in llis_va[0].
  	 */
  	u32 ccfg;
e8689e63d   Linus Walleij   dmaengine: driver...
144
145
146
  };
  
  /**
94ae85220   Russell King - ARM Linux   ARM: PL08x: clean...
147
148
   * struct pl08x_dma_chan_state - holds the PL08x specific virtual channel
   * states
e8689e63d   Linus Walleij   dmaengine: driver...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
   * @PL08X_CHAN_IDLE: the channel is idle
   * @PL08X_CHAN_RUNNING: the channel has allocated a physical transport
   * channel and is running a transfer on it
   * @PL08X_CHAN_PAUSED: the channel has allocated a physical transport
   * channel, but the transfer is currently paused
   * @PL08X_CHAN_WAITING: the channel is waiting for a physical transport
   * channel to become available (only pertains to memcpy channels)
   */
  enum pl08x_dma_chan_state {
  	PL08X_CHAN_IDLE,
  	PL08X_CHAN_RUNNING,
  	PL08X_CHAN_PAUSED,
  	PL08X_CHAN_WAITING,
  };
  
  /**
   * struct pl08x_dma_chan - this structure wraps a DMA ENGINE channel
   * @chan: wrappped abstract channel
   * @phychan: the physical channel utilized by this channel, if there is one
8087aacda   Russell King - ARM Linux   ARM: PL08x: intro...
168
   * @phychan_hold: if non-zero, hold on to the physical channel even if we
94ae85220   Russell King - ARM Linux   ARM: PL08x: clean...
169
   * have no pending entries
e8689e63d   Linus Walleij   dmaengine: driver...
170
171
172
173
174
175
176
   * @tasklet: tasklet scheduled by the IRQ to handle actual work etc
   * @name: name of channel
   * @cd: channel platform data
   * @runtime_addr: address for RX/TX according to the runtime config
   * @runtime_direction: current direction of this channel according to
   * runtime config
   * @lc: last completed transaction on this channel
15c17232f   Russell King - ARM Linux   ARM: PL08x: renam...
177
   * @pend_list: queued transactions pending on this channel
e8689e63d   Linus Walleij   dmaengine: driver...
178
   * @at: active transaction on this channel
e8689e63d   Linus Walleij   dmaengine: driver...
179
180
181
182
   * @lock: a lock for this channel data
   * @host: a pointer to the host (internal use)
   * @state: whether the channel is idle, paused, running etc
   * @slave: whether this channel is a device (slave) or for memcpy
94ae85220   Russell King - ARM Linux   ARM: PL08x: clean...
183
184
   * @waiting: a TX descriptor on this channel which is waiting for a physical
   * channel to become available
e8689e63d   Linus Walleij   dmaengine: driver...
185
186
187
188
   */
  struct pl08x_dma_chan {
  	struct dma_chan chan;
  	struct pl08x_phy_chan *phychan;
8087aacda   Russell King - ARM Linux   ARM: PL08x: intro...
189
  	int phychan_hold;
e8689e63d   Linus Walleij   dmaengine: driver...
190
191
  	struct tasklet_struct tasklet;
  	char *name;
fa020e7d0   Russell King - ARM Linux   DMA: PL08x: const...
192
  	const struct pl08x_channel_data *cd;
b207b4d02   Russell King - ARM Linux   DMA: PL08x: separ...
193
194
  	dma_addr_t src_addr;
  	dma_addr_t dst_addr;
f14c426c7   Russell King - ARM Linux   DMA: PL08x: separ...
195
196
  	u32 src_cctl;
  	u32 dst_cctl;
e8689e63d   Linus Walleij   dmaengine: driver...
197
  	enum dma_data_direction	runtime_direction;
e8689e63d   Linus Walleij   dmaengine: driver...
198
  	dma_cookie_t lc;
15c17232f   Russell King - ARM Linux   ARM: PL08x: renam...
199
  	struct list_head pend_list;
e8689e63d   Linus Walleij   dmaengine: driver...
200
  	struct pl08x_txd *at;
e8689e63d   Linus Walleij   dmaengine: driver...
201
  	spinlock_t lock;
7cb72ad95   Russell King - ARM Linux   ARM: PL08x: avoid...
202
  	struct pl08x_driver_data *host;
e8689e63d   Linus Walleij   dmaengine: driver...
203
204
205
206
207
208
  	enum pl08x_dma_chan_state state;
  	bool slave;
  	struct pl08x_txd *waiting;
  };
  
  /**
94ae85220   Russell King - ARM Linux   ARM: PL08x: clean...
209
210
   * struct pl08x_platform_data - the platform configuration for the PL08x
   * PrimeCells.
e8689e63d   Linus Walleij   dmaengine: driver...
211
212
   * @slave_channels: the channels defined for the different devices on the
   * platform, all inclusive, including multiplexed channels. The available
94ae85220   Russell King - ARM Linux   ARM: PL08x: clean...
213
214
215
216
217
218
   * physical channels will be multiplexed around these signals as they are
   * requested, just enumerate all possible channels.
   * @get_signal: request a physical signal to be used for a DMA transfer
   * immediately: if there is some multiplexing or similar blocking the use
   * of the channel the transfer can be denied by returning less than zero,
   * else it returns the allocated signal number
e8689e63d   Linus Walleij   dmaengine: driver...
219
220
   * @put_signal: indicate to the platform that this physical signal is not
   * running any DMA transfer and multiplexing can be recycled
30749cb4a   Russell King - ARM Linux   ARM: PL08x: allow...
221
222
   * @lli_buses: buses which LLIs can be fetched from: PL08X_AHB1 | PL08X_AHB2
   * @mem_buses: buses which memory can be accessed from: PL08X_AHB1 | PL08X_AHB2
e8689e63d   Linus Walleij   dmaengine: driver...
223
224
   */
  struct pl08x_platform_data {
fa020e7d0   Russell King - ARM Linux   DMA: PL08x: const...
225
  	const struct pl08x_channel_data *slave_channels;
e8689e63d   Linus Walleij   dmaengine: driver...
226
227
228
229
  	unsigned int num_slave_channels;
  	struct pl08x_channel_data memcpy_channel;
  	int (*get_signal)(struct pl08x_dma_chan *);
  	void (*put_signal)(struct pl08x_dma_chan *);
30749cb4a   Russell King - ARM Linux   ARM: PL08x: allow...
230
231
  	u8 lli_buses;
  	u8 mem_buses;
e8689e63d   Linus Walleij   dmaengine: driver...
232
233
234
235
236
237
238
239
240
241
242
243
  };
  
  #ifdef CONFIG_AMBA_PL08X
  bool pl08x_filter_id(struct dma_chan *chan, void *chan_id);
  #else
  static inline bool pl08x_filter_id(struct dma_chan *chan, void *chan_id)
  {
  	return false;
  }
  #endif
  
  #endif	/* AMBA_PL08X_H */