Blame view

drivers/dma/ep93xx_dma.c 38.8 KB
2874c5fd2   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
5fa29a17f   Mika Westerberg   dmaengine: add ep...
2
3
4
5
6
7
8
9
10
11
12
13
14
  /*
   * Driver for the Cirrus Logic EP93xx DMA Controller
   *
   * Copyright (C) 2011 Mika Westerberg
   *
   * DMA M2P implementation is based on the original
   * arch/arm/mach-ep93xx/dma-m2p.c which has following copyrights:
   *
   *   Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
   *   Copyright (C) 2006 Applied Data Systems
   *   Copyright (C) 2009 Ryan Mallon <rmallon@gmail.com>
   *
   * This driver is based on dw_dmac and amba-pl08x drivers.
5fa29a17f   Mika Westerberg   dmaengine: add ep...
15
16
17
18
19
20
   */
  
  #include <linux/clk.h>
  #include <linux/init.h>
  #include <linux/interrupt.h>
  #include <linux/dmaengine.h>
2389d674b   Mika Westerberg   dmaengine/ep93xx_...
21
  #include <linux/module.h>
ac3167257   Randy Dunlap   headers: separate...
22
  #include <linux/mod_devicetable.h>
5fa29a17f   Mika Westerberg   dmaengine: add ep...
23
24
  #include <linux/platform_device.h>
  #include <linux/slab.h>
a3b292454   Arnd Bergmann   ARM: ep93xx: move...
25
  #include <linux/platform_data/dma-ep93xx.h>
5fa29a17f   Mika Westerberg   dmaengine: add ep...
26

d2ebfb335   Russell King - ARM Linux   dmaengine: add pr...
27
  #include "dmaengine.h"
5fa29a17f   Mika Westerberg   dmaengine: add ep...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  /* M2P registers */
  #define M2P_CONTROL			0x0000
  #define M2P_CONTROL_STALLINT		BIT(0)
  #define M2P_CONTROL_NFBINT		BIT(1)
  #define M2P_CONTROL_CH_ERROR_INT	BIT(3)
  #define M2P_CONTROL_ENABLE		BIT(4)
  #define M2P_CONTROL_ICE			BIT(6)
  
  #define M2P_INTERRUPT			0x0004
  #define M2P_INTERRUPT_STALL		BIT(0)
  #define M2P_INTERRUPT_NFB		BIT(1)
  #define M2P_INTERRUPT_ERROR		BIT(3)
  
  #define M2P_PPALLOC			0x0008
  #define M2P_STATUS			0x000c
  
  #define M2P_MAXCNT0			0x0020
  #define M2P_BASE0			0x0024
  #define M2P_MAXCNT1			0x0030
  #define M2P_BASE1			0x0034
  
  #define M2P_STATE_IDLE			0
  #define M2P_STATE_STALL			1
  #define M2P_STATE_ON			2
  #define M2P_STATE_NEXT			3
  
  /* M2M registers */
  #define M2M_CONTROL			0x0000
  #define M2M_CONTROL_DONEINT		BIT(2)
  #define M2M_CONTROL_ENABLE		BIT(3)
  #define M2M_CONTROL_START		BIT(4)
  #define M2M_CONTROL_DAH			BIT(11)
  #define M2M_CONTROL_SAH			BIT(12)
  #define M2M_CONTROL_PW_SHIFT		9
  #define M2M_CONTROL_PW_8		(0 << M2M_CONTROL_PW_SHIFT)
  #define M2M_CONTROL_PW_16		(1 << M2M_CONTROL_PW_SHIFT)
  #define M2M_CONTROL_PW_32		(2 << M2M_CONTROL_PW_SHIFT)
  #define M2M_CONTROL_PW_MASK		(3 << M2M_CONTROL_PW_SHIFT)
  #define M2M_CONTROL_TM_SHIFT		13
  #define M2M_CONTROL_TM_TX		(1 << M2M_CONTROL_TM_SHIFT)
  #define M2M_CONTROL_TM_RX		(2 << M2M_CONTROL_TM_SHIFT)
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
69
  #define M2M_CONTROL_NFBINT		BIT(21)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
70
71
72
73
74
75
76
77
  #define M2M_CONTROL_RSS_SHIFT		22
  #define M2M_CONTROL_RSS_SSPRX		(1 << M2M_CONTROL_RSS_SHIFT)
  #define M2M_CONTROL_RSS_SSPTX		(2 << M2M_CONTROL_RSS_SHIFT)
  #define M2M_CONTROL_RSS_IDE		(3 << M2M_CONTROL_RSS_SHIFT)
  #define M2M_CONTROL_NO_HDSK		BIT(24)
  #define M2M_CONTROL_PWSC_SHIFT		25
  
  #define M2M_INTERRUPT			0x0004
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  #define M2M_INTERRUPT_MASK		6
  
  #define M2M_STATUS			0x000c
  #define M2M_STATUS_CTL_SHIFT		1
  #define M2M_STATUS_CTL_IDLE		(0 << M2M_STATUS_CTL_SHIFT)
  #define M2M_STATUS_CTL_STALL		(1 << M2M_STATUS_CTL_SHIFT)
  #define M2M_STATUS_CTL_MEMRD		(2 << M2M_STATUS_CTL_SHIFT)
  #define M2M_STATUS_CTL_MEMWR		(3 << M2M_STATUS_CTL_SHIFT)
  #define M2M_STATUS_CTL_BWCWAIT		(4 << M2M_STATUS_CTL_SHIFT)
  #define M2M_STATUS_CTL_MASK		(7 << M2M_STATUS_CTL_SHIFT)
  #define M2M_STATUS_BUF_SHIFT		4
  #define M2M_STATUS_BUF_NO		(0 << M2M_STATUS_BUF_SHIFT)
  #define M2M_STATUS_BUF_ON		(1 << M2M_STATUS_BUF_SHIFT)
  #define M2M_STATUS_BUF_NEXT		(2 << M2M_STATUS_BUF_SHIFT)
  #define M2M_STATUS_BUF_MASK		(3 << M2M_STATUS_BUF_SHIFT)
  #define M2M_STATUS_DONE			BIT(6)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
94
95
96
97
98
99
100
101
102
103
104
105
  
  #define M2M_BCR0			0x0010
  #define M2M_BCR1			0x0014
  #define M2M_SAR_BASE0			0x0018
  #define M2M_SAR_BASE1			0x001c
  #define M2M_DAR_BASE0			0x002c
  #define M2M_DAR_BASE1			0x0030
  
  #define DMA_MAX_CHAN_BYTES		0xffff
  #define DMA_MAX_CHAN_DESCRIPTORS	32
  
  struct ep93xx_dma_engine;
