sched: make early bootup sched_clock() use safer
[wrt350n-kernel.git] / include / asm-blackfin / dma.h
blob5abaa2cee8dbd7da51d937ab4c77bc85daaa25e9
1 /*
2 * File: include/asm-blackfin/simple_bf533_dma.h
3 * Based on: none - original work
4 * Author: LG Soft India
5 * Copyright (C) 2004-2005 Analog Devices Inc.
6 * Created: Tue Sep 21 2004
7 * Description: This file contains the major Data structures and constants
8 * used for DMA Implementation in BF533
9 * Modified:
11 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
16 * any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; see the file COPYING.
25 * If not, write to the Free Software Foundation,
26 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #ifndef _BLACKFIN_DMA_H_
30 #define _BLACKFIN_DMA_H_
32 #include <asm/io.h>
33 #include <linux/slab.h>
34 #include <asm/irq.h>
35 #include <asm/signal.h>
36 #include <asm/semaphore.h>
38 #include <linux/kernel.h>
39 #include <asm/mach/dma.h>
40 #include <linux/mm.h>
41 #include <linux/interrupt.h>
42 #include <asm/blackfin.h>
44 #define MAX_DMA_ADDRESS PAGE_OFFSET
46 /*****************************************************************************
47 * Generic DMA Declarations
49 ****************************************************************************/
50 enum dma_chan_status {
51 DMA_CHANNEL_FREE,
52 DMA_CHANNEL_REQUESTED,
53 DMA_CHANNEL_ENABLED,
56 /*-------------------------
57 * config reg bits value
58 *-------------------------*/
59 #define DATA_SIZE_8 0
60 #define DATA_SIZE_16 1
61 #define DATA_SIZE_32 2
63 #define DMA_FLOW_STOP 0
64 #define DMA_FLOW_AUTO 1
65 #define DMA_FLOW_ARRAY 4
66 #define DMA_FLOW_SMALL 6
67 #define DMA_FLOW_LARGE 7
69 #define DIMENSION_LINEAR 0
70 #define DIMENSION_2D 1
72 #define DIR_READ 0
73 #define DIR_WRITE 1
75 #define INTR_DISABLE 0
76 #define INTR_ON_BUF 2
77 #define INTR_ON_ROW 3
79 #define DMA_NOSYNC_KEEP_DMA_BUF 0
80 #define DMA_SYNC_RESTART 1
82 struct dmasg {
83 unsigned long next_desc_addr;
84 unsigned long start_addr;
85 unsigned short cfg;
86 unsigned short x_count;
87 short x_modify;
88 unsigned short y_count;
89 short y_modify;
90 } __attribute__((packed));
92 struct dma_register {
93 unsigned long next_desc_ptr; /* DMA Next Descriptor Pointer register */
94 unsigned long start_addr; /* DMA Start address register */
96 unsigned short cfg; /* DMA Configuration register */
97 unsigned short dummy1; /* DMA Configuration register */
99 unsigned long reserved;
101 unsigned short x_count; /* DMA x_count register */
102 unsigned short dummy2;
104 short x_modify; /* DMA x_modify register */
105 unsigned short dummy3;
107 unsigned short y_count; /* DMA y_count register */
108 unsigned short dummy4;
110 short y_modify; /* DMA y_modify register */
111 unsigned short dummy5;
113 unsigned long curr_desc_ptr; /* DMA Current Descriptor Pointer
114 register */
115 unsigned long curr_addr_ptr; /* DMA Current Address Pointer
116 register */
117 unsigned short irq_status; /* DMA irq status register */
118 unsigned short dummy6;
120 unsigned short peripheral_map; /* DMA peripheral map register */
121 unsigned short dummy7;
123 unsigned short curr_x_count; /* DMA Current x-count register */
124 unsigned short dummy8;
126 unsigned long reserved2;
128 unsigned short curr_y_count; /* DMA Current y-count register */
129 unsigned short dummy9;
131 unsigned long reserved3;
135 typedef irqreturn_t(*dma_interrupt_t) (int irq, void *dev_id);
137 struct dma_channel {
138 struct mutex dmalock;
139 char *device_id;
140 enum dma_chan_status chan_status;
141 struct dma_register *regs;
142 struct dmasg *sg; /* large mode descriptor */
143 unsigned int ctrl_num; /* controller number */
144 dma_interrupt_t irq_callback;
145 void *data;
146 unsigned int dma_enable_flag;
147 unsigned int loopback_flag;
150 /*******************************************************************************
151 * DMA API's
152 *******************************************************************************/
153 /* functions to set register mode */
154 void set_dma_start_addr(unsigned int channel, unsigned long addr);
155 void set_dma_next_desc_addr(unsigned int channel, unsigned long addr);
156 void set_dma_curr_desc_addr(unsigned int channel, unsigned long addr);
157 void set_dma_x_count(unsigned int channel, unsigned short x_count);
158 void set_dma_x_modify(unsigned int channel, short x_modify);
159 void set_dma_y_count(unsigned int channel, unsigned short y_count);
160 void set_dma_y_modify(unsigned int channel, short y_modify);
161 void set_dma_config(unsigned int channel, unsigned short config);
162 unsigned short set_bfin_dma_config(char direction, char flow_mode,
163 char intr_mode, char dma_mode, char width,
164 char syncmode);
165 void set_dma_curr_addr(unsigned int channel, unsigned long addr);
167 /* get curr status for polling */
168 unsigned short get_dma_curr_irqstat(unsigned int channel);
169 unsigned short get_dma_curr_xcount(unsigned int channel);
170 unsigned short get_dma_curr_ycount(unsigned int channel);
171 unsigned long get_dma_next_desc_ptr(unsigned int channel);
172 unsigned long get_dma_curr_desc_ptr(unsigned int channel);
173 unsigned long get_dma_curr_addr(unsigned int channel);
175 /* set large DMA mode descriptor */
176 void set_dma_sg(unsigned int channel, struct dmasg *sg, int nr_sg);
178 /* check if current channel is in use */
179 int dma_channel_active(unsigned int channel);
181 /* common functions must be called in any mode */
182 void free_dma(unsigned int channel);
183 int dma_channel_active(unsigned int channel); /* check if a channel is in use */
184 void disable_dma(unsigned int channel);
185 void enable_dma(unsigned int channel);
186 int request_dma(unsigned int channel, char *device_id);
187 int set_dma_callback(unsigned int channel, dma_interrupt_t callback,
188 void *data);
189 void dma_disable_irq(unsigned int channel);
190 void dma_enable_irq(unsigned int channel);
191 void clear_dma_irqstat(unsigned int channel);
192 void *dma_memcpy(void *dest, const void *src, size_t count);
193 void *safe_dma_memcpy(void *dest, const void *src, size_t count);
195 #endif