2 * dma.h - Blackfin DMA defines/structures/etc...
4 * Copyright 2004-2008 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
8 #ifndef _BLACKFIN_DMA_H_
9 #define _BLACKFIN_DMA_H_
12 #include <linux/slab.h>
14 #include <asm/signal.h>
16 #include <linux/kernel.h>
19 #include <linux/interrupt.h>
20 #include <asm/blackfin.h>
22 #define MAX_DMA_ADDRESS PAGE_OFFSET
24 /*****************************************************************************
25 * Generic DMA Declarations
27 ****************************************************************************/
28 enum dma_chan_status
{
30 DMA_CHANNEL_REQUESTED
,
34 /*-------------------------
35 * config reg bits value
36 *-------------------------*/
38 #define DATA_SIZE_16 1
39 #define DATA_SIZE_32 2
41 #define DMA_FLOW_STOP 0
42 #define DMA_FLOW_AUTO 1
43 #define DMA_FLOW_ARRAY 4
44 #define DMA_FLOW_SMALL 6
45 #define DMA_FLOW_LARGE 7
47 #define DIMENSION_LINEAR 0
48 #define DIMENSION_2D 1
53 #define INTR_DISABLE 0
57 #define DMA_NOSYNC_KEEP_DMA_BUF 0
58 #define DMA_SYNC_RESTART 1
61 unsigned long next_desc_addr
;
62 unsigned long start_addr
;
64 unsigned short x_count
;
66 unsigned short y_count
;
68 } __attribute__((packed
));
71 unsigned long next_desc_ptr
; /* DMA Next Descriptor Pointer register */
72 unsigned long start_addr
; /* DMA Start address register */
74 unsigned short cfg
; /* DMA Configuration register */
75 unsigned short dummy1
; /* DMA Configuration register */
77 unsigned long reserved
;
79 unsigned short x_count
; /* DMA x_count register */
80 unsigned short dummy2
;
82 short x_modify
; /* DMA x_modify register */
83 unsigned short dummy3
;
85 unsigned short y_count
; /* DMA y_count register */
86 unsigned short dummy4
;
88 short y_modify
; /* DMA y_modify register */
89 unsigned short dummy5
;
91 unsigned long curr_desc_ptr
; /* DMA Current Descriptor Pointer
93 unsigned long curr_addr_ptr
; /* DMA Current Address Pointer
95 unsigned short irq_status
; /* DMA irq status register */
96 unsigned short dummy6
;
98 unsigned short peripheral_map
; /* DMA peripheral map register */
99 unsigned short dummy7
;
101 unsigned short curr_x_count
; /* DMA Current x-count register */
102 unsigned short dummy8
;
104 unsigned long reserved2
;
106 unsigned short curr_y_count
; /* DMA Current y-count register */
107 unsigned short dummy9
;
109 unsigned long reserved3
;
113 typedef irqreturn_t(*dma_interrupt_t
) (int irq
, void *dev_id
);
116 struct mutex dmalock
;
117 const char *device_id
;
118 enum dma_chan_status chan_status
;
119 struct dma_register
*regs
;
120 struct dmasg
*sg
; /* large mode descriptor */
121 unsigned int ctrl_num
; /* controller number */
123 dma_interrupt_t irq_callback
;
125 unsigned int dma_enable_flag
;
126 unsigned int loopback_flag
;
128 unsigned short saved_peripheral_map
;
133 int blackfin_dma_suspend(void);
134 void blackfin_dma_resume(void);
137 /*******************************************************************************
139 *******************************************************************************/
140 /* functions to set register mode */
141 void set_dma_start_addr(unsigned int channel
, unsigned long addr
);
142 void set_dma_next_desc_addr(unsigned int channel
, unsigned long addr
);
143 void set_dma_curr_desc_addr(unsigned int channel
, unsigned long addr
);
144 void set_dma_x_count(unsigned int channel
, unsigned short x_count
);
145 void set_dma_x_modify(unsigned int channel
, short x_modify
);
146 void set_dma_y_count(unsigned int channel
, unsigned short y_count
);
147 void set_dma_y_modify(unsigned int channel
, short y_modify
);
148 void set_dma_config(unsigned int channel
, unsigned short config
);
149 unsigned short set_bfin_dma_config(char direction
, char flow_mode
,
150 char intr_mode
, char dma_mode
, char width
,
152 void set_dma_curr_addr(unsigned int channel
, unsigned long addr
);
154 /* get curr status for polling */
155 unsigned short get_dma_curr_irqstat(unsigned int channel
);
156 unsigned short get_dma_curr_xcount(unsigned int channel
);
157 unsigned short get_dma_curr_ycount(unsigned int channel
);
158 unsigned long get_dma_next_desc_ptr(unsigned int channel
);
159 unsigned long get_dma_curr_desc_ptr(unsigned int channel
);
160 unsigned long get_dma_curr_addr(unsigned int channel
);
162 /* set large DMA mode descriptor */
163 void set_dma_sg(unsigned int channel
, struct dmasg
*sg
, int nr_sg
);
165 /* check if current channel is in use */
166 int dma_channel_active(unsigned int channel
);
168 /* common functions must be called in any mode */
169 void free_dma(unsigned int channel
);
170 int dma_channel_active(unsigned int channel
); /* check if a channel is in use */
171 void disable_dma(unsigned int channel
);
172 void enable_dma(unsigned int channel
);
173 int request_dma(unsigned int channel
, const char *device_id
);
174 int set_dma_callback(unsigned int channel
, dma_interrupt_t callback
,
176 void dma_disable_irq(unsigned int channel
);
177 void dma_enable_irq(unsigned int channel
);
178 void clear_dma_irqstat(unsigned int channel
);
179 void *dma_memcpy(void *dest
, const void *src
, size_t count
);
180 void *safe_dma_memcpy(void *dest
, const void *src
, size_t count
);
181 void blackfin_dma_early_init(void);
183 extern int channel2irq(unsigned int channel
);
184 extern struct dma_register
*dma_io_base_addr
[MAX_DMA_CHANNELS
];