4e3c40408   Vinod Koul   dmaengine: ep93xx...
106
107
108
  static int ep93xx_dma_slave_config_write(struct dma_chan *chan,
  					 enum dma_transfer_direction dir,
  					 struct dma_slave_config *config);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  
  /**
   * struct ep93xx_dma_desc - EP93xx specific transaction descriptor
   * @src_addr: source address of the transaction
   * @dst_addr: destination address of the transaction
   * @size: size of the transaction (in bytes)
   * @complete: this descriptor is completed
   * @txd: dmaengine API descriptor
   * @tx_list: list of linked descriptors
   * @node: link used for putting this into a channel queue
   */
  struct ep93xx_dma_desc {
  	u32				src_addr;
  	u32				dst_addr;
  	size_t				size;
  	bool				complete;
  	struct dma_async_tx_descriptor	txd;
  	struct list_head		tx_list;
  	struct list_head		node;
  };
  
  /**
   * struct ep93xx_dma_chan - an EP93xx DMA M2P/M2M channel
   * @chan: dmaengine API channel
   * @edma: pointer to to the engine device
   * @regs: memory mapped registers
   * @irq: interrupt number of the channel
   * @clk: clock used by this channel
   * @tasklet: channel specific tasklet used for callbacks
   * @lock: lock protecting the fields following
   * @flags: flags for the channel
   * @buffer: which buffer to use next (0/1)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
141
142
143
144
   * @active: flattened chain of descriptors currently being processed
   * @queue: pending descriptors which are handled next
   * @free_list: list of free descriptors which can be used
   * @runtime_addr: physical address currently used as dest/src (M2M only). This
b2be07d00   Vinod Koul   dmaengine: ep93xx...
145
   *                is set via .device_config before slave operation is
5fa29a17f   Mika Westerberg   dmaengine: add ep...
146
147
   *                prepared
   * @runtime_ctrl: M2M runtime values for the control register.
ae70f785e   Lee Jones   dmaengine: ep93xx...
148
   * @slave_config: slave configuration
5fa29a17f   Mika Westerberg   dmaengine: add ep...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
   *
   * As EP93xx DMA controller doesn't support real chained DMA descriptors we
   * will have slightly different scheme here: @active points to a head of
   * flattened DMA descriptor chain.
   *
   * @queue holds pending transactions. These are linked through the first
   * descriptor in the chain. When a descriptor is moved to the @active queue,
   * the first and chained descriptors are flattened into a single list.
   *
   * @chan.private holds pointer to &struct ep93xx_dma_data which contains
   * necessary channel configuration information. For memcpy channels this must
   * be %NULL.
   */
  struct ep93xx_dma_chan {
  	struct dma_chan			chan;
  	const struct ep93xx_dma_engine	*edma;
  	void __iomem			*regs;
  	int				irq;
  	struct clk			*clk;
  	struct tasklet_struct		tasklet;
  	/* protects the fields following */
  	spinlock_t			lock;
  	unsigned long			flags;
  /* Channel is configured for cyclic transfers */
  #define EP93XX_DMA_IS_CYCLIC		0
  
  	int				buffer;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
176
177
178
179
180
  	struct list_head		active;
  	struct list_head		queue;
  	struct list_head		free_list;
  	u32				runtime_addr;
  	u32				runtime_ctrl;
4e3c40408   Vinod Koul   dmaengine: ep93xx...
181
  	struct dma_slave_config		slave_config;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
182
183
184
185
186
187
188
  };
  
  /**
   * struct ep93xx_dma_engine - the EP93xx DMA engine instance
   * @dma_dev: holds the dmaengine device
   * @m2m: is this an M2M or M2P device
   * @hw_setup: method which sets the channel up for operation
ae70f785e   Lee Jones   dmaengine: ep93xx...
189
   * @hw_synchronize: synchronizes DMA channel termination to current context
5fa29a17f   Mika Westerberg   dmaengine: add ep...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
   * @hw_shutdown: shuts the channel down and flushes whatever is left
   * @hw_submit: pushes active descriptor(s) to the hardware
   * @hw_interrupt: handle the interrupt
   * @num_channels: number of channels for this instance
   * @channels: array of channels
   *
   * There is one instance of this struct for the M2P channels and one for the
   * M2M channels. hw_xxx() methods are used to perform operations which are
   * different on M2M and M2P channels. These methods are called with channel
   * lock held and interrupts disabled so they cannot sleep.
   */
  struct ep93xx_dma_engine {
  	struct dma_device	dma_dev;
  	bool			m2m;
  	int			(*hw_setup)(struct ep93xx_dma_chan *);
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
205
  	void			(*hw_synchronize)(struct ep93xx_dma_chan *);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
  	void			(*hw_shutdown)(struct ep93xx_dma_chan *);
  	void			(*hw_submit)(struct ep93xx_dma_chan *);
  	int			(*hw_interrupt)(struct ep93xx_dma_chan *);
  #define INTERRUPT_UNKNOWN	0
  #define INTERRUPT_DONE		1
  #define INTERRUPT_NEXT_BUFFER	2
  
  	size_t			num_channels;
  	struct ep93xx_dma_chan	channels[];
  };
  
  static inline struct device *chan2dev(struct ep93xx_dma_chan *edmac)
  {
  	return &edmac->chan.dev->device;
  }
  
  static struct ep93xx_dma_chan *to_ep93xx_dma_chan(struct dma_chan *chan)
  {
  	return container_of(chan, struct ep93xx_dma_chan, chan);
  }
  
  /**
   * ep93xx_dma_set_active - set new active descriptor chain
   * @edmac: channel
   * @desc: head of the new active descriptor chain
   *
   * Sets @desc to be the head of the new active descriptor chain. This is the
   * chain which is processed next. The active list must be empty before calling
   * this function.
   *
   * Called with @edmac->lock held and interrupts disabled.
   */
  static void ep93xx_dma_set_active(struct ep93xx_dma_chan *edmac,
  				  struct ep93xx_dma_desc *desc)
  {
  	BUG_ON(!list_empty(&edmac->active));
  
  	list_add_tail(&desc->node, &edmac->active);
  
  	/* Flatten the @desc->tx_list chain into @edmac->active list */
  	while (!list_empty(&desc->tx_list)) {
  		struct ep93xx_dma_desc *d = list_first_entry(&desc->tx_list,
  			struct ep93xx_dma_desc, node);
  
  		/*
  		 * We copy the callback parameters from the first descriptor
  		 * to all the chained descriptors. This way we can call the
  		 * callback without having to find out the first descriptor in
  		 * the chain. Useful for cyclic transfers.
  		 */
  		d->txd.callback = desc->txd.callback;
  		d->txd.callback_param = desc->txd.callback_param;
  
  		list_move_tail(&d->node, &edmac->active);
  	}
  }
  
  /* Called with @edmac->lock held and interrupts disabled */
  static struct ep93xx_dma_desc *
  ep93xx_dma_get_active(struct ep93xx_dma_chan *edmac)
  {
360af35b0   Masahiro Yamada   dmaengine: cleanu...
267
268
  	return list_first_entry_or_null(&edmac->active,
  					struct ep93xx_dma_desc, node);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
  }
  
  /**
   * ep93xx_dma_advance_active - advances to the next active descriptor
   * @edmac: channel
   *
   * Function advances active descriptor to the next in the @edmac->active and
   * returns %true if we still have descriptors in the chain to process.
   * Otherwise returns %false.
   *
   * When the channel is in cyclic mode always returns %true.
   *
   * Called with @edmac->lock held and interrupts disabled.
   */
  static bool ep93xx_dma_advance_active(struct ep93xx_dma_chan *edmac)
  {
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
285
  	struct ep93xx_dma_desc *desc;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
286
287
288
289
  	list_rotate_left(&edmac->active);
  
  	if (test_bit(EP93XX_DMA_IS_CYCLIC, &edmac->flags))
  		return true;
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
290
291
292
  	desc = ep93xx_dma_get_active(edmac);
  	if (!desc)
  		return false;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
293
294
295
296
  	/*
  	 * If txd.cookie is set it means that we are back in the first
  	 * descriptor in the chain and hence done with it.
  	 */
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
297
  	return !desc->txd.cookie;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
  }
  
  /*
   * M2P DMA implementation
   */
  
  static void m2p_set_control(struct ep93xx_dma_chan *edmac, u32 control)
  {
  	writel(control, edmac->regs + M2P_CONTROL);
  	/*
  	 * EP93xx User's Guide states that we must perform a dummy read after
  	 * write to the control register.
  	 */
  	readl(edmac->regs + M2P_CONTROL);
  }
  
  static int m2p_hw_setup(struct ep93xx_dma_chan *edmac)
  {
  	struct ep93xx_dma_data *data = edmac->chan.private;
  	u32 control;
  
  	writel(data->port & 0xf, edmac->regs + M2P_PPALLOC);
  
  	control = M2P_CONTROL_CH_ERROR_INT | M2P_CONTROL_ICE
  		| M2P_CONTROL_ENABLE;
  	m2p_set_control(edmac, control);
0037ae478   Alexander Sverdlin   dmaengine: ep93xx...
324
  	edmac->buffer = 0;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
325
326
327
328
329
330
331
  	return 0;
  }
  
  static inline u32 m2p_channel_state(struct ep93xx_dma_chan *edmac)
  {
  	return (readl(edmac->regs + M2P_STATUS) >> 4) & 0x3;
  }
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
332
  static void m2p_hw_synchronize(struct ep93xx_dma_chan *edmac)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
