cdk.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*****************************************************************************/
  2. /*
  3. * cdk.h -- CDK interface definitions.
  4. *
  5. * Copyright (C) 1996-1998 Stallion Technologies
  6. * Copyright (C) 1994-1996 Greg Ungerer.
  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. #ifndef _CDK_H
  24. #define _CDK_H
  25. /*****************************************************************************/
  26. #pragma pack(2)
  27. /*
  28. * The following set of definitions is used to communicate with the
  29. * shared memory interface of the Stallion intelligent multiport serial
  30. * boards. The definitions in this file are taken directly from the
  31. * document titled "Generic Stackable Interface, Downloader and
  32. * Communications Development Kit".
  33. */
  34. /*
  35. * Define the set of important shared memory addresses. These are
  36. * required to initialize the board and get things started. All of these
  37. * addresses are relative to the start of the shared memory.
  38. */
  39. #define CDK_SIGADDR 0x200
  40. #define CDK_FEATADDR 0x280
  41. #define CDK_CDKADDR 0x300
  42. #define CDK_RDYADDR 0x262
  43. #define CDK_ALIVEMARKER 13
  44. /*
  45. * On hardware power up the ROMs located on the EasyConnection 8/64 will
  46. * fill out the following signature information into shared memory. This
  47. * way the host system can quickly determine that the board is present
  48. * and is operational.
  49. */
  50. typedef struct cdkecpsig {
  51. unsigned long magic;
  52. unsigned short romver;
  53. unsigned short cputype;
  54. unsigned char panelid[8];
  55. } cdkecpsig_t;
  56. #define ECP_MAGIC 0x21504345
  57. /*
  58. * On hardware power up the ROMs located on the ONboard, Stallion and
  59. * Brumbys will fill out the following signature information into shared
  60. * memory. This way the host system can quickly determine that the board
  61. * is present and is operational.
  62. */
  63. typedef struct cdkonbsig {
  64. unsigned short magic0;
  65. unsigned short magic1;
  66. unsigned short magic2;
  67. unsigned short magic3;
  68. unsigned short romver;
  69. unsigned short memoff;
  70. unsigned short memseg;
  71. unsigned short amask0;
  72. unsigned short pic;
  73. unsigned short status;
  74. unsigned short btype;
  75. unsigned short clkticks;
  76. unsigned short clkspeed;
  77. unsigned short amask1;
  78. unsigned short amask2;
  79. } cdkonbsig_t;
  80. #define ONB_MAGIC0 0xf2a7
  81. #define ONB_MAGIC1 0xa149
  82. #define ONB_MAGIC2 0x6352
  83. #define ONB_MAGIC3 0xf121
  84. /*
  85. * Define the feature area structure. The feature area is the set of
  86. * startup parameters used by the slave image when it starts executing.
  87. * They allow for the specification of buffer sizes, debug trace, etc.
  88. */
  89. typedef struct cdkfeature {
  90. unsigned long debug;
  91. unsigned long banner;
  92. unsigned long etype;
  93. unsigned long nrdevs;
  94. unsigned long brdspec;
  95. unsigned long txrqsize;
  96. unsigned long rxrqsize;
  97. unsigned long flags;
  98. } cdkfeature_t;
  99. #define ETYP_DDK 0
  100. #define ETYP_CDK 1
  101. /*
  102. * Define the CDK header structure. This is the info that the slave
  103. * environment sets up after it has been downloaded and started. It
  104. * essentially provides a memory map for the shared memory interface.
  105. */
  106. typedef struct cdkhdr {
  107. unsigned short command;
  108. unsigned short status;
  109. unsigned short port;
  110. unsigned short mode;
  111. unsigned long cmd_buf[14];
  112. unsigned short alive_cnt;
  113. unsigned short intrpt_mode;
  114. unsigned char intrpt_id[8];
  115. unsigned char ver_release;
  116. unsigned char ver_modification;
  117. unsigned char ver_fix;
  118. unsigned char deadman_restart;
  119. unsigned short deadman;
  120. unsigned short nrdevs;
  121. unsigned long memp;
  122. unsigned long hostp;
  123. unsigned long slavep;
  124. unsigned char hostreq;
  125. unsigned char slavereq;
  126. unsigned char cmd_reserved[30];
  127. } cdkhdr_t;
  128. #define MODE_DDK 0
  129. #define MODE_CDK 1
  130. #define IMD_INTR 0x0
  131. #define IMD_PPINTR 0x1
  132. #define IMD_POLL 0xff
  133. /*
  134. * Define the memory mapping structure. This structure is pointed to by
  135. * the memp field in the stlcdkhdr struct. As many as these structures
  136. * as required are layed out in shared memory to define how the rest of
  137. * shared memory is divided up. There will be one for each port.
  138. */
  139. typedef struct cdkmem {
  140. unsigned short dtype;
  141. unsigned long offset;
  142. } cdkmem_t;
  143. #define TYP_UNDEFINED 0x0
  144. #define TYP_ASYNCTRL 0x1
  145. #define TYP_ASYNC 0x20
  146. #define TYP_PARALLEL 0x40
  147. #define TYP_SYNCX21 0x60
  148. /*****************************************************************************/
  149. /*
  150. * Following is a set of defines and structures used to actually deal
  151. * with the serial ports on the board. Firstly is the set of commands
  152. * that can be applied to ports.
  153. */
  154. #define ASYCMD (((unsigned long) 'a') << 8)
  155. #define A_NULL (ASYCMD | 0)
  156. #define A_FLUSH (ASYCMD | 1)
  157. #define A_BREAK (ASYCMD | 2)
  158. #define A_GETPORT (ASYCMD | 3)
  159. #define A_SETPORT (ASYCMD | 4)
  160. #define A_SETPORTF (ASYCMD | 5)
  161. #define A_SETPORTFTX (ASYCMD | 6)
  162. #define A_SETPORTFRX (ASYCMD | 7)
  163. #define A_GETSIGNALS (ASYCMD | 8)
  164. #define A_SETSIGNALS (ASYCMD | 9)
  165. #define A_SETSIGNALSF (ASYCMD | 10)
  166. #define A_SETSIGNALSFTX (ASYCMD | 11)
  167. #define A_SETSIGNALSFRX (ASYCMD | 12)
  168. #define A_GETNOTIFY (ASYCMD | 13)
  169. #define A_SETNOTIFY (ASYCMD | 14)
  170. #define A_NOTIFY (ASYCMD | 15)
  171. #define A_PORTCTRL (ASYCMD | 16)
  172. #define A_GETSTATS (ASYCMD | 17)
  173. #define A_RQSTATE (ASYCMD | 18)
  174. #define A_FLOWSTATE (ASYCMD | 19)
  175. #define A_CLEARSTATS (ASYCMD | 20)
  176. /*
  177. * Define those arguments used for simple commands.
  178. */
  179. #define FLUSHRX 0x1
  180. #define FLUSHTX 0x2
  181. #define BREAKON -1
  182. #define BREAKOFF -2
  183. /*
  184. * Define the port setting structure, and all those defines that go along
  185. * with it. Basically this structure defines the characteristics of this
  186. * port: baud rate, chars, parity, input/output char cooking etc.
  187. */
  188. typedef struct asyport {
  189. unsigned long baudout;
  190. unsigned long baudin;
  191. unsigned long iflag;
  192. unsigned long oflag;
  193. unsigned long lflag;
  194. unsigned long pflag;
  195. unsigned long flow;
  196. unsigned long spare1;
  197. unsigned short vtime;
  198. unsigned short vmin;
  199. unsigned short txlo;
  200. unsigned short txhi;
  201. unsigned short rxlo;
  202. unsigned short rxhi;
  203. unsigned short rxhog;
  204. unsigned short spare2;
  205. unsigned char csize;
  206. unsigned char stopbs;
  207. unsigned char parity;
  208. unsigned char stopin;
  209. unsigned char startin;
  210. unsigned char stopout;
  211. unsigned char startout;
  212. unsigned char parmark;
  213. unsigned char brkmark;
  214. unsigned char cc[11];
  215. } asyport_t;
  216. #define PT_STOP1 0x0
  217. #define PT_STOP15 0x1
  218. #define PT_STOP2 0x2
  219. #define PT_NOPARITY 0x0
  220. #define PT_ODDPARITY 0x1
  221. #define PT_EVENPARITY 0x2
  222. #define PT_MARKPARITY 0x3
  223. #define PT_SPACEPARITY 0x4
  224. #define F_NONE 0x0
  225. #define F_IXON 0x1
  226. #define F_IXOFF 0x2
  227. #define F_IXANY 0x4
  228. #define F_IOXANY 0x8
  229. #define F_RTSFLOW 0x10
  230. #define F_CTSFLOW 0x20
  231. #define F_DTRFLOW 0x40
  232. #define F_DCDFLOW 0x80
  233. #define F_DSROFLOW 0x100
  234. #define F_DSRIFLOW 0x200
  235. #define FI_NORX 0x1
  236. #define FI_RAW 0x2
  237. #define FI_ISTRIP 0x4
  238. #define FI_UCLC 0x8
  239. #define FI_INLCR 0x10
  240. #define FI_ICRNL 0x20
  241. #define FI_IGNCR 0x40
  242. #define FI_IGNBREAK 0x80
  243. #define FI_DSCRDBREAK 0x100
  244. #define FI_1MARKBREAK 0x200
  245. #define FI_2MARKBREAK 0x400
  246. #define FI_XCHNGBREAK 0x800
  247. #define FI_IGNRXERRS 0x1000
  248. #define FI_DSCDRXERRS 0x2000
  249. #define FI_1MARKRXERRS 0x4000
  250. #define FI_2MARKRXERRS 0x8000
  251. #define FI_XCHNGRXERRS 0x10000
  252. #define FI_DSCRDNULL 0x20000
  253. #define FO_OLCUC 0x1
  254. #define FO_ONLCR 0x2
  255. #define FO_OOCRNL 0x4
  256. #define FO_ONOCR 0x8
  257. #define FO_ONLRET 0x10
  258. #define FO_ONL 0x20
  259. #define FO_OBS 0x40
  260. #define FO_OVT 0x80
  261. #define FO_OFF 0x100
  262. #define FO_OTAB1 0x200
  263. #define FO_OTAB2 0x400
  264. #define FO_OTAB3 0x800
  265. #define FO_OCR1 0x1000
  266. #define FO_OCR2 0x2000
  267. #define FO_OCR3 0x4000
  268. #define FO_OFILL 0x8000
  269. #define FO_ODELL 0x10000
  270. #define P_RTSLOCK 0x1
  271. #define P_CTSLOCK 0x2
  272. #define P_MAPRTS 0x4
  273. #define P_MAPCTS 0x8
  274. #define P_LOOPBACK 0x10
  275. #define P_DTRFOLLOW 0x20
  276. #define P_FAKEDCD 0x40
  277. #define P_RXIMIN 0x10000
  278. #define P_RXITIME 0x20000
  279. #define P_RXTHOLD 0x40000
  280. /*
  281. * Define a structure to communicate serial port signal and data state
  282. * information.
  283. */
  284. typedef struct asysigs {
  285. unsigned long data;
  286. unsigned long signal;
  287. unsigned long sigvalue;
  288. } asysigs_t;
  289. #define DT_TXBUSY 0x1
  290. #define DT_TXEMPTY 0x2
  291. #define DT_TXLOW 0x4
  292. #define DT_TXHIGH 0x8
  293. #define DT_TXFULL 0x10
  294. #define DT_TXHOG 0x20
  295. #define DT_TXFLOWED 0x40
  296. #define DT_TXBREAK 0x80
  297. #define DT_RXBUSY 0x100
  298. #define DT_RXEMPTY 0x200
  299. #define DT_RXLOW 0x400
  300. #define DT_RXHIGH 0x800
  301. #define DT_RXFULL 0x1000
  302. #define DT_RXHOG 0x2000
  303. #define DT_RXFLOWED 0x4000
  304. #define DT_RXBREAK 0x8000
  305. #define SG_DTR 0x1
  306. #define SG_DCD 0x2
  307. #define SG_RTS 0x4
  308. #define SG_CTS 0x8
  309. #define SG_DSR 0x10
  310. #define SG_RI 0x20
  311. /*
  312. * Define the notification setting structure. This is used to tell the
  313. * port what events we want to be informed about. Fields here use the
  314. * same defines as for the asysigs structure above.
  315. */
  316. typedef struct asynotify {
  317. unsigned long ctrl;
  318. unsigned long data;
  319. unsigned long signal;
  320. unsigned long sigvalue;
  321. } asynotify_t;
  322. /*
  323. * Define the port control structure. It is used to do fine grain
  324. * control operations on the port.
  325. */
  326. typedef struct {
  327. unsigned long rxctrl;
  328. unsigned long txctrl;
  329. char rximdch;
  330. char tximdch;
  331. char spare1;
  332. char spare2;
  333. } asyctrl_t;
  334. #define CT_ENABLE 0x1
  335. #define CT_DISABLE 0x2
  336. #define CT_STOP 0x4
  337. #define CT_START 0x8
  338. #define CT_STARTFLOW 0x10
  339. #define CT_STOPFLOW 0x20
  340. #define CT_SENDCHR 0x40
  341. /*
  342. * Define the stats structure kept for each port. This is a useful set
  343. * of data collected for each port on the slave. The A_GETSTATS command
  344. * is used to retrieve this data from the slave.
  345. */
  346. typedef struct asystats {
  347. unsigned long opens;
  348. unsigned long txchars;
  349. unsigned long rxchars;
  350. unsigned long txringq;
  351. unsigned long rxringq;
  352. unsigned long txmsgs;
  353. unsigned long rxmsgs;
  354. unsigned long txflushes;
  355. unsigned long rxflushes;
  356. unsigned long overruns;
  357. unsigned long framing;
  358. unsigned long parity;
  359. unsigned long ringover;
  360. unsigned long lost;
  361. unsigned long rxstart;
  362. unsigned long rxstop;
  363. unsigned long txstart;
  364. unsigned long txstop;
  365. unsigned long dcdcnt;
  366. unsigned long dtrcnt;
  367. unsigned long ctscnt;
  368. unsigned long rtscnt;
  369. unsigned long dsrcnt;
  370. unsigned long ricnt;
  371. unsigned long txbreaks;
  372. unsigned long rxbreaks;
  373. unsigned long signals;
  374. unsigned long state;
  375. unsigned long hwid;
  376. } asystats_t;
  377. /*****************************************************************************/
  378. /*
  379. * All command and control communication with a device on the slave is
  380. * via a control block in shared memory. Each device has its own control
  381. * block, defined by the following structure. The control block allows
  382. * the host to open, close and control the device on the slave.
  383. */
  384. typedef struct cdkctrl {
  385. unsigned char open;
  386. unsigned char close;
  387. unsigned long openarg;
  388. unsigned long closearg;
  389. unsigned long cmd;
  390. unsigned long status;
  391. unsigned long args[32];
  392. } cdkctrl_t;
  393. /*
  394. * Each device on the slave passes data to and from the host via a ring
  395. * queue in shared memory. Define a ring queue structure to hold the
  396. * vital information about each ring queue. Two ring queues will be
  397. * allocated for each port, one for receive data and one for transmit
  398. * data.
  399. */
  400. typedef struct cdkasyrq {
  401. unsigned long offset;
  402. unsigned short size;
  403. unsigned short head;
  404. unsigned short tail;
  405. } cdkasyrq_t;
  406. /*
  407. * Each asynchronous port is defined in shared memory by the following
  408. * structure. It contains a control block to command a device, and also
  409. * the necessary data channel information as well.
  410. */
  411. typedef struct cdkasy {
  412. cdkctrl_t ctrl;
  413. unsigned short notify;
  414. asynotify_t changed;
  415. unsigned short receive;
  416. cdkasyrq_t rxq;
  417. unsigned short transmit;
  418. cdkasyrq_t txq;
  419. } cdkasy_t;
  420. #pragma pack()
  421. /*****************************************************************************/
  422. /*
  423. * Define the set of ioctls used by the driver to do special things
  424. * to the board. These include interrupting it, and initializing
  425. * the driver after board startup and shutdown.
  426. */
  427. #include <linux/ioctl.h>
  428. #define STL_BINTR _IO('s',20)
  429. #define STL_BSTART _IO('s',21)
  430. #define STL_BSTOP _IO('s',22)
  431. #define STL_BRESET _IO('s',23)
  432. /*
  433. * Define a set of ioctl extensions, used to get at special stuff.
  434. */
  435. #define STL_GETPFLAG _IO('s',80)
  436. #define STL_SETPFLAG _IO('s',81)
  437. /*****************************************************************************/
  438. #endif