aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/include/mach/dma.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/include/mach/dma.h')
-rw-r--r--arch/arm/mach-tegra/include/mach/dma.h202
1 files changed, 202 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/include/mach/dma.h b/arch/arm/mach-tegra/include/mach/dma.h
new file mode 100644
index 00000000000..0b0a5d9fd1d
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/dma.h
@@ -0,0 +1,202 @@
1/*
2 * arch/arm/mach-tegra/include/mach/dma.h
3 *
4 * Copyright (c) 2008-2010, NVIDIA Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef __MACH_TEGRA_DMA_H
22#define __MACH_TEGRA_DMA_H
23
24#include <linux/list.h>
25
26#if defined(CONFIG_TEGRA_SYSTEM_DMA)
27
28struct tegra_dma_req;
29struct tegra_dma_channel;
30
31#define TEGRA_DMA_REQ_SEL_CNTR 0
32#define TEGRA_DMA_REQ_SEL_I2S_2 1
33#define TEGRA_DMA_REQ_SEL_APBIF_CH0 TEGRA_DMA_REQ_SEL_I2S_2
34#define TEGRA_DMA_REQ_SEL_I2S_1 2
35#define TEGRA_DMA_REQ_SEL_APBIF_CH1 TEGRA_DMA_REQ_SEL_I2S_1
36#define TEGRA_DMA_REQ_SEL_SPD_I 3
37#define TEGRA_DMA_REQ_SEL_APBIF_CH2 TEGRA_DMA_REQ_SEL_SPD_I
38#define TEGRA_DMA_REQ_SEL_UI_I 4
39#define TEGRA_DMA_REQ_SEL_APBIF_CH3 TEGRA_DMA_REQ_SEL_UI_I
40#define TEGRA_DMA_REQ_SEL_MIPI 5
41#define TEGRA_DMA_REQ_SEL_I2S2_2 6
42#define TEGRA_DMA_REQ_SEL_I2S2_1 7
43#define TEGRA_DMA_REQ_SEL_UARTA 8
44#define TEGRA_DMA_REQ_SEL_UARTB 9
45#define TEGRA_DMA_REQ_SEL_UARTC 10
46#define TEGRA_DMA_REQ_SEL_SPI 11
47#define TEGRA_DMA_REQ_SEL_DTV TEGRA_DMA_REQ_SEL_SPI
48#define TEGRA_DMA_REQ_SEL_AC97 12
49#define TEGRA_DMA_REQ_SEL_ACMODEM 13
50#define TEGRA_DMA_REQ_SEL_SL4B 14
51#define TEGRA_DMA_REQ_SEL_SL2B1 15
52#define TEGRA_DMA_REQ_SEL_SL2B2 16
53#define TEGRA_DMA_REQ_SEL_SL2B3 17
54#define TEGRA_DMA_REQ_SEL_SL2B4 18
55#define TEGRA_DMA_REQ_SEL_UARTD 19
56#define TEGRA_DMA_REQ_SEL_UARTE 20
57#define TEGRA_DMA_REQ_SEL_I2C 21
58#define TEGRA_DMA_REQ_SEL_I2C2 22
59#define TEGRA_DMA_REQ_SEL_I2C3 23
60#define TEGRA_DMA_REQ_SEL_DVC_I2C 24
61#define TEGRA_DMA_REQ_SEL_OWR 25
62#define TEGRA_DMA_REQ_SEL_I2C4 26
63#define TEGRA_DMA_REQ_SEL_SL2B5 27
64#define TEGRA_DMA_REQ_SEL_SL2B6 28
65#define TEGRA_DMA_REQ_SEL_INVALID 31
66
67enum tegra_dma_mode {
68 TEGRA_DMA_SHARED = 1,
69 TEGRA_DMA_MODE_CONTINUOUS = 2,
70 TEGRA_DMA_MODE_CONTINUOUS_DOUBLE = TEGRA_DMA_MODE_CONTINUOUS,
71 TEGRA_DMA_MODE_CONTINUOUS_SINGLE = 4,
72 TEGRA_DMA_MODE_ONESHOT = 8,
73};
74
75/*
76 * tegra_dma_req_status: Dma request status
77 * TEGRA_DMA_REQ_SUCCESS: The request has been successfully completed.
78 * The byte_transferred tells number of bytes transferred.
79 * TEGRA_DMA_REQ_ERROR_ABORTED: The request is aborted by client after
80 * calling tegra_dma_dequeue_req.
81 * The byte_transferred tells number of bytes transferred
82 * which may be more than request size due to buffer
83 * wrap-up in continuous mode.
84 * TEGRA_DMA_REQ_ERROR_STOPPED: Applicable in continuous mode.
85 * The request is stopped forcefully. This may be becasue of
86 * - due to non-available of next request.
87 * - not able to serve current interrupt before next buffer
88 * completed by dma. This can happen if buffer req size is
89 * not enough and it transfer completes before system actually
90 * serve the previous dma interrupts.
91 * The byte_transferred will not be accurate in this case. It will
92 * just give an idea that how much approximately have been
93 * transferred by dma.
94 * TEGRA_DMA_REQ_INFLIGHT: The request is configured in the dma register
95 * for transfer.
96 */
97
98enum tegra_dma_req_status {
99 TEGRA_DMA_REQ_SUCCESS = 0,
100 TEGRA_DMA_REQ_ERROR_ABORTED,
101 TEGRA_DMA_REQ_ERROR_STOPPED,
102 TEGRA_DMA_REQ_INFLIGHT,
103};
104
105enum tegra_dma_req_buff_status {
106 TEGRA_DMA_REQ_BUF_STATUS_EMPTY = 0,
107 TEGRA_DMA_REQ_BUF_STATUS_HALF_FULL,
108 TEGRA_DMA_REQ_BUF_STATUS_FULL,
109};
110
111typedef void (*dma_callback)(struct tegra_dma_req *req);
112
113struct tegra_dma_req {
114 struct list_head node;
115 unsigned int modid;
116 int instance;
117
118 /* Called when the req is complete and from the DMA ISR context.
119 * When this is called the req structure is no longer queued by
120 * the DMA channel.
121 *
122 * State of the DMA depends on the number of req it has. If there are
123 * no DMA requests queued up, then it will STOP the DMA. It there are
124 * more requests in the DMA, then it will queue the next request.
125 */
126 dma_callback complete;
127
128 /* This is a called from the DMA ISR context when the DMA is still in
129 * progress and is actively filling same buffer.
130 *
131 * In case of continuous mode receive, this threshold is 1/2 the buffer
132 * size. In other cases, this will not even be called as there is no
133 * hardware support for it.
134 *
135 * In the case of continuous mode receive, if there is next req already
136 * queued, DMA programs the HW to use that req when this req is
137 * completed. If there is no "next req" queued, then DMA ISR doesn't do
138 * anything before calling this callback.
139 *
140 * This is mainly used by the cases, where the clients has queued
141 * only one req and want to get some sort of DMA threshold
142 * callback to program the next buffer.
143 *
144 */
145 dma_callback threshold;
146
147 /* 1 to copy to memory.
148 * 0 to copy from the memory to device FIFO */
149 int to_memory;
150
151 void *virt_addr;
152
153 unsigned long source_addr;
154 unsigned long dest_addr;
155 unsigned long dest_wrap;
156 unsigned long source_wrap;
157 unsigned long source_bus_width;
158 unsigned long dest_bus_width;
159 unsigned long req_sel;
160 unsigned int size;
161
162 int fixed_burst_size; /* only for dtv */
163
164 /* Updated by the DMA driver on the conpletion of the request. */
165 int bytes_transferred;
166 int status;
167
168 /* DMA completion tracking information */
169 int buffer_status;
170
171 /* Client specific data */
172 void *dev;
173};
174
175int tegra_dma_enqueue_req(struct tegra_dma_channel *ch,
176 struct tegra_dma_req *req);
177int tegra_dma_dequeue_req(struct tegra_dma_channel *ch,
178 struct tegra_dma_req *req);
179void tegra_dma_flush(struct tegra_dma_channel *ch);
180
181bool tegra_dma_is_req_inflight(struct tegra_dma_channel *ch,
182 struct tegra_dma_req *req);
183int tegra_dma_get_transfer_count(struct tegra_dma_channel *ch,
184 struct tegra_dma_req *req);
185bool tegra_dma_is_empty(struct tegra_dma_channel *ch);
186
187struct tegra_dma_channel *tegra_dma_allocate_channel(int mode,
188 const char namefmt[], ...);
189void tegra_dma_free_channel(struct tegra_dma_channel *ch);
190int tegra_dma_cancel(struct tegra_dma_channel *ch);
191
192int __init tegra_dma_init(void);
193
194#else /* !defined(CONFIG_TEGRA_SYSTEM_DMA) */
195static inline int tegra_dma_init(void)
196{
197 return 0;
198}
199
200#endif
201
202#endif