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;
114 struct mutex dmalock;
115 const char *device_id;
116 enum dma_chan_status chan_status;
117 struct dma_register *regs;
118 struct dmasg *sg; /* large mode descriptor */
119 unsigned int ctrl_num; /* controller number */
121 irq_handler_t irq_callback;
123 unsigned int dma_enable_flag;
124 unsigned int loopback_flag;
126 unsigned short saved_peripheral_map;
131 int blackfin_dma_suspend(void);
132 void blackfin_dma_resume(void);
135 /*******************************************************************************
137 *******************************************************************************/
138 /* functions to set register mode */
139 void set_dma_start_addr(unsigned int channel, unsigned long addr);
140 void set_dma_next_desc_addr(unsigned int channel, unsigned long addr);
141 void set_dma_curr_desc_addr(unsigned int channel, unsigned long addr);
142 void set_dma_x_count(unsigned int channel, unsigned short x_count);
143 void set_dma_x_modify(unsigned int channel, short x_modify);
144 void set_dma_y_count(unsigned int channel, unsigned short y_count);
145 void set_dma_y_modify(unsigned int channel, short y_modify);
146 void set_dma_config(unsigned int channel, unsigned short config);
147 unsigned short set_bfin_dma_config(char direction, char flow_mode,
148 char intr_mode, char dma_mode, char width,
150 void set_dma_curr_addr(unsigned int channel, unsigned long addr);
152 /* get curr status for polling */
153 unsigned short get_dma_curr_irqstat(unsigned int channel);
154 unsigned short get_dma_curr_xcount(unsigned int channel);
155 unsigned short get_dma_curr_ycount(unsigned int channel);
156 unsigned long get_dma_next_desc_ptr(unsigned int channel);
157 unsigned long get_dma_curr_desc_ptr(unsigned int channel);
158 unsigned long get_dma_curr_addr(unsigned int channel);
160 /* set large DMA mode descriptor */
161 void set_dma_sg(unsigned int channel, struct dmasg *sg, int nr_sg);
163 /* check if current channel is in use */
164 int dma_channel_active(unsigned int channel);
166 /* common functions must be called in any mode */
167 void free_dma(unsigned int channel);
168 int dma_channel_active(unsigned int channel); /* check if a channel is in use */
169 void disable_dma(unsigned int channel);
170 void enable_dma(unsigned int channel);
171 int request_dma(unsigned int channel, const char *device_id);
172 int set_dma_callback(unsigned int channel, irq_handler_t callback,
174 void dma_disable_irq(unsigned int channel);
175 void dma_enable_irq(unsigned int channel);
176 void clear_dma_irqstat(unsigned int channel);
177 void *dma_memcpy(void *dest, const void *src, size_t count);
178 void *safe_dma_memcpy(void *dest, const void *src, size_t count);
179 void blackfin_dma_early_init(void);
181 extern int channel2irq(unsigned int channel);
182 extern struct dma_register *dma_io_base_addr[MAX_DMA_CHANNELS];