1 /*****************************************************************************/ 2
3 /* 4 * cdk.h -- CDK interface definitions. 5 * 6 * Copyright (C) 1994-1996 Greg Ungerer (gerg@stallion.oz.au). 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 as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22
23 /*****************************************************************************/ 24
25 #ifndef_CDK_H 26 #define_CDK_H 27 /*****************************************************************************/ 28
29 #pragma pack(2)
30
31 /* 32 * The following set of definitions is used to communicate with the 33 * shared memory interface of the Stallion intelligent multiport serial 34 * boards. The definitions in this file are taken directly from the 35 * document titled "Generic Stackable Interface, Downloader and 36 * Communications Development Kit". 37 */ 38
39 /* 40 * Define the set of importrant shared memory addresses. These are 41 * required to intialize the board and get things started. All of these 42 * addresses are relative to the start of the shared memory. 43 */ 44 #defineCDK_SIGADDR 0x200
45 #define CDK_FEATADDR 0x280
46 #defineCDK_CDKADDR 0x300
47 #define CDK_RDYADDR 0x262
48
49 #define CDK_ALIVEMARKER 13
50
51 /* 52 * On hardware power up the ROMs located on the EasyConnection 8/64 will 53 * fill out the following signature information into shared memory. This 54 * way the host system can quickly determine that the board is present 55 * and is operational. 56 */ 57 typedefstruct cdkecpsig { 58 unsignedlongmagic;
59 unsignedshortromver;
60 unsignedshortcputype;
61 unsignedcharpanelid[8];
62 }cdkecpsig_t;
63
64 #defineECP_MAGIC 0x21504345
65
66 /* 67 * On hardware power up the ROMs located on the ONboard, Stallion and 68 * Brumbys will fill out the following signature information into shared 69 * memory. This way the host system can quickly determine that the board 70 * is present and is operational. 71 */ 72 typedefstruct cdkonbsig { 73 unsignedshortmagic0;
74 unsignedshortmagic1;
75 unsignedshortmagic2;
76 unsignedshortmagic3;
77 unsignedshortromver;
78 unsignedshort memoff;
79 unsignedshort memseg;
80 unsignedshortamask0;
81 unsignedshortpic;
82 unsignedshortstatus;
83 unsignedshortbtype;
84 unsignedshort clkticks;
85 unsignedshort clkspeed;
86 unsignedshortamask1;
87 unsignedshortamask2;
88 }cdkonbsig_t;
89
90 #defineONB_MAGIC0 0xf2a7
91 #defineONB_MAGIC1 0xa149
92 #defineONB_MAGIC2 0x6352
93 #defineONB_MAGIC3 0xf121
94
95 /* 96 * Define the feature area structure. The feature area is the set of 97 * startup parameters used by the slave image when it starts executing. 98 * They allow for the specification of buffer sizes, debug trace, etc. 99 */ 100 typedefstruct cdkfeature { 101 unsignedlongdebug;
102 unsignedlong banner;
103 unsignedlongetype;
104 unsignedlongnrdevs;
105 unsignedlong brdspec;
106 unsignedlong txrqsize;
107 unsignedlong rxrqsize;
108 unsignedlongflags;
109 } cdkfeature_t;
110
111 #define ETYP_DDK 0
112 #define ETYP_CDK 1
113
114 /* 115 * Define the CDK header structure. This is the info that the slave 116 * environment sets up after it has been downloaded and started. It 117 * essentially provides a memory map for the shared memory interface. 118 */ 119 typedefstruct cdkhdr { 120 unsignedshortcommand;
121 unsignedshortstatus;
122 unsignedshortport;
123 unsignedshortmode;
124 unsignedlongcmd_buf[14];
125 unsignedshort alive_cnt;
126 unsignedshort intrpt_mode;
127 unsignedchar intrpt_id[8];
128 unsignedcharver_release;
129 unsignedcharver_modification;
130 unsignedcharver_fix;
131 unsignedchar deadman_restart;
132 unsignedshort deadman;
133 unsignedshortnrdevs;
134 unsignedlongmemp;
135 unsignedlonghostp;
136 unsignedlongslavep;
137 unsignedcharhostreq;
138 unsignedcharslavereq;
139 unsignedchar cmd_reserved[30];
140 }cdkhdr_t;
141
142 #define MODE_DDK 0
143 #define MODE_CDK 1
144
145 #define IMD_INTR 0x0
146 #define IMD_PPINTR 0x1
147 #define IMD_POLL 0xff
148
149 /* 150 * Define the memory mapping structure. This structure is pointed to by 151 * the memp field in the stlcdkhdr struct. As many as these structures 152 * as required are layed out in shared memory to define how the rest of 153 * shared memory is divided up. There will be one for each port. 154 */ 155 typedefstruct cdkmem { 156 unsignedshortdtype;
157 unsignedlongoffset;
158 }cdkmem_t;
159
160 #define TYP_UNDEFINED 0x0
161 #defineTYP_ASYNCTRL 0x1
162 #defineTYP_ASYNC 0x20
163 #define TYP_PARALLEL 0x40
164 #define TYP_SYNCX21 0x60
165
166 /*****************************************************************************/ 167
168 /* 169 * Following is a set of defines and structures used to actually deal 170 * with the serial ports on the board. Firstly is the set of commands 171 * that can be applied to ports. 172 */ 173 #defineASYCMD (((unsignedlong) 'a') << 8)
174
175 #define A_NULL (ASYCMD | 0)
176 #defineA_FLUSH (ASYCMD | 1)
177 #defineA_BREAK (ASYCMD | 2)
178 #define A_GETPORT (ASYCMD | 3)
179 #defineA_SETPORT (ASYCMD | 4)
180 #define A_SETPORTF (ASYCMD | 5)
181 #define A_SETPORTFTX (ASYCMD | 6)
182 #define A_SETPORTFRX (ASYCMD | 7)
183 #defineA_GETSIGNALS (ASYCMD | 8)
184 #defineA_SETSIGNALS (ASYCMD | 9)
185 #defineA_SETSIGNALSF (ASYCMD | 10)
186 #defineA_SETSIGNALSFTX (ASYCMD | 11)
187 #defineA_SETSIGNALSFRX (ASYCMD | 12)
188 #define A_GETNOTIFY (ASYCMD | 13)
189 #defineA_SETNOTIFY (ASYCMD | 14)
190 #define A_NOTIFY (ASYCMD | 15)
191 #defineA_PORTCTRL (ASYCMD | 16)
192 #define A_GETSTATS (ASYCMD | 17)
193 #define A_RQSTATE (ASYCMD | 18)
194 #define A_FLOWSTATE (ASYCMD | 19)
195
196 /* 197 * Define those arguments used for simple commands. 198 */ 199 #defineFLUSHRX 0x1
200 #defineFLUSHTX 0x2
201
202 #define BREAKON -1
203 #define BREAKOFF -2
204
205 /* 206 * Define the port setting structure, and all those defines that go along 207 * with it. Basically this structure defines the charcateristics of this 208 * port: baud rate, chars, parity, input/output char cooking etc. 209 */ 210 typedefstruct asyport { 211 unsignedlongbaudout;
212 unsignedlongbaudin;
213 unsignedlongiflag;
214 unsignedlong oflag;
215 unsignedlong lflag;
216 unsignedlongpflag;
217 unsignedlongflow;
218 unsignedlongspare1;
219 unsignedshort vtime;
220 unsignedshort vmin;
221 unsignedshort txlo;
222 unsignedshort txhi;
223 unsignedshort rxlo;
224 unsignedshort rxhi;
225 unsignedshort rxhog;
226 unsignedshortspare2;
227 unsignedcharcsize;
228 unsignedcharstopbs;
229 unsignedcharparity;
230 unsignedcharstopin;
231 unsignedcharstartin;
232 unsignedcharstopout;
233 unsignedcharstartout;
234 unsignedchar parmark;
235 unsignedchar brkmark;
236 unsignedcharcc[11];
237 }asyport_t;
238
239 #definePT_STOP1 0x0
240 #define PT_STOP15 0x1
241 #definePT_STOP2 0x2
242
243 #definePT_NOPARITY 0x0
244 #definePT_ODDPARITY 0x1
245 #definePT_EVENPARITY 0x2
246 #define PT_MARKPARITY 0x3
247 #define PT_SPACEPARITY 0x4
248
249 #define F_NONE 0x0
250 #defineF_IXON 0x1
251 #define F_IXOFF 0x2
252 #defineF_IXANY 0x4
253 #define F_IOXANY 0x8
254 #defineF_RTSFLOW 0x10
255 #defineF_CTSFLOW 0x20
256 #define F_DTRFLOW 0x40
257 #define F_DCDFLOW 0x80
258 #define F_DSROFLOW 0x100
259 #define F_DSRIFLOW 0x200
260
261 #define FI_NORX 0x1
262 #define FI_RAW 0x2
263 #define FI_ISTRIP 0x4
264 #define FI_UCLC 0x8
265 #define FI_INLCR 0x10
266 #define FI_ICRNL 0x20
267 #define FI_IGNCR 0x40
268 #defineFI_IGNBREAK 0x80
269 #define FI_DSCRDBREAK 0x100
270 #define FI_1MARKBREAK 0x200
271 #define FI_2MARKBREAK 0x400
272 #define FI_XCHNGBREAK 0x800
273 #defineFI_IGNRXERRS 0x1000
274 #define FI_DSCDRXERRS 0x2000
275 #defineFI_1MARKRXERRS 0x4000
276 #define FI_2MARKRXERRS 0x8000
277 #define FI_XCHNGRXERRS 0x10000
278 #define FI_DSCRDNULL 0x20000
279
280 #define FO_OLCUC 0x1
281 #define FO_ONLCR 0x2
282 #define FO_OOCRNL 0x4
283 #define FO_ONOCR 0x8
284 #define FO_ONLRET 0x10
285 #define FO_ONL 0x20
286 #define FO_OBS 0x40
287 #define FO_OVT 0x80
288 #define FO_OFF 0x100
289 #define FO_OTAB1 0x200
290 #define FO_OTAB2 0x400
291 #define FO_OTAB3 0x800
292 #define FO_OCR1 0x1000
293 #define FO_OCR2 0x2000
294 #define FO_OCR3 0x4000
295 #define FO_OFILL 0x8000
296 #define FO_ODELL 0x10000
297
298 #define P_RTSLOCK 0x1
299 #define P_CTSLOCK 0x2
300 #define P_MAPRTS 0x4
301 #define P_MAPCTS 0x8
302 #define P_LOOPBACK 0x10
303 #define P_DTRFOLLOW 0x20
304 #define P_FAKEDCD 0x40
305
306 /* 307 * Define a structure to communicate serial port signal and data state 308 * information. 309 */ 310 typedefstruct asysigs { 311 unsignedlongdata;
312 unsignedlongsignal;
313 unsignedlongsigvalue;
314 }asysigs_t;
315
316 #define DT_TXBUSY 0x1
317 #defineDT_TXEMPTY 0x2
318 #defineDT_TXLOW 0x4
319 #define DT_TXHIGH 0x8
320 #define DT_TXFULL 0x10
321 #define DT_TXHOG 0x20
322 #define DT_TXFLOWED 0x40
323 #define DT_TXBREAK 0x80
324
325 #defineDT_RXBUSY 0x100
326 #define DT_RXEMPTY 0x200
327 #define DT_RXLOW 0x400
328 #define DT_RXHIGH 0x800
329 #define DT_RXFULL 0x1000
330 #define DT_RXHOG 0x2000
331 #define DT_RXFLOWED 0x4000
332 #defineDT_RXBREAK 0x8000
333
334 #defineSG_DTR 0x1
335 #defineSG_DCD 0x2
336 #defineSG_RTS 0x4
337 #defineSG_CTS 0x8
338 #defineSG_DSR 0x10
339 #defineSG_RI 0x20
340
341 /* 342 * Define the notification setting structure. This is used to tell the 343 * port what events we want to be informed about. Fields here use the 344 * same defines as for the asysigs structure above. 345 */ 346 typedefstruct asynotify { 347 unsignedlongctrl;
348 unsignedlongdata;
349 unsignedlongsignal;
350 unsignedlongsigvalue;
351 }asynotify_t;
352
353 /* 354 * Define the port control structure. It is used to do fine grain 355 * control operations on the port. 356 */ 357 typedefstruct{ 358 unsignedlong rxctrl;
359 unsignedlongtxctrl;
360 char rximdch;
361 char tximdch;
362 charspare1;
363 charspare2;
364 }asyctrl_t;
365
366 #define CT_ENABLE 0x1
367 #define CT_DISABLE 0x2
368 #define CT_STOP 0x4
369 #define CT_START 0x8
370 #defineCT_STARTFLOW 0x10
371 #defineCT_STOPFLOW 0x20
372 #define CT_SENDCHR 0x40
373
374 /* 375 * Define the stats structure kept for each port. This is a useful set 376 * of data collected for each port on the slave. The A_GETSTATS command 377 * is used to retrive this data from the slave. 378 */ 379 typedefstruct asystats { 380 unsignedlong opens;
381 unsignedlong txchars;
382 unsignedlong rxchars;
383 unsignedlong txringq;
384 unsignedlong rxringq;
385 unsignedlong txmsgs;
386 unsignedlong rxmsgs;
387 unsignedlong overruns;
388 unsignedlong framing;
389 unsignedlongparity;
390 unsignedlong ringover;
391 unsignedlong lost;
392 unsignedlong rxstart;
393 unsignedlong rxstop;
394 unsignedlong txstart;
395 unsignedlong txstop;
396 unsignedlong dcdcnt;
397 unsignedlong dtrcnt;
398 unsignedlong ctscnt;
399 unsignedlong rtscnt;
400 unsignedlong dsrcnt;
401 unsignedlong ricnt;
402 unsignedlong txbreaks;
403 unsignedlong rxbreaks;
404 unsignedlongsignals;
405 unsignedlongstate;
406 } asystats_t;
407
408 /*****************************************************************************/ 409
410 /* 411 * All command and control communication with a device on the slave is 412 * via a control block in shared memory. Each device has its own control 413 * block, defined by the following structure. The control block allows 414 * the host to open, close and control the device on the slave. 415 */ 416 typedefstruct cdkctrl { 417 unsignedcharopen;
418 unsignedcharclose;
419 unsignedlongopenarg;
420 unsignedlongclosearg;
421 unsignedlongcmd;
422 unsignedlongstatus;
423 unsignedlongargs[32];
424 }cdkctrl_t;
425
426 /* 427 * Each device on the slave passes data to and from the host via a ring 428 * queue in shared memory. Define a ring queue structure to hold the 429 * vital information about each ring queue. Two ring queues will be 430 * allocated for each port, one for reveice data and one for transmit 431 * data. 432 */ 433 typedefstruct cdkasyrq { 434 unsignedlongoffset;
435 unsignedshortsize;
436 unsignedshorthead;
437 unsignedshorttail;
438 }cdkasyrq_t;
439
440 /* 441 * Each asynchronous port is defined in shared memory by the following 442 * structure. It contains a control block to command a device, and also 443 * the neccessary data channel information as well. 444 */ 445 typedefstruct cdkasy { 446 cdkctrl_tctrl;
447 unsignedshortnotify;
448 asynotify_tchanged;
449 unsignedshortreceive;
450 cdkasyrq_trxq;
451 unsignedshorttransmit;
452 cdkasyrq_ttxq;
453 }cdkasy_t;
454
455 #pragma pack()
456
457 /*****************************************************************************/ 458
459 /* 460 * Define the set of ioctls used by the driver to do special things 461 * to the board. These include interrupting it, and initializeing 462 * the driver after board startup and shutdown. 463 */ 464 #include <linux/ioctl.h>
465
466 #defineSTL_BINTR_IO('s',20)
467 #defineSTL_BSTART_IO('s',21)
468 #defineSTL_BSTOP_IO('s',22)
469 #defineSTL_BRESET_IO('s',23)
470
471 /* 472 * Define a set of ioctl extensions, used to get at special stuff. 473 */ 474 #defineSTL_GETPFLAG_IO('s',80)
475 #defineSTL_SETPFLAG_IO('s',81)
476
477 /*****************************************************************************/ 478 #endif