Fix misspellings of "whether" in comments.
[deliverable/linux.git] / arch / arm / mach-s3c24xx / include / mach / dma.h
CommitLineData
a09e64fb 1/* arch/arm/mach-s3c2410/include/mach/dma.h
1da177e4 2 *
ccae941e 3 * Copyright (C) 2003-2006 Simtec Electronics
1da177e4
LT
4 * Ben Dooks <ben@simtec.co.uk>
5 *
44dc9404 6 * Samsung S3C24XX DMA support
1da177e4
LT
7 *
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.
1da177e4
LT
11*/
12
13#ifndef __ASM_ARCH_DMA_H
14#define __ASM_ARCH_DMA_H __FILE__
15
4a858cfc 16#include <linux/device.h>
1da177e4 17
1da177e4
LT
18#define MAX_DMA_TRANSFER_SIZE 0x100000 /* Data Unit is half word */
19
505788cc 20/* We use `virtual` dma channels to hide the fact we have only a limited
25985edc 21 * number of DMA channels, and not of all of them (dependent on the device)
505788cc
BD
22 * can be attached to any DMA source. We therefore let the DMA core handle
23 * the allocation of hardware channels to clients.
24*/
25
26enum dma_ch {
e1267371
HS
27 DMACH_DT_PROP = -1, /* not yet supported, do not use */
28 DMACH_XD0 = 0,
505788cc
BD
29 DMACH_XD1,
30 DMACH_SDI,
31 DMACH_SPI0,
32 DMACH_SPI1,
33 DMACH_UART0,
34 DMACH_UART1,
35 DMACH_UART2,
36 DMACH_TIMER,
37 DMACH_I2S_IN,
38 DMACH_I2S_OUT,
39 DMACH_PCM_IN,
40 DMACH_PCM_OUT,
41 DMACH_MIC_IN,
42 DMACH_USB_EP1,
43 DMACH_USB_EP2,
44 DMACH_USB_EP3,
45 DMACH_USB_EP4,
34348012
BD
46 DMACH_UART0_SRC2, /* s3c2412 second uart sources */
47 DMACH_UART1_SRC2,
48 DMACH_UART2_SRC2,
15e4db7b
BD
49 DMACH_UART3, /* s3c2443 has extra uart */
50 DMACH_UART3_SRC2,
ad6c1d43
HS
51 DMACH_SPI0_TX, /* s3c2443/2416/2450 hsspi0 */
52 DMACH_SPI0_RX, /* s3c2443/2416/2450 hsspi0 */
53 DMACH_SPI1_TX, /* s3c2443/2450 hsspi1 */
54 DMACH_SPI1_RX, /* s3c2443/2450 hsspi1 */
505788cc
BD
55 DMACH_MAX, /* the end entry */
56};
57
344b4c48
BK
58static inline bool samsung_dma_has_circular(void)
59{
60 return false;
61}
62
c4e16625
BK
63static inline bool samsung_dma_is_dmadev(void)
64{
65 return false;
66}
67
68#include <plat/dma.h>
69
505788cc
BD
70#define DMACH_LOW_LEVEL (1<<28) /* use this to specifiy hardware ch no */
71
1da177e4 72/* we have 4 dma channels */
7cfdee9f 73#if !defined(CONFIG_CPU_S3C2443) && !defined(CONFIG_CPU_S3C2416)
97c1b145 74#define S3C_DMA_CHANNELS (4)
15e4db7b 75#else
97c1b145 76#define S3C_DMA_CHANNELS (6)
15e4db7b 77#endif
1da177e4
LT
78
79/* types */
80
f105a7df 81enum s3c2410_dma_state {
1da177e4
LT
82 S3C2410_DMA_IDLE,
83 S3C2410_DMA_RUNNING,
84 S3C2410_DMA_PAUSED
f105a7df 85};
1da177e4 86
f105a7df 87/* enum s3c2410_dma_loadst
1da177e4
LT
88 *
89 * This represents the state of the DMA engine, wrt to the loaded / running
90 * transfers. Since we don't have any way of knowing exactly the state of
48fc7f7e 91 * the DMA transfers, we need to know the state to make decisions on whether
1da177e4
LT
92 * we can
93 *
94 * S3C2410_DMA_NONE
95 *
96 * There are no buffers loaded (the channel should be inactive)
97 *
98 * S3C2410_DMA_1LOADED
99 *
100 * There is one buffer loaded, however it has not been confirmed to be
101 * loaded by the DMA engine. This may be because the channel is not
102 * yet running, or the DMA driver decided that it was too costly to
103 * sit and wait for it to happen.
104 *
105 * S3C2410_DMA_1RUNNING
106 *
107 * The buffer has been confirmed running, and not finisged
108 *
109 * S3C2410_DMA_1LOADED_1RUNNING
110 *
111 * There is a buffer waiting to be loaded by the DMA engine, and one
112 * currently running.
113*/
114
f105a7df 115enum s3c2410_dma_loadst {
1da177e4
LT
116 S3C2410_DMALOAD_NONE,
117 S3C2410_DMALOAD_1LOADED,
118 S3C2410_DMALOAD_1RUNNING,
119 S3C2410_DMALOAD_1LOADED_1RUNNING,
f105a7df 120};
1da177e4 121
1da177e4 122
1da177e4
LT
123/* flags */
124
125#define S3C2410_DMAF_SLOW (1<<0) /* slow, so don't worry about
126 * waiting for reloads */
127#define S3C2410_DMAF_AUTOSTART (1<<1) /* auto-start if buffer queued */
128
e3d80248
BD
129#define S3C2410_DMAF_CIRCULAR (1 << 2) /* no circular dma support */
130
1da177e4
LT
131/* dma buffer */
132
c133c290 133struct s3c2410_dma_buf;
1da177e4 134
c133c290 135/* s3c2410_dma_buf
1da177e4
LT
136 *
137 * internally used buffer structure to describe a queued or running
138 * buffer.
139*/
140
f105a7df 141struct s3c2410_dma_buf {
57bcdafc
BD
142 struct s3c2410_dma_buf *next;
143 int magic; /* magic */
144 int size; /* buffer size in bytes */
145 dma_addr_t data; /* start of DMA data */
146 dma_addr_t ptr; /* where the DMA got to [1] */
147 void *id; /* client's id */
1da177e4
LT
148};
149
150/* [1] is this updated for both recv/send modes? */
151
f105a7df 152struct s3c2410_dma_stats {
57bcdafc
BD
153 unsigned long loads;
154 unsigned long timeout_longest;
155 unsigned long timeout_shortest;
156 unsigned long timeout_avg;
157 unsigned long timeout_failed;
1da177e4
LT
158};
159
505788cc
BD
160struct s3c2410_dma_map;
161
f105a7df 162/* struct s3c2410_dma_chan
1da177e4
LT
163 *
164 * full state information for each DMA channel
165*/
166
f105a7df 167struct s3c2410_dma_chan {
1da177e4 168 /* channel state flags and information */
57bcdafc
BD
169 unsigned char number; /* number of this dma channel */
170 unsigned char in_use; /* channel allocated */
171 unsigned char irq_claimed; /* irq claimed for channel */
172 unsigned char irq_enabled; /* irq enabled for channel */
173 unsigned char xfer_unit; /* size of an transfer */
1da177e4
LT
174
175 /* channel state */
176
57bcdafc
BD
177 enum s3c2410_dma_state state;
178 enum s3c2410_dma_loadst load_state;
179 struct s3c2410_dma_client *client;
1da177e4
LT
180
181 /* channel configuration */
51ddf31d 182 enum dma_data_direction source;
8970ef47 183 enum dma_ch req_ch;
57bcdafc
BD
184 unsigned long dev_addr;
185 unsigned long load_timeout;
186 unsigned int flags; /* channel flags */
1da177e4 187
505788cc
BD
188 struct s3c24xx_dma_map *map; /* channel hw maps */
189
1da177e4 190 /* channel's hardware position and configuration */
57bcdafc
BD
191 void __iomem *regs; /* channels registers */
192 void __iomem *addr_reg; /* data address register */
193 unsigned int irq; /* channel irq */
194 unsigned long dcon; /* default value of DCON */
1da177e4
LT
195
196 /* driver handles */
57bcdafc
BD
197 s3c2410_dma_cbfn_t callback_fn; /* buffer done callback */
198 s3c2410_dma_opfn_t op_fn; /* channel op callback */
1da177e4
LT
199
200 /* stats gathering */
57bcdafc
BD
201 struct s3c2410_dma_stats *stats;
202 struct s3c2410_dma_stats stats_store;
1da177e4
LT
203
204 /* buffer list and information */
57bcdafc
BD
205 struct s3c2410_dma_buf *curr; /* current dma buffer */
206 struct s3c2410_dma_buf *next; /* next buffer to load */
207 struct s3c2410_dma_buf *end; /* end of queue */
1da177e4
LT
208
209 /* system device */
4a858cfc 210 struct device dev;
1da177e4
LT
211};
212
1da177e4
LT
213typedef unsigned long dma_device_t;
214
1da177e4 215#endif /* __ASM_ARCH_DMA_H */
This page took 2.051434 seconds and 5 git commands to generate.