cyclades.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. /* $Revision: 3.0 $$Date: 1998/11/02 14:20:59 $
  2. * linux/include/linux/cyclades.h
  3. *
  4. * This file was initially written by
  5. * Randolph Bentson <bentson@grieg.seaslug.org> and is maintained by
  6. * Ivan Passos <ivan@cyclades.com>.
  7. *
  8. * This file contains the general definitions for the cyclades.c driver
  9. *$Log: cyclades.h,v $
  10. *Revision 3.1 2002/01/29 11:36:16 henrique
  11. *added throttle field on struct cyclades_port to indicate whether the
  12. *port is throttled or not
  13. *
  14. *Revision 3.1 2000/04/19 18:52:52 ivan
  15. *converted address fields to unsigned long and added fields for physical
  16. *addresses on cyclades_card structure;
  17. *
  18. *Revision 3.0 1998/11/02 14:20:59 ivan
  19. *added nports field on cyclades_card structure;
  20. *
  21. *Revision 2.5 1998/08/03 16:57:01 ivan
  22. *added cyclades_idle_stats structure;
  23. *
  24. *Revision 2.4 1998/06/01 12:09:53 ivan
  25. *removed closing_wait2 from cyclades_port structure;
  26. *
  27. *Revision 2.3 1998/03/16 18:01:12 ivan
  28. *changes in the cyclades_port structure to get it closer to the
  29. *standard serial port structure;
  30. *added constants for new ioctls;
  31. *
  32. *Revision 2.2 1998/02/17 16:50:00 ivan
  33. *changes in the cyclades_port structure (addition of shutdown_wait and
  34. *chip_rev variables);
  35. *added constants for new ioctls and for CD1400 rev. numbers.
  36. *
  37. *Revision 2.1 1997/10/24 16:03:00 ivan
  38. *added rflow (which allows enabling the CD1400 special flow control
  39. *feature) and rtsdtr_inv (which allows DTR/RTS pin inversion) to
  40. *cyclades_port structure;
  41. *added Alpha support
  42. *
  43. *Revision 2.0 1997/06/30 10:30:00 ivan
  44. *added some new doorbell command constants related to IOCTLW and
  45. *UART error signaling
  46. *
  47. *Revision 1.8 1997/06/03 15:30:00 ivan
  48. *added constant ZFIRM_HLT
  49. *added constant CyPCI_Ze_win ( = 2 * Cy_PCI_Zwin)
  50. *
  51. *Revision 1.7 1997/03/26 10:30:00 daniel
  52. *new entries at the end of cyclades_port struct to reallocate
  53. *variables illegally allocated within card memory.
  54. *
  55. *Revision 1.6 1996/09/09 18:35:30 bentson
  56. *fold in changes for Cyclom-Z -- including structures for
  57. *communicating with board as well modest changes to original
  58. *structures to support new features.
  59. *
  60. *Revision 1.5 1995/11/13 21:13:31 bentson
  61. *changes suggested by Michael Chastain <mec@duracef.shout.net>
  62. *to support use of this file in non-kernel applications
  63. *
  64. *
  65. */
  66. #ifndef _LINUX_CYCLADES_H
  67. #define _LINUX_CYCLADES_H
  68. struct cyclades_monitor {
  69. unsigned long int_count;
  70. unsigned long char_count;
  71. unsigned long char_max;
  72. unsigned long char_last;
  73. };
  74. /*
  75. * These stats all reflect activity since the device was last initialized.
  76. * (i.e., since the port was opened with no other processes already having it
  77. * open)
  78. */
  79. struct cyclades_idle_stats {
  80. time_t in_use; /* Time device has been in use (secs) */
  81. time_t recv_idle; /* Time since last char received (secs) */
  82. time_t xmit_idle; /* Time since last char transmitted (secs) */
  83. unsigned long recv_bytes; /* Bytes received */
  84. unsigned long xmit_bytes; /* Bytes transmitted */
  85. unsigned long overruns; /* Input overruns */
  86. unsigned long frame_errs; /* Input framing errors */
  87. unsigned long parity_errs; /* Input parity errors */
  88. };
  89. #define CYCLADES_MAGIC 0x4359
  90. #define CYGETMON 0x435901
  91. #define CYGETTHRESH 0x435902
  92. #define CYSETTHRESH 0x435903
  93. #define CYGETDEFTHRESH 0x435904
  94. #define CYSETDEFTHRESH 0x435905
  95. #define CYGETTIMEOUT 0x435906
  96. #define CYSETTIMEOUT 0x435907
  97. #define CYGETDEFTIMEOUT 0x435908
  98. #define CYSETDEFTIMEOUT 0x435909
  99. #define CYSETRFLOW 0x43590a
  100. #define CYGETRFLOW 0x43590b
  101. #define CYSETRTSDTR_INV 0x43590c
  102. #define CYGETRTSDTR_INV 0x43590d
  103. #define CYZSETPOLLCYCLE 0x43590e
  104. #define CYZGETPOLLCYCLE 0x43590f
  105. #define CYGETCD1400VER 0x435910
  106. #define CYGETCARDINFO 0x435911
  107. #define CYSETWAIT 0x435912
  108. #define CYGETWAIT 0x435913
  109. /*************** CYCLOM-Z ADDITIONS ***************/
  110. #define CZIOC ('M' << 8)
  111. #define CZ_NBOARDS (CZIOC|0xfa)
  112. #define CZ_BOOT_START (CZIOC|0xfb)
  113. #define CZ_BOOT_DATA (CZIOC|0xfc)
  114. #define CZ_BOOT_END (CZIOC|0xfd)
  115. #define CZ_TEST (CZIOC|0xfe)
  116. #define CZ_DEF_POLL (HZ/25)
  117. #define MAX_BOARD 4 /* Max number of boards */
  118. #define MAX_DEV 256 /* Max number of ports total */
  119. #define CYZ_MAX_SPEED 921600
  120. #define CYZ_FIFO_SIZE 16
  121. #define CYZ_BOOT_NWORDS 0x100
  122. struct CYZ_BOOT_CTRL {
  123. unsigned short nboard;
  124. int status[MAX_BOARD];
  125. int nchannel[MAX_BOARD];
  126. int fw_rev[MAX_BOARD];
  127. unsigned long offset;
  128. unsigned long data[CYZ_BOOT_NWORDS];
  129. };
  130. #ifndef DP_WINDOW_SIZE
  131. /* #include "cyclomz.h" */
  132. /****************** ****************** *******************/
  133. /*
  134. * The data types defined below are used in all ZFIRM interface
  135. * data structures. They accomodate differences between HW
  136. * architectures and compilers.
  137. */
  138. #if defined(__alpha__)
  139. typedef unsigned long ucdouble; /* 64 bits, unsigned */
  140. typedef unsigned int uclong; /* 32 bits, unsigned */
  141. #else
  142. typedef unsigned long uclong; /* 32 bits, unsigned */
  143. #endif
  144. typedef unsigned short ucshort; /* 16 bits, unsigned */
  145. typedef unsigned char ucchar; /* 8 bits, unsigned */
  146. /*
  147. * Memory Window Sizes
  148. */
  149. #define DP_WINDOW_SIZE (0x00080000) /* window size 512 Kb */
  150. #define ZE_DP_WINDOW_SIZE (0x00100000) /* window size 1 Mb (Ze and
  151. 8Zo V.2 */
  152. #define CTRL_WINDOW_SIZE (0x00000080) /* runtime regs 128 bytes */
  153. /*
  154. * CUSTOM_REG - Cyclom-Z/PCI Custom Registers Set. The driver
  155. * normally will access only interested on the fpga_id, fpga_version,
  156. * start_cpu and stop_cpu.
  157. */
  158. struct CUSTOM_REG {
  159. uclong fpga_id; /* FPGA Identification Register */
  160. uclong fpga_version; /* FPGA Version Number Register */
  161. uclong cpu_start; /* CPU start Register (write) */
  162. uclong cpu_stop; /* CPU stop Register (write) */
  163. uclong misc_reg; /* Miscelaneous Register */
  164. uclong idt_mode; /* IDT mode Register */
  165. uclong uart_irq_status; /* UART IRQ status Register */
  166. uclong clear_timer0_irq; /* Clear timer interrupt Register */
  167. uclong clear_timer1_irq; /* Clear timer interrupt Register */
  168. uclong clear_timer2_irq; /* Clear timer interrupt Register */
  169. uclong test_register; /* Test Register */
  170. uclong test_count; /* Test Count Register */
  171. uclong timer_select; /* Timer select register */
  172. uclong pr_uart_irq_status; /* Prioritized UART IRQ stat Reg */
  173. uclong ram_wait_state; /* RAM wait-state Register */
  174. uclong uart_wait_state; /* UART wait-state Register */
  175. uclong timer_wait_state; /* timer wait-state Register */
  176. uclong ack_wait_state; /* ACK wait State Register */
  177. };
  178. /*
  179. * RUNTIME_9060 - PLX PCI9060ES local configuration and shared runtime
  180. * registers. This structure can be used to access the 9060 registers
  181. * (memory mapped).
  182. */
  183. struct RUNTIME_9060 {
  184. uclong loc_addr_range; /* 00h - Local Address Range */
  185. uclong loc_addr_base; /* 04h - Local Address Base */
  186. uclong loc_arbitr; /* 08h - Local Arbitration */
  187. uclong endian_descr; /* 0Ch - Big/Little Endian Descriptor */
  188. uclong loc_rom_range; /* 10h - Local ROM Range */
  189. uclong loc_rom_base; /* 14h - Local ROM Base */
  190. uclong loc_bus_descr; /* 18h - Local Bus descriptor */
  191. uclong loc_range_mst; /* 1Ch - Local Range for Master to PCI */
  192. uclong loc_base_mst; /* 20h - Local Base for Master PCI */
  193. uclong loc_range_io; /* 24h - Local Range for Master IO */
  194. uclong pci_base_mst; /* 28h - PCI Base for Master PCI */
  195. uclong pci_conf_io; /* 2Ch - PCI configuration for Master IO */
  196. uclong filler1; /* 30h */
  197. uclong filler2; /* 34h */
  198. uclong filler3; /* 38h */
  199. uclong filler4; /* 3Ch */
  200. uclong mail_box_0; /* 40h - Mail Box 0 */
  201. uclong mail_box_1; /* 44h - Mail Box 1 */
  202. uclong mail_box_2; /* 48h - Mail Box 2 */
  203. uclong mail_box_3; /* 4Ch - Mail Box 3 */
  204. uclong filler5; /* 50h */
  205. uclong filler6; /* 54h */
  206. uclong filler7; /* 58h */
  207. uclong filler8; /* 5Ch */
  208. uclong pci_doorbell; /* 60h - PCI to Local Doorbell */
  209. uclong loc_doorbell; /* 64h - Local to PCI Doorbell */
  210. uclong intr_ctrl_stat; /* 68h - Interrupt Control/Status */
  211. uclong init_ctrl; /* 6Ch - EEPROM control, Init Control, etc */
  212. };
  213. /* Values for the Local Base Address re-map register */
  214. #define WIN_RAM 0x00000001L /* set the sliding window to RAM */
  215. #define WIN_CREG 0x14000001L /* set the window to custom Registers */
  216. /* Values timer select registers */
  217. #define TIMER_BY_1M 0x00 /* clock divided by 1M */
  218. #define TIMER_BY_256K 0x01 /* clock divided by 256k */
  219. #define TIMER_BY_128K 0x02 /* clock divided by 128k */
  220. #define TIMER_BY_32K 0x03 /* clock divided by 32k */
  221. /****************** ****************** *******************/
  222. #endif
  223. #ifndef ZFIRM_ID
  224. /* #include "zfwint.h" */
  225. /****************** ****************** *******************/
  226. /*
  227. * This file contains the definitions for interfacing with the
  228. * Cyclom-Z ZFIRM Firmware.
  229. */
  230. /* General Constant definitions */
  231. #define MAX_CHAN 64 /* max number of channels per board */
  232. /* firmware id structure (set after boot) */
  233. #define ID_ADDRESS 0x00000180L /* signature/pointer address */
  234. #define ZFIRM_ID 0x5557465AL /* ZFIRM/U signature */
  235. #define ZFIRM_HLT 0x59505B5CL /* ZFIRM needs external power supply */
  236. #define ZFIRM_RST 0x56040674L /* RST signal (due to FW reset) */
  237. #define ZF_TINACT_DEF 1000 /* default inactivity timeout
  238. (1000 ms) */
  239. #define ZF_TINACT ZF_TINACT_DEF
  240. struct FIRM_ID {
  241. uclong signature; /* ZFIRM/U signature */
  242. uclong zfwctrl_addr; /* pointer to ZFW_CTRL structure */
  243. };
  244. /* Op. System id */
  245. #define C_OS_LINUX 0x00000030 /* generic Linux system */
  246. /* channel op_mode */
  247. #define C_CH_DISABLE 0x00000000 /* channel is disabled */
  248. #define C_CH_TXENABLE 0x00000001 /* channel Tx enabled */
  249. #define C_CH_RXENABLE 0x00000002 /* channel Rx enabled */
  250. #define C_CH_ENABLE 0x00000003 /* channel Tx/Rx enabled */
  251. #define C_CH_LOOPBACK 0x00000004 /* Loopback mode */
  252. /* comm_parity - parity */
  253. #define C_PR_NONE 0x00000000 /* None */
  254. #define C_PR_ODD 0x00000001 /* Odd */
  255. #define C_PR_EVEN 0x00000002 /* Even */
  256. #define C_PR_MARK 0x00000004 /* Mark */
  257. #define C_PR_SPACE 0x00000008 /* Space */
  258. #define C_PR_PARITY 0x000000ff
  259. #define C_PR_DISCARD 0x00000100 /* discard char with frame/par error */
  260. #define C_PR_IGNORE 0x00000200 /* ignore frame/par error */
  261. /* comm_data_l - data length and stop bits */
  262. #define C_DL_CS5 0x00000001
  263. #define C_DL_CS6 0x00000002
  264. #define C_DL_CS7 0x00000004
  265. #define C_DL_CS8 0x00000008
  266. #define C_DL_CS 0x0000000f
  267. #define C_DL_1STOP 0x00000010
  268. #define C_DL_15STOP 0x00000020
  269. #define C_DL_2STOP 0x00000040
  270. #define C_DL_STOP 0x000000f0
  271. /* interrupt enabling/status */
  272. #define C_IN_DISABLE 0x00000000 /* zero, disable interrupts */
  273. #define C_IN_TXBEMPTY 0x00000001 /* tx buffer empty */
  274. #define C_IN_TXLOWWM 0x00000002 /* tx buffer below LWM */
  275. #define C_IN_RXHIWM 0x00000010 /* rx buffer above HWM */
  276. #define C_IN_RXNNDT 0x00000020 /* rx no new data timeout */
  277. #define C_IN_MDCD 0x00000100 /* modem DCD change */
  278. #define C_IN_MDSR 0x00000200 /* modem DSR change */
  279. #define C_IN_MRI 0x00000400 /* modem RI change */
  280. #define C_IN_MCTS 0x00000800 /* modem CTS change */
  281. #define C_IN_RXBRK 0x00001000 /* Break received */
  282. #define C_IN_PR_ERROR 0x00002000 /* parity error */
  283. #define C_IN_FR_ERROR 0x00004000 /* frame error */
  284. #define C_IN_OVR_ERROR 0x00008000 /* overrun error */
  285. #define C_IN_RXOFL 0x00010000 /* RX buffer overflow */
  286. #define C_IN_IOCTLW 0x00020000 /* I/O control w/ wait */
  287. #define C_IN_MRTS 0x00040000 /* modem RTS drop */
  288. #define C_IN_ICHAR 0x00080000
  289. /* flow control */
  290. #define C_FL_OXX 0x00000001 /* output Xon/Xoff flow control */
  291. #define C_FL_IXX 0x00000002 /* output Xon/Xoff flow control */
  292. #define C_FL_OIXANY 0x00000004 /* output Xon/Xoff (any xon) */
  293. #define C_FL_SWFLOW 0x0000000f
  294. /* flow status */
  295. #define C_FS_TXIDLE 0x00000000 /* no Tx data in the buffer or UART */
  296. #define C_FS_SENDING 0x00000001 /* UART is sending data */
  297. #define C_FS_SWFLOW 0x00000002 /* Tx is stopped by received Xoff */
  298. /* rs_control/rs_status RS-232 signals */
  299. #define C_RS_PARAM 0x80000000 /* Indicates presence of parameter in
  300. IOCTLM command */
  301. #define C_RS_RTS 0x00000001 /* RTS */
  302. #define C_RS_DTR 0x00000004 /* DTR */
  303. #define C_RS_DCD 0x00000100 /* CD */
  304. #define C_RS_DSR 0x00000200 /* DSR */
  305. #define C_RS_RI 0x00000400 /* RI */
  306. #define C_RS_CTS 0x00000800 /* CTS */
  307. /* commands Host <-> Board */
  308. #define C_CM_RESET 0x01 /* reset/flush buffers */
  309. #define C_CM_IOCTL 0x02 /* re-read CH_CTRL */
  310. #define C_CM_IOCTLW 0x03 /* re-read CH_CTRL, intr when done */
  311. #define C_CM_IOCTLM 0x04 /* RS-232 outputs change */
  312. #define C_CM_SENDXOFF 0x10 /* send Xoff */
  313. #define C_CM_SENDXON 0x11 /* send Xon */
  314. #define C_CM_CLFLOW 0x12 /* Clear flow control (resume) */
  315. #define C_CM_SENDBRK 0x41 /* send break */
  316. #define C_CM_INTBACK 0x42 /* Interrupt back */
  317. #define C_CM_SET_BREAK 0x43 /* Tx break on */
  318. #define C_CM_CLR_BREAK 0x44 /* Tx break off */
  319. #define C_CM_CMD_DONE 0x45 /* Previous command done */
  320. #define C_CM_INTBACK2 0x46 /* Alternate Interrupt back */
  321. #define C_CM_TINACT 0x51 /* set inactivity detection */
  322. #define C_CM_IRQ_ENBL 0x52 /* enable generation of interrupts */
  323. #define C_CM_IRQ_DSBL 0x53 /* disable generation of interrupts */
  324. #define C_CM_ACK_ENBL 0x54 /* enable acknowledged interrupt mode */
  325. #define C_CM_ACK_DSBL 0x55 /* disable acknowledged intr mode */
  326. #define C_CM_FLUSH_RX 0x56 /* flushes Rx buffer */
  327. #define C_CM_FLUSH_TX 0x57 /* flushes Tx buffer */
  328. #define C_CM_Q_ENABLE 0x58 /* enables queue access from the
  329. driver */
  330. #define C_CM_Q_DISABLE 0x59 /* disables queue access from the
  331. driver */
  332. #define C_CM_TXBEMPTY 0x60 /* Tx buffer is empty */
  333. #define C_CM_TXLOWWM 0x61 /* Tx buffer low water mark */
  334. #define C_CM_RXHIWM 0x62 /* Rx buffer high water mark */
  335. #define C_CM_RXNNDT 0x63 /* rx no new data timeout */
  336. #define C_CM_TXFEMPTY 0x64
  337. #define C_CM_ICHAR 0x65
  338. #define C_CM_MDCD 0x70 /* modem DCD change */
  339. #define C_CM_MDSR 0x71 /* modem DSR change */
  340. #define C_CM_MRI 0x72 /* modem RI change */
  341. #define C_CM_MCTS 0x73 /* modem CTS change */
  342. #define C_CM_MRTS 0x74 /* modem RTS drop */
  343. #define C_CM_RXBRK 0x84 /* Break received */
  344. #define C_CM_PR_ERROR 0x85 /* Parity error */
  345. #define C_CM_FR_ERROR 0x86 /* Frame error */
  346. #define C_CM_OVR_ERROR 0x87 /* Overrun error */
  347. #define C_CM_RXOFL 0x88 /* RX buffer overflow */
  348. #define C_CM_CMDERROR 0x90 /* command error */
  349. #define C_CM_FATAL 0x91 /* fatal error */
  350. #define C_CM_HW_RESET 0x92 /* reset board */
  351. /*
  352. * CH_CTRL - This per port structure contains all parameters
  353. * that control an specific port. It can be seen as the
  354. * configuration registers of a "super-serial-controller".
  355. */
  356. struct CH_CTRL {
  357. uclong op_mode; /* operation mode */
  358. uclong intr_enable; /* interrupt masking */
  359. uclong sw_flow; /* SW flow control */
  360. uclong flow_status; /* output flow status */
  361. uclong comm_baud; /* baud rate - numerically specified */
  362. uclong comm_parity; /* parity */
  363. uclong comm_data_l; /* data length/stop */
  364. uclong comm_flags; /* other flags */
  365. uclong hw_flow; /* HW flow control */
  366. uclong rs_control; /* RS-232 outputs */
  367. uclong rs_status; /* RS-232 inputs */
  368. uclong flow_xon; /* xon char */
  369. uclong flow_xoff; /* xoff char */
  370. uclong hw_overflow; /* hw overflow counter */
  371. uclong sw_overflow; /* sw overflow counter */
  372. uclong comm_error; /* frame/parity error counter */
  373. uclong ichar;
  374. uclong filler[7];
  375. };
  376. /*
  377. * BUF_CTRL - This per channel structure contains
  378. * all Tx and Rx buffer control for a given channel.
  379. */
  380. struct BUF_CTRL {
  381. uclong flag_dma; /* buffers are in Host memory */
  382. uclong tx_bufaddr; /* address of the tx buffer */
  383. uclong tx_bufsize; /* tx buffer size */
  384. uclong tx_threshold; /* tx low water mark */
  385. uclong tx_get; /* tail index tx buf */
  386. uclong tx_put; /* head index tx buf */
  387. uclong rx_bufaddr; /* address of the rx buffer */
  388. uclong rx_bufsize; /* rx buffer size */
  389. uclong rx_threshold; /* rx high water mark */
  390. uclong rx_get; /* tail index rx buf */
  391. uclong rx_put; /* head index rx buf */
  392. uclong filler[5]; /* filler to align structures */
  393. };
  394. /*
  395. * BOARD_CTRL - This per board structure contains all global
  396. * control fields related to the board.
  397. */
  398. struct BOARD_CTRL {
  399. /* static info provided by the on-board CPU */
  400. uclong n_channel; /* number of channels */
  401. uclong fw_version; /* firmware version */
  402. /* static info provided by the driver */
  403. uclong op_system; /* op_system id */
  404. uclong dr_version; /* driver version */
  405. /* board control area */
  406. uclong inactivity; /* inactivity control */
  407. /* host to FW commands */
  408. uclong hcmd_channel; /* channel number */
  409. uclong hcmd_param; /* pointer to parameters */
  410. /* FW to Host commands */
  411. uclong fwcmd_channel; /* channel number */
  412. uclong fwcmd_param; /* pointer to parameters */
  413. uclong zf_int_queue_addr; /* offset for INT_QUEUE structure */
  414. /* filler so the structures are aligned */
  415. uclong filler[6];
  416. };
  417. /* Host Interrupt Queue */
  418. #define QUEUE_SIZE (10*MAX_CHAN)
  419. struct INT_QUEUE {
  420. unsigned char intr_code[QUEUE_SIZE];
  421. unsigned long channel[QUEUE_SIZE];
  422. unsigned long param[QUEUE_SIZE];
  423. unsigned long put;
  424. unsigned long get;
  425. };
  426. /*
  427. * ZFW_CTRL - This is the data structure that includes all other
  428. * data structures used by the Firmware.
  429. */
  430. struct ZFW_CTRL {
  431. struct BOARD_CTRL board_ctrl;
  432. struct CH_CTRL ch_ctrl[MAX_CHAN];
  433. struct BUF_CTRL buf_ctrl[MAX_CHAN];
  434. };
  435. /****************** ****************** *******************/
  436. #endif
  437. /* Per card data structure */
  438. struct resource;
  439. struct cyclades_card {
  440. unsigned long base_phys;
  441. unsigned long ctl_phys;
  442. void __iomem *base_addr;
  443. void __iomem *ctl_addr;
  444. int irq;
  445. int num_chips; /* 0 if card absent, -1 if Z/PCI, else Y */
  446. int first_line; /* minor number of first channel on card */
  447. int nports; /* Number of ports in the card */
  448. int bus_index; /* address shift - 0 for ISA, 1 for PCI */
  449. int intr_enabled; /* FW Interrupt flag - 0 disabled, 1 enabled */
  450. struct pci_dev *pdev;
  451. #ifdef __KERNEL__
  452. spinlock_t card_lock;
  453. #else
  454. unsigned long filler;
  455. #endif
  456. };
  457. struct cyclades_chip {
  458. int filler;
  459. };
  460. #ifdef __KERNEL__
  461. /***************************************
  462. * Memory access functions/macros *
  463. * (required to support Alpha systems) *
  464. ***************************************/
  465. #define cy_writeb(port,val) {writeb((val),(port)); mb();}
  466. #define cy_writew(port,val) {writew((val),(port)); mb();}
  467. #define cy_writel(port,val) {writel((val),(port)); mb();}
  468. #define cy_readb(port) readb(port)
  469. #define cy_readw(port) readw(port)
  470. #define cy_readl(port) readl(port)
  471. /*
  472. * Statistics counters
  473. */
  474. struct cyclades_icount {
  475. __u32 cts, dsr, rng, dcd, tx, rx;
  476. __u32 frame, parity, overrun, brk;
  477. __u32 buf_overrun;
  478. };
  479. /*
  480. * This is our internal structure for each serial port's state.
  481. *
  482. * Many fields are paralleled by the structure used by the serial_struct
  483. * structure.
  484. *
  485. * For definitions of the flags field, see tty.h
  486. */
  487. struct cyclades_port {
  488. int magic;
  489. int card;
  490. int line;
  491. int flags; /* defined in tty.h */
  492. int type; /* UART type */
  493. struct tty_struct *tty;
  494. int read_status_mask;
  495. int ignore_status_mask;
  496. int timeout;
  497. int xmit_fifo_size;
  498. int cor1,cor2,cor3,cor4,cor5;
  499. int tbpr,tco,rbpr,rco;
  500. int baud;
  501. int rflow;
  502. int rtsdtr_inv;
  503. int chip_rev;
  504. int custom_divisor;
  505. int x_char; /* to be pushed out ASAP */
  506. int close_delay;
  507. unsigned short closing_wait;
  508. unsigned long event;
  509. unsigned long last_active;
  510. int count; /* # of fd on device */
  511. int breakon;
  512. int breakoff;
  513. int blocked_open; /* # of blocked opens */
  514. unsigned char *xmit_buf;
  515. int xmit_head;
  516. int xmit_tail;
  517. int xmit_cnt;
  518. int default_threshold;
  519. int default_timeout;
  520. unsigned long jiffies[3];
  521. unsigned long rflush_count;
  522. struct cyclades_monitor mon;
  523. struct cyclades_idle_stats idle_stats;
  524. struct cyclades_icount icount;
  525. struct work_struct tqueue;
  526. wait_queue_head_t open_wait;
  527. wait_queue_head_t close_wait;
  528. wait_queue_head_t shutdown_wait;
  529. wait_queue_head_t delta_msr_wait;
  530. int throttle;
  531. };
  532. /*
  533. * Events are used to schedule things to happen at timer-interrupt
  534. * time, instead of at cy interrupt time.
  535. */
  536. #define Cy_EVENT_READ_PROCESS 0
  537. #define Cy_EVENT_WRITE_WAKEUP 1
  538. #define Cy_EVENT_HANGUP 2
  539. #define Cy_EVENT_BREAK 3
  540. #define Cy_EVENT_OPEN_WAKEUP 4
  541. #define Cy_EVENT_SHUTDOWN_WAKEUP 5
  542. #define Cy_EVENT_DELTA_WAKEUP 6
  543. #define Cy_EVENT_Z_RX_FULL 7
  544. #define CLOSING_WAIT_DELAY 30*HZ
  545. #define CY_CLOSING_WAIT_NONE 65535
  546. #define CY_CLOSING_WAIT_INF 0
  547. #define CyMAX_CHIPS_PER_CARD 8
  548. #define CyMAX_CHAR_FIFO 12
  549. #define CyPORTS_PER_CHIP 4
  550. #define CD1400_MAX_SPEED 115200
  551. #define CyISA_Ywin 0x2000
  552. #define CyPCI_Ywin 0x4000
  553. #define CyPCI_Yctl 0x80
  554. #define CyPCI_Zctl CTRL_WINDOW_SIZE
  555. #define CyPCI_Zwin 0x80000
  556. #define CyPCI_Ze_win (2 * CyPCI_Zwin)
  557. #define PCI_DEVICE_ID_MASK 0x06
  558. /**** CD1400 registers ****/
  559. #define CD1400_REV_G 0x46
  560. #define CD1400_REV_J 0x48
  561. #define CyRegSize 0x0400
  562. #define Cy_HwReset 0x1400
  563. #define Cy_ClrIntr 0x1800
  564. #define Cy_EpldRev 0x1e00
  565. /* Global Registers */
  566. #define CyGFRCR (0x40*2)
  567. #define CyRevE (44)
  568. #define CyCAR (0x68*2)
  569. #define CyCHAN_0 (0x00)
  570. #define CyCHAN_1 (0x01)
  571. #define CyCHAN_2 (0x02)
  572. #define CyCHAN_3 (0x03)
  573. #define CyGCR (0x4B*2)
  574. #define CyCH0_SERIAL (0x00)
  575. #define CyCH0_PARALLEL (0x80)
  576. #define CySVRR (0x67*2)
  577. #define CySRModem (0x04)
  578. #define CySRTransmit (0x02)
  579. #define CySRReceive (0x01)
  580. #define CyRICR (0x44*2)
  581. #define CyTICR (0x45*2)
  582. #define CyMICR (0x46*2)
  583. #define CyICR0 (0x00)
  584. #define CyICR1 (0x01)
  585. #define CyICR2 (0x02)
  586. #define CyICR3 (0x03)
  587. #define CyRIR (0x6B*2)
  588. #define CyTIR (0x6A*2)
  589. #define CyMIR (0x69*2)
  590. #define CyIRDirEq (0x80)
  591. #define CyIRBusy (0x40)
  592. #define CyIRUnfair (0x20)
  593. #define CyIRContext (0x1C)
  594. #define CyIRChannel (0x03)
  595. #define CyPPR (0x7E*2)
  596. #define CyCLOCK_20_1MS (0x27)
  597. #define CyCLOCK_25_1MS (0x31)
  598. #define CyCLOCK_25_5MS (0xf4)
  599. #define CyCLOCK_60_1MS (0x75)
  600. #define CyCLOCK_60_2MS (0xea)
  601. /* Virtual Registers */
  602. #define CyRIVR (0x43*2)
  603. #define CyTIVR (0x42*2)
  604. #define CyMIVR (0x41*2)
  605. #define CyIVRMask (0x07)
  606. #define CyIVRRxEx (0x07)
  607. #define CyIVRRxOK (0x03)
  608. #define CyIVRTxOK (0x02)
  609. #define CyIVRMdmOK (0x01)
  610. #define CyTDR (0x63*2)
  611. #define CyRDSR (0x62*2)
  612. #define CyTIMEOUT (0x80)
  613. #define CySPECHAR (0x70)
  614. #define CyBREAK (0x08)
  615. #define CyPARITY (0x04)
  616. #define CyFRAME (0x02)
  617. #define CyOVERRUN (0x01)
  618. #define CyMISR (0x4C*2)
  619. /* see CyMCOR_ and CyMSVR_ for bits*/
  620. #define CyEOSRR (0x60*2)
  621. /* Channel Registers */
  622. #define CyLIVR (0x18*2)
  623. #define CyMscsr (0x01)
  624. #define CyTdsr (0x02)
  625. #define CyRgdsr (0x03)
  626. #define CyRedsr (0x07)
  627. #define CyCCR (0x05*2)
  628. /* Format 1 */
  629. #define CyCHAN_RESET (0x80)
  630. #define CyCHIP_RESET (0x81)
  631. #define CyFlushTransFIFO (0x82)
  632. /* Format 2 */
  633. #define CyCOR_CHANGE (0x40)
  634. #define CyCOR1ch (0x02)
  635. #define CyCOR2ch (0x04)
  636. #define CyCOR3ch (0x08)
  637. /* Format 3 */
  638. #define CySEND_SPEC_1 (0x21)
  639. #define CySEND_SPEC_2 (0x22)
  640. #define CySEND_SPEC_3 (0x23)
  641. #define CySEND_SPEC_4 (0x24)
  642. /* Format 4 */
  643. #define CyCHAN_CTL (0x10)
  644. #define CyDIS_RCVR (0x01)
  645. #define CyENB_RCVR (0x02)
  646. #define CyDIS_XMTR (0x04)
  647. #define CyENB_XMTR (0x08)
  648. #define CySRER (0x06*2)
  649. #define CyMdmCh (0x80)
  650. #define CyRxData (0x10)
  651. #define CyTxRdy (0x04)
  652. #define CyTxMpty (0x02)
  653. #define CyNNDT (0x01)
  654. #define CyCOR1 (0x08*2)
  655. #define CyPARITY_NONE (0x00)
  656. #define CyPARITY_0 (0x20)
  657. #define CyPARITY_1 (0xA0)
  658. #define CyPARITY_E (0x40)
  659. #define CyPARITY_O (0xC0)
  660. #define Cy_1_STOP (0x00)
  661. #define Cy_1_5_STOP (0x04)
  662. #define Cy_2_STOP (0x08)
  663. #define Cy_5_BITS (0x00)
  664. #define Cy_6_BITS (0x01)
  665. #define Cy_7_BITS (0x02)
  666. #define Cy_8_BITS (0x03)
  667. #define CyCOR2 (0x09*2)
  668. #define CyIXM (0x80)
  669. #define CyTxIBE (0x40)
  670. #define CyETC (0x20)
  671. #define CyAUTO_TXFL (0x60)
  672. #define CyLLM (0x10)
  673. #define CyRLM (0x08)
  674. #define CyRtsAO (0x04)
  675. #define CyCtsAE (0x02)
  676. #define CyDsrAE (0x01)
  677. #define CyCOR3 (0x0A*2)
  678. #define CySPL_CH_DRANGE (0x80) /* special character detect range */
  679. #define CySPL_CH_DET1 (0x40) /* enable special character detection
  680. on SCHR4-SCHR3 */
  681. #define CyFL_CTRL_TRNSP (0x20) /* Flow Control Transparency */
  682. #define CySPL_CH_DET2 (0x10) /* Enable special character detection
  683. on SCHR2-SCHR1 */
  684. #define CyREC_FIFO (0x0F) /* Receive FIFO threshold */
  685. #define CyCOR4 (0x1E*2)
  686. #define CyCOR5 (0x1F*2)
  687. #define CyCCSR (0x0B*2)
  688. #define CyRxEN (0x80)
  689. #define CyRxFloff (0x40)
  690. #define CyRxFlon (0x20)
  691. #define CyTxEN (0x08)
  692. #define CyTxFloff (0x04)
  693. #define CyTxFlon (0x02)
  694. #define CyRDCR (0x0E*2)
  695. #define CySCHR1 (0x1A*2)
  696. #define CySCHR2 (0x1B*2)
  697. #define CySCHR3 (0x1C*2)
  698. #define CySCHR4 (0x1D*2)
  699. #define CySCRL (0x22*2)
  700. #define CySCRH (0x23*2)
  701. #define CyLNC (0x24*2)
  702. #define CyMCOR1 (0x15*2)
  703. #define CyMCOR2 (0x16*2)
  704. #define CyRTPR (0x21*2)
  705. #define CyMSVR1 (0x6C*2)
  706. #define CyMSVR2 (0x6D*2)
  707. #define CyANY_DELTA (0xF0)
  708. #define CyDSR (0x80)
  709. #define CyCTS (0x40)
  710. #define CyRI (0x20)
  711. #define CyDCD (0x10)
  712. #define CyDTR (0x02)
  713. #define CyRTS (0x01)
  714. #define CyPVSR (0x6F*2)
  715. #define CyRBPR (0x78*2)
  716. #define CyRCOR (0x7C*2)
  717. #define CyTBPR (0x72*2)
  718. #define CyTCOR (0x76*2)
  719. /* Custom Registers */
  720. #define CyPLX_VER (0x3400)
  721. #define PLX_9050 0x0b
  722. #define PLX_9060 0x0c
  723. #define PLX_9080 0x0d
  724. /***************************************************************************/
  725. #endif /* __KERNEL__ */
  726. #endif /* _LINUX_CYCLADES_H */