2 * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
4 * Refer to drivers/dma/imx-sdma.c
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/init.h>
12 #include <linux/types.h>
14 #include <linux/interrupt.h>
15 #include <linux/clk.h>
16 #include <linux/wait.h>
17 #include <linux/sched.h>
18 #include <linux/semaphore.h>
19 #include <linux/device.h>
20 #include <linux/dma-mapping.h>
21 #include <linux/slab.h>
22 #include <linux/platform_device.h>
23 #include <linux/dmaengine.h>
24 #include <linux/delay.h>
29 #include <mach/common.h>
32 * NOTE: The term "PIO" throughout the mxs-dma implementation means
33 * PIO mode of mxs apbh-dma and apbx-dma. With this working mode,
34 * dma can program the controller registers of peripheral devices.
37 #define MXS_DMA_APBH 0
38 #define MXS_DMA_APBX 1
39 #define dma_is_apbh() (mxs_dma->dev_id == MXS_DMA_APBH)
41 #define APBH_VERSION_LATEST 3
42 #define apbh_is_old() (mxs_dma->version < APBH_VERSION_LATEST)
44 #define HW_APBHX_CTRL0 0x000
45 #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)
46 #define BM_APBH_CTRL0_APB_BURST_EN (1 << 28)
47 #define BP_APBH_CTRL0_CLKGATE_CHANNEL 8
48 #define BP_APBH_CTRL0_RESET_CHANNEL 16
49 #define HW_APBHX_CTRL1 0x010
50 #define HW_APBHX_CTRL2 0x020
51 #define HW_APBHX_CHANNEL_CTRL 0x030
52 #define BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL 16
53 #define HW_APBH_VERSION (cpu_is_mx23() ? 0x3f0 : 0x800)
54 #define HW_APBX_VERSION 0x800
55 #define BP_APBHX_VERSION_MAJOR 24
56 #define HW_APBHX_CHn_NXTCMDAR(n) \
57 (((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
58 #define HW_APBHX_CHn_SEMA(n) \
59 (((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
62 * ccw bits definitions
67 * NAND_LOCK: 4 (1) - not implemented
68 * NAND_WAIT4READY: 5 (1) - not implemented
71 * HALT_ON_TERMINATE: 8 (1)
72 * TERMINATE_FLUSH: 9 (1)
73 * RESERVED: 10..11 (2)
76 #define BP_CCW_COMMAND 0
77 #define BM_CCW_COMMAND (3 << 0)
78 #define CCW_CHAIN (1 << 2)
79 #define CCW_IRQ (1 << 3)
80 #define CCW_DEC_SEM (1 << 6)
81 #define CCW_WAIT4END (1 << 7)
82 #define CCW_HALT_ON_TERM (1 << 8)
83 #define CCW_TERM_FLUSH (1 << 9)
84 #define BP_CCW_PIO_NUM 12
85 #define BM_CCW_PIO_NUM (0xf << 12)
87 #define BF_CCW(value, field) (((value) << BP_CCW_##field) & BM_CCW_##field)
89 #define MXS_DMA_CMD_NO_XFER 0
90 #define MXS_DMA_CMD_WRITE 1
91 #define MXS_DMA_CMD_READ 2
92 #define MXS_DMA_CMD_DMA_SENSE 3 /* not implemented */
98 #define MAX_XFER_BYTES 0xff00
100 #define MXS_PIO_WORDS 16
101 u32 pio_words
[MXS_PIO_WORDS
];
104 #define NUM_CCW (int)(PAGE_SIZE / sizeof(struct mxs_dma_ccw))
106 struct mxs_dma_chan
{
107 struct mxs_dma_engine
*mxs_dma
;
108 struct dma_chan chan
;
109 struct dma_async_tx_descriptor desc
;
110 struct tasklet_struct tasklet
;
112 struct mxs_dma_ccw
*ccw
;
114 dma_cookie_t last_completed
;
115 enum dma_status status
;
117 #define MXS_DMA_SG_LOOP (1 << 0)
120 #define MXS_DMA_CHANNELS 16
121 #define MXS_DMA_CHANNELS_MASK 0xffff
123 struct mxs_dma_engine
{
125 unsigned int version
;
128 struct dma_device dma_device
;
129 struct device_dma_parameters dma_parms
;
130 struct mxs_dma_chan mxs_chans
[MXS_DMA_CHANNELS
];
133 static void mxs_dma_reset_chan(struct mxs_dma_chan
*mxs_chan
)
135 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
136 int chan_id
= mxs_chan
->chan
.chan_id
;
138 if (dma_is_apbh() && apbh_is_old())
139 writel(1 << (chan_id
+ BP_APBH_CTRL0_RESET_CHANNEL
),
140 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
142 writel(1 << (chan_id
+ BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL
),
143 mxs_dma
->base
+ HW_APBHX_CHANNEL_CTRL
+ MXS_SET_ADDR
);
146 static void mxs_dma_enable_chan(struct mxs_dma_chan
*mxs_chan
)
148 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
149 int chan_id
= mxs_chan
->chan
.chan_id
;
151 /* set cmd_addr up */
152 writel(mxs_chan
->ccw_phys
,
153 mxs_dma
->base
+ HW_APBHX_CHn_NXTCMDAR(chan_id
));
155 /* enable apbh channel clock */
158 writel(1 << (chan_id
+ BP_APBH_CTRL0_CLKGATE_CHANNEL
),
159 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_CLR_ADDR
);
162 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_CLR_ADDR
);
165 /* write 1 to SEMA to kick off the channel */
166 writel(1, mxs_dma
->base
+ HW_APBHX_CHn_SEMA(chan_id
));
169 static void mxs_dma_disable_chan(struct mxs_dma_chan
*mxs_chan
)
171 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
172 int chan_id
= mxs_chan
->chan
.chan_id
;
174 /* disable apbh channel clock */
177 writel(1 << (chan_id
+ BP_APBH_CTRL0_CLKGATE_CHANNEL
),
178 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
181 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
184 mxs_chan
->status
= DMA_SUCCESS
;
187 static void mxs_dma_pause_chan(struct mxs_dma_chan
*mxs_chan
)
189 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
190 int chan_id
= mxs_chan
->chan
.chan_id
;
192 /* freeze the channel */
193 if (dma_is_apbh() && apbh_is_old())
195 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
198 mxs_dma
->base
+ HW_APBHX_CHANNEL_CTRL
+ MXS_SET_ADDR
);
200 mxs_chan
->status
= DMA_PAUSED
;
203 static void mxs_dma_resume_chan(struct mxs_dma_chan
*mxs_chan
)
205 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
206 int chan_id
= mxs_chan
->chan
.chan_id
;
208 /* unfreeze the channel */
209 if (dma_is_apbh() && apbh_is_old())
211 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_CLR_ADDR
);
214 mxs_dma
->base
+ HW_APBHX_CHANNEL_CTRL
+ MXS_CLR_ADDR
);
216 mxs_chan
->status
= DMA_IN_PROGRESS
;
219 static dma_cookie_t
mxs_dma_assign_cookie(struct mxs_dma_chan
*mxs_chan
)
221 dma_cookie_t cookie
= mxs_chan
->chan
.cookie
;
226 mxs_chan
->chan
.cookie
= cookie
;
227 mxs_chan
->desc
.cookie
= cookie
;
232 static struct mxs_dma_chan
*to_mxs_dma_chan(struct dma_chan
*chan
)
234 return container_of(chan
, struct mxs_dma_chan
, chan
);
237 static dma_cookie_t
mxs_dma_tx_submit(struct dma_async_tx_descriptor
*tx
)
239 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(tx
->chan
);
241 mxs_dma_enable_chan(mxs_chan
);
243 return mxs_dma_assign_cookie(mxs_chan
);
246 static void mxs_dma_tasklet(unsigned long data
)
248 struct mxs_dma_chan
*mxs_chan
= (struct mxs_dma_chan
*) data
;
250 if (mxs_chan
->desc
.callback
)
251 mxs_chan
->desc
.callback(mxs_chan
->desc
.callback_param
);
254 static irqreturn_t
mxs_dma_int_handler(int irq
, void *dev_id
)
256 struct mxs_dma_engine
*mxs_dma
= dev_id
;
259 /* completion status */
260 stat1
= readl(mxs_dma
->base
+ HW_APBHX_CTRL1
);
261 stat1
&= MXS_DMA_CHANNELS_MASK
;
262 writel(stat1
, mxs_dma
->base
+ HW_APBHX_CTRL1
+ MXS_CLR_ADDR
);
265 stat2
= readl(mxs_dma
->base
+ HW_APBHX_CTRL2
);
266 writel(stat2
, mxs_dma
->base
+ HW_APBHX_CTRL2
+ MXS_CLR_ADDR
);
269 * When both completion and error of termination bits set at the
270 * same time, we do not take it as an error. IOW, it only becomes
271 * an error we need to handler here in case of ether it's (1) an bus
272 * error or (2) a termination error with no completion.
274 stat2
= ((stat2
>> MXS_DMA_CHANNELS
) & stat2
) | /* (1) */
275 (~(stat2
>> MXS_DMA_CHANNELS
) & stat2
& ~stat1
); /* (2) */
277 /* combine error and completion status for checking */
278 stat1
= (stat2
<< MXS_DMA_CHANNELS
) | stat1
;
280 int channel
= fls(stat1
) - 1;
281 struct mxs_dma_chan
*mxs_chan
=
282 &mxs_dma
->mxs_chans
[channel
% MXS_DMA_CHANNELS
];
284 if (channel
>= MXS_DMA_CHANNELS
) {
285 dev_dbg(mxs_dma
->dma_device
.dev
,
286 "%s: error in channel %d\n", __func__
,
287 channel
- MXS_DMA_CHANNELS
);
288 mxs_chan
->status
= DMA_ERROR
;
289 mxs_dma_reset_chan(mxs_chan
);
291 if (mxs_chan
->flags
& MXS_DMA_SG_LOOP
)
292 mxs_chan
->status
= DMA_IN_PROGRESS
;
294 mxs_chan
->status
= DMA_SUCCESS
;
297 stat1
&= ~(1 << channel
);
299 if (mxs_chan
->status
== DMA_SUCCESS
)
300 mxs_chan
->last_completed
= mxs_chan
->desc
.cookie
;
302 /* schedule tasklet on this channel */
303 tasklet_schedule(&mxs_chan
->tasklet
);
309 static int mxs_dma_alloc_chan_resources(struct dma_chan
*chan
)
311 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
312 struct mxs_dma_data
*data
= chan
->private;
313 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
319 mxs_chan
->chan_irq
= data
->chan_irq
;
321 mxs_chan
->ccw
= dma_alloc_coherent(mxs_dma
->dma_device
.dev
, PAGE_SIZE
,
322 &mxs_chan
->ccw_phys
, GFP_KERNEL
);
323 if (!mxs_chan
->ccw
) {
328 memset(mxs_chan
->ccw
, 0, PAGE_SIZE
);
330 ret
= request_irq(mxs_chan
->chan_irq
, mxs_dma_int_handler
,
331 0, "mxs-dma", mxs_dma
);
335 ret
= clk_enable(mxs_dma
->clk
);
339 mxs_dma_reset_chan(mxs_chan
);
341 dma_async_tx_descriptor_init(&mxs_chan
->desc
, chan
);
342 mxs_chan
->desc
.tx_submit
= mxs_dma_tx_submit
;
344 /* the descriptor is ready */
345 async_tx_ack(&mxs_chan
->desc
);
350 free_irq(mxs_chan
->chan_irq
, mxs_dma
);
352 dma_free_coherent(mxs_dma
->dma_device
.dev
, PAGE_SIZE
,
353 mxs_chan
->ccw
, mxs_chan
->ccw_phys
);
358 static void mxs_dma_free_chan_resources(struct dma_chan
*chan
)
360 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
361 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
363 mxs_dma_disable_chan(mxs_chan
);
365 free_irq(mxs_chan
->chan_irq
, mxs_dma
);
367 dma_free_coherent(mxs_dma
->dma_device
.dev
, PAGE_SIZE
,
368 mxs_chan
->ccw
, mxs_chan
->ccw_phys
);
370 clk_disable(mxs_dma
->clk
);
373 static struct dma_async_tx_descriptor
*mxs_dma_prep_slave_sg(
374 struct dma_chan
*chan
, struct scatterlist
*sgl
,
375 unsigned int sg_len
, enum dma_data_direction direction
,
376 unsigned long append
)
378 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
379 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
380 struct mxs_dma_ccw
*ccw
;
381 struct scatterlist
*sg
;
386 if (mxs_chan
->status
== DMA_IN_PROGRESS
&& !append
)
389 if (sg_len
+ (append
? idx
: 0) > NUM_CCW
) {
390 dev_err(mxs_dma
->dma_device
.dev
,
391 "maximum number of sg exceeded: %d > %d\n",
396 mxs_chan
->status
= DMA_IN_PROGRESS
;
400 * If the sg is prepared with append flag set, the sg
401 * will be appended to the last prepared sg.
405 ccw
= &mxs_chan
->ccw
[idx
- 1];
406 ccw
->next
= mxs_chan
->ccw_phys
+ sizeof(*ccw
) * idx
;
407 ccw
->bits
|= CCW_CHAIN
;
408 ccw
->bits
&= ~CCW_IRQ
;
409 ccw
->bits
&= ~CCW_DEC_SEM
;
410 ccw
->bits
&= ~CCW_WAIT4END
;
415 if (direction
== DMA_NONE
) {
416 ccw
= &mxs_chan
->ccw
[idx
++];
419 for (j
= 0; j
< sg_len
;)
420 ccw
->pio_words
[j
++] = *pio
++;
423 ccw
->bits
|= CCW_IRQ
;
424 ccw
->bits
|= CCW_DEC_SEM
;
425 ccw
->bits
|= CCW_WAIT4END
;
426 ccw
->bits
|= CCW_HALT_ON_TERM
;
427 ccw
->bits
|= CCW_TERM_FLUSH
;
428 ccw
->bits
|= BF_CCW(sg_len
, PIO_NUM
);
429 ccw
->bits
|= BF_CCW(MXS_DMA_CMD_NO_XFER
, COMMAND
);
431 for_each_sg(sgl
, sg
, sg_len
, i
) {
432 if (sg
->length
> MAX_XFER_BYTES
) {
433 dev_err(mxs_dma
->dma_device
.dev
, "maximum bytes for sg entry exceeded: %d > %d\n",
434 sg
->length
, MAX_XFER_BYTES
);
438 ccw
= &mxs_chan
->ccw
[idx
++];
440 ccw
->next
= mxs_chan
->ccw_phys
+ sizeof(*ccw
) * idx
;
441 ccw
->bufaddr
= sg
->dma_address
;
442 ccw
->xfer_bytes
= sg
->length
;
445 ccw
->bits
|= CCW_CHAIN
;
446 ccw
->bits
|= CCW_HALT_ON_TERM
;
447 ccw
->bits
|= CCW_TERM_FLUSH
;
448 ccw
->bits
|= BF_CCW(direction
== DMA_FROM_DEVICE
?
449 MXS_DMA_CMD_WRITE
: MXS_DMA_CMD_READ
,
452 if (i
+ 1 == sg_len
) {
453 ccw
->bits
&= ~CCW_CHAIN
;
454 ccw
->bits
|= CCW_IRQ
;
455 ccw
->bits
|= CCW_DEC_SEM
;
456 ccw
->bits
|= CCW_WAIT4END
;
461 return &mxs_chan
->desc
;
464 mxs_chan
->status
= DMA_ERROR
;
468 static struct dma_async_tx_descriptor
*mxs_dma_prep_dma_cyclic(
469 struct dma_chan
*chan
, dma_addr_t dma_addr
, size_t buf_len
,
470 size_t period_len
, enum dma_data_direction direction
)
472 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
473 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
474 int num_periods
= buf_len
/ period_len
;
477 if (mxs_chan
->status
== DMA_IN_PROGRESS
)
480 mxs_chan
->status
= DMA_IN_PROGRESS
;
481 mxs_chan
->flags
|= MXS_DMA_SG_LOOP
;
483 if (num_periods
> NUM_CCW
) {
484 dev_err(mxs_dma
->dma_device
.dev
,
485 "maximum number of sg exceeded: %d > %d\n",
486 num_periods
, NUM_CCW
);
490 if (period_len
> MAX_XFER_BYTES
) {
491 dev_err(mxs_dma
->dma_device
.dev
,
492 "maximum period size exceeded: %d > %d\n",
493 period_len
, MAX_XFER_BYTES
);
497 while (buf
< buf_len
) {
498 struct mxs_dma_ccw
*ccw
= &mxs_chan
->ccw
[i
];
500 if (i
+ 1 == num_periods
)
501 ccw
->next
= mxs_chan
->ccw_phys
;
503 ccw
->next
= mxs_chan
->ccw_phys
+ sizeof(*ccw
) * (i
+ 1);
505 ccw
->bufaddr
= dma_addr
;
506 ccw
->xfer_bytes
= period_len
;
509 ccw
->bits
|= CCW_CHAIN
;
510 ccw
->bits
|= CCW_IRQ
;
511 ccw
->bits
|= CCW_HALT_ON_TERM
;
512 ccw
->bits
|= CCW_TERM_FLUSH
;
513 ccw
->bits
|= BF_CCW(direction
== DMA_FROM_DEVICE
?
514 MXS_DMA_CMD_WRITE
: MXS_DMA_CMD_READ
, COMMAND
);
516 dma_addr
+= period_len
;
522 return &mxs_chan
->desc
;
525 mxs_chan
->status
= DMA_ERROR
;
529 static int mxs_dma_control(struct dma_chan
*chan
, enum dma_ctrl_cmd cmd
,
532 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
536 case DMA_TERMINATE_ALL
:
537 mxs_dma_disable_chan(mxs_chan
);
540 mxs_dma_pause_chan(mxs_chan
);
543 mxs_dma_resume_chan(mxs_chan
);
552 static enum dma_status
mxs_dma_tx_status(struct dma_chan
*chan
,
553 dma_cookie_t cookie
, struct dma_tx_state
*txstate
)
555 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
556 dma_cookie_t last_used
;
558 last_used
= chan
->cookie
;
559 dma_set_tx_state(txstate
, mxs_chan
->last_completed
, last_used
, 0);
561 return mxs_chan
->status
;
564 static void mxs_dma_issue_pending(struct dma_chan
*chan
)
567 * Nothing to do. We only have a single descriptor.
571 static int __init
mxs_dma_init(struct mxs_dma_engine
*mxs_dma
)
575 ret
= clk_enable(mxs_dma
->clk
);
579 ret
= mxs_reset_block(mxs_dma
->base
);
583 /* only major version matters */
584 mxs_dma
->version
= readl(mxs_dma
->base
+
585 ((mxs_dma
->dev_id
== MXS_DMA_APBX
) ?
586 HW_APBX_VERSION
: HW_APBH_VERSION
)) >>
587 BP_APBHX_VERSION_MAJOR
;
589 /* enable apbh burst */
591 writel(BM_APBH_CTRL0_APB_BURST_EN
,
592 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
593 writel(BM_APBH_CTRL0_APB_BURST8_EN
,
594 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
597 /* enable irq for all the channels */
598 writel(MXS_DMA_CHANNELS_MASK
<< MXS_DMA_CHANNELS
,
599 mxs_dma
->base
+ HW_APBHX_CTRL1
+ MXS_SET_ADDR
);
601 clk_disable(mxs_dma
->clk
);
609 static int __init
mxs_dma_probe(struct platform_device
*pdev
)
611 const struct platform_device_id
*id_entry
=
612 platform_get_device_id(pdev
);
613 struct mxs_dma_engine
*mxs_dma
;
614 struct resource
*iores
;
617 mxs_dma
= kzalloc(sizeof(*mxs_dma
), GFP_KERNEL
);
621 mxs_dma
->dev_id
= id_entry
->driver_data
;
623 iores
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
625 if (!request_mem_region(iores
->start
, resource_size(iores
),
628 goto err_request_region
;
631 mxs_dma
->base
= ioremap(iores
->start
, resource_size(iores
));
632 if (!mxs_dma
->base
) {
637 mxs_dma
->clk
= clk_get(&pdev
->dev
, NULL
);
638 if (IS_ERR(mxs_dma
->clk
)) {
639 ret
= PTR_ERR(mxs_dma
->clk
);
643 dma_cap_set(DMA_SLAVE
, mxs_dma
->dma_device
.cap_mask
);
644 dma_cap_set(DMA_CYCLIC
, mxs_dma
->dma_device
.cap_mask
);
646 INIT_LIST_HEAD(&mxs_dma
->dma_device
.channels
);
648 /* Initialize channel parameters */
649 for (i
= 0; i
< MXS_DMA_CHANNELS
; i
++) {
650 struct mxs_dma_chan
*mxs_chan
= &mxs_dma
->mxs_chans
[i
];
652 mxs_chan
->mxs_dma
= mxs_dma
;
653 mxs_chan
->chan
.device
= &mxs_dma
->dma_device
;
655 tasklet_init(&mxs_chan
->tasklet
, mxs_dma_tasklet
,
656 (unsigned long) mxs_chan
);
659 /* Add the channel to mxs_chan list */
660 list_add_tail(&mxs_chan
->chan
.device_node
,
661 &mxs_dma
->dma_device
.channels
);
664 ret
= mxs_dma_init(mxs_dma
);
668 mxs_dma
->dma_device
.dev
= &pdev
->dev
;
670 /* mxs_dma gets 65535 bytes maximum sg size */
671 mxs_dma
->dma_device
.dev
->dma_parms
= &mxs_dma
->dma_parms
;
672 dma_set_max_seg_size(mxs_dma
->dma_device
.dev
, MAX_XFER_BYTES
);
674 mxs_dma
->dma_device
.device_alloc_chan_resources
= mxs_dma_alloc_chan_resources
;
675 mxs_dma
->dma_device
.device_free_chan_resources
= mxs_dma_free_chan_resources
;
676 mxs_dma
->dma_device
.device_tx_status
= mxs_dma_tx_status
;
677 mxs_dma
->dma_device
.device_prep_slave_sg
= mxs_dma_prep_slave_sg
;
678 mxs_dma
->dma_device
.device_prep_dma_cyclic
= mxs_dma_prep_dma_cyclic
;
679 mxs_dma
->dma_device
.device_control
= mxs_dma_control
;
680 mxs_dma
->dma_device
.device_issue_pending
= mxs_dma_issue_pending
;
682 ret
= dma_async_device_register(&mxs_dma
->dma_device
);
684 dev_err(mxs_dma
->dma_device
.dev
, "unable to register\n");
688 dev_info(mxs_dma
->dma_device
.dev
, "initialized\n");
693 clk_put(mxs_dma
->clk
);
695 iounmap(mxs_dma
->base
);
697 release_mem_region(iores
->start
, resource_size(iores
));
703 static struct platform_device_id mxs_dma_type
[] = {
705 .name
= "mxs-dma-apbh",
706 .driver_data
= MXS_DMA_APBH
,
708 .name
= "mxs-dma-apbx",
709 .driver_data
= MXS_DMA_APBX
,
713 static struct platform_driver mxs_dma_driver
= {
717 .id_table
= mxs_dma_type
,
720 static int __init
mxs_dma_module_init(void)
722 return platform_driver_probe(&mxs_dma_driver
, mxs_dma_probe
);
724 subsys_initcall(mxs_dma_module_init
);