Merge tag 'jfs-3.7' of git://github.com/kleikamp/linux-shaggy
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / ced1401 / ced_ioctl.h
CommitLineData
cd915200
GKH
1/*
2 * IOCTL calls for the CED1401 driver
3 * Copyright (C) 2010 Cambridge Electronic Design Ltd
4 * Author Greg P Smith (greg@ced.co.uk)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
2eae6bdc
AS
16#ifndef __CED_IOCTL_H__
17#define __CED_IOCTL_H__
2eae6bdc 18
cd915200
GKH
19#include <linux/ioctl.h>
20
21/* dma modes, only MODE_CHAR and MODE_LINEAR are used in this driver */
22#define MODE_CHAR 0
23#define MODE_LINEAR 1
2eae6bdc
AS
24
25/****************************************************************************
26** TypeDefs
27*****************************************************************************/
28
cd915200 29typedef unsigned short TBLOCKENTRY; /* index the blk transfer table 0-7 */
2eae6bdc 30
cd915200
GKH
31typedef struct TransferDesc {
32 long long lpvBuff; /* address of transfer area (for 64 or 32 bit) */
33 unsigned int dwLength; /* length of the area */
34 TBLOCKENTRY wAreaNum; /* number of transfer area to set up */
35 short eSize; /* element size - is tohost flag for circular */
2eae6bdc
AS
36} TRANSFERDESC;
37
cd915200 38typedef TRANSFERDESC * LPTRANSFERDESC;
2eae6bdc 39
cd915200
GKH
40typedef struct TransferEvent {
41 unsigned int dwStart; /* offset into the area */
42 unsigned int dwLength; /* length of the region */
43 unsigned short wAreaNum; /* the area number */
44 unsigned short wFlags; /* bit 0 set for toHost */
45 int iSetEvent; /* could be dummy in LINUX */
2eae6bdc
AS
46} TRANSFEREVENT;
47
cd915200
GKH
48#define MAX_TRANSFER_SIZE 0x4000 /* Maximum data bytes per IRP */
49#define MAX_AREA_LENGTH 0x100000 /* Maximum size of transfer area */
50#define MAX_TRANSAREAS 8 /* definitions for dma set up */
2eae6bdc 51
cd915200
GKH
52typedef struct TGetSelfTest {
53 int code; /* self-test error code */
54 int x, y; /* additional information */
2eae6bdc
AS
55} TGET_SELFTEST;
56
cd915200
GKH
57/* Debug block used for several commands. Not all fields are used for all commands. */
58typedef struct TDbgBlock {
59 int iAddr; /* the address in the 1401 */
60 int iRepeats; /* number of repeats */
61 int iWidth; /* width in bytes 1, 2, 4 */
62 int iDefault; /* default value */
63 int iMask; /* mask to apply */
64 int iData; /* data for poke, result for peek */
2eae6bdc
AS
65} TDBGBLOCK;
66
cd915200
GKH
67/* Used to collect information about a circular block from the device driver */
68typedef struct TCircBlock {
69 unsigned int nArea; /* the area to collect information from */
70 unsigned int dwOffset; /* offset into the area to the available block */
71 unsigned int dwSize; /* size of the area */
2eae6bdc
AS
72} TCIRCBLOCK;
73
cd915200
GKH
74/* Used to clollect the 1401 status */
75typedef struct TCSBlock {
76 unsigned int uiState;
77 unsigned int uiError;
2eae6bdc
AS
78} TCSBLOCK;
79
cd915200
GKH
80/*
81 * As seen by the user, an ioctl call looks like: int ioctl(int fd, unsigned
82 * long cmd, char* argp); We will then have all sorts of variants on this that
83 * can be used to pass stuff to our driver. We will generate macros for each
84 * type of call so as to provide some sort of type safety in the calling:
85 */
2eae6bdc
AS
86#define CED_MAGIC_IOC 0xce
87
cd915200
GKH
88/* NBNB: READ and WRITE are from the point of view of the device, not user. */
89typedef struct ced_ioc_string {
90 int nChars;
91 char buffer[256];
2eae6bdc
AS
92} CED_IOC_STRING;
93
cd915200
GKH
94#define IOCTL_CED_SENDSTRING(n) _IOC(_IOC_WRITE, CED_MAGIC_IOC, 2, n)
95
96#define IOCTL_CED_RESET1401 _IO(CED_MAGIC_IOC, 3)
97#define IOCTL_CED_GETCHAR _IO(CED_MAGIC_IOC, 4)
98#define IOCTL_CED_SENDCHAR _IO(CED_MAGIC_IOC, 5)
99#define IOCTL_CED_STAT1401 _IO(CED_MAGIC_IOC, 6)
100#define IOCTL_CED_LINECOUNT _IO(CED_MAGIC_IOC, 7)
101#define IOCTL_CED_GETSTRING(nMax) _IOC(_IOC_READ, CED_MAGIC_IOC, 8, nMax)
102
103#define IOCTL_CED_SETTRANSFER _IOW(CED_MAGIC_IOC, 11, TRANSFERDESC)
104#define IOCTL_CED_UNSETTRANSFER _IO(CED_MAGIC_IOC, 12)
105#define IOCTL_CED_SETEVENT _IOW(CED_MAGIC_IOC, 13, TRANSFEREVENT)
106#define IOCTL_CED_GETOUTBUFSPACE _IO(CED_MAGIC_IOC, 14)
107#define IOCTL_CED_GETBASEADDRESS _IO(CED_MAGIC_IOC, 15)
108#define IOCTL_CED_GETDRIVERREVISION _IO(CED_MAGIC_IOC, 16)
109
110#define IOCTL_CED_GETTRANSFER _IOR(CED_MAGIC_IOC, 17, TGET_TX_BLOCK)
111#define IOCTL_CED_KILLIO1401 _IO(CED_MAGIC_IOC, 18)
112#define IOCTL_CED_BLKTRANSSTATE _IO(CED_MAGIC_IOC, 19)
113
114#define IOCTL_CED_STATEOF1401 _IO(CED_MAGIC_IOC, 23)
115#define IOCTL_CED_GRAB1401 _IO(CED_MAGIC_IOC, 25)
116#define IOCTL_CED_FREE1401 _IO(CED_MAGIC_IOC, 26)
117#define IOCTL_CED_STARTSELFTEST _IO(CED_MAGIC_IOC, 31)
118#define IOCTL_CED_CHECKSELFTEST _IOR(CED_MAGIC_IOC, 32, TGET_SELFTEST)
119#define IOCTL_CED_TYPEOF1401 _IO(CED_MAGIC_IOC, 33)
120#define IOCTL_CED_TRANSFERFLAGS _IO(CED_MAGIC_IOC, 34)
121
122#define IOCTL_CED_DBGPEEK _IOW(CED_MAGIC_IOC, 35, TDBGBLOCK)
123#define IOCTL_CED_DBGPOKE _IOW(CED_MAGIC_IOC, 36, TDBGBLOCK)
124#define IOCTL_CED_DBGRAMPDATA _IOW(CED_MAGIC_IOC, 37, TDBGBLOCK)
125#define IOCTL_CED_DBGRAMPADDR _IOW(CED_MAGIC_IOC, 38, TDBGBLOCK)
126#define IOCTL_CED_DBGGETDATA _IOR(CED_MAGIC_IOC, 39, TDBGBLOCK)
127#define IOCTL_CED_DBGSTOPLOOP _IO(CED_MAGIC_IOC, 40)
128#define IOCTL_CED_FULLRESET _IO(CED_MAGIC_IOC, 41)
129#define IOCTL_CED_SETCIRCULAR _IOW(CED_MAGIC_IOC, 42, TRANSFERDESC)
130#define IOCTL_CED_GETCIRCBLOCK _IOWR(CED_MAGIC_IOC, 43, TCIRCBLOCK)
131#define IOCTL_CED_FREECIRCBLOCK _IOWR(CED_MAGIC_IOC, 44, TCIRCBLOCK)
132#define IOCTL_CED_WAITEVENT _IO(CED_MAGIC_IOC, 45)
133#define IOCTL_CED_TESTEVENT _IO(CED_MAGIC_IOC, 46)
2eae6bdc
AS
134
135#ifndef __KERNEL__
cd915200
GKH
136/*
137 * If nothing said about return value, it is a U14ERR_... error code
138 * (U14ERR_NOERROR for none)
139 */
140inline int CED_SendString(int fh, const char *szText, int n)
141{
142 return ioctl(fh, IOCTL_CED_SENDSTRING(n), szText);
143}
2eae6bdc 144
cd915200
GKH
145inline int CED_Reset1401(int fh)
146{
147 return ioctl(fh, IOCTL_CED_RESET1401);
148}
2eae6bdc 149
cd915200
GKH
150/* Return the singe character or a -ve error code. */
151inline int CED_GetChar(int fh)
152{
153 return ioctl(fh, IOCTL_CED_GETCHAR);
154}
2eae6bdc 155
cd915200
GKH
156/* Return character count in input buffer */
157inline int CED_Stat1401(int fh)
158{
159 return ioctl(fh, IOCTL_CED_STAT1401);
160}
2eae6bdc 161
cd915200
GKH
162inline int CED_SendChar(int fh, char c)
163{
164 return ioctl(fh, IOCTL_CED_SENDCHAR, c);
165}
2eae6bdc 166
cd915200
GKH
167inline int CED_LineCount(int fh)
168{
169 return ioctl(fh, IOCTL_CED_LINECOUNT);
170}
171
172/*
173 * return the count of characters returned. If the string was terminated by CR
174 * or 0, then the 0 is part of the count. Otherwise, we will add a zero if
175 * there is room, but it is not included in the count. The return value is 0
176 * if there was nothing to read.
177 */
178inline int CED_GetString(int fh, char *szText, int nMax)
179{
180 return ioctl(fh, IOCTL_CED_GETSTRING(nMax), szText);
181}
2eae6bdc 182
cd915200
GKH
183/* returns space in the output buffer. */
184inline int CED_GetOutBufSpace(int fh)
185{
186 return ioctl(fh, IOCTL_CED_GETOUTBUFSPACE);
187}
2eae6bdc 188
cd915200
GKH
189/* This always returns -1 as not implemented. */
190inline int CED_GetBaseAddress(int fh)
191{
192 return ioctl(fh, IOCTL_CED_GETBASEADDRESS);
193}
2eae6bdc 194
cd915200
GKH
195/* returns the major revision <<16 | minor revision. */
196inline int CED_GetDriverRevision(int fh)
197{
198 return ioctl(fh, IOCTL_CED_GETDRIVERREVISION);
199}
2eae6bdc 200
cd915200
GKH
201inline int CED_SetTransfer(int fh, TRANSFERDESC *pTD)
202{
203 return ioctl(fh, IOCTL_CED_SETTRANSFER, pTD);
204}
2eae6bdc 205
cd915200
GKH
206inline int CED_UnsetTransfer(int fh, int nArea)
207{
208 return ioctl(fh, IOCTL_CED_UNSETTRANSFER, nArea);
209}
2eae6bdc 210
cd915200
GKH
211inline int CED_SetEvent(int fh, TRANSFEREVENT *pTE)
212{
213 return ioctl(fh, IOCTL_CED_SETEVENT, pTE);
214}
2eae6bdc 215
cd915200
GKH
216inline int CED_GetTransfer(int fh, TGET_TX_BLOCK *pTX)
217{
218 return ioctl(fh, IOCTL_CED_GETTRANSFER, pTX);
219}
2eae6bdc 220
cd915200
GKH
221inline int CED_KillIO1401(int fh)
222{
223 return ioctl(fh, IOCTL_CED_KILLIO1401);
224}
2eae6bdc 225
cd915200
GKH
226/* returns 0 if no active DMA, 1 if active */
227inline int CED_BlkTransState(int fh)
228{
229 return ioctl(fh, IOCTL_CED_BLKTRANSSTATE);
230}
2eae6bdc 231
cd915200
GKH
232inline int CED_StateOf1401(int fh)
233{
234 return ioctl(fh, IOCTL_CED_STATEOF1401);
235}
2eae6bdc 236
cd915200
GKH
237inline int CED_Grab1401(int fh)
238{
239 return ioctl(fh, IOCTL_CED_GRAB1401);
240}
2eae6bdc 241
cd915200
GKH
242inline int CED_Free1401(int fh)
243{
244 return ioctl(fh, IOCTL_CED_FREE1401);
245}
2eae6bdc 246
cd915200
GKH
247inline int CED_StartSelfTest(int fh)
248{
249 return ioctl(fh, IOCTL_CED_STARTSELFTEST);
250}
251
252inline int CED_CheckSelfTest(int fh, TGET_SELFTEST *pGST)
253{
254 return ioctl(fh, IOCTL_CED_CHECKSELFTEST, pGST);
255}
256
257inline int CED_TypeOf1401(int fh)
258{
259 return ioctl(fh, IOCTL_CED_TYPEOF1401);
260}
261
262inline int CED_TransferFlags(int fh)
263{
264 return ioctl(fh, IOCTL_CED_TRANSFERFLAGS);
265}
266
267inline int CED_DbgPeek(int fh, TDBGBLOCK *pDB)
268{
269 return ioctl(fh, IOCTL_CED_DBGPEEK, pDB);
270}
271
272inline int CED_DbgPoke(int fh, TDBGBLOCK *pDB)
273{
274 return ioctl(fh, IOCTL_CED_DBGPOKE, pDB);
275}
276
277inline int CED_DbgRampData(int fh, TDBGBLOCK *pDB)
278{
279 return ioctl(fh, IOCTL_CED_DBGRAMPDATA, pDB);
280}
2eae6bdc 281
cd915200
GKH
282inline int CED_DbgRampAddr(int fh, TDBGBLOCK *pDB)
283{
284 return ioctl(fh, IOCTL_CED_DBGRAMPADDR, pDB);
285}
2eae6bdc 286
cd915200
GKH
287inline int CED_DbgGetData(int fh, TDBGBLOCK *pDB)
288{
289 return ioctl(fh, IOCTL_CED_DBGGETDATA, pDB);
290}
2eae6bdc 291
cd915200
GKH
292inline int CED_DbgStopLoop(int fh)
293{
294 return ioctl(fh, IOCTL_CED_DBGSTOPLOOP);
295}
2eae6bdc 296
cd915200
GKH
297inline int CED_FullReset(int fh)
298{
299 return ioctl(fh, IOCTL_CED_FULLRESET);
300}
2eae6bdc 301
cd915200
GKH
302inline int CED_SetCircular(int fh, TRANSFERDESC *pTD)
303{
304 return ioctl(fh, IOCTL_CED_SETCIRCULAR, pTD);
305}
306
307inline int CED_GetCircBlock(int fh, TCIRCBLOCK *pCB)
308{
309 return ioctl(fh, IOCTL_CED_GETCIRCBLOCK, pCB);
310}
311
312inline int CED_FreeCircBlock(int fh, TCIRCBLOCK *pCB)
313{
314 return ioctl(fh, IOCTL_CED_FREECIRCBLOCK, pCB);
315}
316
317inline int CED_WaitEvent(int fh, int nArea, int msTimeOut)
318{
319 return ioctl(fh, IOCTL_CED_WAITEVENT, (nArea & 0xff)|(msTimeOut << 8));
320}
321
322inline int CED_TestEvent(int fh, int nArea)
323{
324 return ioctl(fh, IOCTL_CED_TESTEVENT, nArea);
325}
2eae6bdc
AS
326#endif
327
328#ifdef NOTWANTEDYET
cd915200
GKH
329#define IOCTL_CED_REGCALLBACK _IO(CED_MAGIC_IOC, 9) /* Not used */
330#define IOCTL_CED_GETMONITORBUF _IO(CED_MAGIC_IOC, 10) /* Not used */
2eae6bdc 331
cd915200
GKH
332#define IOCTL_CED_BYTECOUNT _IO(CED_MAGIC_IOC, 20) /* Not used */
333#define IOCTL_CED_ZEROBLOCKCOUNT _IO(CED_MAGIC_IOC, 21) /* Not used */
334#define IOCTL_CED_STOPCIRCULAR _IO(CED_MAGIC_IOC, 22) /* Not used */
2eae6bdc 335
cd915200
GKH
336#define IOCTL_CED_REGISTERS1401 _IO(CED_MAGIC_IOC, 24) /* Not used */
337#define IOCTL_CED_STEP1401 _IO(CED_MAGIC_IOC, 27) /* Not used */
338#define IOCTL_CED_SET1401REGISTERS _IO(CED_MAGIC_IOC, 28) /* Not used */
339#define IOCTL_CED_STEPTILL1401 _IO(CED_MAGIC_IOC, 29) /* Not used */
340#define IOCTL_CED_SETORIN _IO(CED_MAGIC_IOC, 30) /* Not used */
2eae6bdc
AS
341
342#endif
343
cd915200 344/* __CED_IOCTL_H__ */
2eae6bdc 345#endif