blob: 1474fcbe9bc53a803cbf70b772ac1224096cceec [file] [log] [blame]
Brian Swetland8a0f6f12008-09-10 14:58:25 -07001/* linux/include/asm-arm/arch-msm/dma.h
Russell Kinga09e64f2008-08-05 16:14:15 +01002 *
3 * Copyright (C) 2007 Google, Inc.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004 * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
Russell Kinga09e64f2008-08-05 16:14:15 +01005 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef __ASM_ARCH_MSM_DMA_H
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#define __ASM_ARCH_MSM_DMA_H
Russell Kinga09e64f2008-08-05 16:14:15 +010019
20#include <linux/list.h>
21#include <mach/msm_iomap.h>
22
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#if defined(CONFIG_ARCH_FSM9XXX)
24#include <mach/dma-fsm9xxx.h>
25#endif
26
Brian Swetland8a0f6f12008-09-10 14:58:25 -070027struct msm_dmov_errdata {
28 uint32_t flush[6];
29};
30
Russell Kinga09e64f2008-08-05 16:14:15 +010031struct msm_dmov_cmd {
32 struct list_head list;
33 unsigned int cmdptr;
Brian Swetland8a0f6f12008-09-10 14:58:25 -070034 void (*complete_func)(struct msm_dmov_cmd *cmd,
35 unsigned int result,
36 struct msm_dmov_errdata *err);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037 void (*exec_func)(struct msm_dmov_cmd *cmd);
38 void *user; /* Pointer for caller's reference */
Russell Kinga09e64f2008-08-05 16:14:15 +010039};
40
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070041struct msm_dmov_pdata {
42 int sd;
43 size_t sd_size;
44};
45
Russell Kinga09e64f2008-08-05 16:14:15 +010046void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047void msm_dmov_enqueue_cmd_ext(unsigned id, struct msm_dmov_cmd *cmd);
Brian Swetland8a0f6f12008-09-10 14:58:25 -070048void msm_dmov_stop_cmd(unsigned id, struct msm_dmov_cmd *cmd, int graceful);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049void msm_dmov_flush(unsigned int id);
Jeff Ohlsteindc39f972011-09-02 13:55:16 -070050int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr);
Russell Kinga09e64f2008-08-05 16:14:15 +010051
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#define DMOV_CRCIS_PER_CONF 10
Russell Kinga09e64f2008-08-05 16:14:15 +010053
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070054#define DMOV_ADDR(off, ch) ((off) + ((ch) << 2))
Russell Kinga09e64f2008-08-05 16:14:15 +010055
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070056#define DMOV_CMD_PTR(ch) DMOV_ADDR(0x000, ch)
Russell Kinga09e64f2008-08-05 16:14:15 +010057#define DMOV_CMD_LIST (0 << 29) /* does not work */
58#define DMOV_CMD_PTR_LIST (1 << 29) /* works */
59#define DMOV_CMD_INPUT_CFG (2 << 29) /* untested */
60#define DMOV_CMD_OUTPUT_CFG (3 << 29) /* untested */
61#define DMOV_CMD_ADDR(addr) ((addr) >> 3)
62
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070063#define DMOV_RSLT(ch) DMOV_ADDR(0x040, ch)
Russell Kinga09e64f2008-08-05 16:14:15 +010064#define DMOV_RSLT_VALID (1 << 31) /* 0 == host has empties result fifo */
65#define DMOV_RSLT_ERROR (1 << 3)
66#define DMOV_RSLT_FLUSH (1 << 2)
67#define DMOV_RSLT_DONE (1 << 1) /* top pointer done */
68#define DMOV_RSLT_USER (1 << 0) /* command with FR force result */
69
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070070#define DMOV_FLUSH0(ch) DMOV_ADDR(0x080, ch)
71#define DMOV_FLUSH1(ch) DMOV_ADDR(0x0C0, ch)
72#define DMOV_FLUSH2(ch) DMOV_ADDR(0x100, ch)
73#define DMOV_FLUSH3(ch) DMOV_ADDR(0x140, ch)
74#define DMOV_FLUSH4(ch) DMOV_ADDR(0x180, ch)
75#define DMOV_FLUSH5(ch) DMOV_ADDR(0x1C0, ch)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076#define DMOV_FLUSH_TYPE (1 << 31)
Russell Kinga09e64f2008-08-05 16:14:15 +010077
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070078#define DMOV_STATUS(ch) DMOV_ADDR(0x200, ch)
Russell Kinga09e64f2008-08-05 16:14:15 +010079#define DMOV_STATUS_RSLT_COUNT(n) (((n) >> 29))
80#define DMOV_STATUS_CMD_COUNT(n) (((n) >> 27) & 3)
81#define DMOV_STATUS_RSLT_VALID (1 << 1)
82#define DMOV_STATUS_CMD_PTR_RDY (1 << 0)
83
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070084#define DMOV_CONF(ch) DMOV_ADDR(0x240, ch)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085#define DMOV_CONF_SD(sd) (((sd & 4) << 11) | ((sd & 3) << 4))
86#define DMOV_CONF_IRQ_EN (1 << 6)
87#define DMOV_CONF_FORCE_RSLT_EN (1 << 7)
88#define DMOV_CONF_SHADOW_EN (1 << 12)
89#define DMOV_CONF_MPU_DISABLE (1 << 11)
90#define DMOV_CONF_PRIORITY(n) (n << 0)
91
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070092#define DMOV_DBG_ERR(ci) DMOV_ADDR(0x280, ci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070094#define DMOV_RSLT_CONF(ch) DMOV_ADDR(0x300, ch)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#define DMOV_RSLT_CONF_FORCE_TOP_PTR_RSLT (1 << 2)
96#define DMOV_RSLT_CONF_FORCE_FLUSH_RSLT (1 << 1)
97#define DMOV_RSLT_CONF_IRQ_EN (1 << 0)
98
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070099#define DMOV_ISR DMOV_ADDR(0x380, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700101#define DMOV_CI_CONF(ci) DMOV_ADDR(0x390, ci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102#define DMOV_CI_CONF_RANGE_END(n) ((n) << 24)
103#define DMOV_CI_CONF_RANGE_START(n) ((n) << 16)
104#define DMOV_CI_CONF_MAX_BURST(n) ((n) << 0)
105
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700106#define DMOV_CI_DBG_ERR(ci) DMOV_ADDR(0x3B0, ci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700108#define DMOV_CRCI_CONF0 DMOV_ADDR(0x3D0, 0)
109#define DMOV_CRCI_CONF1 DMOV_ADDR(0x3D4, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110#define DMOV_CRCI_CONF0_SD(crci, sd) (sd << (crci*3))
111#define DMOV_CRCI_CONF1_SD(crci, sd) (sd << ((crci-DMOV_CRCIS_PER_CONF)*3))
112
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700113#define DMOV_CRCI_CTL(crci) DMOV_ADDR(0x400, crci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#define DMOV_CRCI_CTL_BLK_SZ(n) ((n) << 0)
115#define DMOV_CRCI_CTL_RST (1 << 17)
116#define DMOV_CRCI_MUX (1 << 18)
Russell Kinga09e64f2008-08-05 16:14:15 +0100117
118/* channel assignments */
119
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700120/*
121 * Format of CRCI numbers: crci number + (muxsel << 4)
122 */
123
124#if defined(CONFIG_ARCH_MSM8X60)
125#define DMOV_GP_CHAN 15
126
127#define DMOV_NAND_CHAN 17
128#define DMOV_NAND_CHAN_MODEM 26
129#define DMOV_NAND_CHAN_Q6 27
130#define DMOV_NAND_CRCI_CMD 15
131#define DMOV_NAND_CRCI_DATA 3
132
133#define DMOV_CE_IN_CHAN 2
134#define DMOV_CE_IN_CRCI 4
135
136#define DMOV_CE_OUT_CHAN 3
137#define DMOV_CE_OUT_CRCI 5
138
139#define DMOV_CE_HASH_CRCI 15
140
141#define DMOV_SDC1_CHAN 18
142#define DMOV_SDC1_CRCI 1
143
144#define DMOV_SDC2_CHAN 19
145#define DMOV_SDC2_CRCI 4
146
147#define DMOV_SDC3_CHAN 20
148#define DMOV_SDC3_CRCI 2
149
150#define DMOV_SDC4_CHAN 21
151#define DMOV_SDC4_CRCI 5
152
153#define DMOV_SDC5_CHAN 21
154#define DMOV_SDC5_CRCI 14
155
156#define DMOV_TSIF_CHAN 4
157#define DMOV_TSIF_CRCI 6
158
159#define DMOV_HSUART1_TX_CHAN 22
160#define DMOV_HSUART1_TX_CRCI 8
161
162#define DMOV_HSUART1_RX_CHAN 23
163#define DMOV_HSUART1_RX_CRCI 9
164
165#define DMOV_HSUART2_TX_CHAN 8
166#define DMOV_HSUART2_TX_CRCI 13
167
168#define DMOV_HSUART2_RX_CHAN 8
169#define DMOV_HSUART2_RX_CRCI 14
170
171#elif defined(CONFIG_ARCH_MSM8960)
Jeff Ohlstein66987302011-08-26 11:59:40 -0700172#define DMOV_GP_CHAN 9
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700173
174#define DMOV_CE_IN_CHAN 0
175#define DMOV_CE_IN_CRCI 2
176
177#define DMOV_CE_OUT_CHAN 1
178#define DMOV_CE_OUT_CRCI 3
179
Mayank Rana9f51f582011-08-04 18:35:59 +0530180#define DMOV_HSUART_GSBI6_TX_CHAN 7
181#define DMOV_HSUART_GSBI6_TX_CRCI 6
182
183#define DMOV_HSUART_GSBI6_RX_CHAN 8
184#define DMOV_HSUART_GSBI6_RX_CRCI 11
185
Jeff Ohlsteind19bf442011-09-09 12:48:18 -0700186#elif defined(CONFIG_ARCH_MSM9615)
187
188#define DMOV_GP_CHAN 4
189
190#define DMOV_CE_IN_CHAN 0
191#define DMOV_CE_IN_CRCI 12
192
193#define DMOV_CE_OUT_CHAN 1
194#define DMOV_CE_OUT_CRCI 13
195
196#define DMOV_NAND_CHAN 3
197#define DMOV_NAND_CRCI_CMD 15
198#define DMOV_NAND_CRCI_DATA 3
199
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700200#elif defined(CONFIG_ARCH_FSM9XXX)
201/* defined in dma-fsm9xxx.h */
202
203#else
204#define DMOV_GP_CHAN 4
205
206#define DMOV_CE_IN_CHAN 5
207#define DMOV_CE_IN_CRCI 1
208
209#define DMOV_CE_OUT_CHAN 6
210#define DMOV_CE_OUT_CRCI 2
211
212#define DMOV_CE_HASH_CRCI 3
213
Russell Kinga09e64f2008-08-05 16:14:15 +0100214#define DMOV_NAND_CHAN 7
215#define DMOV_NAND_CRCI_CMD 5
216#define DMOV_NAND_CRCI_DATA 4
217
218#define DMOV_SDC1_CHAN 8
219#define DMOV_SDC1_CRCI 6
220
221#define DMOV_SDC2_CHAN 8
222#define DMOV_SDC2_CRCI 7
223
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700224#define DMOV_SDC3_CHAN 8
225#define DMOV_SDC3_CRCI 12
226
227#define DMOV_SDC4_CHAN 8
228#define DMOV_SDC4_CRCI 13
229
Russell Kinga09e64f2008-08-05 16:14:15 +0100230#define DMOV_TSIF_CHAN 10
231#define DMOV_TSIF_CRCI 10
232
233#define DMOV_USB_CHAN 11
234
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700235#define DMOV_HSUART1_TX_CHAN 4
236#define DMOV_HSUART1_TX_CRCI 8
237
238#define DMOV_HSUART1_RX_CHAN 9
239#define DMOV_HSUART1_RX_CRCI 9
240
241#define DMOV_HSUART2_TX_CHAN 4
242#define DMOV_HSUART2_TX_CRCI 14
243
244#define DMOV_HSUART2_RX_CHAN 11
245#define DMOV_HSUART2_RX_CRCI 15
246#endif
247
248
Russell Kinga09e64f2008-08-05 16:14:15 +0100249/* no client rate control ifc (eg, ram) */
250#define DMOV_NONE_CRCI 0
251
252
253/* If the CMD_PTR register has CMD_PTR_LIST selected, the data mover
254 * is going to walk a list of 32bit pointers as described below. Each
255 * pointer points to a *array* of dmov_s, etc structs. The last pointer
256 * in the list is marked with CMD_PTR_LP. The last struct in each array
257 * is marked with CMD_LC (see below).
258 */
259#define CMD_PTR_ADDR(addr) ((addr) >> 3)
260#define CMD_PTR_LP (1 << 31) /* last pointer */
261#define CMD_PTR_PT (3 << 29) /* ? */
262
263/* Single Item Mode */
264typedef struct {
265 unsigned cmd;
266 unsigned src;
267 unsigned dst;
268 unsigned len;
269} dmov_s;
270
271/* Scatter/Gather Mode */
272typedef struct {
273 unsigned cmd;
274 unsigned src_dscr;
275 unsigned dst_dscr;
276 unsigned _reserved;
277} dmov_sg;
278
Brian Swetland8a0f6f12008-09-10 14:58:25 -0700279/* Box mode */
280typedef struct {
281 uint32_t cmd;
282 uint32_t src_row_addr;
283 uint32_t dst_row_addr;
284 uint32_t src_dst_len;
285 uint32_t num_rows;
286 uint32_t row_offset;
287} dmov_box;
288
Russell Kinga09e64f2008-08-05 16:14:15 +0100289/* bits for the cmd field of the above structures */
290
291#define CMD_LC (1 << 31) /* last command */
292#define CMD_FR (1 << 22) /* force result -- does not work? */
293#define CMD_OCU (1 << 21) /* other channel unblock */
294#define CMD_OCB (1 << 20) /* other channel block */
295#define CMD_TCB (1 << 19) /* ? */
296#define CMD_DAH (1 << 18) /* destination address hold -- does not work?*/
297#define CMD_SAH (1 << 17) /* source address hold -- does not work? */
298
299#define CMD_MODE_SINGLE (0 << 0) /* dmov_s structure used */
300#define CMD_MODE_SG (1 << 0) /* untested */
301#define CMD_MODE_IND_SG (2 << 0) /* untested */
302#define CMD_MODE_BOX (3 << 0) /* untested */
303
304#define CMD_DST_SWAP_BYTES (1 << 14) /* exchange each byte n with byte n+1 */
305#define CMD_DST_SWAP_SHORTS (1 << 15) /* exchange each short n with short n+1 */
306#define CMD_DST_SWAP_WORDS (1 << 16) /* exchange each word n with word n+1 */
307
308#define CMD_SRC_SWAP_BYTES (1 << 11) /* exchange each byte n with byte n+1 */
309#define CMD_SRC_SWAP_SHORTS (1 << 12) /* exchange each short n with short n+1 */
310#define CMD_SRC_SWAP_WORDS (1 << 13) /* exchange each word n with word n+1 */
311
312#define CMD_DST_CRCI(n) (((n) & 15) << 7)
313#define CMD_SRC_CRCI(n) (((n) & 15) << 3)
314
315#endif