333
  {
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
334
  	unsigned long flags;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
335
  	u32 control;
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
336
  	spin_lock_irqsave(&edmac->lock, flags);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
337
338
339
  	control = readl(edmac->regs + M2P_CONTROL);
  	control &= ~(M2P_CONTROL_STALLINT | M2P_CONTROL_NFBINT);
  	m2p_set_control(edmac, control);
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
340
  	spin_unlock_irqrestore(&edmac->lock, flags);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
341
342
  
  	while (m2p_channel_state(edmac) >= M2P_STATE_ON)
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
343
344
  		schedule();
  }
5fa29a17f   Mika Westerberg   dmaengine: add ep...
345

98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
346
347
  static void m2p_hw_shutdown(struct ep93xx_dma_chan *edmac)
  {
5fa29a17f   Mika Westerberg   dmaengine: add ep...
348
  	m2p_set_control(edmac, 0);
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
349
350
351
  	while (m2p_channel_state(edmac) != M2P_STATE_IDLE)
  		dev_warn(chan2dev(edmac), "M2P: Not yet IDLE
  ");
5fa29a17f   Mika Westerberg   dmaengine: add ep...
352
353
354
355
  }
  
  static void m2p_fill_desc(struct ep93xx_dma_chan *edmac)
  {
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
356
  	struct ep93xx_dma_desc *desc;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
357
  	u32 bus_addr;
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
358
359
360
361
362
363
  	desc = ep93xx_dma_get_active(edmac);
  	if (!desc) {
  		dev_warn(chan2dev(edmac), "M2P: empty descriptor list
  ");
  		return;
  	}
db8196df4   Vinod Koul   dmaengine: move d...
364
  	if (ep93xx_dma_chan_direction(&edmac->chan) == DMA_MEM_TO_DEV)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
  		bus_addr = desc->src_addr;
  	else
  		bus_addr = desc->dst_addr;
  
  	if (edmac->buffer == 0) {
  		writel(desc->size, edmac->regs + M2P_MAXCNT0);
  		writel(bus_addr, edmac->regs + M2P_BASE0);
  	} else {
  		writel(desc->size, edmac->regs + M2P_MAXCNT1);
  		writel(bus_addr, edmac->regs + M2P_BASE1);
  	}
  
  	edmac->buffer ^= 1;
  }
  
  static void m2p_hw_submit(struct ep93xx_dma_chan *edmac)
  {
  	u32 control = readl(edmac->regs + M2P_CONTROL);
  
  	m2p_fill_desc(edmac);
  	control |= M2P_CONTROL_STALLINT;
  
  	if (ep93xx_dma_advance_active(edmac)) {
  		m2p_fill_desc(edmac);
  		control |= M2P_CONTROL_NFBINT;
  	}
  
  	m2p_set_control(edmac, control);
  }
  
  static int m2p_hw_interrupt(struct ep93xx_dma_chan *edmac)
  {
  	u32 irq_status = readl(edmac->regs + M2P_INTERRUPT);
  	u32 control;
  
  	if (irq_status & M2P_INTERRUPT_ERROR) {
  		struct ep93xx_dma_desc *desc = ep93xx_dma_get_active(edmac);
  
  		/* Clear the error interrupt */
  		writel(1, edmac->regs + M2P_INTERRUPT);
  
  		/*
  		 * It seems that there is no easy way of reporting errors back
  		 * to client so we just report the error here and continue as
  		 * usual.
  		 *
  		 * Revisit this when there is a mechanism to report back the
  		 * errors.
  		 */
  		dev_err(chan2dev(edmac),
  			"DMA transfer failed! Details:
  "
  			"\tcookie	: %d
  "
  			"\tsrc_addr	: 0x%08x
  "
  			"\tdst_addr	: 0x%08x
  "
  			"\tsize		: %zu
  ",
  			desc->txd.cookie, desc->src_addr, desc->dst_addr,
  			desc->size);
  	}
94901e1b2   Alexander Sverdlin   dmaengine: ep93xx...
428
429
430
431
432
433
434
  	/*
  	 * Even latest E2 silicon revision sometimes assert STALL interrupt
  	 * instead of NFB. Therefore we treat them equally, basing on the
  	 * amount of data we still have to transfer.
  	 */
  	if (!(irq_status & (M2P_INTERRUPT_STALL | M2P_INTERRUPT_NFB)))
  		return INTERRUPT_UNKNOWN;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
435

94901e1b2   Alexander Sverdlin   dmaengine: ep93xx...
436
437
  	if (ep93xx_dma_advance_active(edmac)) {
  		m2p_fill_desc(edmac);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
438
439
  		return INTERRUPT_NEXT_BUFFER;
  	}
94901e1b2   Alexander Sverdlin   dmaengine: ep93xx...
440
441
442
443
444
445
  	/* Disable interrupts */
  	control = readl(edmac->regs + M2P_CONTROL);
  	control &= ~(M2P_CONTROL_STALLINT | M2P_CONTROL_NFBINT);
  	m2p_set_control(edmac, control);
  
  	return INTERRUPT_DONE;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
446
447
448
449
  }
  
  /*
   * M2M DMA implementation
5fa29a17f   Mika Westerberg   dmaengine: add ep...
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
   */
  
  static int m2m_hw_setup(struct ep93xx_dma_chan *edmac)
  {
  	const struct ep93xx_dma_data *data = edmac->chan.private;
  	u32 control = 0;
  
  	if (!data) {
  		/* This is memcpy channel, nothing to configure */
  		writel(control, edmac->regs + M2M_CONTROL);
  		return 0;
  	}
  
  	switch (data->port) {
  	case EP93XX_DMA_SSP:
  		/*
  		 * This was found via experimenting - anything less than 5
  		 * causes the channel to perform only a partial transfer which
  		 * leads to problems since we don't get DONE interrupt then.
  		 */
  		control = (5 << M2M_CONTROL_PWSC_SHIFT);
  		control |= M2M_CONTROL_NO_HDSK;
db8196df4   Vinod Koul   dmaengine: move d...
472
  		if (data->direction == DMA_MEM_TO_DEV) {
5fa29a17f   Mika Westerberg   dmaengine: add ep...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
  			control |= M2M_CONTROL_DAH;
  			control |= M2M_CONTROL_TM_TX;
  			control |= M2M_CONTROL_RSS_SSPTX;
  		} else {
  			control |= M2M_CONTROL_SAH;
  			control |= M2M_CONTROL_TM_RX;
  			control |= M2M_CONTROL_RSS_SSPRX;
  		}
  		break;
  
  	case EP93XX_DMA_IDE:
  		/*
  		 * This IDE part is totally untested. Values below are taken
  		 * from the EP93xx Users's Guide and might not be correct.
  		 */
db8196df4   Vinod Koul   dmaengine: move d...
488
  		if (data->direction == DMA_MEM_TO_DEV) {
5fa29a17f   Mika Westerberg   dmaengine: add ep...
489
490
491
492
493
494
495
496
497
  			/* Worst case from the UG */
  			control = (3 << M2M_CONTROL_PWSC_SHIFT);
  			control |= M2M_CONTROL_DAH;
  			control |= M2M_CONTROL_TM_TX;
  		} else {
  			control = (2 << M2M_CONTROL_PWSC_SHIFT);
  			control |= M2M_CONTROL_SAH;
  			control |= M2M_CONTROL_TM_RX;
  		}
b62cfc5e0   Rafal Prylowski   dma/ep93xx_dma: f...
498
499
500
501
  
  		control |= M2M_CONTROL_NO_HDSK;
  		control |= M2M_CONTROL_RSS_IDE;
  		control |= M2M_CONTROL_PW_16;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
  		break;
  
  	default:
  		return -EINVAL;
  	}
  
  	writel(control, edmac->regs + M2M_CONTROL);
  	return 0;
  }
  
  static void m2m_hw_shutdown(struct ep93xx_dma_chan *edmac)
  {
  	/* Just disable the channel */
  	writel(0, edmac->regs + M2M_CONTROL);
  }
  
  static void m2m_fill_desc(struct ep93xx_dma_chan *edmac)
  {
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
520
521
522
523
524
525
526
527
  	struct ep93xx_dma_desc *desc;
  
  	desc = ep93xx_dma_get_active(edmac);
  	if (!desc) {
  		dev_warn(chan2dev(edmac), "M2M: empty descriptor list
  ");
  		return;
  	}
5fa29a17f   Mika Westerberg   dmaengine: add ep...
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
  
  	if (edmac->buffer == 0) {
  		writel(desc->src_addr, edmac->regs + M2M_SAR_BASE0);
  		writel(desc->dst_addr, edmac->regs + M2M_DAR_BASE0);
  		writel(desc->size, edmac->regs + M2M_BCR0);
  	} else {
  		writel(desc->src_addr, edmac->regs + M2M_SAR_BASE1);
  		writel(desc->dst_addr, edmac->regs + M2M_DAR_BASE1);
  		writel(desc->size, edmac->regs + M2M_BCR1);
  	}
  
  	edmac->buffer ^= 1;
  }
  
  static void m2m_hw_submit(struct ep93xx_dma_chan *edmac)
  {
  	struct ep93xx_dma_data *data = edmac->chan.private;
  	u32 control = readl(edmac->regs + M2M_CONTROL);
  
  	/*
  	 * Since we allow clients to configure PW (peripheral width) we always
  	 * clear PW bits here and then set them according what is given in
  	 * the runtime configuration.
  	 */
  	control &= ~M2M_CONTROL_PW_MASK;
  	control |= edmac->runtime_ctrl;
  
  	m2m_fill_desc(edmac);
  	control |= M2M_CONTROL_DONEINT;
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
557
558
559
560
  	if (ep93xx_dma_advance_active(edmac)) {
  		m2m_fill_desc(edmac);
  		control |= M2M_CONTROL_NFBINT;
  	}
5fa29a17f   Mika Westerberg   dmaengine: add ep...
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
  	/*
  	 * Now we can finally enable the channel. For M2M channel this must be
  	 * done _after_ the BCRx registers are programmed.
  	 */
  	control |= M2M_CONTROL_ENABLE;
  	writel(control, edmac->regs + M2M_CONTROL);
  
  	if (!data) {
  		/*
  		 * For memcpy channels the software trigger must be asserted
  		 * in order to start the memcpy operation.
  		 */
  		control |= M2M_CONTROL_START;
  		writel(control, edmac->regs + M2M_CONTROL);
  	}
  }
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
577
578
579
580
581
582
583
584
585
586
  /*
   * According to EP93xx User's Guide, we should receive DONE interrupt when all
   * M2M DMA controller transactions complete normally. This is not always the
   * case - sometimes EP93xx M2M DMA asserts DONE interrupt when the DMA channel
   * is still running (channel Buffer FSM in DMA_BUF_ON state, and channel
   * Control FSM in DMA_MEM_RD state, observed at least in IDE-DMA operation).
   * In effect, disabling the channel when only DONE bit is set could stop
   * currently running DMA transfer. To avoid this, we use Buffer FSM and
   * Control FSM to check current state of DMA channel.
   */
5fa29a17f   Mika Westerberg   dmaengine: add ep...
587
588
  static int m2m_hw_interrupt(struct ep93xx_dma_chan *edmac)
  {
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
589
590
591
592
593
  	u32 status = readl(edmac->regs + M2M_STATUS);
  	u32 ctl_fsm = status & M2M_STATUS_CTL_MASK;
  	u32 buf_fsm = status & M2M_STATUS_BUF_MASK;
  	bool done = status & M2M_STATUS_DONE;
  	bool last_done;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
594
  	u32 control;
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
595
  	struct ep93xx_dma_desc *desc;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
596

2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
597
598
  	/* Accept only DONE and NFB interrupts */
  	if (!(readl(edmac->regs + M2M_INTERRUPT) & M2M_INTERRUPT_MASK))
5fa29a17f   Mika Westerberg   dmaengine: add ep...
599
  		return INTERRUPT_UNKNOWN;
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
600
601
602
603
  	if (done) {
  		/* Clear the DONE bit */
  		writel(0, edmac->regs + M2M_INTERRUPT);
  	}
5fa29a17f   Mika Westerberg   dmaengine: add ep...
604

2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
605
606
607
608
609
610
  	/*
  	 * Check whether we are done with descriptors or not. This, together
  	 * with DMA channel state, determines action to take in interrupt.
  	 */
  	desc = ep93xx_dma_get_active(edmac);
  	last_done = !desc || desc->txd.cookie;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
611
612
  
  	/*
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
613
614
615
  	 * Use M2M DMA Buffer FSM and Control FSM to check current state of
  	 * DMA channel. Using DONE and NFB bits from channel status register
  	 * or bits from channel interrupt register is not reliable.
5fa29a17f   Mika Westerberg   dmaengine: add ep...
616
  	 */
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
  	if (!last_done &&
  	    (buf_fsm == M2M_STATUS_BUF_NO ||
  	     buf_fsm == M2M_STATUS_BUF_ON)) {
  		/*
  		 * Two buffers are ready for update when Buffer FSM is in
  		 * DMA_NO_BUF state. Only one buffer can be prepared without
  		 * disabling the channel or polling the DONE bit.
  		 * To simplify things, always prepare only one buffer.
  		 */
  		if (ep93xx_dma_advance_active(edmac)) {
  			m2m_fill_desc(edmac);
  			if (done && !edmac->chan.private) {
  				/* Software trigger for memcpy channel */
  				control = readl(edmac->regs + M2M_CONTROL);
  				control |= M2M_CONTROL_START;
  				writel(control, edmac->regs + M2M_CONTROL);
  			}
  			return INTERRUPT_NEXT_BUFFER;
  		} else {
  			last_done = true;
  		}
5fa29a17f   Mika Westerberg   dmaengine: add ep...
638
  	}
2b3c83efc   Rafal Prylowski   dmaengine/ep93xx_...
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
  	/*
  	 * Disable the channel only when Buffer FSM is in DMA_NO_BUF state
  	 * and Control FSM is in DMA_STALL state.
  	 */
  	if (last_done &&
  	    buf_fsm == M2M_STATUS_BUF_NO &&
  	    ctl_fsm == M2M_STATUS_CTL_STALL) {
  		/* Disable interrupts and the channel */
  		control = readl(edmac->regs + M2M_CONTROL);
  		control &= ~(M2M_CONTROL_DONEINT | M2M_CONTROL_NFBINT
  			    | M2M_CONTROL_ENABLE);
  		writel(control, edmac->regs + M2M_CONTROL);
  		return INTERRUPT_DONE;
  	}
  
  	/*
  	 * Nothing to do this time.
  	 */
  	return INTERRUPT_NEXT_BUFFER;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
  }
  
  /*
   * DMA engine API implementation
   */
  
  static struct ep93xx_dma_desc *
  ep93xx_dma_desc_get(struct ep93xx_dma_chan *edmac)
  {
  	struct ep93xx_dma_desc *desc, *_desc;
  	struct ep93xx_dma_desc *ret = NULL;
  	unsigned long flags;
  
  	spin_lock_irqsave(&edmac->lock, flags);
  	list_for_each_entry_safe(desc, _desc, &edmac->free_list, node) {
  		if (async_tx_test_ack(&desc->txd)) {
  			list_del_init(&desc->node);
  
  			/* Re-initialize the descriptor */
  			desc->src_addr = 0;
  			desc->dst_addr = 0;
  			desc->size = 0;
  			desc->complete = false;
  			desc->txd.cookie = 0;
  			desc->txd.callback = NULL;
  			desc->txd.callback_param = NULL;
  
  			ret = desc;
  			break;
  		}
  	}
  	spin_unlock_irqrestore(&edmac->lock, flags);
  	return ret;
  }
  
  static void ep93xx_dma_desc_put(struct ep93xx_dma_chan *edmac,
  				struct ep93xx_dma_desc *desc)
  {
  	if (desc) {
  		unsigned long flags;
  
  		spin_lock_irqsave(&edmac->lock, flags);
  		list_splice_init(&desc->tx_list, &edmac->free_list);
  		list_add(&desc->node, &edmac->free_list);
  		spin_unlock_irqrestore(&edmac->lock, flags);
  	}
  }
  
  /**
   * ep93xx_dma_advance_work - start processing the next pending transaction
   * @edmac: channel
   *
   * If we have pending transactions queued and we are currently idling, this
   * function takes the next queued transaction from the @edmac->queue and
   * pushes it to the hardware for execution.
   */
  static void ep93xx_dma_advance_work(struct ep93xx_dma_chan *edmac)
  {
  	struct ep93xx_dma_desc *new;
  	unsigned long flags;
  
  	spin_lock_irqsave(&edmac->lock, flags);
  	if (!list_empty(&edmac->active) || list_empty(&edmac->queue)) {
  		spin_unlock_irqrestore(&edmac->lock, flags);
  		return;
  	}
  
  	/* Take the next descriptor from the pending queue */
  	new = list_first_entry(&edmac->queue, struct ep93xx_dma_desc, node);
  	list_del_init(&new->node);
  
  	ep93xx_dma_set_active(edmac, new);
  
  	/* Push it to the hardware */
  	edmac->edma->hw_submit(edmac);
  	spin_unlock_irqrestore(&edmac->lock, flags);
  }
95fbf1634   Allen Pais   dmaengine: ep93xx...
735
  static void ep93xx_dma_tasklet(struct tasklet_struct *t)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
736
  {
95fbf1634   Allen Pais   dmaengine: ep93xx...
737
  	struct ep93xx_dma_chan *edmac = from_tasklet(edmac, t, tasklet);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
738
  	struct ep93xx_dma_desc *desc, *d;
dac86a148   Dave Jiang   dmaengine: ep93xx...
739
  	struct dmaengine_desc_callback cb;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
740
  	LIST_HEAD(list);
dac86a148   Dave Jiang   dmaengine: ep93xx...
741
  	memset(&cb, 0, sizeof(cb));
5fa29a17f   Mika Westerberg   dmaengine: add ep...
742
  	spin_lock_irq(&edmac->lock);
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
743
744
745
746
747
  	/*
  	 * If dma_terminate_all() was called before we get to run, the active
  	 * list has become empty. If that happens we aren't supposed to do
  	 * anything more than call ep93xx_dma_advance_work().
  	 */
5fa29a17f   Mika Westerberg   dmaengine: add ep...
748
  	desc = ep93xx_dma_get_active(edmac);
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
749
750
  	if (desc) {
  		if (desc->complete) {
d41160524   Vinod Koul   dmaengine: fix cy...
751
752
753
  			/* mark descriptor complete for non cyclic case only */
  			if (!test_bit(EP93XX_DMA_IS_CYCLIC, &edmac->flags))
  				dma_cookie_complete(&desc->txd);
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
754
755
  			list_splice_init(&edmac->active, &list);
  		}
dac86a148   Dave Jiang   dmaengine: ep93xx...
756
  		dmaengine_desc_get_callback(&desc->txd, &cb);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
757
758
759
760
761
  	}
  	spin_unlock_irq(&edmac->lock);
  
  	/* Pick up the next descriptor from the queue */
  	ep93xx_dma_advance_work(edmac);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
762
763
  	/* Now we can release all the chained descriptors */
  	list_for_each_entry_safe(desc, d, &list, node) {
d38a8c622   Dan Williams   dmaengine: prepar...
764
  		dma_descriptor_unmap(&desc->txd);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
765
766
  		ep93xx_dma_desc_put(edmac, desc);
  	}
dac86a148   Dave Jiang   dmaengine: ep93xx...
767
  	dmaengine_desc_callback_invoke(&cb, NULL);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
768
769
770
771
772
  }
  
  static irqreturn_t ep93xx_dma_interrupt(int irq, void *dev_id)
  {
  	struct ep93xx_dma_chan *edmac = dev_id;
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
773
  	struct ep93xx_dma_desc *desc;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
774
775
776
  	irqreturn_t ret = IRQ_HANDLED;
  
  	spin_lock(&edmac->lock);
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
777
778
779
780
781
782
783
784
  	desc = ep93xx_dma_get_active(edmac);
  	if (!desc) {
  		dev_warn(chan2dev(edmac),
  			 "got interrupt while active list is empty
  ");
  		spin_unlock(&edmac->lock);
  		return IRQ_NONE;
  	}
5fa29a17f   Mika Westerberg   dmaengine: add ep...
785
786
  	switch (edmac->edma->hw_interrupt(edmac)) {
  	case INTERRUPT_DONE:
6d0709d20   Mika Westerberg   dma/ep93xx_dma: p...
787
  		desc->complete = true;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
  		tasklet_schedule(&edmac->tasklet);
  		break;
  
  	case INTERRUPT_NEXT_BUFFER:
  		if (test_bit(EP93XX_DMA_IS_CYCLIC, &edmac->flags))
  			tasklet_schedule(&edmac->tasklet);
  		break;
  
  	default:
  		dev_warn(chan2dev(edmac), "unknown interrupt!
  ");
  		ret = IRQ_NONE;
  		break;
  	}
  
  	spin_unlock(&edmac->lock);
  	return ret;
  }
  
  /**
   * ep93xx_dma_tx_submit - set the prepared descriptor(s) to be executed
   * @tx: descriptor to be executed
   *
   * Function will execute given descriptor on the hardware or if the hardware
   * is busy, queue the descriptor to be executed later on. Returns cookie which
   * can be used to poll the status of the descriptor.
   */
  static dma_cookie_t ep93xx_dma_tx_submit(struct dma_async_tx_descriptor *tx)
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(tx->chan);
  	struct ep93xx_dma_desc *desc;
  	dma_cookie_t cookie;
  	unsigned long flags;
  
  	spin_lock_irqsave(&edmac->lock, flags);
884485e1f   Russell King - ARM Linux   dmaengine: consol...
823
  	cookie = dma_cookie_assign(tx);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
824
825
  
  	desc = container_of(tx, struct ep93xx_dma_desc, txd);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
  	/*
  	 * If nothing is currently prosessed, we push this descriptor
  	 * directly to the hardware. Otherwise we put the descriptor
  	 * to the pending queue.
  	 */
  	if (list_empty(&edmac->active)) {
  		ep93xx_dma_set_active(edmac, desc);
  		edmac->edma->hw_submit(edmac);
  	} else {
  		list_add_tail(&desc->node, &edmac->queue);
  	}
  
  	spin_unlock_irqrestore(&edmac->lock, flags);
  	return cookie;
  }
  
  /**
   * ep93xx_dma_alloc_chan_resources - allocate resources for the channel
   * @chan: channel to allocate resources
   *
   * Function allocates necessary resources for the given DMA channel and
   * returns number of allocated descriptors for the channel. Negative errno
   * is returned in case of failure.
   */
  static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
  	struct ep93xx_dma_data *data = chan->private;
  	const char *name = dma_chan_name(chan);
  	int ret, i;
  
  	/* Sanity check the channel parameters */
  	if (!edmac->edma->m2m) {
  		if (!data)
  			return -EINVAL;
  		if (data->port < EP93XX_DMA_I2S1 ||
  		    data->port > EP93XX_DMA_IRDA)
  			return -EINVAL;
  		if (data->direction != ep93xx_dma_chan_direction(chan))
  			return -EINVAL;
  	} else {
  		if (data) {
  			switch (data->port) {
  			case EP93XX_DMA_SSP:
  			case EP93XX_DMA_IDE:
0efcdb20f   Andy Shevchenko   dma: ep93xx_dma: ...
871
  				if (!is_slave_direction(data->direction))
5fa29a17f   Mika Westerberg   dmaengine: add ep...
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
  					return -EINVAL;
  				break;
  			default:
  				return -EINVAL;
  			}
  		}
  	}
  
  	if (data && data->name)
  		name = data->name;
  
  	ret = clk_enable(edmac->clk);
  	if (ret)
  		return ret;
  
  	ret = request_irq(edmac->irq, ep93xx_dma_interrupt, 0, name, edmac);
  	if (ret)
  		goto fail_clk_disable;
  
  	spin_lock_irq(&edmac->lock);
d3ee98cdc   Russell King - ARM Linux   dmaengine: consol...
892
  	dma_cookie_init(&edmac->chan);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
  	ret = edmac->edma->hw_setup(edmac);
  	spin_unlock_irq(&edmac->lock);
  
  	if (ret)
  		goto fail_free_irq;
  
  	for (i = 0; i < DMA_MAX_CHAN_DESCRIPTORS; i++) {
  		struct ep93xx_dma_desc *desc;
  
  		desc = kzalloc(sizeof(*desc), GFP_KERNEL);
  		if (!desc) {
  			dev_warn(chan2dev(edmac), "not enough descriptors
  ");
  			break;
  		}
  
  		INIT_LIST_HEAD(&desc->tx_list);
  
  		dma_async_tx_descriptor_init(&desc->txd, chan);
  		desc->txd.flags = DMA_CTRL_ACK;
  		desc->txd.tx_submit = ep93xx_dma_tx_submit;
  
  		ep93xx_dma_desc_put(edmac, desc);
  	}
  
  	return i;
  
  fail_free_irq:
  	free_irq(edmac->irq, edmac);
  fail_clk_disable:
  	clk_disable(edmac->clk);
  
  	return ret;
  }
  
  /**
   * ep93xx_dma_free_chan_resources - release resources for the channel
   * @chan: channel
   *
   * Function releases all the resources allocated for the given channel.
   * The channel must be idle when this is called.
   */
  static void ep93xx_dma_free_chan_resources(struct dma_chan *chan)
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
  	struct ep93xx_dma_desc *desc, *d;
  	unsigned long flags;
  	LIST_HEAD(list);
  
  	BUG_ON(!list_empty(&edmac->active));
  	BUG_ON(!list_empty(&edmac->queue));
  
  	spin_lock_irqsave(&edmac->lock, flags);
  	edmac->edma->hw_shutdown(edmac);
  	edmac->runtime_addr = 0;
  	edmac->runtime_ctrl = 0;
  	edmac->buffer = 0;
  	list_splice_init(&edmac->free_list, &list);
  	spin_unlock_irqrestore(&edmac->lock, flags);
  
  	list_for_each_entry_safe(desc, d, &list, node)
  		kfree(desc);
  
  	clk_disable(edmac->clk);
  	free_irq(edmac->irq, edmac);
  }
  
  /**
   * ep93xx_dma_prep_dma_memcpy - prepare a memcpy DMA operation
   * @chan: channel
   * @dest: destination bus address
   * @src: source bus address
   * @len: size of the transaction
   * @flags: flags for the descriptor
   *
   * Returns a valid DMA descriptor or %NULL in case of failure.
   */
e2f5e5a71   H Hartley Sweeten   dma/ep93xx_dma.c:...
970
  static struct dma_async_tx_descriptor *
5fa29a17f   Mika Westerberg   dmaengine: add ep...
971
972
973
974
975
976
977
978
979
980
981
  ep93xx_dma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest,
  			   dma_addr_t src, size_t len, unsigned long flags)
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
  	struct ep93xx_dma_desc *desc, *first;
  	size_t bytes, offset;
  
  	first = NULL;
  	for (offset = 0; offset < len; offset += bytes) {
  		desc = ep93xx_dma_desc_get(edmac);
  		if (!desc) {
9b68cc012   Yangtao Li   dmaengine: ep93xx...
982
983
  			dev_warn(chan2dev(edmac), "couldn't get descriptor
  ");
5fa29a17f   Mika Westerberg   dmaengine: add ep...
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
  			goto fail;
  		}
  
  		bytes = min_t(size_t, len - offset, DMA_MAX_CHAN_BYTES);
  
  		desc->src_addr = src + offset;
  		desc->dst_addr = dest + offset;
  		desc->size = bytes;
  
  		if (!first)
  			first = desc;
  		else
  			list_add_tail(&desc->node, &first->tx_list);
  	}
  
  	first->txd.cookie = -EBUSY;
  	first->txd.flags = flags;
  
  	return &first->txd;
  fail:
  	ep93xx_dma_desc_put(edmac, first);
  	return NULL;
  }
  
  /**
   * ep93xx_dma_prep_slave_sg - prepare a slave DMA operation
   * @chan: channel
   * @sgl: list of buffers to transfer
   * @sg_len: number of entries in @sgl
   * @dir: direction of tha DMA transfer
   * @flags: flags for the descriptor
185ecb5f4   Alexandre Bounine   dmaengine: add co...
1015
   * @context: operation context (ignored)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1016
1017
1018
1019
1020
   *
   * Returns a valid DMA descriptor or %NULL in case of failure.
   */
  static struct dma_async_tx_descriptor *
  ep93xx_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
db8196df4   Vinod Koul   dmaengine: move d...
1021
  			 unsigned int sg_len, enum dma_transfer_direction dir,
185ecb5f4   Alexandre Bounine   dmaengine: add co...
1022
  			 unsigned long flags, void *context)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
  	struct ep93xx_dma_desc *desc, *first;
  	struct scatterlist *sg;
  	int i;
  
  	if (!edmac->edma->m2m && dir != ep93xx_dma_chan_direction(chan)) {
  		dev_warn(chan2dev(edmac),
  			 "channel was configured with different direction
  ");
  		return NULL;
  	}
  
  	if (test_bit(EP93XX_DMA_IS_CYCLIC, &edmac->flags)) {
  		dev_warn(chan2dev(edmac),
  			 "channel is already used for cyclic transfers
  ");
  		return NULL;
  	}
4e3c40408   Vinod Koul   dmaengine: ep93xx...
1042
  	ep93xx_dma_slave_config_write(chan, dir, &edmac->slave_config);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1043
1044
  	first = NULL;
  	for_each_sg(sgl, sg, sg_len, i) {
8f913bffb   Vinod Koul   dmaengine: ep93xx...
1045
  		size_t len = sg_dma_len(sg);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1046

8f913bffb   Vinod Koul   dmaengine: ep93xx...
1047
  		if (len > DMA_MAX_CHAN_BYTES) {
567df5e97   Vinod Koul   dmaengine: ep93xx...
1048
1049
  			dev_warn(chan2dev(edmac), "too big transfer size %zu
  ",
8f913bffb   Vinod Koul   dmaengine: ep93xx...
1050
  				 len);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1051
1052
1053
1054
1055
  			goto fail;
  		}
  
  		desc = ep93xx_dma_desc_get(edmac);
  		if (!desc) {
9b68cc012   Yangtao Li   dmaengine: ep93xx...
1056
1057
  			dev_warn(chan2dev(edmac), "couldn't get descriptor
  ");
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1058
1059
  			goto fail;
  		}
db8196df4   Vinod Koul   dmaengine: move d...
1060
  		if (dir == DMA_MEM_TO_DEV) {
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1061
1062
1063
1064
1065
1066
  			desc->src_addr = sg_dma_address(sg);
  			desc->dst_addr = edmac->runtime_addr;
  		} else {
  			desc->src_addr = edmac->runtime_addr;
  			desc->dst_addr = sg_dma_address(sg);
  		}
8f913bffb   Vinod Koul   dmaengine: ep93xx...
1067
  		desc->size = len;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
  
  		if (!first)
  			first = desc;
  		else
  			list_add_tail(&desc->node, &first->tx_list);
  	}
  
  	first->txd.cookie = -EBUSY;
  	first->txd.flags = flags;
  
  	return &first->txd;
  
  fail:
  	ep93xx_dma_desc_put(edmac, first);
  	return NULL;
  }
  
  /**
   * ep93xx_dma_prep_dma_cyclic - prepare a cyclic DMA operation
   * @chan: channel
   * @dma_addr: DMA mapped address of the buffer
   * @buf_len: length of the buffer (in bytes)
d73111c6d   Masanari Iida   dma: fix comments
1090
   * @period_len: length of a single period
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1091
   * @dir: direction of the operation
ec8b5e48c   Peter Ujfalusi   dmaengine: Pass f...
1092
   * @flags: tx descriptor status flags
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
   *
   * Prepares a descriptor for cyclic DMA operation. This means that once the
   * descriptor is submitted, we will be submitting in a @period_len sized
   * buffers and calling callback once the period has been elapsed. Transfer
   * terminates only when client calls dmaengine_terminate_all() for this
   * channel.
   *
   * Returns a valid DMA descriptor or %NULL in case of failure.
   */
  static struct dma_async_tx_descriptor *
  ep93xx_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
  			   size_t buf_len, size_t period_len,
31c1e5a13   Laurent Pinchart   dmaengine: Remove...
1105
  			   enum dma_transfer_direction dir, unsigned long flags)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
  	struct ep93xx_dma_desc *desc, *first;
  	size_t offset = 0;
  
  	if (!edmac->edma->m2m && dir != ep93xx_dma_chan_direction(chan)) {
  		dev_warn(chan2dev(edmac),
  			 "channel was configured with different direction
  ");
  		return NULL;
  	}
  
  	if (test_and_set_bit(EP93XX_DMA_IS_CYCLIC, &edmac->flags)) {
  		dev_warn(chan2dev(edmac),
  			 "channel is already used for cyclic transfers
  ");
  		return NULL;
  	}
  
  	if (period_len > DMA_MAX_CHAN_BYTES) {
567df5e97   Vinod Koul   dmaengine: ep93xx...
1126
1127
  		dev_warn(chan2dev(edmac), "too big period length %zu
  ",
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1128
1129
1130
  			 period_len);
  		return NULL;
  	}
4e3c40408   Vinod Koul   dmaengine: ep93xx...
1131
  	ep93xx_dma_slave_config_write(chan, dir, &edmac->slave_config);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1132
1133
1134
1135
1136
  	/* Split the buffer into period size chunks */
  	first = NULL;
  	for (offset = 0; offset < buf_len; offset += period_len) {
  		desc = ep93xx_dma_desc_get(edmac);
  		if (!desc) {
9b68cc012   Yangtao Li   dmaengine: ep93xx...
1137
1138
  			dev_warn(chan2dev(edmac), "couldn't get descriptor
  ");
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1139
1140
  			goto fail;
  		}
db8196df4   Vinod Koul   dmaengine: move d...
1141
  		if (dir == DMA_MEM_TO_DEV) {
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
  			desc->src_addr = dma_addr + offset;
  			desc->dst_addr = edmac->runtime_addr;
  		} else {
  			desc->src_addr = edmac->runtime_addr;
  			desc->dst_addr = dma_addr + offset;
  		}
  
  		desc->size = period_len;
  
  		if (!first)
  			first = desc;
  		else
  			list_add_tail(&desc->node, &first->tx_list);
  	}
  
  	first->txd.cookie = -EBUSY;
  
  	return &first->txd;
  
  fail:
  	ep93xx_dma_desc_put(edmac, first);
  	return NULL;
  }
  
  /**
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
   * ep93xx_dma_synchronize - Synchronizes the termination of transfers to the
   * current context.
   * @chan: channel
   *
   * Synchronizes the DMA channel termination to the current context. When this
   * function returns it is guaranteed that all transfers for previously issued
   * descriptors have stopped and and it is safe to free the memory associated
   * with them. Furthermore it is guaranteed that all complete callback functions
   * for a previously submitted descriptor have finished running and it is safe to
   * free resources accessed from within the complete callbacks.
   */
  static void ep93xx_dma_synchronize(struct dma_chan *chan)
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
  
  	if (edmac->edma->hw_synchronize)
  		edmac->edma->hw_synchronize(edmac);
  }
  
  /**
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1187
   * ep93xx_dma_terminate_all - terminate all transactions
2258b6754   Maxime Ripard   dmaengine: ep93xx...
1188
   * @chan: channel
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1189
1190
1191
1192
   *
   * Stops all DMA transactions. All descriptors are put back to the
   * @edmac->free_list and callbacks are _not_ called.
   */
2258b6754   Maxime Ripard   dmaengine: ep93xx...
1193
  static int ep93xx_dma_terminate_all(struct dma_chan *chan)
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1194
  {
2258b6754   Maxime Ripard   dmaengine: ep93xx...
1195
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
  	struct ep93xx_dma_desc *desc, *_d;
  	unsigned long flags;
  	LIST_HEAD(list);
  
  	spin_lock_irqsave(&edmac->lock, flags);
  	/* First we disable and flush the DMA channel */
  	edmac->edma->hw_shutdown(edmac);
  	clear_bit(EP93XX_DMA_IS_CYCLIC, &edmac->flags);
  	list_splice_init(&edmac->active, &list);
  	list_splice_init(&edmac->queue, &list);
  	/*
  	 * We then re-enable the channel. This way we can continue submitting
  	 * the descriptors by just calling ->hw_submit() again.
  	 */
  	edmac->edma->hw_setup(edmac);
  	spin_unlock_irqrestore(&edmac->lock, flags);
  
  	list_for_each_entry_safe(desc, _d, &list, node)
  		ep93xx_dma_desc_put(edmac, desc);
  
  	return 0;
  }
2258b6754   Maxime Ripard   dmaengine: ep93xx...
1218
  static int ep93xx_dma_slave_config(struct dma_chan *chan,
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1219
1220
  				   struct dma_slave_config *config)
  {
2258b6754   Maxime Ripard   dmaengine: ep93xx...
1221
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
4e3c40408   Vinod Koul   dmaengine: ep93xx...
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
  
  	memcpy(&edmac->slave_config, config, sizeof(*config));
  
  	return 0;
  }
  
  static int ep93xx_dma_slave_config_write(struct dma_chan *chan,
  					 enum dma_transfer_direction dir,
  					 struct dma_slave_config *config)
  {
  	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1233
1234
1235
1236
1237
1238
  	enum dma_slave_buswidth width;
  	unsigned long flags;
  	u32 addr, ctrl;
  
  	if (!edmac->edma->m2m)
  		return -EINVAL;
4e3c40408   Vinod Koul   dmaengine: ep93xx...
1239
  	switch (dir) {
db8196df4   Vinod Koul   dmaengine: move d...
1240
  	case DMA_DEV_TO_MEM:
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1241
1242
1243
  		width = config->src_addr_width;
  		addr = config->src_addr;
  		break;
db8196df4   Vinod Koul   dmaengine: move d...
1244
  	case DMA_MEM_TO_DEV:
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
  		width = config->dst_addr_width;
  		addr = config->dst_addr;
  		break;
  
  	default:
  		return -EINVAL;
  	}
  
  	switch (width) {
  	case DMA_SLAVE_BUSWIDTH_1_BYTE:
  		ctrl = 0;
  		break;
  	case DMA_SLAVE_BUSWIDTH_2_BYTES:
  		ctrl = M2M_CONTROL_PW_16;
  		break;
  	case DMA_SLAVE_BUSWIDTH_4_BYTES:
  		ctrl = M2M_CONTROL_PW_32;
  		break;
  	default:
  		return -EINVAL;
  	}
  
  	spin_lock_irqsave(&edmac->lock, flags);
  	edmac->runtime_addr = addr;
  	edmac->runtime_ctrl = ctrl;
  	spin_unlock_irqrestore(&edmac->lock, flags);
  
  	return 0;
  }
  
  /**
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
   * ep93xx_dma_tx_status - check if a transaction is completed
   * @chan: channel
   * @cookie: transaction specific cookie
   * @state: state of the transaction is stored here if given
   *
   * This function can be used to query state of a given transaction.
   */
  static enum dma_status ep93xx_dma_tx_status(struct dma_chan *chan,
  					    dma_cookie_t cookie,
  					    struct dma_tx_state *state)
  {
2302cec22   Andy Shevchenko   ep93xx_dma: remov...
1287
  	return dma_cookie_status(chan, cookie, state);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
  }
  
  /**
   * ep93xx_dma_issue_pending - push pending transactions to the hardware
   * @chan: channel
   *
   * When this function is called, all pending transactions are pushed to the
   * hardware and executed.
   */
  static void ep93xx_dma_issue_pending(struct dma_chan *chan)
  {
  	ep93xx_dma_advance_work(to_ep93xx_dma_chan(chan));
  }
  
  static int __init ep93xx_dma_probe(struct platform_device *pdev)
  {
  	struct ep93xx_dma_platform_data *pdata = dev_get_platdata(&pdev->dev);
  	struct ep93xx_dma_engine *edma;
  	struct dma_device *dma_dev;
  	size_t edma_size;
  	int ret, i;
  
  	edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan);
  	edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL);
  	if (!edma)
  		return -ENOMEM;
  
  	dma_dev = &edma->dma_dev;
  	edma->m2m = platform_get_device_id(pdev)->driver_data;
  	edma->num_channels = pdata->num_channels;
  
  	INIT_LIST_HEAD(&dma_dev->channels);
  	for (i = 0; i < pdata->num_channels; i++) {
  		const struct ep93xx_dma_chan_data *cdata = &pdata->channels[i];
  		struct ep93xx_dma_chan *edmac = &edma->channels[i];
  
  		edmac->chan.device = dma_dev;
  		edmac->regs = cdata->base;
  		edmac->irq = cdata->irq;
  		edmac->edma = edma;
  
  		edmac->clk = clk_get(NULL, cdata->name);
  		if (IS_ERR(edmac->clk)) {
  			dev_warn(&pdev->dev, "failed to get clock for %s
  ",
  				 cdata->name);
  			continue;
  		}
  
  		spin_lock_init(&edmac->lock);
  		INIT_LIST_HEAD(&edmac->active);
  		INIT_LIST_HEAD(&edmac->queue);
  		INIT_LIST_HEAD(&edmac->free_list);
95fbf1634   Allen Pais   dmaengine: ep93xx...
1341
  		tasklet_setup(&edmac->tasklet, ep93xx_dma_tasklet);
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
  
  		list_add_tail(&edmac->chan.device_node,
  			      &dma_dev->channels);
  	}
  
  	dma_cap_zero(dma_dev->cap_mask);
  	dma_cap_set(DMA_SLAVE, dma_dev->cap_mask);
  	dma_cap_set(DMA_CYCLIC, dma_dev->cap_mask);
  
  	dma_dev->dev = &pdev->dev;
  	dma_dev->device_alloc_chan_resources = ep93xx_dma_alloc_chan_resources;
  	dma_dev->device_free_chan_resources = ep93xx_dma_free_chan_resources;
  	dma_dev->device_prep_slave_sg = ep93xx_dma_prep_slave_sg;
  	dma_dev->device_prep_dma_cyclic = ep93xx_dma_prep_dma_cyclic;
2258b6754   Maxime Ripard   dmaengine: ep93xx...
1356
  	dma_dev->device_config = ep93xx_dma_slave_config;
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
1357
  	dma_dev->device_synchronize = ep93xx_dma_synchronize;
2258b6754   Maxime Ripard   dmaengine: ep93xx...
1358
  	dma_dev->device_terminate_all = ep93xx_dma_terminate_all;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
  	dma_dev->device_issue_pending = ep93xx_dma_issue_pending;
  	dma_dev->device_tx_status = ep93xx_dma_tx_status;
  
  	dma_set_max_seg_size(dma_dev->dev, DMA_MAX_CHAN_BYTES);
  
  	if (edma->m2m) {
  		dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask);
  		dma_dev->device_prep_dma_memcpy = ep93xx_dma_prep_dma_memcpy;
  
  		edma->hw_setup = m2m_hw_setup;
  		edma->hw_shutdown = m2m_hw_shutdown;
  		edma->hw_submit = m2m_hw_submit;
  		edma->hw_interrupt = m2m_hw_interrupt;
  	} else {
  		dma_cap_set(DMA_PRIVATE, dma_dev->cap_mask);
98f9de366   Alexander Sverdlin   dmaengine: ep93xx...
1374
  		edma->hw_synchronize = m2p_hw_synchronize;
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
  		edma->hw_setup = m2p_hw_setup;
  		edma->hw_shutdown = m2p_hw_shutdown;
  		edma->hw_submit = m2p_hw_submit;
  		edma->hw_interrupt = m2p_hw_interrupt;
  	}
  
  	ret = dma_async_device_register(dma_dev);
  	if (unlikely(ret)) {
  		for (i = 0; i < edma->num_channels; i++) {
  			struct ep93xx_dma_chan *edmac = &edma->channels[i];
  			if (!IS_ERR_OR_NULL(edmac->clk))
  				clk_put(edmac->clk);
  		}
  		kfree(edma);
  	} else {
  		dev_info(dma_dev->dev, "EP93xx M2%s DMA ready
  ",
  			 edma->m2m ? "M" : "P");
  	}
  
  	return ret;
  }
577d2e062   Krzysztof Kozlowski   dmaengine: ep93xx...
1397
  static const struct platform_device_id ep93xx_dma_driver_ids[] = {
5fa29a17f   Mika Westerberg   dmaengine: add ep...
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
  	{ "ep93xx-dma-m2p", 0 },
  	{ "ep93xx-dma-m2m", 1 },
  	{ },
  };
  
  static struct platform_driver ep93xx_dma_driver = {
  	.driver		= {
  		.name	= "ep93xx-dma",
  	},
  	.id_table	= ep93xx_dma_driver_ids,
  };
  
  static int __init ep93xx_dma_module_init(void)
  {
  	return platform_driver_probe(&ep93xx_dma_driver, ep93xx_dma_probe);
  }
  subsys_initcall(ep93xx_dma_module_init);
  
  MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>");
  MODULE_DESCRIPTION("EP93xx DMA driver");
  MODULE_LICENSE("GPL");