[MIPS] BCM1480: Cleanup debug code left behind in the PCI driver.
[linux-2.6/verdex.git] / include / asm-arm / arch-s3c2410 / dma.h
blobb011e14f3bc663d6858fb7afc2811eaf7395c3d5
1 /* linux/include/asm-arm/arch-bast/dma.h
3 * Copyright (C) 2003,2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * Samsung S3C2410X DMA support
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Changelog:
13 * ??-May-2003 BJD Created file
14 * ??-Jun-2003 BJD Added more dma functionality to go with arch
15 * 10-Nov-2004 BJD Added sys_device support
18 #ifndef __ASM_ARCH_DMA_H
19 #define __ASM_ARCH_DMA_H __FILE__
21 #include <linux/config.h>
22 #include <linux/sysdev.h>
23 #include "hardware.h"
27 * This is the maximum DMA address(physical address) that can be DMAd to.
30 #define MAX_DMA_ADDRESS 0x20000000
31 #define MAX_DMA_TRANSFER_SIZE 0x100000 /* Data Unit is half word */
34 /* we have 4 dma channels */
35 #define S3C2410_DMA_CHANNELS (4)
37 /* types */
39 typedef enum {
40 S3C2410_DMA_IDLE,
41 S3C2410_DMA_RUNNING,
42 S3C2410_DMA_PAUSED
43 } s3c2410_dma_state_t;
46 /* s3c2410_dma_loadst_t
48 * This represents the state of the DMA engine, wrt to the loaded / running
49 * transfers. Since we don't have any way of knowing exactly the state of
50 * the DMA transfers, we need to know the state to make decisions on wether
51 * we can
53 * S3C2410_DMA_NONE
55 * There are no buffers loaded (the channel should be inactive)
57 * S3C2410_DMA_1LOADED
59 * There is one buffer loaded, however it has not been confirmed to be
60 * loaded by the DMA engine. This may be because the channel is not
61 * yet running, or the DMA driver decided that it was too costly to
62 * sit and wait for it to happen.
64 * S3C2410_DMA_1RUNNING
66 * The buffer has been confirmed running, and not finisged
68 * S3C2410_DMA_1LOADED_1RUNNING
70 * There is a buffer waiting to be loaded by the DMA engine, and one
71 * currently running.
74 typedef enum {
75 S3C2410_DMALOAD_NONE,
76 S3C2410_DMALOAD_1LOADED,
77 S3C2410_DMALOAD_1RUNNING,
78 S3C2410_DMALOAD_1LOADED_1RUNNING,
79 } s3c2410_dma_loadst_t;
81 typedef enum {
82 S3C2410_RES_OK,
83 S3C2410_RES_ERR,
84 S3C2410_RES_ABORT
85 } s3c2410_dma_buffresult_t;
88 typedef enum s3c2410_dmasrc_e s3c2410_dmasrc_t;
90 enum s3c2410_dmasrc_e {
91 S3C2410_DMASRC_HW, /* source is memory */
92 S3C2410_DMASRC_MEM /* source is hardware */
95 /* enum s3c2410_chan_op_e
97 * operation codes passed to the DMA code by the user, and also used
98 * to inform the current channel owner of any changes to the system state
101 enum s3c2410_chan_op_e {
102 S3C2410_DMAOP_START,
103 S3C2410_DMAOP_STOP,
104 S3C2410_DMAOP_PAUSE,
105 S3C2410_DMAOP_RESUME,
106 S3C2410_DMAOP_FLUSH,
107 S3C2410_DMAOP_TIMEOUT, /* internal signal to handler */
110 typedef enum s3c2410_chan_op_e s3c2410_chan_op_t;
112 /* flags */
114 #define S3C2410_DMAF_SLOW (1<<0) /* slow, so don't worry about
115 * waiting for reloads */
116 #define S3C2410_DMAF_AUTOSTART (1<<1) /* auto-start if buffer queued */
118 /* dma buffer */
120 typedef struct s3c2410_dma_buf_s s3c2410_dma_buf_t;
122 struct s3c2410_dma_client {
123 char *name;
126 typedef struct s3c2410_dma_client s3c2410_dma_client_t;
128 /* s3c2410_dma_buf_s
130 * internally used buffer structure to describe a queued or running
131 * buffer.
134 struct s3c2410_dma_buf_s {
135 s3c2410_dma_buf_t *next;
136 int magic; /* magic */
137 int size; /* buffer size in bytes */
138 dma_addr_t data; /* start of DMA data */
139 dma_addr_t ptr; /* where the DMA got to [1] */
140 void *id; /* client's id */
143 /* [1] is this updated for both recv/send modes? */
145 typedef struct s3c2410_dma_chan_s s3c2410_dma_chan_t;
147 /* s3c2410_dma_cbfn_t
149 * buffer callback routine type
152 typedef void (*s3c2410_dma_cbfn_t)(s3c2410_dma_chan_t *, void *buf, int size,
153 s3c2410_dma_buffresult_t result);
155 typedef int (*s3c2410_dma_opfn_t)(s3c2410_dma_chan_t *,
156 s3c2410_chan_op_t );
158 struct s3c2410_dma_stats_s {
159 unsigned long loads;
160 unsigned long timeout_longest;
161 unsigned long timeout_shortest;
162 unsigned long timeout_avg;
163 unsigned long timeout_failed;
166 typedef struct s3c2410_dma_stats_s s3c2410_dma_stats_t;
168 /* struct s3c2410_dma_chan_s
170 * full state information for each DMA channel
173 struct s3c2410_dma_chan_s {
174 /* channel state flags and information */
175 unsigned char number; /* number of this dma channel */
176 unsigned char in_use; /* channel allocated */
177 unsigned char irq_claimed; /* irq claimed for channel */
178 unsigned char irq_enabled; /* irq enabled for channel */
179 unsigned char xfer_unit; /* size of an transfer */
181 /* channel state */
183 s3c2410_dma_state_t state;
184 s3c2410_dma_loadst_t load_state;
185 s3c2410_dma_client_t *client;
187 /* channel configuration */
188 s3c2410_dmasrc_t source;
189 unsigned long dev_addr;
190 unsigned long load_timeout;
191 unsigned int flags; /* channel flags */
193 /* channel's hardware position and configuration */
194 void __iomem *regs; /* channels registers */
195 void __iomem *addr_reg; /* data address register */
196 unsigned int irq; /* channel irq */
197 unsigned long dcon; /* default value of DCON */
199 /* driver handles */
200 s3c2410_dma_cbfn_t callback_fn; /* buffer done callback */
201 s3c2410_dma_opfn_t op_fn; /* channel operation callback */
203 /* stats gathering */
204 s3c2410_dma_stats_t *stats;
205 s3c2410_dma_stats_t stats_store;
207 /* buffer list and information */
208 s3c2410_dma_buf_t *curr; /* current dma buffer */
209 s3c2410_dma_buf_t *next; /* next buffer to load */
210 s3c2410_dma_buf_t *end; /* end of queue */
212 /* system device */
213 struct sys_device dev;
216 /* the currently allocated channel information */
217 extern s3c2410_dma_chan_t s3c2410_chans[];
219 /* note, we don't really use dma_device_t at the moment */
220 typedef unsigned long dma_device_t;
222 /* functions --------------------------------------------------------------- */
224 /* s3c2410_dma_request
226 * request a dma channel exclusivley
229 extern int s3c2410_dma_request(dmach_t channel,
230 s3c2410_dma_client_t *, void *dev);
233 /* s3c2410_dma_ctrl
235 * change the state of the dma channel
238 extern int s3c2410_dma_ctrl(dmach_t channel, s3c2410_chan_op_t op);
240 /* s3c2410_dma_setflags
242 * set the channel's flags to a given state
245 extern int s3c2410_dma_setflags(dmach_t channel,
246 unsigned int flags);
248 /* s3c2410_dma_free
250 * free the dma channel (will also abort any outstanding operations)
253 extern int s3c2410_dma_free(dmach_t channel, s3c2410_dma_client_t *);
255 /* s3c2410_dma_enqueue
257 * place the given buffer onto the queue of operations for the channel.
258 * The buffer must be allocated from dma coherent memory, or the Dcache/WB
259 * drained before the buffer is given to the DMA system.
262 extern int s3c2410_dma_enqueue(dmach_t channel, void *id,
263 dma_addr_t data, int size);
265 /* s3c2410_dma_config
267 * configure the dma channel
270 extern int s3c2410_dma_config(dmach_t channel, int xferunit, int dcon);
272 /* s3c2410_dma_devconfig
274 * configure the device we're talking to
277 extern int s3c2410_dma_devconfig(int channel, s3c2410_dmasrc_t source,
278 int hwcfg, unsigned long devaddr);
280 /* s3c2410_dma_getposition
282 * get the position that the dma transfer is currently at
285 extern int s3c2410_dma_getposition(dmach_t channel,
286 dma_addr_t *src, dma_addr_t *dest);
288 extern int s3c2410_dma_set_opfn(dmach_t, s3c2410_dma_opfn_t rtn);
289 extern int s3c2410_dma_set_buffdone_fn(dmach_t, s3c2410_dma_cbfn_t rtn);
291 /* DMA Register definitions */
293 #define S3C2410_DMA_DISRC (0x00)
294 #define S3C2410_DMA_DISRCC (0x04)
295 #define S3C2410_DMA_DIDST (0x08)
296 #define S3C2410_DMA_DIDSTC (0x0C)
297 #define S3C2410_DMA_DCON (0x10)
298 #define S3C2410_DMA_DSTAT (0x14)
299 #define S3C2410_DMA_DCSRC (0x18)
300 #define S3C2410_DMA_DCDST (0x1C)
301 #define S3C2410_DMA_DMASKTRIG (0x20)
303 #define S3C2410_DISRCC_INC (1<<0)
304 #define S3C2410_DISRCC_APB (1<<1)
306 #define S3C2410_DMASKTRIG_STOP (1<<2)
307 #define S3C2410_DMASKTRIG_ON (1<<1)
308 #define S3C2410_DMASKTRIG_SWTRIG (1<<0)
310 #define S3C2410_DCON_DEMAND (0<<31)
311 #define S3C2410_DCON_HANDSHAKE (1<<31)
312 #define S3C2410_DCON_SYNC_PCLK (0<<30)
313 #define S3C2410_DCON_SYNC_HCLK (1<<30)
315 #define S3C2410_DCON_INTREQ (1<<29)
317 #define S3C2410_DCON_CH0_XDREQ0 (0<<24)
318 #define S3C2410_DCON_CH0_UART0 (1<<24)
319 #define S3C2410_DCON_CH0_SDI (2<<24)
320 #define S3C2410_DCON_CH0_TIMER (3<<24)
321 #define S3C2410_DCON_CH0_USBEP1 (4<<24)
323 #define S3C2410_DCON_CH1_XDREQ1 (0<<24)
324 #define S3C2410_DCON_CH1_UART1 (1<<24)
325 #define S3C2410_DCON_CH1_I2SSDI (2<<24)
326 #define S3C2410_DCON_CH1_SPI (3<<24)
327 #define S3C2410_DCON_CH1_USBEP2 (4<<24)
329 #define S3C2410_DCON_CH2_I2SSDO (0<<24)
330 #define S3C2410_DCON_CH2_I2SSDI (1<<24)
331 #define S3C2410_DCON_CH2_SDI (2<<24)
332 #define S3C2410_DCON_CH2_TIMER (3<<24)
333 #define S3C2410_DCON_CH2_USBEP3 (4<<24)
335 #define S3C2410_DCON_CH3_UART2 (0<<24)
336 #define S3C2410_DCON_CH3_SDI (1<<24)
337 #define S3C2410_DCON_CH3_SPI (2<<24)
338 #define S3C2410_DCON_CH3_TIMER (3<<24)
339 #define S3C2410_DCON_CH3_USBEP4 (4<<24)
341 #define S3C2410_DCON_SRCSHIFT (24)
342 #define S3C2410_DCON_SRCMASK (7<<24)
344 #define S3C2410_DCON_BYTE (0<<20)
345 #define S3C2410_DCON_HALFWORD (1<<20)
346 #define S3C2410_DCON_WORD (2<<20)
348 #define S3C2410_DCON_AUTORELOAD (0<<22)
349 #define S3C2410_DCON_NORELOAD (1<<22)
350 #define S3C2410_DCON_HWTRIG (1<<23)
352 #ifdef CONFIG_CPU_S3C2440
353 #define S3C2440_DIDSTC_CHKINT (1<<2)
355 #define S3C2440_DCON_CH0_I2SSDO (5<<24)
356 #define S3C2440_DCON_CH0_PCMIN (6<<24)
358 #define S3C2440_DCON_CH1_PCMOUT (5<<24)
359 #define S3C2440_DCON_CH1_SDI (6<<24)
361 #define S3C2440_DCON_CH2_PCMIN (5<<24)
362 #define S3C2440_DCON_CH2_MICIN (6<<24)
364 #define S3C2440_DCON_CH3_MICIN (5<<24)
365 #define S3C2440_DCON_CH3_PCMOUT (6<<24)
366 #endif
368 #endif /* __ASM_ARCH_DMA_H */