2 * linux/arch/arm/plat-omap/dma.c
4 * Copyright (C) 2003 Nokia Corporation
5 * Author: Juha Yrjölä <juha.yrjola@nokia.com>
6 * DMA channel linking for 1610 by Samuel Ortiz <samuel.ortiz@nokia.com>
7 * Graphics DMA and LCD DMA graphics tranformations
8 * by Imre Deak <imre.deak@nokia.com>
9 * OMAP2/3 support Copyright (C) 2004-2007 Texas Instruments, Inc.
10 * Merged to support both OMAP1 and OMAP2 by Tony Lindgren <tony@atomide.com>
11 * Some functions based on earlier dma-omap.c Copyright (C) 2001 RidgeRun, Inc.
13 * Support functions for the OMAP internal DMA channels.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as
17 * published by the Free Software Foundation.
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/sched.h>
24 #include <linux/spinlock.h>
25 #include <linux/errno.h>
26 #include <linux/interrupt.h>
27 #include <linux/irq.h>
29 #include <asm/system.h>
30 #include <asm/hardware.h>
34 #include <asm/arch/tc.h>
38 #ifndef CONFIG_ARCH_OMAP1
39 enum { DMA_CH_ALLOC_DONE
, DMA_CH_PARAMS_SET_DONE
, DMA_CH_STARTED
,
40 DMA_CH_QUEUED
, DMA_CH_NOTSTARTED
, DMA_CH_PAUSED
, DMA_CH_LINK_ENABLED
43 enum { DMA_CHAIN_STARTED
, DMA_CHAIN_NOTSTARTED
};
46 #define OMAP_DMA_ACTIVE 0x01
47 #define OMAP_DMA_CCR_EN (1 << 7)
48 #define OMAP2_DMA_CSR_CLEAR_MASK 0xffe
50 #define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec)
52 static int enable_1510_mode
= 0;
60 void (* callback
)(int lch
, u16 ch_status
, void *data
);
63 #ifndef CONFIG_ARCH_OMAP1
64 /* required for Dynamic chaining */
75 #ifndef CONFIG_ARCH_OMAP1
76 struct dma_link_info
{
78 int no_of_lchs_linked
;
89 static struct dma_link_info dma_linked_lch
[OMAP_LOGICAL_DMA_CH_COUNT
];
91 /* Chain handling macros */
92 #define OMAP_DMA_CHAIN_QINIT(chain_id) \
94 dma_linked_lch[chain_id].q_head = \
95 dma_linked_lch[chain_id].q_tail = \
96 dma_linked_lch[chain_id].q_count = 0; \
98 #define OMAP_DMA_CHAIN_QFULL(chain_id) \
99 (dma_linked_lch[chain_id].no_of_lchs_linked == \
100 dma_linked_lch[chain_id].q_count)
101 #define OMAP_DMA_CHAIN_QLAST(chain_id) \
103 ((dma_linked_lch[chain_id].no_of_lchs_linked-1) == \
104 dma_linked_lch[chain_id].q_count) \
106 #define OMAP_DMA_CHAIN_QEMPTY(chain_id) \
107 (0 == dma_linked_lch[chain_id].q_count)
108 #define __OMAP_DMA_CHAIN_INCQ(end) \
109 ((end) = ((end)+1) % dma_linked_lch[chain_id].no_of_lchs_linked)
110 #define OMAP_DMA_CHAIN_INCQHEAD(chain_id) \
112 __OMAP_DMA_CHAIN_INCQ(dma_linked_lch[chain_id].q_head); \
113 dma_linked_lch[chain_id].q_count--; \
116 #define OMAP_DMA_CHAIN_INCQTAIL(chain_id) \
118 __OMAP_DMA_CHAIN_INCQ(dma_linked_lch[chain_id].q_tail); \
119 dma_linked_lch[chain_id].q_count++; \
122 static int dma_chan_count
;
124 static spinlock_t dma_chan_lock
;
125 static struct omap_dma_lch dma_chan
[OMAP_LOGICAL_DMA_CH_COUNT
];
127 static const u8 omap1_dma_irq
[OMAP_LOGICAL_DMA_CH_COUNT
] = {
128 INT_DMA_CH0_6
, INT_DMA_CH1_7
, INT_DMA_CH2_8
, INT_DMA_CH3
,
129 INT_DMA_CH4
, INT_DMA_CH5
, INT_1610_DMA_CH6
, INT_1610_DMA_CH7
,
130 INT_1610_DMA_CH8
, INT_1610_DMA_CH9
, INT_1610_DMA_CH10
,
131 INT_1610_DMA_CH11
, INT_1610_DMA_CH12
, INT_1610_DMA_CH13
,
132 INT_1610_DMA_CH14
, INT_1610_DMA_CH15
, INT_DMA_LCD
135 static inline void disable_lnk(int lch
);
136 static void omap_disable_channel_irq(int lch
);
137 static inline void omap_enable_channel_irq(int lch
);
139 #define REVISIT_24XX() printk(KERN_ERR "FIXME: no %s on 24xx\n", \
142 #ifdef CONFIG_ARCH_OMAP15XX
143 /* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */
144 int omap_dma_in_1510_mode(void)
146 return enable_1510_mode
;
149 #define omap_dma_in_1510_mode() 0
152 #ifdef CONFIG_ARCH_OMAP1
153 static inline int get_gdma_dev(int req
)
155 u32 reg
= OMAP_FUNC_MUX_ARM_BASE
+ ((req
- 1) / 5) * 4;
156 int shift
= ((req
- 1) % 5) * 6;
158 return ((omap_readl(reg
) >> shift
) & 0x3f) + 1;
161 static inline void set_gdma_dev(int req
, int dev
)
163 u32 reg
= OMAP_FUNC_MUX_ARM_BASE
+ ((req
- 1) / 5) * 4;
164 int shift
= ((req
- 1) % 5) * 6;
168 l
&= ~(0x3f << shift
);
169 l
|= (dev
- 1) << shift
;
173 #define set_gdma_dev(req, dev) do {} while (0)
176 static void clear_lch_regs(int lch
)
179 u32 lch_base
= OMAP_DMA_BASE
+ lch
* 0x40;
181 for (i
= 0; i
< 0x2c; i
+= 2)
182 omap_writew(0, lch_base
+ i
);
185 void omap_set_dma_priority(int lch
, int dst_port
, int priority
)
190 if (cpu_class_is_omap1()) {
192 case OMAP_DMA_PORT_OCP_T1
: /* FFFECC00 */
193 reg
= OMAP_TC_OCPT1_PRIOR
;
195 case OMAP_DMA_PORT_OCP_T2
: /* FFFECCD0 */
196 reg
= OMAP_TC_OCPT2_PRIOR
;
198 case OMAP_DMA_PORT_EMIFF
: /* FFFECC08 */
199 reg
= OMAP_TC_EMIFF_PRIOR
;
201 case OMAP_DMA_PORT_EMIFS
: /* FFFECC04 */
202 reg
= OMAP_TC_EMIFS_PRIOR
;
210 l
|= (priority
& 0xf) << 8;
214 if (cpu_class_is_omap2()) {
216 OMAP_DMA_CCR_REG(lch
) |= (1 << 6);
218 OMAP_DMA_CCR_REG(lch
) &= ~(1 << 6);
222 void omap_set_dma_transfer_params(int lch
, int data_type
, int elem_count
,
223 int frame_count
, int sync_mode
,
224 int dma_trigger
, int src_or_dst_synch
)
226 OMAP_DMA_CSDP_REG(lch
) &= ~0x03;
227 OMAP_DMA_CSDP_REG(lch
) |= data_type
;
229 if (cpu_class_is_omap1()) {
230 OMAP_DMA_CCR_REG(lch
) &= ~(1 << 5);
231 if (sync_mode
== OMAP_DMA_SYNC_FRAME
)
232 OMAP_DMA_CCR_REG(lch
) |= 1 << 5;
234 OMAP1_DMA_CCR2_REG(lch
) &= ~(1 << 2);
235 if (sync_mode
== OMAP_DMA_SYNC_BLOCK
)
236 OMAP1_DMA_CCR2_REG(lch
) |= 1 << 2;
239 if (cpu_class_is_omap2() && dma_trigger
) {
240 u32 val
= OMAP_DMA_CCR_REG(lch
);
243 if (dma_trigger
> 63)
245 if (dma_trigger
> 31)
249 val
|= (dma_trigger
& 0x1f);
251 if (sync_mode
& OMAP_DMA_SYNC_FRAME
)
256 if (sync_mode
& OMAP_DMA_SYNC_BLOCK
)
261 if (src_or_dst_synch
)
262 val
|= 1 << 24; /* source synch */
264 val
&= ~(1 << 24); /* dest synch */
266 OMAP_DMA_CCR_REG(lch
) = val
;
269 OMAP_DMA_CEN_REG(lch
) = elem_count
;
270 OMAP_DMA_CFN_REG(lch
) = frame_count
;
273 void omap_set_dma_color_mode(int lch
, enum omap_dma_color_mode mode
, u32 color
)
277 BUG_ON(omap_dma_in_1510_mode());
279 if (cpu_class_is_omap2()) {
284 w
= OMAP1_DMA_CCR2_REG(lch
) & ~0x03;
286 case OMAP_DMA_CONSTANT_FILL
:
289 case OMAP_DMA_TRANSPARENT_COPY
:
292 case OMAP_DMA_COLOR_DIS
:
297 OMAP1_DMA_CCR2_REG(lch
) = w
;
299 w
= OMAP1_DMA_LCH_CTRL_REG(lch
) & ~0x0f;
300 /* Default is channel type 2D */
302 OMAP1_DMA_COLOR_L_REG(lch
) = (u16
)color
;
303 OMAP1_DMA_COLOR_U_REG(lch
) = (u16
)(color
>> 16);
304 w
|= 1; /* Channel type G */
306 OMAP1_DMA_LCH_CTRL_REG(lch
) = w
;
309 void omap_set_dma_write_mode(int lch
, enum omap_dma_write_mode mode
)
311 if (cpu_class_is_omap2()) {
312 OMAP_DMA_CSDP_REG(lch
) &= ~(0x3 << 16);
313 OMAP_DMA_CSDP_REG(lch
) |= (mode
<< 16);
317 /* Note that src_port is only for omap1 */
318 void omap_set_dma_src_params(int lch
, int src_port
, int src_amode
,
319 unsigned long src_start
,
320 int src_ei
, int src_fi
)
322 if (cpu_class_is_omap1()) {
323 OMAP_DMA_CSDP_REG(lch
) &= ~(0x1f << 2);
324 OMAP_DMA_CSDP_REG(lch
) |= src_port
<< 2;
327 OMAP_DMA_CCR_REG(lch
) &= ~(0x03 << 12);
328 OMAP_DMA_CCR_REG(lch
) |= src_amode
<< 12;
330 if (cpu_class_is_omap1()) {
331 OMAP1_DMA_CSSA_U_REG(lch
) = src_start
>> 16;
332 OMAP1_DMA_CSSA_L_REG(lch
) = src_start
;
335 if (cpu_class_is_omap2())
336 OMAP2_DMA_CSSA_REG(lch
) = src_start
;
338 OMAP_DMA_CSEI_REG(lch
) = src_ei
;
339 OMAP_DMA_CSFI_REG(lch
) = src_fi
;
342 void omap_set_dma_params(int lch
, struct omap_dma_channel_params
* params
)
344 omap_set_dma_transfer_params(lch
, params
->data_type
,
345 params
->elem_count
, params
->frame_count
,
346 params
->sync_mode
, params
->trigger
,
347 params
->src_or_dst_synch
);
348 omap_set_dma_src_params(lch
, params
->src_port
,
349 params
->src_amode
, params
->src_start
,
350 params
->src_ei
, params
->src_fi
);
352 omap_set_dma_dest_params(lch
, params
->dst_port
,
353 params
->dst_amode
, params
->dst_start
,
354 params
->dst_ei
, params
->dst_fi
);
355 if (params
->read_prio
|| params
->write_prio
)
356 omap_dma_set_prio_lch(lch
, params
->read_prio
,
360 void omap_set_dma_src_index(int lch
, int eidx
, int fidx
)
362 if (cpu_class_is_omap2()) {
366 OMAP_DMA_CSEI_REG(lch
) = eidx
;
367 OMAP_DMA_CSFI_REG(lch
) = fidx
;
370 void omap_set_dma_src_data_pack(int lch
, int enable
)
372 OMAP_DMA_CSDP_REG(lch
) &= ~(1 << 6);
374 OMAP_DMA_CSDP_REG(lch
) |= (1 << 6);
377 void omap_set_dma_src_burst_mode(int lch
, enum omap_dma_burst_mode burst_mode
)
379 unsigned int burst
= 0;
380 OMAP_DMA_CSDP_REG(lch
) &= ~(0x03 << 7);
382 switch (burst_mode
) {
383 case OMAP_DMA_DATA_BURST_DIS
:
385 case OMAP_DMA_DATA_BURST_4
:
386 if (cpu_class_is_omap2())
391 case OMAP_DMA_DATA_BURST_8
:
392 if (cpu_class_is_omap2()) {
396 /* not supported by current hardware on OMAP1
400 case OMAP_DMA_DATA_BURST_16
:
401 if (cpu_class_is_omap2()) {
405 /* OMAP1 don't support burst 16
411 OMAP_DMA_CSDP_REG(lch
) |= (burst
<< 7);
414 /* Note that dest_port is only for OMAP1 */
415 void omap_set_dma_dest_params(int lch
, int dest_port
, int dest_amode
,
416 unsigned long dest_start
,
417 int dst_ei
, int dst_fi
)
419 if (cpu_class_is_omap1()) {
420 OMAP_DMA_CSDP_REG(lch
) &= ~(0x1f << 9);
421 OMAP_DMA_CSDP_REG(lch
) |= dest_port
<< 9;
424 OMAP_DMA_CCR_REG(lch
) &= ~(0x03 << 14);
425 OMAP_DMA_CCR_REG(lch
) |= dest_amode
<< 14;
427 if (cpu_class_is_omap1()) {
428 OMAP1_DMA_CDSA_U_REG(lch
) = dest_start
>> 16;
429 OMAP1_DMA_CDSA_L_REG(lch
) = dest_start
;
432 if (cpu_class_is_omap2())
433 OMAP2_DMA_CDSA_REG(lch
) = dest_start
;
435 OMAP_DMA_CDEI_REG(lch
) = dst_ei
;
436 OMAP_DMA_CDFI_REG(lch
) = dst_fi
;
439 void omap_set_dma_dest_index(int lch
, int eidx
, int fidx
)
441 if (cpu_class_is_omap2()) {
445 OMAP_DMA_CDEI_REG(lch
) = eidx
;
446 OMAP_DMA_CDFI_REG(lch
) = fidx
;
449 void omap_set_dma_dest_data_pack(int lch
, int enable
)
451 OMAP_DMA_CSDP_REG(lch
) &= ~(1 << 13);
453 OMAP_DMA_CSDP_REG(lch
) |= 1 << 13;
456 void omap_set_dma_dest_burst_mode(int lch
, enum omap_dma_burst_mode burst_mode
)
458 unsigned int burst
= 0;
459 OMAP_DMA_CSDP_REG(lch
) &= ~(0x03 << 14);
461 switch (burst_mode
) {
462 case OMAP_DMA_DATA_BURST_DIS
:
464 case OMAP_DMA_DATA_BURST_4
:
465 if (cpu_class_is_omap2())
470 case OMAP_DMA_DATA_BURST_8
:
471 if (cpu_class_is_omap2())
476 case OMAP_DMA_DATA_BURST_16
:
477 if (cpu_class_is_omap2()) {
481 /* OMAP1 don't support burst 16
485 printk(KERN_ERR
"Invalid DMA burst mode\n");
489 OMAP_DMA_CSDP_REG(lch
) |= (burst
<< 14);
492 static inline void omap_enable_channel_irq(int lch
)
497 if (cpu_class_is_omap1())
498 status
= OMAP_DMA_CSR_REG(lch
);
499 else if (cpu_class_is_omap2())
500 OMAP_DMA_CSR_REG(lch
) = OMAP2_DMA_CSR_CLEAR_MASK
;
502 /* Enable some nice interrupts. */
503 OMAP_DMA_CICR_REG(lch
) = dma_chan
[lch
].enabled_irqs
;
505 dma_chan
[lch
].flags
|= OMAP_DMA_ACTIVE
;
508 static void omap_disable_channel_irq(int lch
)
510 if (cpu_class_is_omap2())
511 OMAP_DMA_CICR_REG(lch
) = 0;
514 void omap_enable_dma_irq(int lch
, u16 bits
)
516 dma_chan
[lch
].enabled_irqs
|= bits
;
519 void omap_disable_dma_irq(int lch
, u16 bits
)
521 dma_chan
[lch
].enabled_irqs
&= ~bits
;
524 static inline void enable_lnk(int lch
)
526 if (cpu_class_is_omap1())
527 OMAP_DMA_CLNK_CTRL_REG(lch
) &= ~(1 << 14);
529 /* Set the ENABLE_LNK bits */
530 if (dma_chan
[lch
].next_lch
!= -1)
531 OMAP_DMA_CLNK_CTRL_REG(lch
) =
532 dma_chan
[lch
].next_lch
| (1 << 15);
534 #ifndef CONFIG_ARCH_OMAP1
535 if (dma_chan
[lch
].next_linked_ch
!= -1)
536 OMAP_DMA_CLNK_CTRL_REG(lch
) =
537 dma_chan
[lch
].next_linked_ch
| (1 << 15);
541 static inline void disable_lnk(int lch
)
543 /* Disable interrupts */
544 if (cpu_class_is_omap1()) {
545 OMAP_DMA_CICR_REG(lch
) = 0;
546 /* Set the STOP_LNK bit */
547 OMAP_DMA_CLNK_CTRL_REG(lch
) |= 1 << 14;
550 if (cpu_class_is_omap2()) {
551 omap_disable_channel_irq(lch
);
552 /* Clear the ENABLE_LNK bit */
553 OMAP_DMA_CLNK_CTRL_REG(lch
) &= ~(1 << 15);
556 dma_chan
[lch
].flags
&= ~OMAP_DMA_ACTIVE
;
559 static inline void omap2_enable_irq_lch(int lch
)
563 if (!cpu_class_is_omap2())
566 val
= omap_readl(OMAP_DMA4_IRQENABLE_L0
);
568 omap_writel(val
, OMAP_DMA4_IRQENABLE_L0
);
571 int omap_request_dma(int dev_id
, const char *dev_name
,
572 void (* callback
)(int lch
, u16 ch_status
, void *data
),
573 void *data
, int *dma_ch_out
)
575 int ch
, free_ch
= -1;
577 struct omap_dma_lch
*chan
;
579 spin_lock_irqsave(&dma_chan_lock
, flags
);
580 for (ch
= 0; ch
< dma_chan_count
; ch
++) {
581 if (free_ch
== -1 && dma_chan
[ch
].dev_id
== -1) {
588 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
591 chan
= dma_chan
+ free_ch
;
592 chan
->dev_id
= dev_id
;
594 if (cpu_class_is_omap1())
595 clear_lch_regs(free_ch
);
597 if (cpu_class_is_omap2())
598 omap_clear_dma(free_ch
);
600 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
602 chan
->dev_name
= dev_name
;
603 chan
->callback
= callback
;
605 #ifndef CONFIG_ARCH_OMAP1
608 chan
->enabled_irqs
= OMAP_DMA_DROP_IRQ
| OMAP_DMA_BLOCK_IRQ
;
610 if (cpu_class_is_omap1())
611 chan
->enabled_irqs
|= OMAP1_DMA_TOUT_IRQ
;
612 else if (cpu_class_is_omap2())
613 chan
->enabled_irqs
|= OMAP2_DMA_MISALIGNED_ERR_IRQ
|
614 OMAP2_DMA_TRANS_ERR_IRQ
;
616 if (cpu_is_omap16xx()) {
617 /* If the sync device is set, configure it dynamically. */
619 set_gdma_dev(free_ch
+ 1, dev_id
);
620 dev_id
= free_ch
+ 1;
622 /* Disable the 1510 compatibility mode and set the sync device
624 OMAP_DMA_CCR_REG(free_ch
) = dev_id
| (1 << 10);
625 } else if (cpu_is_omap730() || cpu_is_omap15xx()) {
626 OMAP_DMA_CCR_REG(free_ch
) = dev_id
;
629 if (cpu_class_is_omap2()) {
630 omap2_enable_irq_lch(free_ch
);
632 omap_enable_channel_irq(free_ch
);
633 /* Clear the CSR register and IRQ status register */
634 OMAP_DMA_CSR_REG(free_ch
) = OMAP2_DMA_CSR_CLEAR_MASK
;
635 omap_writel(1 << free_ch
, OMAP_DMA4_IRQSTATUS_L0
);
638 *dma_ch_out
= free_ch
;
643 void omap_free_dma(int lch
)
647 spin_lock_irqsave(&dma_chan_lock
, flags
);
648 if (dma_chan
[lch
].dev_id
== -1) {
649 printk("omap_dma: trying to free nonallocated DMA channel %d\n",
651 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
654 dma_chan
[lch
].dev_id
= -1;
655 dma_chan
[lch
].next_lch
= -1;
656 dma_chan
[lch
].callback
= NULL
;
657 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
659 if (cpu_class_is_omap1()) {
660 /* Disable all DMA interrupts for the channel. */
661 OMAP_DMA_CICR_REG(lch
) = 0;
662 /* Make sure the DMA transfer is stopped. */
663 OMAP_DMA_CCR_REG(lch
) = 0;
666 if (cpu_class_is_omap2()) {
668 /* Disable interrupts */
669 val
= omap_readl(OMAP_DMA4_IRQENABLE_L0
);
671 omap_writel(val
, OMAP_DMA4_IRQENABLE_L0
);
673 /* Clear the CSR register and IRQ status register */
674 OMAP_DMA_CSR_REG(lch
) = OMAP2_DMA_CSR_CLEAR_MASK
;
675 omap_writel(1 << lch
, OMAP_DMA4_IRQSTATUS_L0
);
677 /* Disable all DMA interrupts for the channel. */
678 OMAP_DMA_CICR_REG(lch
) = 0;
680 /* Make sure the DMA transfer is stopped. */
681 OMAP_DMA_CCR_REG(lch
) = 0;
687 * @brief omap_dma_set_global_params : Set global priority settings for dma
690 * @param max_fifo_depth
691 * @param tparams - Number of thereads to reserve : DMA_THREAD_RESERVE_NORM
692 * DMA_THREAD_RESERVE_ONET
693 * DMA_THREAD_RESERVE_TWOT
694 * DMA_THREAD_RESERVE_THREET
697 omap_dma_set_global_params(int arb_rate
, int max_fifo_depth
, int tparams
)
701 if (!cpu_class_is_omap2()) {
702 printk(KERN_ERR
"FIXME: no %s on 15xx/16xx\n", __FUNCTION__
);
709 reg
= (arb_rate
& 0xff) << 16;
710 reg
|= (0xff & max_fifo_depth
);
712 omap_writel(reg
, OMAP_DMA4_GCR_REG
);
714 EXPORT_SYMBOL(omap_dma_set_global_params
);
717 * @brief omap_dma_set_prio_lch : Set channel wise priority settings
720 * @param read_prio - Read priority
721 * @param write_prio - Write priority
722 * Both of the above can be set with one of the following values :
723 * DMA_CH_PRIO_HIGH/DMA_CH_PRIO_LOW
726 omap_dma_set_prio_lch(int lch
, unsigned char read_prio
,
727 unsigned char write_prio
)
731 if (unlikely((lch
< 0 || lch
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
732 printk(KERN_ERR
"Invalid channel id\n");
735 w
= OMAP_DMA_CCR_REG(lch
);
736 w
&= ~((1 << 6) | (1 << 26));
737 if (cpu_is_omap2430() || cpu_is_omap34xx())
738 w
|= ((read_prio
& 0x1) << 6) | ((write_prio
& 0x1) << 26);
740 w
|= ((read_prio
& 0x1) << 6);
742 OMAP_DMA_CCR_REG(lch
) = w
;
745 EXPORT_SYMBOL(omap_dma_set_prio_lch
);
748 * Clears any DMA state so the DMA engine is ready to restart with new buffers
749 * through omap_start_dma(). Any buffers in flight are discarded.
751 void omap_clear_dma(int lch
)
755 local_irq_save(flags
);
757 if (cpu_class_is_omap1()) {
759 OMAP_DMA_CCR_REG(lch
) &= ~OMAP_DMA_CCR_EN
;
761 /* Clear pending interrupts */
762 status
= OMAP_DMA_CSR_REG(lch
);
765 if (cpu_class_is_omap2()) {
767 u32 lch_base
= OMAP_DMA4_BASE
+ lch
* 0x60 + 0x80;
768 for (i
= 0; i
< 0x44; i
+= 4)
769 omap_writel(0, lch_base
+ i
);
772 local_irq_restore(flags
);
775 void omap_start_dma(int lch
)
777 if (!omap_dma_in_1510_mode() && dma_chan
[lch
].next_lch
!= -1) {
778 int next_lch
, cur_lch
;
779 char dma_chan_link_map
[OMAP_LOGICAL_DMA_CH_COUNT
];
781 dma_chan_link_map
[lch
] = 1;
782 /* Set the link register of the first channel */
785 memset(dma_chan_link_map
, 0, sizeof(dma_chan_link_map
));
786 cur_lch
= dma_chan
[lch
].next_lch
;
788 next_lch
= dma_chan
[cur_lch
].next_lch
;
790 /* The loop case: we've been here already */
791 if (dma_chan_link_map
[cur_lch
])
793 /* Mark the current channel */
794 dma_chan_link_map
[cur_lch
] = 1;
797 omap_enable_channel_irq(cur_lch
);
800 } while (next_lch
!= -1);
801 } else if (cpu_class_is_omap2()) {
802 /* Errata: Need to write lch even if not using chaining */
803 OMAP_DMA_CLNK_CTRL_REG(lch
) = lch
;
806 omap_enable_channel_irq(lch
);
808 /* Errata: On ES2.0 BUFFERING disable must be set.
809 * This will always fail on ES1.0 */
810 if (cpu_is_omap24xx()) {
811 OMAP_DMA_CCR_REG(lch
) |= OMAP_DMA_CCR_EN
;
814 OMAP_DMA_CCR_REG(lch
) |= OMAP_DMA_CCR_EN
;
816 dma_chan
[lch
].flags
|= OMAP_DMA_ACTIVE
;
819 void omap_stop_dma(int lch
)
821 if (!omap_dma_in_1510_mode() && dma_chan
[lch
].next_lch
!= -1) {
822 int next_lch
, cur_lch
= lch
;
823 char dma_chan_link_map
[OMAP_LOGICAL_DMA_CH_COUNT
];
825 memset(dma_chan_link_map
, 0, sizeof(dma_chan_link_map
));
827 /* The loop case: we've been here already */
828 if (dma_chan_link_map
[cur_lch
])
830 /* Mark the current channel */
831 dma_chan_link_map
[cur_lch
] = 1;
833 disable_lnk(cur_lch
);
835 next_lch
= dma_chan
[cur_lch
].next_lch
;
837 } while (next_lch
!= -1);
842 /* Disable all interrupts on the channel */
843 if (cpu_class_is_omap1())
844 OMAP_DMA_CICR_REG(lch
) = 0;
846 OMAP_DMA_CCR_REG(lch
) &= ~OMAP_DMA_CCR_EN
;
847 dma_chan
[lch
].flags
&= ~OMAP_DMA_ACTIVE
;
851 * Allows changing the DMA callback function or data. This may be needed if
852 * the driver shares a single DMA channel for multiple dma triggers.
854 int omap_set_dma_callback(int lch
,
855 void (* callback
)(int lch
, u16 ch_status
, void *data
),
863 spin_lock_irqsave(&dma_chan_lock
, flags
);
864 if (dma_chan
[lch
].dev_id
== -1) {
865 printk(KERN_ERR
"DMA callback for not set for free channel\n");
866 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
869 dma_chan
[lch
].callback
= callback
;
870 dma_chan
[lch
].data
= data
;
871 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
877 * Returns current physical source address for the given DMA channel.
878 * If the channel is running the caller must disable interrupts prior calling
879 * this function and process the returned value before re-enabling interrupt to
880 * prevent races with the interrupt handler. Note that in continuous mode there
881 * is a chance for CSSA_L register overflow inbetween the two reads resulting
882 * in incorrect return value.
884 dma_addr_t
omap_get_dma_src_pos(int lch
)
886 dma_addr_t offset
= 0;
888 if (cpu_class_is_omap1())
889 offset
= (dma_addr_t
) (OMAP1_DMA_CSSA_L_REG(lch
) |
890 (OMAP1_DMA_CSSA_U_REG(lch
) << 16));
892 if (cpu_class_is_omap2())
893 offset
= OMAP_DMA_CSAC_REG(lch
);
899 * Returns current physical destination address for the given DMA channel.
900 * If the channel is running the caller must disable interrupts prior calling
901 * this function and process the returned value before re-enabling interrupt to
902 * prevent races with the interrupt handler. Note that in continuous mode there
903 * is a chance for CDSA_L register overflow inbetween the two reads resulting
904 * in incorrect return value.
906 dma_addr_t
omap_get_dma_dst_pos(int lch
)
908 dma_addr_t offset
= 0;
910 if (cpu_class_is_omap1())
911 offset
= (dma_addr_t
) (OMAP1_DMA_CDSA_L_REG(lch
) |
912 (OMAP1_DMA_CDSA_U_REG(lch
) << 16));
914 if (cpu_class_is_omap2())
915 offset
= OMAP_DMA_CDAC_REG(lch
);
921 * Returns current source transfer counting for the given DMA channel.
922 * Can be used to monitor the progress of a transfer inside a block.
923 * It must be called with disabled interrupts.
925 int omap_get_dma_src_addr_counter(int lch
)
927 return (dma_addr_t
) OMAP_DMA_CSAC_REG(lch
);
930 int omap_dma_running(void)
934 /* Check if LCD DMA is running */
935 if (cpu_is_omap16xx())
936 if (omap_readw(OMAP1610_DMA_LCD_CCR
) & OMAP_DMA_CCR_EN
)
939 for (lch
= 0; lch
< dma_chan_count
; lch
++)
940 if (OMAP_DMA_CCR_REG(lch
) & OMAP_DMA_CCR_EN
)
947 * lch_queue DMA will start right after lch_head one is finished.
948 * For this DMA link to start, you still need to start (see omap_start_dma)
949 * the first one. That will fire up the entire queue.
951 void omap_dma_link_lch (int lch_head
, int lch_queue
)
953 if (omap_dma_in_1510_mode()) {
954 printk(KERN_ERR
"DMA linking is not supported in 1510 mode\n");
959 if ((dma_chan
[lch_head
].dev_id
== -1) ||
960 (dma_chan
[lch_queue
].dev_id
== -1)) {
961 printk(KERN_ERR
"omap_dma: trying to link "
962 "non requested channels\n");
966 dma_chan
[lch_head
].next_lch
= lch_queue
;
970 * Once the DMA queue is stopped, we can destroy it.
972 void omap_dma_unlink_lch (int lch_head
, int lch_queue
)
974 if (omap_dma_in_1510_mode()) {
975 printk(KERN_ERR
"DMA linking is not supported in 1510 mode\n");
980 if (dma_chan
[lch_head
].next_lch
!= lch_queue
||
981 dma_chan
[lch_head
].next_lch
== -1) {
982 printk(KERN_ERR
"omap_dma: trying to unlink "
983 "non linked channels\n");
988 if ((dma_chan
[lch_head
].flags
& OMAP_DMA_ACTIVE
) ||
989 (dma_chan
[lch_head
].flags
& OMAP_DMA_ACTIVE
)) {
990 printk(KERN_ERR
"omap_dma: You need to stop the DMA channels "
991 "before unlinking\n");
995 dma_chan
[lch_head
].next_lch
= -1;
998 #ifndef CONFIG_ARCH_OMAP1
999 /* Create chain of DMA channesls */
1000 static void create_dma_lch_chain(int lch_head
, int lch_queue
)
1004 /* Check if this is the first link in chain */
1005 if (dma_chan
[lch_head
].next_linked_ch
== -1) {
1006 dma_chan
[lch_head
].next_linked_ch
= lch_queue
;
1007 dma_chan
[lch_head
].prev_linked_ch
= lch_queue
;
1008 dma_chan
[lch_queue
].next_linked_ch
= lch_head
;
1009 dma_chan
[lch_queue
].prev_linked_ch
= lch_head
;
1012 /* a link exists, link the new channel in circular chain */
1014 dma_chan
[lch_queue
].next_linked_ch
=
1015 dma_chan
[lch_head
].next_linked_ch
;
1016 dma_chan
[lch_queue
].prev_linked_ch
= lch_head
;
1017 dma_chan
[lch_head
].next_linked_ch
= lch_queue
;
1018 dma_chan
[dma_chan
[lch_queue
].next_linked_ch
].prev_linked_ch
=
1022 w
= OMAP_DMA_CLNK_CTRL_REG(lch_head
);
1025 OMAP_DMA_CLNK_CTRL_REG(lch_head
) = w
;
1027 w
= OMAP_DMA_CLNK_CTRL_REG(lch_queue
);
1029 w
|= (dma_chan
[lch_queue
].next_linked_ch
);
1030 OMAP_DMA_CLNK_CTRL_REG(lch_queue
) = w
;
1034 * @brief omap_request_dma_chain : Request a chain of DMA channels
1036 * @param dev_id - Device id using the dma channel
1037 * @param dev_name - Device name
1038 * @param callback - Call back function
1040 * @no_of_chans - Number of channels requested
1041 * @chain_mode - Dynamic or static chaining : OMAP_DMA_STATIC_CHAIN
1042 * OMAP_DMA_DYNAMIC_CHAIN
1043 * @params - Channel parameters
1045 * @return - Succes : 0
1046 * Failure: -EINVAL/-ENOMEM
1048 int omap_request_dma_chain(int dev_id
, const char *dev_name
,
1049 void (*callback
) (int chain_id
, u16 ch_status
,
1051 int *chain_id
, int no_of_chans
, int chain_mode
,
1052 struct omap_dma_channel_params params
)
1057 /* Is the chain mode valid ? */
1058 if (chain_mode
!= OMAP_DMA_STATIC_CHAIN
1059 && chain_mode
!= OMAP_DMA_DYNAMIC_CHAIN
) {
1060 printk(KERN_ERR
"Invalid chain mode requested\n");
1064 if (unlikely((no_of_chans
< 1
1065 || no_of_chans
> OMAP_LOGICAL_DMA_CH_COUNT
))) {
1066 printk(KERN_ERR
"Invalid Number of channels requested\n");
1070 /* Allocate a queue to maintain the status of the channels
1072 channels
= kmalloc(sizeof(*channels
) * no_of_chans
, GFP_KERNEL
);
1073 if (channels
== NULL
) {
1074 printk(KERN_ERR
"omap_dma: No memory for channel queue\n");
1078 /* request and reserve DMA channels for the chain */
1079 for (i
= 0; i
< no_of_chans
; i
++) {
1080 err
= omap_request_dma(dev_id
, dev_name
,
1081 callback
, 0, &channels
[i
]);
1084 for (j
= 0; j
< i
; j
++)
1085 omap_free_dma(channels
[j
]);
1087 printk(KERN_ERR
"omap_dma: Request failed %d\n", err
);
1090 dma_chan
[channels
[i
]].next_linked_ch
= -1;
1091 dma_chan
[channels
[i
]].prev_linked_ch
= -1;
1092 dma_chan
[channels
[i
]].state
= DMA_CH_NOTSTARTED
;
1095 * Allowing client drivers to set common parameters now,
1096 * so that later only relevant (src_start, dest_start
1097 * and element count) can be set
1099 omap_set_dma_params(channels
[i
], ¶ms
);
1102 *chain_id
= channels
[0];
1103 dma_linked_lch
[*chain_id
].linked_dmach_q
= channels
;
1104 dma_linked_lch
[*chain_id
].chain_mode
= chain_mode
;
1105 dma_linked_lch
[*chain_id
].chain_state
= DMA_CHAIN_NOTSTARTED
;
1106 dma_linked_lch
[*chain_id
].no_of_lchs_linked
= no_of_chans
;
1108 for (i
= 0; i
< no_of_chans
; i
++)
1109 dma_chan
[channels
[i
]].chain_id
= *chain_id
;
1111 /* Reset the Queue pointers */
1112 OMAP_DMA_CHAIN_QINIT(*chain_id
);
1114 /* Set up the chain */
1115 if (no_of_chans
== 1)
1116 create_dma_lch_chain(channels
[0], channels
[0]);
1118 for (i
= 0; i
< (no_of_chans
- 1); i
++)
1119 create_dma_lch_chain(channels
[i
], channels
[i
+ 1]);
1123 EXPORT_SYMBOL(omap_request_dma_chain
);
1126 * @brief omap_modify_dma_chain_param : Modify the chain's params - Modify the
1127 * params after setting it. Dont do this while dma is running!!
1129 * @param chain_id - Chained logical channel id.
1132 * @return - Success : 0
1135 int omap_modify_dma_chain_params(int chain_id
,
1136 struct omap_dma_channel_params params
)
1141 /* Check for input params */
1142 if (unlikely((chain_id
< 0
1143 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1144 printk(KERN_ERR
"Invalid chain id\n");
1148 /* Check if the chain exists */
1149 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1150 printk(KERN_ERR
"Chain doesn't exists\n");
1153 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1155 for (i
= 0; i
< dma_linked_lch
[chain_id
].no_of_lchs_linked
; i
++) {
1157 * Allowing client drivers to set common parameters now,
1158 * so that later only relevant (src_start, dest_start
1159 * and element count) can be set
1161 omap_set_dma_params(channels
[i
], ¶ms
);
1165 EXPORT_SYMBOL(omap_modify_dma_chain_params
);
1168 * @brief omap_free_dma_chain - Free all the logical channels in a chain.
1172 * @return - Success : 0
1175 int omap_free_dma_chain(int chain_id
)
1180 /* Check for input params */
1181 if (unlikely((chain_id
< 0 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1182 printk(KERN_ERR
"Invalid chain id\n");
1186 /* Check if the chain exists */
1187 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1188 printk(KERN_ERR
"Chain doesn't exists\n");
1192 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1193 for (i
= 0; i
< dma_linked_lch
[chain_id
].no_of_lchs_linked
; i
++) {
1194 dma_chan
[channels
[i
]].next_linked_ch
= -1;
1195 dma_chan
[channels
[i
]].prev_linked_ch
= -1;
1196 dma_chan
[channels
[i
]].chain_id
= -1;
1197 dma_chan
[channels
[i
]].state
= DMA_CH_NOTSTARTED
;
1198 omap_free_dma(channels
[i
]);
1203 dma_linked_lch
[chain_id
].linked_dmach_q
= NULL
;
1204 dma_linked_lch
[chain_id
].chain_mode
= -1;
1205 dma_linked_lch
[chain_id
].chain_state
= -1;
1208 EXPORT_SYMBOL(omap_free_dma_chain
);
1211 * @brief omap_dma_chain_status - Check if the chain is in
1212 * active / inactive state.
1215 * @return - Success : OMAP_DMA_CHAIN_ACTIVE/OMAP_DMA_CHAIN_INACTIVE
1218 int omap_dma_chain_status(int chain_id
)
1220 /* Check for input params */
1221 if (unlikely((chain_id
< 0 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1222 printk(KERN_ERR
"Invalid chain id\n");
1226 /* Check if the chain exists */
1227 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1228 printk(KERN_ERR
"Chain doesn't exists\n");
1231 pr_debug("CHAINID=%d, qcnt=%d\n", chain_id
,
1232 dma_linked_lch
[chain_id
].q_count
);
1234 if (OMAP_DMA_CHAIN_QEMPTY(chain_id
))
1235 return OMAP_DMA_CHAIN_INACTIVE
;
1236 return OMAP_DMA_CHAIN_ACTIVE
;
1238 EXPORT_SYMBOL(omap_dma_chain_status
);
1241 * @brief omap_dma_chain_a_transfer - Get a free channel from a chain,
1242 * set the params and start the transfer.
1245 * @param src_start - buffer start address
1246 * @param dest_start - Dest address
1248 * @param frame_count
1249 * @param callbk_data - channel callback parameter data.
1251 * @return - Success : start_dma status
1252 * Failure: -EINVAL/-EBUSY
1254 int omap_dma_chain_a_transfer(int chain_id
, int src_start
, int dest_start
,
1255 int elem_count
, int frame_count
, void *callbk_data
)
1261 /* if buffer size is less than 1 then there is
1262 * no use of starting the chain */
1263 if (elem_count
< 1) {
1264 printk(KERN_ERR
"Invalid buffer size\n");
1268 /* Check for input params */
1269 if (unlikely((chain_id
< 0
1270 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1271 printk(KERN_ERR
"Invalid chain id\n");
1275 /* Check if the chain exists */
1276 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1277 printk(KERN_ERR
"Chain doesn't exist\n");
1281 /* Check if all the channels in chain are in use */
1282 if (OMAP_DMA_CHAIN_QFULL(chain_id
))
1285 /* Frame count may be negative in case of indexed transfers */
1286 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1288 /* Get a free channel */
1289 lch
= channels
[dma_linked_lch
[chain_id
].q_tail
];
1291 /* Store the callback data */
1292 dma_chan
[lch
].data
= callbk_data
;
1294 /* Increment the q_tail */
1295 OMAP_DMA_CHAIN_INCQTAIL(chain_id
);
1297 /* Set the params to the free channel */
1299 OMAP2_DMA_CSSA_REG(lch
) = src_start
;
1300 if (dest_start
!= 0)
1301 OMAP2_DMA_CDSA_REG(lch
) = dest_start
;
1303 /* Write the buffer size */
1304 OMAP_DMA_CEN_REG(lch
) = elem_count
;
1305 OMAP_DMA_CFN_REG(lch
) = frame_count
;
1307 /* If the chain is dynamically linked,
1308 * then we may have to start the chain if its not active */
1309 if (dma_linked_lch
[chain_id
].chain_mode
== OMAP_DMA_DYNAMIC_CHAIN
) {
1311 /* In Dynamic chain, if the chain is not started,
1312 * queue the channel */
1313 if (dma_linked_lch
[chain_id
].chain_state
==
1314 DMA_CHAIN_NOTSTARTED
) {
1315 /* Enable the link in previous channel */
1316 if (dma_chan
[dma_chan
[lch
].prev_linked_ch
].state
==
1318 enable_lnk(dma_chan
[lch
].prev_linked_ch
);
1319 dma_chan
[lch
].state
= DMA_CH_QUEUED
;
1322 /* Chain is already started, make sure its active,
1323 * if not then start the chain */
1327 if (dma_chan
[dma_chan
[lch
].prev_linked_ch
].state
==
1329 enable_lnk(dma_chan
[lch
].prev_linked_ch
);
1330 dma_chan
[lch
].state
= DMA_CH_QUEUED
;
1332 if (0 == ((1 << 7) & (OMAP_DMA_CCR_REG
1333 (dma_chan
[lch
].prev_linked_ch
)))) {
1334 disable_lnk(dma_chan
[lch
].
1336 pr_debug("\n prev ch is stopped\n");
1341 else if (dma_chan
[dma_chan
[lch
].prev_linked_ch
].state
1343 enable_lnk(dma_chan
[lch
].prev_linked_ch
);
1344 dma_chan
[lch
].state
= DMA_CH_QUEUED
;
1347 omap_enable_channel_irq(lch
);
1349 w
= OMAP_DMA_CCR_REG(lch
);
1351 if ((0 == (w
& (1 << 24))))
1355 if (start_dma
== 1) {
1356 if (0 == (w
& (1 << 7))) {
1358 dma_chan
[lch
].state
= DMA_CH_STARTED
;
1359 pr_debug("starting %d\n", lch
);
1360 OMAP_DMA_CCR_REG(lch
) = w
;
1364 if (0 == (w
& (1 << 7)))
1365 OMAP_DMA_CCR_REG(lch
) = w
;
1367 dma_chan
[lch
].flags
|= OMAP_DMA_ACTIVE
;
1372 EXPORT_SYMBOL(omap_dma_chain_a_transfer
);
1375 * @brief omap_start_dma_chain_transfers - Start the chain
1379 * @return - Success : 0
1380 * Failure : -EINVAL/-EBUSY
1382 int omap_start_dma_chain_transfers(int chain_id
)
1387 if (unlikely((chain_id
< 0 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1388 printk(KERN_ERR
"Invalid chain id\n");
1392 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1394 if (dma_linked_lch
[channels
[0]].chain_state
== DMA_CHAIN_STARTED
) {
1395 printk(KERN_ERR
"Chain is already started\n");
1399 if (dma_linked_lch
[chain_id
].chain_mode
== OMAP_DMA_STATIC_CHAIN
) {
1400 for (i
= 0; i
< dma_linked_lch
[chain_id
].no_of_lchs_linked
;
1402 enable_lnk(channels
[i
]);
1403 omap_enable_channel_irq(channels
[i
]);
1406 omap_enable_channel_irq(channels
[0]);
1409 w
= OMAP_DMA_CCR_REG(channels
[0]);
1411 dma_linked_lch
[chain_id
].chain_state
= DMA_CHAIN_STARTED
;
1412 dma_chan
[channels
[0]].state
= DMA_CH_STARTED
;
1414 if ((0 == (w
& (1 << 24))))
1418 OMAP_DMA_CCR_REG(channels
[0]) = w
;
1420 dma_chan
[channels
[0]].flags
|= OMAP_DMA_ACTIVE
;
1423 EXPORT_SYMBOL(omap_start_dma_chain_transfers
);
1426 * @brief omap_stop_dma_chain_transfers - Stop the dma transfer of a chain.
1430 * @return - Success : 0
1433 int omap_stop_dma_chain_transfers(int chain_id
)
1439 /* Check for input params */
1440 if (unlikely((chain_id
< 0 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1441 printk(KERN_ERR
"Invalid chain id\n");
1445 /* Check if the chain exists */
1446 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1447 printk(KERN_ERR
"Chain doesn't exists\n");
1450 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1453 * Special programming model needed to disable DMA before end of block
1455 sys_cf
= omap_readl(OMAP_DMA4_OCP_SYSCONFIG
);
1457 /* Middle mode reg set no Standby */
1458 w
&= ~((1 << 12)|(1 << 13));
1459 omap_writel(w
, OMAP_DMA4_OCP_SYSCONFIG
);
1461 for (i
= 0; i
< dma_linked_lch
[chain_id
].no_of_lchs_linked
; i
++) {
1463 /* Stop the Channel transmission */
1464 w
= OMAP_DMA_CCR_REG(channels
[i
]);
1466 OMAP_DMA_CCR_REG(channels
[i
]) = w
;
1468 /* Disable the link in all the channels */
1469 disable_lnk(channels
[i
]);
1470 dma_chan
[channels
[i
]].state
= DMA_CH_NOTSTARTED
;
1473 dma_linked_lch
[chain_id
].chain_state
= DMA_CHAIN_NOTSTARTED
;
1475 /* Reset the Queue pointers */
1476 OMAP_DMA_CHAIN_QINIT(chain_id
);
1478 /* Errata - put in the old value */
1479 omap_writel(sys_cf
, OMAP_DMA4_OCP_SYSCONFIG
);
1482 EXPORT_SYMBOL(omap_stop_dma_chain_transfers
);
1484 /* Get the index of the ongoing DMA in chain */
1486 * @brief omap_get_dma_chain_index - Get the element and frame index
1487 * of the ongoing DMA in chain
1490 * @param ei - Element index
1491 * @param fi - Frame index
1493 * @return - Success : 0
1496 int omap_get_dma_chain_index(int chain_id
, int *ei
, int *fi
)
1501 /* Check for input params */
1502 if (unlikely((chain_id
< 0 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1503 printk(KERN_ERR
"Invalid chain id\n");
1507 /* Check if the chain exists */
1508 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1509 printk(KERN_ERR
"Chain doesn't exists\n");
1515 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1517 /* Get the current channel */
1518 lch
= channels
[dma_linked_lch
[chain_id
].q_head
];
1520 *ei
= OMAP2_DMA_CCEN_REG(lch
);
1521 *fi
= OMAP2_DMA_CCFN_REG(lch
);
1525 EXPORT_SYMBOL(omap_get_dma_chain_index
);
1528 * @brief omap_get_dma_chain_dst_pos - Get the destination position of the
1529 * ongoing DMA in chain
1533 * @return - Success : Destination position
1536 int omap_get_dma_chain_dst_pos(int chain_id
)
1541 /* Check for input params */
1542 if (unlikely((chain_id
< 0 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1543 printk(KERN_ERR
"Invalid chain id\n");
1547 /* Check if the chain exists */
1548 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1549 printk(KERN_ERR
"Chain doesn't exists\n");
1553 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1555 /* Get the current channel */
1556 lch
= channels
[dma_linked_lch
[chain_id
].q_head
];
1558 return (OMAP_DMA_CDAC_REG(lch
));
1560 EXPORT_SYMBOL(omap_get_dma_chain_dst_pos
);
1563 * @brief omap_get_dma_chain_src_pos - Get the source position
1564 * of the ongoing DMA in chain
1567 * @return - Success : Destination position
1570 int omap_get_dma_chain_src_pos(int chain_id
)
1575 /* Check for input params */
1576 if (unlikely((chain_id
< 0 || chain_id
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
1577 printk(KERN_ERR
"Invalid chain id\n");
1581 /* Check if the chain exists */
1582 if (dma_linked_lch
[chain_id
].linked_dmach_q
== NULL
) {
1583 printk(KERN_ERR
"Chain doesn't exists\n");
1587 channels
= dma_linked_lch
[chain_id
].linked_dmach_q
;
1589 /* Get the current channel */
1590 lch
= channels
[dma_linked_lch
[chain_id
].q_head
];
1592 return (OMAP_DMA_CSAC_REG(lch
));
1594 EXPORT_SYMBOL(omap_get_dma_chain_src_pos
);
1597 /*----------------------------------------------------------------------------*/
1599 #ifdef CONFIG_ARCH_OMAP1
1601 static int omap1_dma_handle_ch(int ch
)
1605 if (enable_1510_mode
&& ch
>= 6) {
1606 csr
= dma_chan
[ch
].saved_csr
;
1607 dma_chan
[ch
].saved_csr
= 0;
1609 csr
= OMAP_DMA_CSR_REG(ch
);
1610 if (enable_1510_mode
&& ch
<= 2 && (csr
>> 7) != 0) {
1611 dma_chan
[ch
+ 6].saved_csr
= csr
>> 7;
1614 if ((csr
& 0x3f) == 0)
1616 if (unlikely(dma_chan
[ch
].dev_id
== -1)) {
1617 printk(KERN_WARNING
"Spurious interrupt from DMA channel "
1618 "%d (CSR %04x)\n", ch
, csr
);
1621 if (unlikely(csr
& OMAP1_DMA_TOUT_IRQ
))
1622 printk(KERN_WARNING
"DMA timeout with device %d\n",
1623 dma_chan
[ch
].dev_id
);
1624 if (unlikely(csr
& OMAP_DMA_DROP_IRQ
))
1625 printk(KERN_WARNING
"DMA synchronization event drop occurred "
1626 "with device %d\n", dma_chan
[ch
].dev_id
);
1627 if (likely(csr
& OMAP_DMA_BLOCK_IRQ
))
1628 dma_chan
[ch
].flags
&= ~OMAP_DMA_ACTIVE
;
1629 if (likely(dma_chan
[ch
].callback
!= NULL
))
1630 dma_chan
[ch
].callback(ch
, csr
, dma_chan
[ch
].data
);
1634 static irqreturn_t
omap1_dma_irq_handler(int irq
, void *dev_id
)
1636 int ch
= ((int) dev_id
) - 1;
1640 int handled_now
= 0;
1642 handled_now
+= omap1_dma_handle_ch(ch
);
1643 if (enable_1510_mode
&& dma_chan
[ch
+ 6].saved_csr
)
1644 handled_now
+= omap1_dma_handle_ch(ch
+ 6);
1647 handled
+= handled_now
;
1650 return handled
? IRQ_HANDLED
: IRQ_NONE
;
1654 #define omap1_dma_irq_handler NULL
1657 #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
1659 static int omap2_dma_handle_ch(int ch
)
1661 u32 status
= OMAP_DMA_CSR_REG(ch
);
1664 if (printk_ratelimit())
1665 printk(KERN_WARNING
"Spurious DMA IRQ for lch %d\n", ch
);
1668 if (unlikely(dma_chan
[ch
].dev_id
== -1)) {
1669 if (printk_ratelimit())
1670 printk(KERN_WARNING
"IRQ %04x for non-allocated DMA"
1671 "channel %d\n", status
, ch
);
1674 if (unlikely(status
& OMAP_DMA_DROP_IRQ
))
1676 "DMA synchronization event drop occurred with device "
1677 "%d\n", dma_chan
[ch
].dev_id
);
1678 if (unlikely(status
& OMAP2_DMA_TRANS_ERR_IRQ
))
1679 printk(KERN_INFO
"DMA transaction error with device %d\n",
1680 dma_chan
[ch
].dev_id
);
1681 if (unlikely(status
& OMAP2_DMA_SECURE_ERR_IRQ
))
1682 printk(KERN_INFO
"DMA secure error with device %d\n",
1683 dma_chan
[ch
].dev_id
);
1684 if (unlikely(status
& OMAP2_DMA_MISALIGNED_ERR_IRQ
))
1685 printk(KERN_INFO
"DMA misaligned error with device %d\n",
1686 dma_chan
[ch
].dev_id
);
1688 OMAP_DMA_CSR_REG(ch
) = OMAP2_DMA_CSR_CLEAR_MASK
;
1689 omap_writel(1 << ch
, OMAP_DMA4_IRQSTATUS_L0
);
1691 /* If the ch is not chained then chain_id will be -1 */
1692 if (dma_chan
[ch
].chain_id
!= -1) {
1693 int chain_id
= dma_chan
[ch
].chain_id
;
1694 dma_chan
[ch
].state
= DMA_CH_NOTSTARTED
;
1695 if (OMAP_DMA_CLNK_CTRL_REG(ch
) & (1 << 15))
1696 dma_chan
[dma_chan
[ch
].next_linked_ch
].state
=
1698 if (dma_linked_lch
[chain_id
].chain_mode
==
1699 OMAP_DMA_DYNAMIC_CHAIN
)
1702 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id
))
1703 OMAP_DMA_CHAIN_INCQHEAD(chain_id
);
1705 status
= OMAP_DMA_CSR_REG(ch
);
1708 if (likely(dma_chan
[ch
].callback
!= NULL
))
1709 dma_chan
[ch
].callback(ch
, status
, dma_chan
[ch
].data
);
1711 OMAP_DMA_CSR_REG(ch
) = status
;
1716 /* STATUS register count is from 1-32 while our is 0-31 */
1717 static irqreturn_t
omap2_dma_irq_handler(int irq
, void *dev_id
)
1722 val
= omap_readl(OMAP_DMA4_IRQSTATUS_L0
);
1724 if (printk_ratelimit())
1725 printk(KERN_WARNING
"Spurious DMA IRQ\n");
1728 for (i
= 0; i
< OMAP_LOGICAL_DMA_CH_COUNT
&& val
!= 0; i
++) {
1730 omap2_dma_handle_ch(i
);
1737 static struct irqaction omap24xx_dma_irq
= {
1739 .handler
= omap2_dma_irq_handler
,
1740 .flags
= IRQF_DISABLED
1744 static struct irqaction omap24xx_dma_irq
;
1747 /*----------------------------------------------------------------------------*/
1749 static struct lcd_dma_info
{
1752 void (* callback
)(u16 status
, void *data
);
1756 unsigned long addr
, size
;
1757 int rotate
, data_type
, xres
, yres
;
1763 int single_transfer
;
1766 void omap_set_lcd_dma_b1(unsigned long addr
, u16 fb_xres
, u16 fb_yres
,
1769 lcd_dma
.addr
= addr
;
1770 lcd_dma
.data_type
= data_type
;
1771 lcd_dma
.xres
= fb_xres
;
1772 lcd_dma
.yres
= fb_yres
;
1775 void omap_set_lcd_dma_src_port(int port
)
1777 lcd_dma
.src_port
= port
;
1780 void omap_set_lcd_dma_ext_controller(int external
)
1782 lcd_dma
.ext_ctrl
= external
;
1785 void omap_set_lcd_dma_single_transfer(int single
)
1787 lcd_dma
.single_transfer
= single
;
1791 void omap_set_lcd_dma_b1_rotation(int rotate
)
1793 if (omap_dma_in_1510_mode()) {
1794 printk(KERN_ERR
"DMA rotation is not supported in 1510 mode\n");
1798 lcd_dma
.rotate
= rotate
;
1801 void omap_set_lcd_dma_b1_mirror(int mirror
)
1803 if (omap_dma_in_1510_mode()) {
1804 printk(KERN_ERR
"DMA mirror is not supported in 1510 mode\n");
1807 lcd_dma
.mirror
= mirror
;
1810 void omap_set_lcd_dma_b1_vxres(unsigned long vxres
)
1812 if (omap_dma_in_1510_mode()) {
1813 printk(KERN_ERR
"DMA virtual resulotion is not supported "
1817 lcd_dma
.vxres
= vxres
;
1820 void omap_set_lcd_dma_b1_scale(unsigned int xscale
, unsigned int yscale
)
1822 if (omap_dma_in_1510_mode()) {
1823 printk(KERN_ERR
"DMA scale is not supported in 1510 mode\n");
1826 lcd_dma
.xscale
= xscale
;
1827 lcd_dma
.yscale
= yscale
;
1830 static void set_b1_regs(void)
1832 unsigned long top
, bottom
;
1835 unsigned long en
, fn
;
1837 unsigned long vxres
;
1838 unsigned int xscale
, yscale
;
1840 switch (lcd_dma
.data_type
) {
1841 case OMAP_DMA_DATA_TYPE_S8
:
1844 case OMAP_DMA_DATA_TYPE_S16
:
1847 case OMAP_DMA_DATA_TYPE_S32
:
1855 vxres
= lcd_dma
.vxres
? lcd_dma
.vxres
: lcd_dma
.xres
;
1856 xscale
= lcd_dma
.xscale
? lcd_dma
.xscale
: 1;
1857 yscale
= lcd_dma
.yscale
? lcd_dma
.yscale
: 1;
1858 BUG_ON(vxres
< lcd_dma
.xres
);
1859 #define PIXADDR(x,y) (lcd_dma.addr + ((y) * vxres * yscale + (x) * xscale) * es)
1860 #define PIXSTEP(sx, sy, dx, dy) (PIXADDR(dx, dy) - PIXADDR(sx, sy) - es + 1)
1861 switch (lcd_dma
.rotate
) {
1863 if (!lcd_dma
.mirror
) {
1864 top
= PIXADDR(0, 0);
1865 bottom
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1866 /* 1510 DMA requires the bottom address to be 2 more
1867 * than the actual last memory access location. */
1868 if (omap_dma_in_1510_mode() &&
1869 lcd_dma
.data_type
== OMAP_DMA_DATA_TYPE_S32
)
1871 ei
= PIXSTEP(0, 0, 1, 0);
1872 fi
= PIXSTEP(lcd_dma
.xres
- 1, 0, 0, 1);
1874 top
= PIXADDR(lcd_dma
.xres
- 1, 0);
1875 bottom
= PIXADDR(0, lcd_dma
.yres
- 1);
1876 ei
= PIXSTEP(1, 0, 0, 0);
1877 fi
= PIXSTEP(0, 0, lcd_dma
.xres
- 1, 1);
1883 if (!lcd_dma
.mirror
) {
1884 top
= PIXADDR(0, lcd_dma
.yres
- 1);
1885 bottom
= PIXADDR(lcd_dma
.xres
- 1, 0);
1886 ei
= PIXSTEP(0, 1, 0, 0);
1887 fi
= PIXSTEP(0, 0, 1, lcd_dma
.yres
- 1);
1889 top
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1890 bottom
= PIXADDR(0, 0);
1891 ei
= PIXSTEP(0, 1, 0, 0);
1892 fi
= PIXSTEP(1, 0, 0, lcd_dma
.yres
- 1);
1898 if (!lcd_dma
.mirror
) {
1899 top
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1900 bottom
= PIXADDR(0, 0);
1901 ei
= PIXSTEP(1, 0, 0, 0);
1902 fi
= PIXSTEP(0, 1, lcd_dma
.xres
- 1, 0);
1904 top
= PIXADDR(0, lcd_dma
.yres
- 1);
1905 bottom
= PIXADDR(lcd_dma
.xres
- 1, 0);
1906 ei
= PIXSTEP(0, 0, 1, 0);
1907 fi
= PIXSTEP(lcd_dma
.xres
- 1, 1, 0, 0);
1913 if (!lcd_dma
.mirror
) {
1914 top
= PIXADDR(lcd_dma
.xres
- 1, 0);
1915 bottom
= PIXADDR(0, lcd_dma
.yres
- 1);
1916 ei
= PIXSTEP(0, 0, 0, 1);
1917 fi
= PIXSTEP(1, lcd_dma
.yres
- 1, 0, 0);
1919 top
= PIXADDR(0, 0);
1920 bottom
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1921 ei
= PIXSTEP(0, 0, 0, 1);
1922 fi
= PIXSTEP(0, lcd_dma
.yres
- 1, 1, 0);
1929 return; /* Suppress warning about uninitialized vars */
1932 if (omap_dma_in_1510_mode()) {
1933 omap_writew(top
>> 16, OMAP1510_DMA_LCD_TOP_F1_U
);
1934 omap_writew(top
, OMAP1510_DMA_LCD_TOP_F1_L
);
1935 omap_writew(bottom
>> 16, OMAP1510_DMA_LCD_BOT_F1_U
);
1936 omap_writew(bottom
, OMAP1510_DMA_LCD_BOT_F1_L
);
1942 omap_writew(top
>> 16, OMAP1610_DMA_LCD_TOP_B1_U
);
1943 omap_writew(top
, OMAP1610_DMA_LCD_TOP_B1_L
);
1944 omap_writew(bottom
>> 16, OMAP1610_DMA_LCD_BOT_B1_U
);
1945 omap_writew(bottom
, OMAP1610_DMA_LCD_BOT_B1_L
);
1947 omap_writew(en
, OMAP1610_DMA_LCD_SRC_EN_B1
);
1948 omap_writew(fn
, OMAP1610_DMA_LCD_SRC_FN_B1
);
1950 w
= omap_readw(OMAP1610_DMA_LCD_CSDP
);
1952 w
|= lcd_dma
.data_type
;
1953 omap_writew(w
, OMAP1610_DMA_LCD_CSDP
);
1955 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
1956 /* Always set the source port as SDRAM for now*/
1958 if (lcd_dma
.callback
!= NULL
)
1959 w
|= 1 << 1; /* Block interrupt enable */
1962 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
1964 if (!(lcd_dma
.rotate
|| lcd_dma
.mirror
||
1965 lcd_dma
.vxres
|| lcd_dma
.xscale
|| lcd_dma
.yscale
))
1968 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
1969 /* Set the double-indexed addressing mode */
1971 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
1973 omap_writew(ei
, OMAP1610_DMA_LCD_SRC_EI_B1
);
1974 omap_writew(fi
>> 16, OMAP1610_DMA_LCD_SRC_FI_B1_U
);
1975 omap_writew(fi
, OMAP1610_DMA_LCD_SRC_FI_B1_L
);
1978 static irqreturn_t
lcd_dma_irq_handler(int irq
, void *dev_id
)
1982 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
1983 if (unlikely(!(w
& (1 << 3)))) {
1984 printk(KERN_WARNING
"Spurious LCD DMA IRQ\n");
1989 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
1991 if (lcd_dma
.callback
!= NULL
)
1992 lcd_dma
.callback(w
, lcd_dma
.cb_data
);
1997 int omap_request_lcd_dma(void (* callback
)(u16 status
, void *data
),
2000 spin_lock_irq(&lcd_dma
.lock
);
2001 if (lcd_dma
.reserved
) {
2002 spin_unlock_irq(&lcd_dma
.lock
);
2003 printk(KERN_ERR
"LCD DMA channel already reserved\n");
2007 lcd_dma
.reserved
= 1;
2008 spin_unlock_irq(&lcd_dma
.lock
);
2009 lcd_dma
.callback
= callback
;
2010 lcd_dma
.cb_data
= data
;
2012 lcd_dma
.single_transfer
= 0;
2018 lcd_dma
.ext_ctrl
= 0;
2019 lcd_dma
.src_port
= 0;
2024 void omap_free_lcd_dma(void)
2026 spin_lock(&lcd_dma
.lock
);
2027 if (!lcd_dma
.reserved
) {
2028 spin_unlock(&lcd_dma
.lock
);
2029 printk(KERN_ERR
"LCD DMA is not reserved\n");
2033 if (!enable_1510_mode
)
2034 omap_writew(omap_readw(OMAP1610_DMA_LCD_CCR
) & ~1,
2035 OMAP1610_DMA_LCD_CCR
);
2036 lcd_dma
.reserved
= 0;
2037 spin_unlock(&lcd_dma
.lock
);
2040 void omap_enable_lcd_dma(void)
2044 /* Set the Enable bit only if an external controller is
2045 * connected. Otherwise the OMAP internal controller will
2046 * start the transfer when it gets enabled.
2048 if (enable_1510_mode
|| !lcd_dma
.ext_ctrl
)
2051 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
2053 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
2057 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
2059 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
2062 void omap_setup_lcd_dma(void)
2064 BUG_ON(lcd_dma
.active
);
2065 if (!enable_1510_mode
) {
2066 /* Set some reasonable defaults */
2067 omap_writew(0x5440, OMAP1610_DMA_LCD_CCR
);
2068 omap_writew(0x9102, OMAP1610_DMA_LCD_CSDP
);
2069 omap_writew(0x0004, OMAP1610_DMA_LCD_LCH_CTRL
);
2072 if (!enable_1510_mode
) {
2075 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
2076 /* If DMA was already active set the end_prog bit to have
2077 * the programmed register set loaded into the active
2080 w
|= 1 << 11; /* End_prog */
2081 if (!lcd_dma
.single_transfer
)
2082 w
|= (3 << 8); /* Auto_init, repeat */
2083 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
2087 void omap_stop_lcd_dma(void)
2092 if (enable_1510_mode
|| !lcd_dma
.ext_ctrl
)
2095 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
2097 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
2099 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
2101 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
2104 /*----------------------------------------------------------------------------*/
2106 static int __init
omap_init_dma(void)
2110 if (cpu_is_omap15xx()) {
2111 printk(KERN_INFO
"DMA support for OMAP15xx initialized\n");
2113 enable_1510_mode
= 1;
2114 } else if (cpu_is_omap16xx() || cpu_is_omap730()) {
2115 printk(KERN_INFO
"OMAP DMA hardware version %d\n",
2116 omap_readw(OMAP_DMA_HW_ID
));
2117 printk(KERN_INFO
"DMA capabilities: %08x:%08x:%04x:%04x:%04x\n",
2118 (omap_readw(OMAP_DMA_CAPS_0_U
) << 16) |
2119 omap_readw(OMAP_DMA_CAPS_0_L
),
2120 (omap_readw(OMAP_DMA_CAPS_1_U
) << 16) |
2121 omap_readw(OMAP_DMA_CAPS_1_L
),
2122 omap_readw(OMAP_DMA_CAPS_2
), omap_readw(OMAP_DMA_CAPS_3
),
2123 omap_readw(OMAP_DMA_CAPS_4
));
2124 if (!enable_1510_mode
) {
2127 /* Disable OMAP 3.0/3.1 compatibility mode. */
2128 w
= omap_readw(OMAP_DMA_GSCR
);
2130 omap_writew(w
, OMAP_DMA_GSCR
);
2131 dma_chan_count
= 16;
2134 if (cpu_is_omap16xx()) {
2137 /* this would prevent OMAP sleep */
2138 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
2140 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
2142 } else if (cpu_class_is_omap2()) {
2143 u8 revision
= omap_readb(OMAP_DMA4_REVISION
);
2144 printk(KERN_INFO
"OMAP DMA hardware revision %d.%d\n",
2145 revision
>> 4, revision
& 0xf);
2146 dma_chan_count
= OMAP_LOGICAL_DMA_CH_COUNT
;
2152 memset(&lcd_dma
, 0, sizeof(lcd_dma
));
2153 spin_lock_init(&lcd_dma
.lock
);
2154 spin_lock_init(&dma_chan_lock
);
2155 memset(&dma_chan
, 0, sizeof(dma_chan
));
2157 for (ch
= 0; ch
< dma_chan_count
; ch
++) {
2159 dma_chan
[ch
].dev_id
= -1;
2160 dma_chan
[ch
].next_lch
= -1;
2162 if (ch
>= 6 && enable_1510_mode
)
2165 if (cpu_class_is_omap1()) {
2166 /* request_irq() doesn't like dev_id (ie. ch) being
2167 * zero, so we have to kludge around this. */
2168 r
= request_irq(omap1_dma_irq
[ch
],
2169 omap1_dma_irq_handler
, 0, "DMA",
2174 printk(KERN_ERR
"unable to request IRQ %d "
2175 "for DMA (error %d)\n",
2176 omap1_dma_irq
[ch
], r
);
2177 for (i
= 0; i
< ch
; i
++)
2178 free_irq(omap1_dma_irq
[i
],
2185 if (cpu_is_omap2430() || cpu_is_omap34xx())
2186 omap_dma_set_global_params(DMA_DEFAULT_ARB_RATE
,
2187 DMA_DEFAULT_FIFO_DEPTH
, 0);
2189 if (cpu_class_is_omap2())
2190 setup_irq(INT_24XX_SDMA_IRQ0
, &omap24xx_dma_irq
);
2192 /* FIXME: Update LCD DMA to work on 24xx */
2193 if (cpu_class_is_omap1()) {
2194 r
= request_irq(INT_DMA_LCD
, lcd_dma_irq_handler
, 0,
2199 printk(KERN_ERR
"unable to request IRQ for LCD DMA "
2201 for (i
= 0; i
< dma_chan_count
; i
++)
2202 free_irq(omap1_dma_irq
[i
], (void *) (i
+ 1));
2210 arch_initcall(omap_init_dma
);
2212 EXPORT_SYMBOL(omap_get_dma_src_pos
);
2213 EXPORT_SYMBOL(omap_get_dma_dst_pos
);
2214 EXPORT_SYMBOL(omap_get_dma_src_addr_counter
);
2215 EXPORT_SYMBOL(omap_clear_dma
);
2216 EXPORT_SYMBOL(omap_set_dma_priority
);
2217 EXPORT_SYMBOL(omap_request_dma
);
2218 EXPORT_SYMBOL(omap_free_dma
);
2219 EXPORT_SYMBOL(omap_start_dma
);
2220 EXPORT_SYMBOL(omap_stop_dma
);
2221 EXPORT_SYMBOL(omap_set_dma_callback
);
2222 EXPORT_SYMBOL(omap_enable_dma_irq
);
2223 EXPORT_SYMBOL(omap_disable_dma_irq
);
2225 EXPORT_SYMBOL(omap_set_dma_transfer_params
);
2226 EXPORT_SYMBOL(omap_set_dma_color_mode
);
2227 EXPORT_SYMBOL(omap_set_dma_write_mode
);
2229 EXPORT_SYMBOL(omap_set_dma_src_params
);
2230 EXPORT_SYMBOL(omap_set_dma_src_index
);
2231 EXPORT_SYMBOL(omap_set_dma_src_data_pack
);
2232 EXPORT_SYMBOL(omap_set_dma_src_burst_mode
);
2234 EXPORT_SYMBOL(omap_set_dma_dest_params
);
2235 EXPORT_SYMBOL(omap_set_dma_dest_index
);
2236 EXPORT_SYMBOL(omap_set_dma_dest_data_pack
);
2237 EXPORT_SYMBOL(omap_set_dma_dest_burst_mode
);
2239 EXPORT_SYMBOL(omap_set_dma_params
);
2241 EXPORT_SYMBOL(omap_dma_link_lch
);
2242 EXPORT_SYMBOL(omap_dma_unlink_lch
);
2244 EXPORT_SYMBOL(omap_request_lcd_dma
);
2245 EXPORT_SYMBOL(omap_free_lcd_dma
);
2246 EXPORT_SYMBOL(omap_enable_lcd_dma
);
2247 EXPORT_SYMBOL(omap_setup_lcd_dma
);
2248 EXPORT_SYMBOL(omap_stop_lcd_dma
);
2249 EXPORT_SYMBOL(omap_set_lcd_dma_b1
);
2250 EXPORT_SYMBOL(omap_set_lcd_dma_single_transfer
);
2251 EXPORT_SYMBOL(omap_set_lcd_dma_ext_controller
);
2252 EXPORT_SYMBOL(omap_set_lcd_dma_b1_rotation
);
2253 EXPORT_SYMBOL(omap_set_lcd_dma_b1_vxres
);
2254 EXPORT_SYMBOL(omap_set_lcd_dma_b1_scale
);
2255 EXPORT_SYMBOL(omap_set_lcd_dma_b1_mirror
);