blob: 0f27f883084dd5341a4bb2692a698689accdc870 [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.
Duy Truong790f06d2013-02-13 16:38:12 -08004 * Copyright (c) 2008-2012, The Linux Foundation. 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);
Jeff Ohlsteina530a7b2012-06-28 19:42:03 -070038 struct work_struct work;
39 unsigned id; /* For internal use */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040 void *user; /* Pointer for caller's reference */
Jeff Ohlsteina530a7b2012-06-28 19:42:03 -070041 u8 toflush;
Russell Kinga09e64f2008-08-05 16:14:15 +010042};
43
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070044struct msm_dmov_pdata {
45 int sd;
46 size_t sd_size;
47};
48
Russell Kinga09e64f2008-08-05 16:14:15 +010049void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050void msm_dmov_enqueue_cmd_ext(unsigned id, struct msm_dmov_cmd *cmd);
Jeff Ohlstein6bf7b3a2012-04-27 12:27:53 -070051void msm_dmov_flush(unsigned int id, int graceful);
Jeff Ohlsteindc39f972011-09-02 13:55:16 -070052int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr);
Russell Kinga09e64f2008-08-05 16:14:15 +010053
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054#define DMOV_CRCIS_PER_CONF 10
Russell Kinga09e64f2008-08-05 16:14:15 +010055
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070056#define DMOV_ADDR(off, ch) ((off) + ((ch) << 2))
Russell Kinga09e64f2008-08-05 16:14:15 +010057
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070058#define DMOV_CMD_PTR(ch) DMOV_ADDR(0x000, ch)
Russell Kinga09e64f2008-08-05 16:14:15 +010059#define DMOV_CMD_LIST (0 << 29) /* does not work */
60#define DMOV_CMD_PTR_LIST (1 << 29) /* works */
61#define DMOV_CMD_INPUT_CFG (2 << 29) /* untested */
62#define DMOV_CMD_OUTPUT_CFG (3 << 29) /* untested */
63#define DMOV_CMD_ADDR(addr) ((addr) >> 3)
64
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070065#define DMOV_RSLT(ch) DMOV_ADDR(0x040, ch)
Russell Kinga09e64f2008-08-05 16:14:15 +010066#define DMOV_RSLT_VALID (1 << 31) /* 0 == host has empties result fifo */
67#define DMOV_RSLT_ERROR (1 << 3)
68#define DMOV_RSLT_FLUSH (1 << 2)
69#define DMOV_RSLT_DONE (1 << 1) /* top pointer done */
70#define DMOV_RSLT_USER (1 << 0) /* command with FR force result */
71
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070072#define DMOV_FLUSH0(ch) DMOV_ADDR(0x080, ch)
73#define DMOV_FLUSH1(ch) DMOV_ADDR(0x0C0, ch)
74#define DMOV_FLUSH2(ch) DMOV_ADDR(0x100, ch)
75#define DMOV_FLUSH3(ch) DMOV_ADDR(0x140, ch)
76#define DMOV_FLUSH4(ch) DMOV_ADDR(0x180, ch)
77#define DMOV_FLUSH5(ch) DMOV_ADDR(0x1C0, ch)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078#define DMOV_FLUSH_TYPE (1 << 31)
Russell Kinga09e64f2008-08-05 16:14:15 +010079
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070080#define DMOV_STATUS(ch) DMOV_ADDR(0x200, ch)
Russell Kinga09e64f2008-08-05 16:14:15 +010081#define DMOV_STATUS_RSLT_COUNT(n) (((n) >> 29))
82#define DMOV_STATUS_CMD_COUNT(n) (((n) >> 27) & 3)
83#define DMOV_STATUS_RSLT_VALID (1 << 1)
84#define DMOV_STATUS_CMD_PTR_RDY (1 << 0)
85
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070086#define DMOV_CONF(ch) DMOV_ADDR(0x240, ch)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#define DMOV_CONF_SD(sd) (((sd & 4) << 11) | ((sd & 3) << 4))
88#define DMOV_CONF_IRQ_EN (1 << 6)
89#define DMOV_CONF_FORCE_RSLT_EN (1 << 7)
90#define DMOV_CONF_SHADOW_EN (1 << 12)
91#define DMOV_CONF_MPU_DISABLE (1 << 11)
92#define DMOV_CONF_PRIORITY(n) (n << 0)
93
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070094#define DMOV_DBG_ERR(ci) DMOV_ADDR(0x280, ci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070096#define DMOV_RSLT_CONF(ch) DMOV_ADDR(0x300, ch)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097#define DMOV_RSLT_CONF_FORCE_TOP_PTR_RSLT (1 << 2)
98#define DMOV_RSLT_CONF_FORCE_FLUSH_RSLT (1 << 1)
99#define DMOV_RSLT_CONF_IRQ_EN (1 << 0)
100
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700101#define DMOV_ISR DMOV_ADDR(0x380, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700103#define DMOV_CI_CONF(ci) DMOV_ADDR(0x390, ci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104#define DMOV_CI_CONF_RANGE_END(n) ((n) << 24)
105#define DMOV_CI_CONF_RANGE_START(n) ((n) << 16)
106#define DMOV_CI_CONF_MAX_BURST(n) ((n) << 0)
107
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700108#define DMOV_CI_DBG_ERR(ci) DMOV_ADDR(0x3B0, ci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700110#define DMOV_CRCI_CONF0 DMOV_ADDR(0x3D0, 0)
111#define DMOV_CRCI_CONF1 DMOV_ADDR(0x3D4, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112#define DMOV_CRCI_CONF0_SD(crci, sd) (sd << (crci*3))
113#define DMOV_CRCI_CONF1_SD(crci, sd) (sd << ((crci-DMOV_CRCIS_PER_CONF)*3))
114
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -0700115#define DMOV_CRCI_CTL(crci) DMOV_ADDR(0x400, crci)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116#define DMOV_CRCI_CTL_BLK_SZ(n) ((n) << 0)
117#define DMOV_CRCI_CTL_RST (1 << 17)
118#define DMOV_CRCI_MUX (1 << 18)
Russell Kinga09e64f2008-08-05 16:14:15 +0100119
120/* channel assignments */
121
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700122/*
123 * Format of CRCI numbers: crci number + (muxsel << 4)
124 */
125
126#if defined(CONFIG_ARCH_MSM8X60)
127#define DMOV_GP_CHAN 15
128
129#define DMOV_NAND_CHAN 17
130#define DMOV_NAND_CHAN_MODEM 26
131#define DMOV_NAND_CHAN_Q6 27
132#define DMOV_NAND_CRCI_CMD 15
133#define DMOV_NAND_CRCI_DATA 3
134
135#define DMOV_CE_IN_CHAN 2
136#define DMOV_CE_IN_CRCI 4
137
138#define DMOV_CE_OUT_CHAN 3
139#define DMOV_CE_OUT_CRCI 5
140
141#define DMOV_CE_HASH_CRCI 15
142
143#define DMOV_SDC1_CHAN 18
144#define DMOV_SDC1_CRCI 1
145
146#define DMOV_SDC2_CHAN 19
147#define DMOV_SDC2_CRCI 4
148
149#define DMOV_SDC3_CHAN 20
150#define DMOV_SDC3_CRCI 2
151
152#define DMOV_SDC4_CHAN 21
153#define DMOV_SDC4_CRCI 5
154
155#define DMOV_SDC5_CHAN 21
156#define DMOV_SDC5_CRCI 14
157
158#define DMOV_TSIF_CHAN 4
159#define DMOV_TSIF_CRCI 6
160
161#define DMOV_HSUART1_TX_CHAN 22
162#define DMOV_HSUART1_TX_CRCI 8
163
164#define DMOV_HSUART1_RX_CHAN 23
165#define DMOV_HSUART1_RX_CRCI 9
166
167#define DMOV_HSUART2_TX_CHAN 8
168#define DMOV_HSUART2_TX_CRCI 13
169
170#define DMOV_HSUART2_RX_CHAN 8
171#define DMOV_HSUART2_RX_CRCI 14
172
173#elif defined(CONFIG_ARCH_MSM8960)
Jeff Ohlstein66987302011-08-26 11:59:40 -0700174#define DMOV_GP_CHAN 9
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700175
176#define DMOV_CE_IN_CHAN 0
177#define DMOV_CE_IN_CRCI 2
178
179#define DMOV_CE_OUT_CHAN 1
180#define DMOV_CE_OUT_CRCI 3
181
Joel Nidera1261942011-09-12 16:30:09 +0300182#define DMOV_TSIF_CHAN 2
183#define DMOV_TSIF_CRCI 11
184
Mayank Rana9f51f582011-08-04 18:35:59 +0530185#define DMOV_HSUART_GSBI6_TX_CHAN 7
186#define DMOV_HSUART_GSBI6_TX_CRCI 6
187
188#define DMOV_HSUART_GSBI6_RX_CHAN 8
189#define DMOV_HSUART_GSBI6_RX_CRCI 11
190
Mayank Rana1f02d952012-07-04 19:11:20 +0530191#define DMOV_HSUART_GSBI8_TX_CHAN 7
192#define DMOV_HSUART_GSBI8_TX_CRCI 10
193
194#define DMOV_HSUART_GSBI8_RX_CHAN 8
195#define DMOV_HSUART_GSBI8_RX_CRCI 9
196
Mayank Ranae009c922012-03-22 03:02:06 +0530197#define DMOV_HSUART_GSBI9_TX_CHAN 4
198#define DMOV_HSUART_GSBI9_TX_CRCI 13
199
200#define DMOV_HSUART_GSBI9_RX_CHAN 3
201#define DMOV_HSUART_GSBI9_RX_CRCI 12
202
Jeff Ohlsteind19bf442011-09-09 12:48:18 -0700203#elif defined(CONFIG_ARCH_MSM9615)
204
205#define DMOV_GP_CHAN 4
206
207#define DMOV_CE_IN_CHAN 0
208#define DMOV_CE_IN_CRCI 12
209
210#define DMOV_CE_OUT_CHAN 1
211#define DMOV_CE_OUT_CRCI 13
212
213#define DMOV_NAND_CHAN 3
214#define DMOV_NAND_CRCI_CMD 15
215#define DMOV_NAND_CRCI_DATA 3
216
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700217#elif defined(CONFIG_ARCH_FSM9XXX)
218/* defined in dma-fsm9xxx.h */
219
220#else
221#define DMOV_GP_CHAN 4
222
223#define DMOV_CE_IN_CHAN 5
224#define DMOV_CE_IN_CRCI 1
225
226#define DMOV_CE_OUT_CHAN 6
227#define DMOV_CE_OUT_CRCI 2
228
229#define DMOV_CE_HASH_CRCI 3
230
Russell Kinga09e64f2008-08-05 16:14:15 +0100231#define DMOV_NAND_CHAN 7
232#define DMOV_NAND_CRCI_CMD 5
233#define DMOV_NAND_CRCI_DATA 4
234
235#define DMOV_SDC1_CHAN 8
236#define DMOV_SDC1_CRCI 6
237
238#define DMOV_SDC2_CHAN 8
239#define DMOV_SDC2_CRCI 7
240
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700241#define DMOV_SDC3_CHAN 8
242#define DMOV_SDC3_CRCI 12
243
244#define DMOV_SDC4_CHAN 8
245#define DMOV_SDC4_CRCI 13
246
Russell Kinga09e64f2008-08-05 16:14:15 +0100247#define DMOV_TSIF_CHAN 10
248#define DMOV_TSIF_CRCI 10
249
250#define DMOV_USB_CHAN 11
251
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700252#define DMOV_HSUART1_TX_CHAN 4
253#define DMOV_HSUART1_TX_CRCI 8
254
255#define DMOV_HSUART1_RX_CHAN 9
256#define DMOV_HSUART1_RX_CRCI 9
257
258#define DMOV_HSUART2_TX_CHAN 4
259#define DMOV_HSUART2_TX_CRCI 14
260
261#define DMOV_HSUART2_RX_CHAN 11
262#define DMOV_HSUART2_RX_CRCI 15
263#endif
264
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700265/* channels for APQ8064 */
Jeff Ohlstein1d1172b2012-04-09 19:49:04 -0700266#define DMOV8064_CE_IN_CHAN 0
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700267#define DMOV8064_CE_IN_CRCI 14
268
Jeff Ohlstein1d1172b2012-04-09 19:49:04 -0700269#define DMOV8064_CE_OUT_CHAN 1
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700270#define DMOV8064_CE_OUT_CRCI 15
271
Liron Kuch43e8f9b2012-11-12 19:43:19 +0200272#define DMOV8064_TSIF_CHAN 4
Joel Nider67deb3c2012-06-28 16:08:46 +0300273#define DMOV8064_TSIF_CRCI 1
274
Mayank Rana262e9032012-05-10 15:14:00 -0700275/* channels for MPQ8064 */
276#define DMOV_MPQ8064_HSUART_GSBI6_TX_CHAN 7
277#define DMOV_MPQ8064_HSUART_GSBI6_TX_CRCI 6
278
279#define DMOV_MPQ8064_HSUART_GSBI6_RX_CHAN 6
280#define DMOV_MPQ8064_HSUART_GSBI6_RX_CRCI 11
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700281
Russell Kinga09e64f2008-08-05 16:14:15 +0100282/* no client rate control ifc (eg, ram) */
283#define DMOV_NONE_CRCI 0
284
285
286/* If the CMD_PTR register has CMD_PTR_LIST selected, the data mover
287 * is going to walk a list of 32bit pointers as described below. Each
288 * pointer points to a *array* of dmov_s, etc structs. The last pointer
289 * in the list is marked with CMD_PTR_LP. The last struct in each array
290 * is marked with CMD_LC (see below).
291 */
292#define CMD_PTR_ADDR(addr) ((addr) >> 3)
293#define CMD_PTR_LP (1 << 31) /* last pointer */
294#define CMD_PTR_PT (3 << 29) /* ? */
295
296/* Single Item Mode */
297typedef struct {
298 unsigned cmd;
299 unsigned src;
300 unsigned dst;
301 unsigned len;
302} dmov_s;
303
304/* Scatter/Gather Mode */
305typedef struct {
306 unsigned cmd;
307 unsigned src_dscr;
308 unsigned dst_dscr;
309 unsigned _reserved;
310} dmov_sg;
311
Brian Swetland8a0f6f12008-09-10 14:58:25 -0700312/* Box mode */
313typedef struct {
314 uint32_t cmd;
315 uint32_t src_row_addr;
316 uint32_t dst_row_addr;
317 uint32_t src_dst_len;
318 uint32_t num_rows;
319 uint32_t row_offset;
320} dmov_box;
321
Russell Kinga09e64f2008-08-05 16:14:15 +0100322/* bits for the cmd field of the above structures */
323
324#define CMD_LC (1 << 31) /* last command */
325#define CMD_FR (1 << 22) /* force result -- does not work? */
326#define CMD_OCU (1 << 21) /* other channel unblock */
327#define CMD_OCB (1 << 20) /* other channel block */
328#define CMD_TCB (1 << 19) /* ? */
329#define CMD_DAH (1 << 18) /* destination address hold -- does not work?*/
330#define CMD_SAH (1 << 17) /* source address hold -- does not work? */
331
332#define CMD_MODE_SINGLE (0 << 0) /* dmov_s structure used */
333#define CMD_MODE_SG (1 << 0) /* untested */
334#define CMD_MODE_IND_SG (2 << 0) /* untested */
335#define CMD_MODE_BOX (3 << 0) /* untested */
336
337#define CMD_DST_SWAP_BYTES (1 << 14) /* exchange each byte n with byte n+1 */
338#define CMD_DST_SWAP_SHORTS (1 << 15) /* exchange each short n with short n+1 */
339#define CMD_DST_SWAP_WORDS (1 << 16) /* exchange each word n with word n+1 */
340
341#define CMD_SRC_SWAP_BYTES (1 << 11) /* exchange each byte n with byte n+1 */
342#define CMD_SRC_SWAP_SHORTS (1 << 12) /* exchange each short n with short n+1 */
343#define CMD_SRC_SWAP_WORDS (1 << 13) /* exchange each word n with word n+1 */
344
345#define CMD_DST_CRCI(n) (((n) & 15) << 7)
346#define CMD_SRC_CRCI(n) (((n) & 15) << 3)
347
348#endif