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>
25 #include <linux/fsl/mxs-dma.h>
29 #include <mach/common.h>
31 #include "dmaengine.h"
34 * NOTE: The term "PIO" throughout the mxs-dma implementation means
35 * PIO mode of mxs apbh-dma and apbx-dma. With this working mode,
36 * dma can program the controller registers of peripheral devices.
39 #define MXS_DMA_APBH 0
40 #define MXS_DMA_APBX 1
41 #define dma_is_apbh() (mxs_dma->dev_id == MXS_DMA_APBH)
43 #define APBH_VERSION_LATEST 3
44 #define apbh_is_old() (mxs_dma->version < APBH_VERSION_LATEST)
46 #define HW_APBHX_CTRL0 0x000
47 #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)
48 #define BM_APBH_CTRL0_APB_BURST_EN (1 << 28)
49 #define BP_APBH_CTRL0_RESET_CHANNEL 16
50 #define HW_APBHX_CTRL1 0x010
51 #define HW_APBHX_CTRL2 0x020
52 #define HW_APBHX_CHANNEL_CTRL 0x030
53 #define BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL 16
54 #define HW_APBH_VERSION (cpu_is_mx23() ? 0x3f0 : 0x800)
55 #define HW_APBX_VERSION 0x800
56 #define BP_APBHX_VERSION_MAJOR 24
57 #define HW_APBHX_CHn_NXTCMDAR(n) \
58 (((dma_is_apbh() && apbh_is_old()) ? 0x050 : 0x110) + (n) * 0x70)
59 #define HW_APBHX_CHn_SEMA(n) \
60 (((dma_is_apbh() && apbh_is_old()) ? 0x080 : 0x140) + (n) * 0x70)
63 * ccw bits definitions
68 * NAND_LOCK: 4 (1) - not implemented
69 * NAND_WAIT4READY: 5 (1) - not implemented
72 * HALT_ON_TERMINATE: 8 (1)
73 * TERMINATE_FLUSH: 9 (1)
74 * RESERVED: 10..11 (2)
77 #define BP_CCW_COMMAND 0
78 #define BM_CCW_COMMAND (3 << 0)
79 #define CCW_CHAIN (1 << 2)
80 #define CCW_IRQ (1 << 3)
81 #define CCW_DEC_SEM (1 << 6)
82 #define CCW_WAIT4END (1 << 7)
83 #define CCW_HALT_ON_TERM (1 << 8)
84 #define CCW_TERM_FLUSH (1 << 9)
85 #define BP_CCW_PIO_NUM 12
86 #define BM_CCW_PIO_NUM (0xf << 12)
88 #define BF_CCW(value, field) (((value) << BP_CCW_##field) & BM_CCW_##field)
90 #define MXS_DMA_CMD_NO_XFER 0
91 #define MXS_DMA_CMD_WRITE 1
92 #define MXS_DMA_CMD_READ 2
93 #define MXS_DMA_CMD_DMA_SENSE 3 /* not implemented */
99 #define MAX_XFER_BYTES 0xff00
101 #define MXS_PIO_WORDS 16
102 u32 pio_words
[MXS_PIO_WORDS
];
105 #define NUM_CCW (int)(PAGE_SIZE / sizeof(struct mxs_dma_ccw))
107 struct mxs_dma_chan
{
108 struct mxs_dma_engine
*mxs_dma
;
109 struct dma_chan chan
;
110 struct dma_async_tx_descriptor desc
;
111 struct tasklet_struct tasklet
;
113 struct mxs_dma_ccw
*ccw
;
116 enum dma_status status
;
118 #define MXS_DMA_SG_LOOP (1 << 0)
121 #define MXS_DMA_CHANNELS 16
122 #define MXS_DMA_CHANNELS_MASK 0xffff
124 struct mxs_dma_engine
{
126 unsigned int version
;
129 struct dma_device dma_device
;
130 struct device_dma_parameters dma_parms
;
131 struct mxs_dma_chan mxs_chans
[MXS_DMA_CHANNELS
];
134 static void mxs_dma_reset_chan(struct mxs_dma_chan
*mxs_chan
)
136 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
137 int chan_id
= mxs_chan
->chan
.chan_id
;
139 if (dma_is_apbh() && apbh_is_old())
140 writel(1 << (chan_id
+ BP_APBH_CTRL0_RESET_CHANNEL
),
141 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
143 writel(1 << (chan_id
+ BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL
),
144 mxs_dma
->base
+ HW_APBHX_CHANNEL_CTRL
+ MXS_SET_ADDR
);
147 static void mxs_dma_enable_chan(struct mxs_dma_chan
*mxs_chan
)
149 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
150 int chan_id
= mxs_chan
->chan
.chan_id
;
152 /* set cmd_addr up */
153 writel(mxs_chan
->ccw_phys
,
154 mxs_dma
->base
+ HW_APBHX_CHn_NXTCMDAR(chan_id
));
156 /* write 1 to SEMA to kick off the channel */
157 writel(1, mxs_dma
->base
+ HW_APBHX_CHn_SEMA(chan_id
));
160 static void mxs_dma_disable_chan(struct mxs_dma_chan
*mxs_chan
)
162 mxs_chan
->status
= DMA_SUCCESS
;
165 static void mxs_dma_pause_chan(struct mxs_dma_chan
*mxs_chan
)
167 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
168 int chan_id
= mxs_chan
->chan
.chan_id
;
170 /* freeze the channel */
171 if (dma_is_apbh() && apbh_is_old())
173 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
176 mxs_dma
->base
+ HW_APBHX_CHANNEL_CTRL
+ MXS_SET_ADDR
);
178 mxs_chan
->status
= DMA_PAUSED
;
181 static void mxs_dma_resume_chan(struct mxs_dma_chan
*mxs_chan
)
183 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
184 int chan_id
= mxs_chan
->chan
.chan_id
;
186 /* unfreeze the channel */
187 if (dma_is_apbh() && apbh_is_old())
189 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_CLR_ADDR
);
192 mxs_dma
->base
+ HW_APBHX_CHANNEL_CTRL
+ MXS_CLR_ADDR
);
194 mxs_chan
->status
= DMA_IN_PROGRESS
;
197 static struct mxs_dma_chan
*to_mxs_dma_chan(struct dma_chan
*chan
)
199 return container_of(chan
, struct mxs_dma_chan
, chan
);
202 static dma_cookie_t
mxs_dma_tx_submit(struct dma_async_tx_descriptor
*tx
)
204 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(tx
->chan
);
206 mxs_dma_enable_chan(mxs_chan
);
208 return dma_cookie_assign(tx
);
211 static void mxs_dma_tasklet(unsigned long data
)
213 struct mxs_dma_chan
*mxs_chan
= (struct mxs_dma_chan
*) data
;
215 if (mxs_chan
->desc
.callback
)
216 mxs_chan
->desc
.callback(mxs_chan
->desc
.callback_param
);
219 static irqreturn_t
mxs_dma_int_handler(int irq
, void *dev_id
)
221 struct mxs_dma_engine
*mxs_dma
= dev_id
;
224 /* completion status */
225 stat1
= readl(mxs_dma
->base
+ HW_APBHX_CTRL1
);
226 stat1
&= MXS_DMA_CHANNELS_MASK
;
227 writel(stat1
, mxs_dma
->base
+ HW_APBHX_CTRL1
+ MXS_CLR_ADDR
);
230 stat2
= readl(mxs_dma
->base
+ HW_APBHX_CTRL2
);
231 writel(stat2
, mxs_dma
->base
+ HW_APBHX_CTRL2
+ MXS_CLR_ADDR
);
234 * When both completion and error of termination bits set at the
235 * same time, we do not take it as an error. IOW, it only becomes
236 * an error we need to handle here in case of either it's (1) a bus
237 * error or (2) a termination error with no completion.
239 stat2
= ((stat2
>> MXS_DMA_CHANNELS
) & stat2
) | /* (1) */
240 (~(stat2
>> MXS_DMA_CHANNELS
) & stat2
& ~stat1
); /* (2) */
242 /* combine error and completion status for checking */
243 stat1
= (stat2
<< MXS_DMA_CHANNELS
) | stat1
;
245 int channel
= fls(stat1
) - 1;
246 struct mxs_dma_chan
*mxs_chan
=
247 &mxs_dma
->mxs_chans
[channel
% MXS_DMA_CHANNELS
];
249 if (channel
>= MXS_DMA_CHANNELS
) {
250 dev_dbg(mxs_dma
->dma_device
.dev
,
251 "%s: error in channel %d\n", __func__
,
252 channel
- MXS_DMA_CHANNELS
);
253 mxs_chan
->status
= DMA_ERROR
;
254 mxs_dma_reset_chan(mxs_chan
);
256 if (mxs_chan
->flags
& MXS_DMA_SG_LOOP
)
257 mxs_chan
->status
= DMA_IN_PROGRESS
;
259 mxs_chan
->status
= DMA_SUCCESS
;
262 stat1
&= ~(1 << channel
);
264 if (mxs_chan
->status
== DMA_SUCCESS
)
265 dma_cookie_complete(&mxs_chan
->desc
);
267 /* schedule tasklet on this channel */
268 tasklet_schedule(&mxs_chan
->tasklet
);
274 static int mxs_dma_alloc_chan_resources(struct dma_chan
*chan
)
276 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
277 struct mxs_dma_data
*data
= chan
->private;
278 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
284 mxs_chan
->chan_irq
= data
->chan_irq
;
286 mxs_chan
->ccw
= dma_alloc_coherent(mxs_dma
->dma_device
.dev
, PAGE_SIZE
,
287 &mxs_chan
->ccw_phys
, GFP_KERNEL
);
288 if (!mxs_chan
->ccw
) {
293 memset(mxs_chan
->ccw
, 0, PAGE_SIZE
);
295 if (mxs_chan
->chan_irq
!= NO_IRQ
) {
296 ret
= request_irq(mxs_chan
->chan_irq
, mxs_dma_int_handler
,
297 0, "mxs-dma", mxs_dma
);
302 ret
= clk_prepare_enable(mxs_dma
->clk
);
306 mxs_dma_reset_chan(mxs_chan
);
308 dma_async_tx_descriptor_init(&mxs_chan
->desc
, chan
);
309 mxs_chan
->desc
.tx_submit
= mxs_dma_tx_submit
;
311 /* the descriptor is ready */
312 async_tx_ack(&mxs_chan
->desc
);
317 free_irq(mxs_chan
->chan_irq
, mxs_dma
);
319 dma_free_coherent(mxs_dma
->dma_device
.dev
, PAGE_SIZE
,
320 mxs_chan
->ccw
, mxs_chan
->ccw_phys
);
325 static void mxs_dma_free_chan_resources(struct dma_chan
*chan
)
327 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
328 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
330 mxs_dma_disable_chan(mxs_chan
);
332 free_irq(mxs_chan
->chan_irq
, mxs_dma
);
334 dma_free_coherent(mxs_dma
->dma_device
.dev
, PAGE_SIZE
,
335 mxs_chan
->ccw
, mxs_chan
->ccw_phys
);
337 clk_disable_unprepare(mxs_dma
->clk
);
341 * How to use the flags for ->device_prep_slave_sg() :
342 * [1] If there is only one DMA command in the DMA chain, the code should be:
344 * ->device_prep_slave_sg(DMA_CTRL_ACK);
346 * [2] If there are two DMA commands in the DMA chain, the code should be
348 * ->device_prep_slave_sg(0);
350 * ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
352 * [3] If there are more than two DMA commands in the DMA chain, the code
355 * ->device_prep_slave_sg(0); // First
357 * ->device_prep_slave_sg(DMA_PREP_INTERRUPT [| DMA_CTRL_ACK]);
359 * ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK); // Last
362 static struct dma_async_tx_descriptor
*mxs_dma_prep_slave_sg(
363 struct dma_chan
*chan
, struct scatterlist
*sgl
,
364 unsigned int sg_len
, enum dma_transfer_direction direction
,
365 unsigned long flags
, void *context
)
367 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
368 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
369 struct mxs_dma_ccw
*ccw
;
370 struct scatterlist
*sg
;
373 bool append
= flags
& DMA_PREP_INTERRUPT
;
374 int idx
= append
? mxs_chan
->desc_count
: 0;
376 if (mxs_chan
->status
== DMA_IN_PROGRESS
&& !append
)
379 if (sg_len
+ (append
? idx
: 0) > NUM_CCW
) {
380 dev_err(mxs_dma
->dma_device
.dev
,
381 "maximum number of sg exceeded: %d > %d\n",
386 mxs_chan
->status
= DMA_IN_PROGRESS
;
390 * If the sg is prepared with append flag set, the sg
391 * will be appended to the last prepared sg.
395 ccw
= &mxs_chan
->ccw
[idx
- 1];
396 ccw
->next
= mxs_chan
->ccw_phys
+ sizeof(*ccw
) * idx
;
397 ccw
->bits
|= CCW_CHAIN
;
398 ccw
->bits
&= ~CCW_IRQ
;
399 ccw
->bits
&= ~CCW_DEC_SEM
;
404 if (direction
== DMA_TRANS_NONE
) {
405 ccw
= &mxs_chan
->ccw
[idx
++];
408 for (j
= 0; j
< sg_len
;)
409 ccw
->pio_words
[j
++] = *pio
++;
412 ccw
->bits
|= CCW_IRQ
;
413 ccw
->bits
|= CCW_DEC_SEM
;
414 if (flags
& DMA_CTRL_ACK
)
415 ccw
->bits
|= CCW_WAIT4END
;
416 ccw
->bits
|= CCW_HALT_ON_TERM
;
417 ccw
->bits
|= CCW_TERM_FLUSH
;
418 ccw
->bits
|= BF_CCW(sg_len
, PIO_NUM
);
419 ccw
->bits
|= BF_CCW(MXS_DMA_CMD_NO_XFER
, COMMAND
);
421 for_each_sg(sgl
, sg
, sg_len
, i
) {
422 if (sg
->length
> MAX_XFER_BYTES
) {
423 dev_err(mxs_dma
->dma_device
.dev
, "maximum bytes for sg entry exceeded: %d > %d\n",
424 sg
->length
, MAX_XFER_BYTES
);
428 ccw
= &mxs_chan
->ccw
[idx
++];
430 ccw
->next
= mxs_chan
->ccw_phys
+ sizeof(*ccw
) * idx
;
431 ccw
->bufaddr
= sg
->dma_address
;
432 ccw
->xfer_bytes
= sg
->length
;
435 ccw
->bits
|= CCW_CHAIN
;
436 ccw
->bits
|= CCW_HALT_ON_TERM
;
437 ccw
->bits
|= CCW_TERM_FLUSH
;
438 ccw
->bits
|= BF_CCW(direction
== DMA_DEV_TO_MEM
?
439 MXS_DMA_CMD_WRITE
: MXS_DMA_CMD_READ
,
442 if (i
+ 1 == sg_len
) {
443 ccw
->bits
&= ~CCW_CHAIN
;
444 ccw
->bits
|= CCW_IRQ
;
445 ccw
->bits
|= CCW_DEC_SEM
;
446 if (flags
& DMA_CTRL_ACK
)
447 ccw
->bits
|= CCW_WAIT4END
;
451 mxs_chan
->desc_count
= idx
;
453 return &mxs_chan
->desc
;
456 mxs_chan
->status
= DMA_ERROR
;
460 static struct dma_async_tx_descriptor
*mxs_dma_prep_dma_cyclic(
461 struct dma_chan
*chan
, dma_addr_t dma_addr
, size_t buf_len
,
462 size_t period_len
, enum dma_transfer_direction direction
,
465 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
466 struct mxs_dma_engine
*mxs_dma
= mxs_chan
->mxs_dma
;
467 int num_periods
= buf_len
/ period_len
;
470 if (mxs_chan
->status
== DMA_IN_PROGRESS
)
473 mxs_chan
->status
= DMA_IN_PROGRESS
;
474 mxs_chan
->flags
|= MXS_DMA_SG_LOOP
;
476 if (num_periods
> NUM_CCW
) {
477 dev_err(mxs_dma
->dma_device
.dev
,
478 "maximum number of sg exceeded: %d > %d\n",
479 num_periods
, NUM_CCW
);
483 if (period_len
> MAX_XFER_BYTES
) {
484 dev_err(mxs_dma
->dma_device
.dev
,
485 "maximum period size exceeded: %d > %d\n",
486 period_len
, MAX_XFER_BYTES
);
490 while (buf
< buf_len
) {
491 struct mxs_dma_ccw
*ccw
= &mxs_chan
->ccw
[i
];
493 if (i
+ 1 == num_periods
)
494 ccw
->next
= mxs_chan
->ccw_phys
;
496 ccw
->next
= mxs_chan
->ccw_phys
+ sizeof(*ccw
) * (i
+ 1);
498 ccw
->bufaddr
= dma_addr
;
499 ccw
->xfer_bytes
= period_len
;
502 ccw
->bits
|= CCW_CHAIN
;
503 ccw
->bits
|= CCW_IRQ
;
504 ccw
->bits
|= CCW_HALT_ON_TERM
;
505 ccw
->bits
|= CCW_TERM_FLUSH
;
506 ccw
->bits
|= BF_CCW(direction
== DMA_DEV_TO_MEM
?
507 MXS_DMA_CMD_WRITE
: MXS_DMA_CMD_READ
, COMMAND
);
509 dma_addr
+= period_len
;
514 mxs_chan
->desc_count
= i
;
516 return &mxs_chan
->desc
;
519 mxs_chan
->status
= DMA_ERROR
;
523 static int mxs_dma_control(struct dma_chan
*chan
, enum dma_ctrl_cmd cmd
,
526 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
530 case DMA_TERMINATE_ALL
:
531 mxs_dma_reset_chan(mxs_chan
);
532 mxs_dma_disable_chan(mxs_chan
);
535 mxs_dma_pause_chan(mxs_chan
);
538 mxs_dma_resume_chan(mxs_chan
);
547 static enum dma_status
mxs_dma_tx_status(struct dma_chan
*chan
,
548 dma_cookie_t cookie
, struct dma_tx_state
*txstate
)
550 struct mxs_dma_chan
*mxs_chan
= to_mxs_dma_chan(chan
);
551 dma_cookie_t last_used
;
553 last_used
= chan
->cookie
;
554 dma_set_tx_state(txstate
, chan
->completed_cookie
, last_used
, 0);
556 return mxs_chan
->status
;
559 static void mxs_dma_issue_pending(struct dma_chan
*chan
)
562 * Nothing to do. We only have a single descriptor.
566 static int __init
mxs_dma_init(struct mxs_dma_engine
*mxs_dma
)
570 ret
= clk_prepare_enable(mxs_dma
->clk
);
574 ret
= mxs_reset_block(mxs_dma
->base
);
578 /* only major version matters */
579 mxs_dma
->version
= readl(mxs_dma
->base
+
580 ((mxs_dma
->dev_id
== MXS_DMA_APBX
) ?
581 HW_APBX_VERSION
: HW_APBH_VERSION
)) >>
582 BP_APBHX_VERSION_MAJOR
;
584 /* enable apbh burst */
586 writel(BM_APBH_CTRL0_APB_BURST_EN
,
587 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
588 writel(BM_APBH_CTRL0_APB_BURST8_EN
,
589 mxs_dma
->base
+ HW_APBHX_CTRL0
+ MXS_SET_ADDR
);
592 /* enable irq for all the channels */
593 writel(MXS_DMA_CHANNELS_MASK
<< MXS_DMA_CHANNELS
,
594 mxs_dma
->base
+ HW_APBHX_CTRL1
+ MXS_SET_ADDR
);
597 clk_disable_unprepare(mxs_dma
->clk
);
601 static int __init
mxs_dma_probe(struct platform_device
*pdev
)
603 const struct platform_device_id
*id_entry
=
604 platform_get_device_id(pdev
);
605 struct mxs_dma_engine
*mxs_dma
;
606 struct resource
*iores
;
609 mxs_dma
= kzalloc(sizeof(*mxs_dma
), GFP_KERNEL
);
613 mxs_dma
->dev_id
= id_entry
->driver_data
;
615 iores
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
617 if (!request_mem_region(iores
->start
, resource_size(iores
),
620 goto err_request_region
;
623 mxs_dma
->base
= ioremap(iores
->start
, resource_size(iores
));
624 if (!mxs_dma
->base
) {
629 mxs_dma
->clk
= clk_get(&pdev
->dev
, NULL
);
630 if (IS_ERR(mxs_dma
->clk
)) {
631 ret
= PTR_ERR(mxs_dma
->clk
);
635 dma_cap_set(DMA_SLAVE
, mxs_dma
->dma_device
.cap_mask
);
636 dma_cap_set(DMA_CYCLIC
, mxs_dma
->dma_device
.cap_mask
);
638 INIT_LIST_HEAD(&mxs_dma
->dma_device
.channels
);
640 /* Initialize channel parameters */
641 for (i
= 0; i
< MXS_DMA_CHANNELS
; i
++) {
642 struct mxs_dma_chan
*mxs_chan
= &mxs_dma
->mxs_chans
[i
];
644 mxs_chan
->mxs_dma
= mxs_dma
;
645 mxs_chan
->chan
.device
= &mxs_dma
->dma_device
;
646 dma_cookie_init(&mxs_chan
->chan
);
648 tasklet_init(&mxs_chan
->tasklet
, mxs_dma_tasklet
,
649 (unsigned long) mxs_chan
);
652 /* Add the channel to mxs_chan list */
653 list_add_tail(&mxs_chan
->chan
.device_node
,
654 &mxs_dma
->dma_device
.channels
);
657 ret
= mxs_dma_init(mxs_dma
);
661 mxs_dma
->dma_device
.dev
= &pdev
->dev
;
663 /* mxs_dma gets 65535 bytes maximum sg size */
664 mxs_dma
->dma_device
.dev
->dma_parms
= &mxs_dma
->dma_parms
;
665 dma_set_max_seg_size(mxs_dma
->dma_device
.dev
, MAX_XFER_BYTES
);
667 mxs_dma
->dma_device
.device_alloc_chan_resources
= mxs_dma_alloc_chan_resources
;
668 mxs_dma
->dma_device
.device_free_chan_resources
= mxs_dma_free_chan_resources
;
669 mxs_dma
->dma_device
.device_tx_status
= mxs_dma_tx_status
;
670 mxs_dma
->dma_device
.device_prep_slave_sg
= mxs_dma_prep_slave_sg
;
671 mxs_dma
->dma_device
.device_prep_dma_cyclic
= mxs_dma_prep_dma_cyclic
;
672 mxs_dma
->dma_device
.device_control
= mxs_dma_control
;
673 mxs_dma
->dma_device
.device_issue_pending
= mxs_dma_issue_pending
;
675 ret
= dma_async_device_register(&mxs_dma
->dma_device
);
677 dev_err(mxs_dma
->dma_device
.dev
, "unable to register\n");
681 dev_info(mxs_dma
->dma_device
.dev
, "initialized\n");
686 clk_put(mxs_dma
->clk
);
688 iounmap(mxs_dma
->base
);
690 release_mem_region(iores
->start
, resource_size(iores
));
696 static struct platform_device_id mxs_dma_type
[] = {
698 .name
= "mxs-dma-apbh",
699 .driver_data
= MXS_DMA_APBH
,
701 .name
= "mxs-dma-apbx",
702 .driver_data
= MXS_DMA_APBX
,
708 static struct platform_driver mxs_dma_driver
= {
712 .id_table
= mxs_dma_type
,
715 static int __init
mxs_dma_module_init(void)
717 return platform_driver_probe(&mxs_dma_driver
, mxs_dma_probe
);
719 subsys_initcall(mxs_dma_module_init
);