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
607 chan
->next_linked_ch
= -1;
609 chan
->enabled_irqs
= OMAP_DMA_DROP_IRQ
| OMAP_DMA_BLOCK_IRQ
;
611 if (cpu_class_is_omap1())
612 chan
->enabled_irqs
|= OMAP1_DMA_TOUT_IRQ
;
613 else if (cpu_class_is_omap2())
614 chan
->enabled_irqs
|= OMAP2_DMA_MISALIGNED_ERR_IRQ
|
615 OMAP2_DMA_TRANS_ERR_IRQ
;
617 if (cpu_is_omap16xx()) {
618 /* If the sync device is set, configure it dynamically. */
620 set_gdma_dev(free_ch
+ 1, dev_id
);
621 dev_id
= free_ch
+ 1;
623 /* Disable the 1510 compatibility mode and set the sync device
625 OMAP_DMA_CCR_REG(free_ch
) = dev_id
| (1 << 10);
626 } else if (cpu_is_omap730() || cpu_is_omap15xx()) {
627 OMAP_DMA_CCR_REG(free_ch
) = dev_id
;
630 if (cpu_class_is_omap2()) {
631 omap2_enable_irq_lch(free_ch
);
633 omap_enable_channel_irq(free_ch
);
634 /* Clear the CSR register and IRQ status register */
635 OMAP_DMA_CSR_REG(free_ch
) = OMAP2_DMA_CSR_CLEAR_MASK
;
636 omap_writel(1 << free_ch
, OMAP_DMA4_IRQSTATUS_L0
);
639 *dma_ch_out
= free_ch
;
644 void omap_free_dma(int lch
)
648 spin_lock_irqsave(&dma_chan_lock
, flags
);
649 if (dma_chan
[lch
].dev_id
== -1) {
650 printk("omap_dma: trying to free nonallocated DMA channel %d\n",
652 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
655 dma_chan
[lch
].dev_id
= -1;
656 dma_chan
[lch
].next_lch
= -1;
657 dma_chan
[lch
].callback
= NULL
;
658 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
660 if (cpu_class_is_omap1()) {
661 /* Disable all DMA interrupts for the channel. */
662 OMAP_DMA_CICR_REG(lch
) = 0;
663 /* Make sure the DMA transfer is stopped. */
664 OMAP_DMA_CCR_REG(lch
) = 0;
667 if (cpu_class_is_omap2()) {
669 /* Disable interrupts */
670 val
= omap_readl(OMAP_DMA4_IRQENABLE_L0
);
672 omap_writel(val
, OMAP_DMA4_IRQENABLE_L0
);
674 /* Clear the CSR register and IRQ status register */
675 OMAP_DMA_CSR_REG(lch
) = OMAP2_DMA_CSR_CLEAR_MASK
;
676 omap_writel(1 << lch
, OMAP_DMA4_IRQSTATUS_L0
);
678 /* Disable all DMA interrupts for the channel. */
679 OMAP_DMA_CICR_REG(lch
) = 0;
681 /* Make sure the DMA transfer is stopped. */
682 OMAP_DMA_CCR_REG(lch
) = 0;
688 * @brief omap_dma_set_global_params : Set global priority settings for dma
691 * @param max_fifo_depth
692 * @param tparams - Number of thereads to reserve : DMA_THREAD_RESERVE_NORM
693 * DMA_THREAD_RESERVE_ONET
694 * DMA_THREAD_RESERVE_TWOT
695 * DMA_THREAD_RESERVE_THREET
698 omap_dma_set_global_params(int arb_rate
, int max_fifo_depth
, int tparams
)
702 if (!cpu_class_is_omap2()) {
703 printk(KERN_ERR
"FIXME: no %s on 15xx/16xx\n", __func__
);
710 reg
= (arb_rate
& 0xff) << 16;
711 reg
|= (0xff & max_fifo_depth
);
713 omap_writel(reg
, OMAP_DMA4_GCR_REG
);
715 EXPORT_SYMBOL(omap_dma_set_global_params
);
718 * @brief omap_dma_set_prio_lch : Set channel wise priority settings
721 * @param read_prio - Read priority
722 * @param write_prio - Write priority
723 * Both of the above can be set with one of the following values :
724 * DMA_CH_PRIO_HIGH/DMA_CH_PRIO_LOW
727 omap_dma_set_prio_lch(int lch
, unsigned char read_prio
,
728 unsigned char write_prio
)
732 if (unlikely((lch
< 0 || lch
>= OMAP_LOGICAL_DMA_CH_COUNT
))) {
733 printk(KERN_ERR
"Invalid channel id\n");
736 w
= OMAP_DMA_CCR_REG(lch
);
737 w
&= ~((1 << 6) | (1 << 26));
738 if (cpu_is_omap2430() || cpu_is_omap34xx())
739 w
|= ((read_prio
& 0x1) << 6) | ((write_prio
& 0x1) << 26);
741 w
|= ((read_prio
& 0x1) << 6);
743 OMAP_DMA_CCR_REG(lch
) = w
;
746 EXPORT_SYMBOL(omap_dma_set_prio_lch
);
749 * Clears any DMA state so the DMA engine is ready to restart with new buffers
750 * through omap_start_dma(). Any buffers in flight are discarded.
752 void omap_clear_dma(int lch
)
756 local_irq_save(flags
);
758 if (cpu_class_is_omap1()) {
760 OMAP_DMA_CCR_REG(lch
) &= ~OMAP_DMA_CCR_EN
;
762 /* Clear pending interrupts */
763 status
= OMAP_DMA_CSR_REG(lch
);
766 if (cpu_class_is_omap2()) {
768 u32 lch_base
= OMAP_DMA4_BASE
+ lch
* 0x60 + 0x80;
769 for (i
= 0; i
< 0x44; i
+= 4)
770 omap_writel(0, lch_base
+ i
);
773 local_irq_restore(flags
);
776 void omap_start_dma(int lch
)
778 if (!omap_dma_in_1510_mode() && dma_chan
[lch
].next_lch
!= -1) {
779 int next_lch
, cur_lch
;
780 char dma_chan_link_map
[OMAP_LOGICAL_DMA_CH_COUNT
];
782 dma_chan_link_map
[lch
] = 1;
783 /* Set the link register of the first channel */
786 memset(dma_chan_link_map
, 0, sizeof(dma_chan_link_map
));
787 cur_lch
= dma_chan
[lch
].next_lch
;
789 next_lch
= dma_chan
[cur_lch
].next_lch
;
791 /* The loop case: we've been here already */
792 if (dma_chan_link_map
[cur_lch
])
794 /* Mark the current channel */
795 dma_chan_link_map
[cur_lch
] = 1;
798 omap_enable_channel_irq(cur_lch
);
801 } while (next_lch
!= -1);
802 } else if (cpu_class_is_omap2()) {
803 /* Errata: Need to write lch even if not using chaining */
804 OMAP_DMA_CLNK_CTRL_REG(lch
) = lch
;
807 omap_enable_channel_irq(lch
);
809 /* Errata: On ES2.0 BUFFERING disable must be set.
810 * This will always fail on ES1.0 */
811 if (cpu_is_omap24xx()) {
812 OMAP_DMA_CCR_REG(lch
) |= OMAP_DMA_CCR_EN
;
815 OMAP_DMA_CCR_REG(lch
) |= OMAP_DMA_CCR_EN
;
817 dma_chan
[lch
].flags
|= OMAP_DMA_ACTIVE
;
820 void omap_stop_dma(int lch
)
822 if (!omap_dma_in_1510_mode() && dma_chan
[lch
].next_lch
!= -1) {
823 int next_lch
, cur_lch
= lch
;
824 char dma_chan_link_map
[OMAP_LOGICAL_DMA_CH_COUNT
];
826 memset(dma_chan_link_map
, 0, sizeof(dma_chan_link_map
));
828 /* The loop case: we've been here already */
829 if (dma_chan_link_map
[cur_lch
])
831 /* Mark the current channel */
832 dma_chan_link_map
[cur_lch
] = 1;
834 disable_lnk(cur_lch
);
836 next_lch
= dma_chan
[cur_lch
].next_lch
;
838 } while (next_lch
!= -1);
843 /* Disable all interrupts on the channel */
844 if (cpu_class_is_omap1())
845 OMAP_DMA_CICR_REG(lch
) = 0;
847 OMAP_DMA_CCR_REG(lch
) &= ~OMAP_DMA_CCR_EN
;
848 dma_chan
[lch
].flags
&= ~OMAP_DMA_ACTIVE
;
852 * Allows changing the DMA callback function or data. This may be needed if
853 * the driver shares a single DMA channel for multiple dma triggers.
855 int omap_set_dma_callback(int lch
,
856 void (* callback
)(int lch
, u16 ch_status
, void *data
),
864 spin_lock_irqsave(&dma_chan_lock
, flags
);
865 if (dma_chan
[lch
].dev_id
== -1) {
866 printk(KERN_ERR
"DMA callback for not set for free channel\n");
867 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
870 dma_chan
[lch
].callback
= callback
;
871 dma_chan
[lch
].data
= data
;
872 spin_unlock_irqrestore(&dma_chan_lock
, flags
);
878 * Returns current physical source address for the given DMA channel.
879 * If the channel is running the caller must disable interrupts prior calling
880 * this function and process the returned value before re-enabling interrupt to
881 * prevent races with the interrupt handler. Note that in continuous mode there
882 * is a chance for CSSA_L register overflow inbetween the two reads resulting
883 * in incorrect return value.
885 dma_addr_t
omap_get_dma_src_pos(int lch
)
887 dma_addr_t offset
= 0;
889 if (cpu_class_is_omap1())
890 offset
= (dma_addr_t
) (OMAP1_DMA_CSSA_L_REG(lch
) |
891 (OMAP1_DMA_CSSA_U_REG(lch
) << 16));
893 if (cpu_class_is_omap2())
894 offset
= OMAP_DMA_CSAC_REG(lch
);
900 * Returns current physical destination address for the given DMA channel.
901 * If the channel is running the caller must disable interrupts prior calling
902 * this function and process the returned value before re-enabling interrupt to
903 * prevent races with the interrupt handler. Note that in continuous mode there
904 * is a chance for CDSA_L register overflow inbetween the two reads resulting
905 * in incorrect return value.
907 dma_addr_t
omap_get_dma_dst_pos(int lch
)
909 dma_addr_t offset
= 0;
911 if (cpu_class_is_omap1())
912 offset
= (dma_addr_t
) (OMAP1_DMA_CDSA_L_REG(lch
) |
913 (OMAP1_DMA_CDSA_U_REG(lch
) << 16));
915 if (cpu_class_is_omap2())
916 offset
= OMAP_DMA_CDAC_REG(lch
);
922 * Returns current source transfer counting for the given DMA channel.
923 * Can be used to monitor the progress of a transfer inside a block.
924 * It must be called with disabled interrupts.
926 int omap_get_dma_src_addr_counter(int lch
)
928 return (dma_addr_t
) OMAP_DMA_CSAC_REG(lch
);
931 int omap_dma_running(void)
935 /* Check if LCD DMA is running */
936 if (cpu_is_omap16xx())
937 if (omap_readw(OMAP1610_DMA_LCD_CCR
) & OMAP_DMA_CCR_EN
)
940 for (lch
= 0; lch
< dma_chan_count
; lch
++)
941 if (OMAP_DMA_CCR_REG(lch
) & OMAP_DMA_CCR_EN
)
948 * lch_queue DMA will start right after lch_head one is finished.
949 * For this DMA link to start, you still need to start (see omap_start_dma)
950 * the first one. That will fire up the entire queue.
952 void omap_dma_link_lch (int lch_head
, int lch_queue
)
954 if (omap_dma_in_1510_mode()) {
955 printk(KERN_ERR
"DMA linking is not supported in 1510 mode\n");
960 if ((dma_chan
[lch_head
].dev_id
== -1) ||
961 (dma_chan
[lch_queue
].dev_id
== -1)) {
962 printk(KERN_ERR
"omap_dma: trying to link "
963 "non requested channels\n");
967 dma_chan
[lch_head
].next_lch
= lch_queue
;
971 * Once the DMA queue is stopped, we can destroy it.
973 void omap_dma_unlink_lch (int lch_head
, int lch_queue
)
975 if (omap_dma_in_1510_mode()) {
976 printk(KERN_ERR
"DMA linking is not supported in 1510 mode\n");
981 if (dma_chan
[lch_head
].next_lch
!= lch_queue
||
982 dma_chan
[lch_head
].next_lch
== -1) {
983 printk(KERN_ERR
"omap_dma: trying to unlink "
984 "non linked channels\n");
989 if ((dma_chan
[lch_head
].flags
& OMAP_DMA_ACTIVE
) ||
990 (dma_chan
[lch_head
].flags
& OMAP_DMA_ACTIVE
)) {
991 printk(KERN_ERR
"omap_dma: You need to stop the DMA channels "
992 "before unlinking\n");
996 dma_chan
[lch_head
].next_lch
= -1;
999 #ifndef CONFIG_ARCH_OMAP1
1000 /* Create chain of DMA channesls */
1001 static void create_dma_lch_chain(int lch_head
, int lch_queue
)
1005 /* Check if this is the first link in chain */
1006 if (dma_chan
[lch_head
].next_linked_ch
== -1) {
1007 dma_chan
[lch_head
].next_linked_ch
= lch_queue
;
1008 dma_chan
[lch_head
].prev_linked_ch
= lch_queue
;
1009 dma_chan
[lch_queue
].next_linked_ch
= lch_head
;
1010 dma_chan
[lch_queue
].prev_linked_ch
= lch_head
;
1013 /* a link exists, link the new channel in circular chain */
1015 dma_chan
[lch_queue
].next_linked_ch
=
1016 dma_chan
[lch_head
].next_linked_ch
;
1017 dma_chan
[lch_queue
].prev_linked_ch
= lch_head
;
1018 dma_chan
[lch_head
].next_linked_ch
= lch_queue
;
1019 dma_chan
[dma_chan
[lch_queue
].next_linked_ch
].prev_linked_ch
=
1023 w
= OMAP_DMA_CLNK_CTRL_REG(lch_head
);
1026 OMAP_DMA_CLNK_CTRL_REG(lch_head
) = w
;
1028 w
= OMAP_DMA_CLNK_CTRL_REG(lch_queue
);
1030 w
|= (dma_chan
[lch_queue
].next_linked_ch
);
1031 OMAP_DMA_CLNK_CTRL_REG(lch_queue
) = w
;
1035 * @brief omap_request_dma_chain : Request a chain of DMA channels
1037 * @param dev_id - Device id using the dma channel
1038 * @param dev_name - Device name
1039 * @param callback - Call back function
1041 * @no_of_chans - Number of channels requested
1042 * @chain_mode - Dynamic or static chaining : OMAP_DMA_STATIC_CHAIN
1043 * OMAP_DMA_DYNAMIC_CHAIN
1044 * @params - Channel parameters
1046 * @return - Succes : 0
1047 * Failure: -EINVAL/-ENOMEM
1049 int omap_request_dma_chain(int dev_id
, const char *dev_name
,
1050 void (*callback
) (int chain_id
, u16 ch_status
,
1052 int *chain_id
, int no_of_chans
, int chain_mode
,
1053 struct omap_dma_channel_params params
)
1058 /* Is the chain mode valid ? */
1059 if (chain_mode
!= OMAP_DMA_STATIC_CHAIN
1060 && chain_mode
!= OMAP_DMA_DYNAMIC_CHAIN
) {
1061 printk(KERN_ERR
"Invalid chain mode requested\n");
1065 if (unlikely((no_of_chans
< 1
1066 || no_of_chans
> OMAP_LOGICAL_DMA_CH_COUNT
))) {
1067 printk(KERN_ERR
"Invalid Number of channels requested\n");
1071 /* Allocate a queue to maintain the status of the channels
1073 channels
= kmalloc(sizeof(*channels
) * no_of_chans
, GFP_KERNEL
);
1074 if (channels
== NULL
) {
1075 printk(KERN_ERR
"omap_dma: No memory for channel queue\n");
1079 /* request and reserve DMA channels for the chain */
1080 for (i
= 0; i
< no_of_chans
; i
++) {
1081 err
= omap_request_dma(dev_id
, dev_name
,
1082 callback
, 0, &channels
[i
]);
1085 for (j
= 0; j
< i
; j
++)
1086 omap_free_dma(channels
[j
]);
1088 printk(KERN_ERR
"omap_dma: Request failed %d\n", err
);
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 : 0
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
);
1666 omap_writel(1 << ch
, OMAP_DMA4_IRQSTATUS_L0
);
1669 if (unlikely(dma_chan
[ch
].dev_id
== -1)) {
1670 if (printk_ratelimit())
1671 printk(KERN_WARNING
"IRQ %04x for non-allocated DMA"
1672 "channel %d\n", status
, ch
);
1675 if (unlikely(status
& OMAP_DMA_DROP_IRQ
))
1677 "DMA synchronization event drop occurred with device "
1678 "%d\n", dma_chan
[ch
].dev_id
);
1679 if (unlikely(status
& OMAP2_DMA_TRANS_ERR_IRQ
))
1680 printk(KERN_INFO
"DMA transaction error with device %d\n",
1681 dma_chan
[ch
].dev_id
);
1682 if (unlikely(status
& OMAP2_DMA_SECURE_ERR_IRQ
))
1683 printk(KERN_INFO
"DMA secure error with device %d\n",
1684 dma_chan
[ch
].dev_id
);
1685 if (unlikely(status
& OMAP2_DMA_MISALIGNED_ERR_IRQ
))
1686 printk(KERN_INFO
"DMA misaligned error with device %d\n",
1687 dma_chan
[ch
].dev_id
);
1689 OMAP_DMA_CSR_REG(ch
) = OMAP2_DMA_CSR_CLEAR_MASK
;
1690 omap_writel(1 << ch
, OMAP_DMA4_IRQSTATUS_L0
);
1692 /* If the ch is not chained then chain_id will be -1 */
1693 if (dma_chan
[ch
].chain_id
!= -1) {
1694 int chain_id
= dma_chan
[ch
].chain_id
;
1695 dma_chan
[ch
].state
= DMA_CH_NOTSTARTED
;
1696 if (OMAP_DMA_CLNK_CTRL_REG(ch
) & (1 << 15))
1697 dma_chan
[dma_chan
[ch
].next_linked_ch
].state
=
1699 if (dma_linked_lch
[chain_id
].chain_mode
==
1700 OMAP_DMA_DYNAMIC_CHAIN
)
1703 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id
))
1704 OMAP_DMA_CHAIN_INCQHEAD(chain_id
);
1706 status
= OMAP_DMA_CSR_REG(ch
);
1709 if (likely(dma_chan
[ch
].callback
!= NULL
))
1710 dma_chan
[ch
].callback(ch
, status
, dma_chan
[ch
].data
);
1712 OMAP_DMA_CSR_REG(ch
) = status
;
1717 /* STATUS register count is from 1-32 while our is 0-31 */
1718 static irqreturn_t
omap2_dma_irq_handler(int irq
, void *dev_id
)
1723 val
= omap_readl(OMAP_DMA4_IRQSTATUS_L0
);
1725 if (printk_ratelimit())
1726 printk(KERN_WARNING
"Spurious DMA IRQ\n");
1729 for (i
= 0; i
< OMAP_LOGICAL_DMA_CH_COUNT
&& val
!= 0; i
++) {
1731 omap2_dma_handle_ch(i
);
1738 static struct irqaction omap24xx_dma_irq
= {
1740 .handler
= omap2_dma_irq_handler
,
1741 .flags
= IRQF_DISABLED
1745 static struct irqaction omap24xx_dma_irq
;
1748 /*----------------------------------------------------------------------------*/
1750 static struct lcd_dma_info
{
1753 void (* callback
)(u16 status
, void *data
);
1757 unsigned long addr
, size
;
1758 int rotate
, data_type
, xres
, yres
;
1764 int single_transfer
;
1767 void omap_set_lcd_dma_b1(unsigned long addr
, u16 fb_xres
, u16 fb_yres
,
1770 lcd_dma
.addr
= addr
;
1771 lcd_dma
.data_type
= data_type
;
1772 lcd_dma
.xres
= fb_xres
;
1773 lcd_dma
.yres
= fb_yres
;
1776 void omap_set_lcd_dma_src_port(int port
)
1778 lcd_dma
.src_port
= port
;
1781 void omap_set_lcd_dma_ext_controller(int external
)
1783 lcd_dma
.ext_ctrl
= external
;
1786 void omap_set_lcd_dma_single_transfer(int single
)
1788 lcd_dma
.single_transfer
= single
;
1792 void omap_set_lcd_dma_b1_rotation(int rotate
)
1794 if (omap_dma_in_1510_mode()) {
1795 printk(KERN_ERR
"DMA rotation is not supported in 1510 mode\n");
1799 lcd_dma
.rotate
= rotate
;
1802 void omap_set_lcd_dma_b1_mirror(int mirror
)
1804 if (omap_dma_in_1510_mode()) {
1805 printk(KERN_ERR
"DMA mirror is not supported in 1510 mode\n");
1808 lcd_dma
.mirror
= mirror
;
1811 void omap_set_lcd_dma_b1_vxres(unsigned long vxres
)
1813 if (omap_dma_in_1510_mode()) {
1814 printk(KERN_ERR
"DMA virtual resulotion is not supported "
1818 lcd_dma
.vxres
= vxres
;
1821 void omap_set_lcd_dma_b1_scale(unsigned int xscale
, unsigned int yscale
)
1823 if (omap_dma_in_1510_mode()) {
1824 printk(KERN_ERR
"DMA scale is not supported in 1510 mode\n");
1827 lcd_dma
.xscale
= xscale
;
1828 lcd_dma
.yscale
= yscale
;
1831 static void set_b1_regs(void)
1833 unsigned long top
, bottom
;
1836 unsigned long en
, fn
;
1838 unsigned long vxres
;
1839 unsigned int xscale
, yscale
;
1841 switch (lcd_dma
.data_type
) {
1842 case OMAP_DMA_DATA_TYPE_S8
:
1845 case OMAP_DMA_DATA_TYPE_S16
:
1848 case OMAP_DMA_DATA_TYPE_S32
:
1856 vxres
= lcd_dma
.vxres
? lcd_dma
.vxres
: lcd_dma
.xres
;
1857 xscale
= lcd_dma
.xscale
? lcd_dma
.xscale
: 1;
1858 yscale
= lcd_dma
.yscale
? lcd_dma
.yscale
: 1;
1859 BUG_ON(vxres
< lcd_dma
.xres
);
1860 #define PIXADDR(x,y) (lcd_dma.addr + ((y) * vxres * yscale + (x) * xscale) * es)
1861 #define PIXSTEP(sx, sy, dx, dy) (PIXADDR(dx, dy) - PIXADDR(sx, sy) - es + 1)
1862 switch (lcd_dma
.rotate
) {
1864 if (!lcd_dma
.mirror
) {
1865 top
= PIXADDR(0, 0);
1866 bottom
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1867 /* 1510 DMA requires the bottom address to be 2 more
1868 * than the actual last memory access location. */
1869 if (omap_dma_in_1510_mode() &&
1870 lcd_dma
.data_type
== OMAP_DMA_DATA_TYPE_S32
)
1872 ei
= PIXSTEP(0, 0, 1, 0);
1873 fi
= PIXSTEP(lcd_dma
.xres
- 1, 0, 0, 1);
1875 top
= PIXADDR(lcd_dma
.xres
- 1, 0);
1876 bottom
= PIXADDR(0, lcd_dma
.yres
- 1);
1877 ei
= PIXSTEP(1, 0, 0, 0);
1878 fi
= PIXSTEP(0, 0, lcd_dma
.xres
- 1, 1);
1884 if (!lcd_dma
.mirror
) {
1885 top
= PIXADDR(0, lcd_dma
.yres
- 1);
1886 bottom
= PIXADDR(lcd_dma
.xres
- 1, 0);
1887 ei
= PIXSTEP(0, 1, 0, 0);
1888 fi
= PIXSTEP(0, 0, 1, lcd_dma
.yres
- 1);
1890 top
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1891 bottom
= PIXADDR(0, 0);
1892 ei
= PIXSTEP(0, 1, 0, 0);
1893 fi
= PIXSTEP(1, 0, 0, lcd_dma
.yres
- 1);
1899 if (!lcd_dma
.mirror
) {
1900 top
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1901 bottom
= PIXADDR(0, 0);
1902 ei
= PIXSTEP(1, 0, 0, 0);
1903 fi
= PIXSTEP(0, 1, lcd_dma
.xres
- 1, 0);
1905 top
= PIXADDR(0, lcd_dma
.yres
- 1);
1906 bottom
= PIXADDR(lcd_dma
.xres
- 1, 0);
1907 ei
= PIXSTEP(0, 0, 1, 0);
1908 fi
= PIXSTEP(lcd_dma
.xres
- 1, 1, 0, 0);
1914 if (!lcd_dma
.mirror
) {
1915 top
= PIXADDR(lcd_dma
.xres
- 1, 0);
1916 bottom
= PIXADDR(0, lcd_dma
.yres
- 1);
1917 ei
= PIXSTEP(0, 0, 0, 1);
1918 fi
= PIXSTEP(1, lcd_dma
.yres
- 1, 0, 0);
1920 top
= PIXADDR(0, 0);
1921 bottom
= PIXADDR(lcd_dma
.xres
- 1, lcd_dma
.yres
- 1);
1922 ei
= PIXSTEP(0, 0, 0, 1);
1923 fi
= PIXSTEP(0, lcd_dma
.yres
- 1, 1, 0);
1930 return; /* Suppress warning about uninitialized vars */
1933 if (omap_dma_in_1510_mode()) {
1934 omap_writew(top
>> 16, OMAP1510_DMA_LCD_TOP_F1_U
);
1935 omap_writew(top
, OMAP1510_DMA_LCD_TOP_F1_L
);
1936 omap_writew(bottom
>> 16, OMAP1510_DMA_LCD_BOT_F1_U
);
1937 omap_writew(bottom
, OMAP1510_DMA_LCD_BOT_F1_L
);
1943 omap_writew(top
>> 16, OMAP1610_DMA_LCD_TOP_B1_U
);
1944 omap_writew(top
, OMAP1610_DMA_LCD_TOP_B1_L
);
1945 omap_writew(bottom
>> 16, OMAP1610_DMA_LCD_BOT_B1_U
);
1946 omap_writew(bottom
, OMAP1610_DMA_LCD_BOT_B1_L
);
1948 omap_writew(en
, OMAP1610_DMA_LCD_SRC_EN_B1
);
1949 omap_writew(fn
, OMAP1610_DMA_LCD_SRC_FN_B1
);
1951 w
= omap_readw(OMAP1610_DMA_LCD_CSDP
);
1953 w
|= lcd_dma
.data_type
;
1954 omap_writew(w
, OMAP1610_DMA_LCD_CSDP
);
1956 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
1957 /* Always set the source port as SDRAM for now*/
1959 if (lcd_dma
.callback
!= NULL
)
1960 w
|= 1 << 1; /* Block interrupt enable */
1963 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
1965 if (!(lcd_dma
.rotate
|| lcd_dma
.mirror
||
1966 lcd_dma
.vxres
|| lcd_dma
.xscale
|| lcd_dma
.yscale
))
1969 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
1970 /* Set the double-indexed addressing mode */
1972 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
1974 omap_writew(ei
, OMAP1610_DMA_LCD_SRC_EI_B1
);
1975 omap_writew(fi
>> 16, OMAP1610_DMA_LCD_SRC_FI_B1_U
);
1976 omap_writew(fi
, OMAP1610_DMA_LCD_SRC_FI_B1_L
);
1979 static irqreturn_t
lcd_dma_irq_handler(int irq
, void *dev_id
)
1983 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
1984 if (unlikely(!(w
& (1 << 3)))) {
1985 printk(KERN_WARNING
"Spurious LCD DMA IRQ\n");
1990 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
1992 if (lcd_dma
.callback
!= NULL
)
1993 lcd_dma
.callback(w
, lcd_dma
.cb_data
);
1998 int omap_request_lcd_dma(void (* callback
)(u16 status
, void *data
),
2001 spin_lock_irq(&lcd_dma
.lock
);
2002 if (lcd_dma
.reserved
) {
2003 spin_unlock_irq(&lcd_dma
.lock
);
2004 printk(KERN_ERR
"LCD DMA channel already reserved\n");
2008 lcd_dma
.reserved
= 1;
2009 spin_unlock_irq(&lcd_dma
.lock
);
2010 lcd_dma
.callback
= callback
;
2011 lcd_dma
.cb_data
= data
;
2013 lcd_dma
.single_transfer
= 0;
2019 lcd_dma
.ext_ctrl
= 0;
2020 lcd_dma
.src_port
= 0;
2025 void omap_free_lcd_dma(void)
2027 spin_lock(&lcd_dma
.lock
);
2028 if (!lcd_dma
.reserved
) {
2029 spin_unlock(&lcd_dma
.lock
);
2030 printk(KERN_ERR
"LCD DMA is not reserved\n");
2034 if (!enable_1510_mode
)
2035 omap_writew(omap_readw(OMAP1610_DMA_LCD_CCR
) & ~1,
2036 OMAP1610_DMA_LCD_CCR
);
2037 lcd_dma
.reserved
= 0;
2038 spin_unlock(&lcd_dma
.lock
);
2041 void omap_enable_lcd_dma(void)
2045 /* Set the Enable bit only if an external controller is
2046 * connected. Otherwise the OMAP internal controller will
2047 * start the transfer when it gets enabled.
2049 if (enable_1510_mode
|| !lcd_dma
.ext_ctrl
)
2052 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
2054 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
2058 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
2060 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
2063 void omap_setup_lcd_dma(void)
2065 BUG_ON(lcd_dma
.active
);
2066 if (!enable_1510_mode
) {
2067 /* Set some reasonable defaults */
2068 omap_writew(0x5440, OMAP1610_DMA_LCD_CCR
);
2069 omap_writew(0x9102, OMAP1610_DMA_LCD_CSDP
);
2070 omap_writew(0x0004, OMAP1610_DMA_LCD_LCH_CTRL
);
2073 if (!enable_1510_mode
) {
2076 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
2077 /* If DMA was already active set the end_prog bit to have
2078 * the programmed register set loaded into the active
2081 w
|= 1 << 11; /* End_prog */
2082 if (!lcd_dma
.single_transfer
)
2083 w
|= (3 << 8); /* Auto_init, repeat */
2084 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
2088 void omap_stop_lcd_dma(void)
2093 if (enable_1510_mode
|| !lcd_dma
.ext_ctrl
)
2096 w
= omap_readw(OMAP1610_DMA_LCD_CCR
);
2098 omap_writew(w
, OMAP1610_DMA_LCD_CCR
);
2100 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
2102 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
2105 /*----------------------------------------------------------------------------*/
2107 static int __init
omap_init_dma(void)
2111 if (cpu_is_omap15xx()) {
2112 printk(KERN_INFO
"DMA support for OMAP15xx initialized\n");
2114 enable_1510_mode
= 1;
2115 } else if (cpu_is_omap16xx() || cpu_is_omap730()) {
2116 printk(KERN_INFO
"OMAP DMA hardware version %d\n",
2117 omap_readw(OMAP_DMA_HW_ID
));
2118 printk(KERN_INFO
"DMA capabilities: %08x:%08x:%04x:%04x:%04x\n",
2119 (omap_readw(OMAP_DMA_CAPS_0_U
) << 16) |
2120 omap_readw(OMAP_DMA_CAPS_0_L
),
2121 (omap_readw(OMAP_DMA_CAPS_1_U
) << 16) |
2122 omap_readw(OMAP_DMA_CAPS_1_L
),
2123 omap_readw(OMAP_DMA_CAPS_2
), omap_readw(OMAP_DMA_CAPS_3
),
2124 omap_readw(OMAP_DMA_CAPS_4
));
2125 if (!enable_1510_mode
) {
2128 /* Disable OMAP 3.0/3.1 compatibility mode. */
2129 w
= omap_readw(OMAP_DMA_GSCR
);
2131 omap_writew(w
, OMAP_DMA_GSCR
);
2132 dma_chan_count
= 16;
2135 if (cpu_is_omap16xx()) {
2138 /* this would prevent OMAP sleep */
2139 w
= omap_readw(OMAP1610_DMA_LCD_CTRL
);
2141 omap_writew(w
, OMAP1610_DMA_LCD_CTRL
);
2143 } else if (cpu_class_is_omap2()) {
2144 u8 revision
= omap_readb(OMAP_DMA4_REVISION
);
2145 printk(KERN_INFO
"OMAP DMA hardware revision %d.%d\n",
2146 revision
>> 4, revision
& 0xf);
2147 dma_chan_count
= OMAP_LOGICAL_DMA_CH_COUNT
;
2153 memset(&lcd_dma
, 0, sizeof(lcd_dma
));
2154 spin_lock_init(&lcd_dma
.lock
);
2155 spin_lock_init(&dma_chan_lock
);
2156 memset(&dma_chan
, 0, sizeof(dma_chan
));
2158 for (ch
= 0; ch
< dma_chan_count
; ch
++) {
2160 dma_chan
[ch
].dev_id
= -1;
2161 dma_chan
[ch
].next_lch
= -1;
2163 if (ch
>= 6 && enable_1510_mode
)
2166 if (cpu_class_is_omap1()) {
2167 /* request_irq() doesn't like dev_id (ie. ch) being
2168 * zero, so we have to kludge around this. */
2169 r
= request_irq(omap1_dma_irq
[ch
],
2170 omap1_dma_irq_handler
, 0, "DMA",
2175 printk(KERN_ERR
"unable to request IRQ %d "
2176 "for DMA (error %d)\n",
2177 omap1_dma_irq
[ch
], r
);
2178 for (i
= 0; i
< ch
; i
++)
2179 free_irq(omap1_dma_irq
[i
],
2186 if (cpu_is_omap2430() || cpu_is_omap34xx())
2187 omap_dma_set_global_params(DMA_DEFAULT_ARB_RATE
,
2188 DMA_DEFAULT_FIFO_DEPTH
, 0);
2190 if (cpu_class_is_omap2())
2191 setup_irq(INT_24XX_SDMA_IRQ0
, &omap24xx_dma_irq
);
2193 /* FIXME: Update LCD DMA to work on 24xx */
2194 if (cpu_class_is_omap1()) {
2195 r
= request_irq(INT_DMA_LCD
, lcd_dma_irq_handler
, 0,
2200 printk(KERN_ERR
"unable to request IRQ for LCD DMA "
2202 for (i
= 0; i
< dma_chan_count
; i
++)
2203 free_irq(omap1_dma_irq
[i
], (void *) (i
+ 1));
2211 arch_initcall(omap_init_dma
);
2213 EXPORT_SYMBOL(omap_get_dma_src_pos
);
2214 EXPORT_SYMBOL(omap_get_dma_dst_pos
);
2215 EXPORT_SYMBOL(omap_get_dma_src_addr_counter
);
2216 EXPORT_SYMBOL(omap_clear_dma
);
2217 EXPORT_SYMBOL(omap_set_dma_priority
);
2218 EXPORT_SYMBOL(omap_request_dma
);
2219 EXPORT_SYMBOL(omap_free_dma
);
2220 EXPORT_SYMBOL(omap_start_dma
);
2221 EXPORT_SYMBOL(omap_stop_dma
);
2222 EXPORT_SYMBOL(omap_set_dma_callback
);
2223 EXPORT_SYMBOL(omap_enable_dma_irq
);
2224 EXPORT_SYMBOL(omap_disable_dma_irq
);
2226 EXPORT_SYMBOL(omap_set_dma_transfer_params
);
2227 EXPORT_SYMBOL(omap_set_dma_color_mode
);
2228 EXPORT_SYMBOL(omap_set_dma_write_mode
);
2230 EXPORT_SYMBOL(omap_set_dma_src_params
);
2231 EXPORT_SYMBOL(omap_set_dma_src_index
);
2232 EXPORT_SYMBOL(omap_set_dma_src_data_pack
);
2233 EXPORT_SYMBOL(omap_set_dma_src_burst_mode
);
2235 EXPORT_SYMBOL(omap_set_dma_dest_params
);
2236 EXPORT_SYMBOL(omap_set_dma_dest_index
);
2237 EXPORT_SYMBOL(omap_set_dma_dest_data_pack
);
2238 EXPORT_SYMBOL(omap_set_dma_dest_burst_mode
);
2240 EXPORT_SYMBOL(omap_set_dma_params
);
2242 EXPORT_SYMBOL(omap_dma_link_lch
);
2243 EXPORT_SYMBOL(omap_dma_unlink_lch
);
2245 EXPORT_SYMBOL(omap_request_lcd_dma
);
2246 EXPORT_SYMBOL(omap_free_lcd_dma
);
2247 EXPORT_SYMBOL(omap_enable_lcd_dma
);
2248 EXPORT_SYMBOL(omap_setup_lcd_dma
);
2249 EXPORT_SYMBOL(omap_stop_lcd_dma
);
2250 EXPORT_SYMBOL(omap_set_lcd_dma_b1
);
2251 EXPORT_SYMBOL(omap_set_lcd_dma_single_transfer
);
2252 EXPORT_SYMBOL(omap_set_lcd_dma_ext_controller
);
2253 EXPORT_SYMBOL(omap_set_lcd_dma_b1_rotation
);
2254 EXPORT_SYMBOL(omap_set_lcd_dma_b1_vxres
);
2255 EXPORT_SYMBOL(omap_set_lcd_dma_b1_scale
);
2256 EXPORT_SYMBOL(omap_set_lcd_dma_b1_mirror
);