rocket_int.h 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  1. /*
  2. * rocket_int.h --- internal header file for rocket.c
  3. *
  4. * Written by Theodore Ts'o, Copyright 1997.
  5. * Copyright 1997 Comtrol Corporation.
  6. *
  7. */
  8. /*
  9. * Definition of the types in rcktpt_type
  10. */
  11. #define ROCKET_TYPE_NORMAL 0
  12. #define ROCKET_TYPE_MODEM 1
  13. #define ROCKET_TYPE_MODEMII 2
  14. #define ROCKET_TYPE_MODEMIII 3
  15. #define ROCKET_TYPE_PC104 4
  16. #include <linux/mutex.h>
  17. #include <asm/io.h>
  18. #include <asm/byteorder.h>
  19. typedef unsigned char Byte_t;
  20. typedef unsigned int ByteIO_t;
  21. typedef unsigned int Word_t;
  22. typedef unsigned int WordIO_t;
  23. typedef unsigned long DWord_t;
  24. typedef unsigned int DWordIO_t;
  25. /*
  26. * Note! Normally the Linux I/O macros already take care of
  27. * byte-swapping the I/O instructions. However, all accesses using
  28. * sOutDW aren't really 32-bit accesses, but should be handled in byte
  29. * order. Hence the use of the cpu_to_le32() macro to byte-swap
  30. * things to no-op the byte swapping done by the big-endian outl()
  31. * instruction.
  32. */
  33. #ifdef ROCKET_DEBUG_IO
  34. static inline void sOutB(unsigned short port, unsigned char value)
  35. {
  36. #ifdef ROCKET_DEBUG_IO
  37. printk("sOutB(%x, %x)...", port, value);
  38. #endif
  39. outb_p(value, port);
  40. }
  41. static inline void sOutW(unsigned short port, unsigned short value)
  42. {
  43. #ifdef ROCKET_DEBUG_IO
  44. printk("sOutW(%x, %x)...", port, value);
  45. #endif
  46. outw_p(value, port);
  47. }
  48. static inline void sOutDW(unsigned short port, unsigned long value)
  49. {
  50. #ifdef ROCKET_DEBUG_IO
  51. printk("sOutDW(%x, %lx)...", port, value);
  52. #endif
  53. outl_p(cpu_to_le32(value), port);
  54. }
  55. static inline unsigned char sInB(unsigned short port)
  56. {
  57. return inb_p(port);
  58. }
  59. static inline unsigned short sInW(unsigned short port)
  60. {
  61. return inw_p(port);
  62. }
  63. #else /* !ROCKET_DEBUG_IO */
  64. #define sOutB(a, b) outb_p(b, a)
  65. #define sOutW(a, b) outw_p(b, a)
  66. #define sOutDW(port, value) outl_p(cpu_to_le32(value), port)
  67. #define sInB(a) (inb_p(a))
  68. #define sInW(a) (inw_p(a))
  69. #endif /* ROCKET_DEBUG_IO */
  70. /* This is used to move arrays of bytes so byte swapping isn't appropriate. */
  71. #define sOutStrW(port, addr, count) if (count) outsw(port, addr, count)
  72. #define sInStrW(port, addr, count) if (count) insw(port, addr, count)
  73. #define CTL_SIZE 8
  74. #define AIOP_CTL_SIZE 4
  75. #define CHAN_AIOP_SIZE 8
  76. #define MAX_PORTS_PER_AIOP 8
  77. #define MAX_AIOPS_PER_BOARD 4
  78. #define MAX_PORTS_PER_BOARD 32
  79. /* Bus type ID */
  80. #define isISA 0
  81. #define isPCI 1
  82. #define isMC 2
  83. /* Controller ID numbers */
  84. #define CTLID_NULL -1 /* no controller exists */
  85. #define CTLID_0001 0x0001 /* controller release 1 */
  86. /* AIOP ID numbers, identifies AIOP type implementing channel */
  87. #define AIOPID_NULL -1 /* no AIOP or channel exists */
  88. #define AIOPID_0001 0x0001 /* AIOP release 1 */
  89. #define NULLDEV -1 /* identifies non-existant device */
  90. #define NULLCTL -1 /* identifies non-existant controller */
  91. #define NULLCTLPTR (CONTROLLER_T *)0 /* identifies non-existant controller */
  92. #define NULLAIOP -1 /* identifies non-existant AIOP */
  93. #define NULLCHAN -1 /* identifies non-existant channel */
  94. /************************************************************************
  95. Global Register Offsets - Direct Access - Fixed values
  96. ************************************************************************/
  97. #define _CMD_REG 0x38 /* Command Register 8 Write */
  98. #define _INT_CHAN 0x39 /* Interrupt Channel Register 8 Read */
  99. #define _INT_MASK 0x3A /* Interrupt Mask Register 8 Read / Write */
  100. #define _UNUSED 0x3B /* Unused 8 */
  101. #define _INDX_ADDR 0x3C /* Index Register Address 16 Write */
  102. #define _INDX_DATA 0x3E /* Index Register Data 8/16 Read / Write */
  103. /************************************************************************
  104. Channel Register Offsets for 1st channel in AIOP - Direct Access
  105. ************************************************************************/
  106. #define _TD0 0x00 /* Transmit Data 16 Write */
  107. #define _RD0 0x00 /* Receive Data 16 Read */
  108. #define _CHN_STAT0 0x20 /* Channel Status 8/16 Read / Write */
  109. #define _FIFO_CNT0 0x10 /* Transmit/Receive FIFO Count 16 Read */
  110. #define _INT_ID0 0x30 /* Interrupt Identification 8 Read */
  111. /************************************************************************
  112. Tx Control Register Offsets - Indexed - External - Fixed
  113. ************************************************************************/
  114. #define _TX_ENBLS 0x980 /* Tx Processor Enables Register 8 Read / Write */
  115. #define _TXCMP1 0x988 /* Transmit Compare Value #1 8 Read / Write */
  116. #define _TXCMP2 0x989 /* Transmit Compare Value #2 8 Read / Write */
  117. #define _TXREP1B1 0x98A /* Tx Replace Value #1 - Byte 1 8 Read / Write */
  118. #define _TXREP1B2 0x98B /* Tx Replace Value #1 - Byte 2 8 Read / Write */
  119. #define _TXREP2 0x98C /* Transmit Replace Value #2 8 Read / Write */
  120. /************************************************************************
  121. Memory Controller Register Offsets - Indexed - External - Fixed
  122. ************************************************************************/
  123. #define _RX_FIFO 0x000 /* Rx FIFO */
  124. #define _TX_FIFO 0x800 /* Tx FIFO */
  125. #define _RXF_OUTP 0x990 /* Rx FIFO OUT pointer 16 Read / Write */
  126. #define _RXF_INP 0x992 /* Rx FIFO IN pointer 16 Read / Write */
  127. #define _TXF_OUTP 0x994 /* Tx FIFO OUT pointer 8 Read / Write */
  128. #define _TXF_INP 0x995 /* Tx FIFO IN pointer 8 Read / Write */
  129. #define _TXP_CNT 0x996 /* Tx Priority Count 8 Read / Write */
  130. #define _TXP_PNTR 0x997 /* Tx Priority Pointer 8 Read / Write */
  131. #define PRI_PEND 0x80 /* Priority data pending (bit7, Tx pri cnt) */
  132. #define TXFIFO_SIZE 255 /* size of Tx FIFO */
  133. #define RXFIFO_SIZE 1023 /* size of Rx FIFO */
  134. /************************************************************************
  135. Tx Priority Buffer - Indexed - External - Fixed
  136. ************************************************************************/
  137. #define _TXP_BUF 0x9C0 /* Tx Priority Buffer 32 Bytes Read / Write */
  138. #define TXP_SIZE 0x20 /* 32 bytes */
  139. /************************************************************************
  140. Channel Register Offsets - Indexed - Internal - Fixed
  141. ************************************************************************/
  142. #define _TX_CTRL 0xFF0 /* Transmit Control 16 Write */
  143. #define _RX_CTRL 0xFF2 /* Receive Control 8 Write */
  144. #define _BAUD 0xFF4 /* Baud Rate 16 Write */
  145. #define _CLK_PRE 0xFF6 /* Clock Prescaler 8 Write */
  146. #define STMBREAK 0x08 /* BREAK */
  147. #define STMFRAME 0x04 /* framing error */
  148. #define STMRCVROVR 0x02 /* receiver over run error */
  149. #define STMPARITY 0x01 /* parity error */
  150. #define STMERROR (STMBREAK | STMFRAME | STMPARITY)
  151. #define STMBREAKH 0x800 /* BREAK */
  152. #define STMFRAMEH 0x400 /* framing error */
  153. #define STMRCVROVRH 0x200 /* receiver over run error */
  154. #define STMPARITYH 0x100 /* parity error */
  155. #define STMERRORH (STMBREAKH | STMFRAMEH | STMPARITYH)
  156. #define CTS_ACT 0x20 /* CTS input asserted */
  157. #define DSR_ACT 0x10 /* DSR input asserted */
  158. #define CD_ACT 0x08 /* CD input asserted */
  159. #define TXFIFOMT 0x04 /* Tx FIFO is empty */
  160. #define TXSHRMT 0x02 /* Tx shift register is empty */
  161. #define RDA 0x01 /* Rx data available */
  162. #define DRAINED (TXFIFOMT | TXSHRMT) /* indicates Tx is drained */
  163. #define STATMODE 0x8000 /* status mode enable bit */
  164. #define RXFOVERFL 0x2000 /* receive FIFO overflow */
  165. #define RX2MATCH 0x1000 /* receive compare byte 2 match */
  166. #define RX1MATCH 0x0800 /* receive compare byte 1 match */
  167. #define RXBREAK 0x0400 /* received BREAK */
  168. #define RXFRAME 0x0200 /* received framing error */
  169. #define RXPARITY 0x0100 /* received parity error */
  170. #define STATERROR (RXBREAK | RXFRAME | RXPARITY)
  171. #define CTSFC_EN 0x80 /* CTS flow control enable bit */
  172. #define RTSTOG_EN 0x40 /* RTS toggle enable bit */
  173. #define TXINT_EN 0x10 /* transmit interrupt enable */
  174. #define STOP2 0x08 /* enable 2 stop bits (0 = 1 stop) */
  175. #define PARITY_EN 0x04 /* enable parity (0 = no parity) */
  176. #define EVEN_PAR 0x02 /* even parity (0 = odd parity) */
  177. #define DATA8BIT 0x01 /* 8 bit data (0 = 7 bit data) */
  178. #define SETBREAK 0x10 /* send break condition (must clear) */
  179. #define LOCALLOOP 0x08 /* local loopback set for test */
  180. #define SET_DTR 0x04 /* assert DTR */
  181. #define SET_RTS 0x02 /* assert RTS */
  182. #define TX_ENABLE 0x01 /* enable transmitter */
  183. #define RTSFC_EN 0x40 /* RTS flow control enable */
  184. #define RXPROC_EN 0x20 /* receive processor enable */
  185. #define TRIG_NO 0x00 /* Rx FIFO trigger level 0 (no trigger) */
  186. #define TRIG_1 0x08 /* trigger level 1 char */
  187. #define TRIG_1_2 0x10 /* trigger level 1/2 */
  188. #define TRIG_7_8 0x18 /* trigger level 7/8 */
  189. #define TRIG_MASK 0x18 /* trigger level mask */
  190. #define SRCINT_EN 0x04 /* special Rx condition interrupt enable */
  191. #define RXINT_EN 0x02 /* Rx interrupt enable */
  192. #define MCINT_EN 0x01 /* modem change interrupt enable */
  193. #define RXF_TRIG 0x20 /* Rx FIFO trigger level interrupt */
  194. #define TXFIFO_MT 0x10 /* Tx FIFO empty interrupt */
  195. #define SRC_INT 0x08 /* special receive condition interrupt */
  196. #define DELTA_CD 0x04 /* CD change interrupt */
  197. #define DELTA_CTS 0x02 /* CTS change interrupt */
  198. #define DELTA_DSR 0x01 /* DSR change interrupt */
  199. #define REP1W2_EN 0x10 /* replace byte 1 with 2 bytes enable */
  200. #define IGN2_EN 0x08 /* ignore byte 2 enable */
  201. #define IGN1_EN 0x04 /* ignore byte 1 enable */
  202. #define COMP2_EN 0x02 /* compare byte 2 enable */
  203. #define COMP1_EN 0x01 /* compare byte 1 enable */
  204. #define RESET_ALL 0x80 /* reset AIOP (all channels) */
  205. #define TXOVERIDE 0x40 /* Transmit software off override */
  206. #define RESETUART 0x20 /* reset channel's UART */
  207. #define RESTXFCNT 0x10 /* reset channel's Tx FIFO count register */
  208. #define RESRXFCNT 0x08 /* reset channel's Rx FIFO count register */
  209. #define INTSTAT0 0x01 /* AIOP 0 interrupt status */
  210. #define INTSTAT1 0x02 /* AIOP 1 interrupt status */
  211. #define INTSTAT2 0x04 /* AIOP 2 interrupt status */
  212. #define INTSTAT3 0x08 /* AIOP 3 interrupt status */
  213. #define INTR_EN 0x08 /* allow interrupts to host */
  214. #define INT_STROB 0x04 /* strobe and clear interrupt line (EOI) */
  215. /**************************************************************************
  216. MUDBAC remapped for PCI
  217. **************************************************************************/
  218. #define _CFG_INT_PCI 0x40
  219. #define _PCI_INT_FUNC 0x3A
  220. #define PCI_STROB 0x2000 /* bit 13 of int aiop register */
  221. #define INTR_EN_PCI 0x0010 /* allow interrupts to host */
  222. /*
  223. * Definitions for Universal PCI board registers
  224. */
  225. #define _PCI_9030_INT_CTRL 0x4c /* Offsets from BAR1 */
  226. #define _PCI_9030_GPIO_CTRL 0x54
  227. #define PCI_INT_CTRL_AIOP 0x0001
  228. #define PCI_GPIO_CTRL_8PORT 0x4000
  229. #define _PCI_9030_RING_IND 0xc0 /* Offsets from BAR1 */
  230. #define CHAN3_EN 0x08 /* enable AIOP 3 */
  231. #define CHAN2_EN 0x04 /* enable AIOP 2 */
  232. #define CHAN1_EN 0x02 /* enable AIOP 1 */
  233. #define CHAN0_EN 0x01 /* enable AIOP 0 */
  234. #define FREQ_DIS 0x00
  235. #define FREQ_274HZ 0x60
  236. #define FREQ_137HZ 0x50
  237. #define FREQ_69HZ 0x40
  238. #define FREQ_34HZ 0x30
  239. #define FREQ_17HZ 0x20
  240. #define FREQ_9HZ 0x10
  241. #define PERIODIC_ONLY 0x80 /* only PERIODIC interrupt */
  242. #define CHANINT_EN 0x0100 /* flags to enable/disable channel ints */
  243. #define RDATASIZE 72
  244. #define RREGDATASIZE 52
  245. /*
  246. * AIOP interrupt bits for ISA/PCI boards and UPCI boards.
  247. */
  248. #define AIOP_INTR_BIT_0 0x0001
  249. #define AIOP_INTR_BIT_1 0x0002
  250. #define AIOP_INTR_BIT_2 0x0004
  251. #define AIOP_INTR_BIT_3 0x0008
  252. #define AIOP_INTR_BITS ( \
  253. AIOP_INTR_BIT_0 \
  254. | AIOP_INTR_BIT_1 \
  255. | AIOP_INTR_BIT_2 \
  256. | AIOP_INTR_BIT_3)
  257. #define UPCI_AIOP_INTR_BIT_0 0x0004
  258. #define UPCI_AIOP_INTR_BIT_1 0x0020
  259. #define UPCI_AIOP_INTR_BIT_2 0x0100
  260. #define UPCI_AIOP_INTR_BIT_3 0x0800
  261. #define UPCI_AIOP_INTR_BITS ( \
  262. UPCI_AIOP_INTR_BIT_0 \
  263. | UPCI_AIOP_INTR_BIT_1 \
  264. | UPCI_AIOP_INTR_BIT_2 \
  265. | UPCI_AIOP_INTR_BIT_3)
  266. /* Controller level information structure */
  267. typedef struct {
  268. int CtlID;
  269. int CtlNum;
  270. int BusType;
  271. int boardType;
  272. int isUPCI;
  273. WordIO_t PCIIO;
  274. WordIO_t PCIIO2;
  275. ByteIO_t MBaseIO;
  276. ByteIO_t MReg1IO;
  277. ByteIO_t MReg2IO;
  278. ByteIO_t MReg3IO;
  279. Byte_t MReg2;
  280. Byte_t MReg3;
  281. int NumAiop;
  282. int AltChanRingIndicator;
  283. ByteIO_t UPCIRingInd;
  284. WordIO_t AiopIO[AIOP_CTL_SIZE];
  285. ByteIO_t AiopIntChanIO[AIOP_CTL_SIZE];
  286. int AiopID[AIOP_CTL_SIZE];
  287. int AiopNumChan[AIOP_CTL_SIZE];
  288. Word_t *AiopIntrBits;
  289. } CONTROLLER_T;
  290. typedef CONTROLLER_T CONTROLLER_t;
  291. /* Channel level information structure */
  292. typedef struct {
  293. CONTROLLER_T *CtlP;
  294. int AiopNum;
  295. int ChanID;
  296. int ChanNum;
  297. int rtsToggle;
  298. ByteIO_t Cmd;
  299. ByteIO_t IntChan;
  300. ByteIO_t IntMask;
  301. DWordIO_t IndexAddr;
  302. WordIO_t IndexData;
  303. WordIO_t TxRxData;
  304. WordIO_t ChanStat;
  305. WordIO_t TxRxCount;
  306. ByteIO_t IntID;
  307. Word_t TxFIFO;
  308. Word_t TxFIFOPtrs;
  309. Word_t RxFIFO;
  310. Word_t RxFIFOPtrs;
  311. Word_t TxPrioCnt;
  312. Word_t TxPrioPtr;
  313. Word_t TxPrioBuf;
  314. Byte_t R[RREGDATASIZE];
  315. Byte_t BaudDiv[4];
  316. Byte_t TxControl[4];
  317. Byte_t RxControl[4];
  318. Byte_t TxEnables[4];
  319. Byte_t TxCompare[4];
  320. Byte_t TxReplace1[4];
  321. Byte_t TxReplace2[4];
  322. } CHANNEL_T;
  323. typedef CHANNEL_T CHANNEL_t;
  324. typedef CHANNEL_T *CHANPTR_T;
  325. #define InterfaceModeRS232 0x00
  326. #define InterfaceModeRS422 0x08
  327. #define InterfaceModeRS485 0x10
  328. #define InterfaceModeRS232T 0x18
  329. /***************************************************************************
  330. Function: sClrBreak
  331. Purpose: Stop sending a transmit BREAK signal
  332. Call: sClrBreak(ChP)
  333. CHANNEL_T *ChP; Ptr to channel structure
  334. */
  335. #define sClrBreak(ChP) \
  336. do { \
  337. (ChP)->TxControl[3] &= ~SETBREAK; \
  338. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  339. } while (0)
  340. /***************************************************************************
  341. Function: sClrDTR
  342. Purpose: Clr the DTR output
  343. Call: sClrDTR(ChP)
  344. CHANNEL_T *ChP; Ptr to channel structure
  345. */
  346. #define sClrDTR(ChP) \
  347. do { \
  348. (ChP)->TxControl[3] &= ~SET_DTR; \
  349. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  350. } while (0)
  351. /***************************************************************************
  352. Function: sClrRTS
  353. Purpose: Clr the RTS output
  354. Call: sClrRTS(ChP)
  355. CHANNEL_T *ChP; Ptr to channel structure
  356. */
  357. #define sClrRTS(ChP) \
  358. do { \
  359. if ((ChP)->rtsToggle) break; \
  360. (ChP)->TxControl[3] &= ~SET_RTS; \
  361. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  362. } while (0)
  363. /***************************************************************************
  364. Function: sClrTxXOFF
  365. Purpose: Clear any existing transmit software flow control off condition
  366. Call: sClrTxXOFF(ChP)
  367. CHANNEL_T *ChP; Ptr to channel structure
  368. */
  369. #define sClrTxXOFF(ChP) \
  370. do { \
  371. sOutB((ChP)->Cmd,TXOVERIDE | (Byte_t)(ChP)->ChanNum); \
  372. sOutB((ChP)->Cmd,(Byte_t)(ChP)->ChanNum); \
  373. } while (0)
  374. /***************************************************************************
  375. Function: sCtlNumToCtlPtr
  376. Purpose: Convert a controller number to controller structure pointer
  377. Call: sCtlNumToCtlPtr(CtlNum)
  378. int CtlNum; Controller number
  379. Return: CONTROLLER_T *: Ptr to controller structure
  380. */
  381. #define sCtlNumToCtlPtr(CTLNUM) &sController[CTLNUM]
  382. /***************************************************************************
  383. Function: sControllerEOI
  384. Purpose: Strobe the MUDBAC's End Of Interrupt bit.
  385. Call: sControllerEOI(CtlP)
  386. CONTROLLER_T *CtlP; Ptr to controller structure
  387. */
  388. #define sControllerEOI(CTLP) sOutB((CTLP)->MReg2IO,(CTLP)->MReg2 | INT_STROB)
  389. /***************************************************************************
  390. Function: sPCIControllerEOI
  391. Purpose: Strobe the PCI End Of Interrupt bit.
  392. For the UPCI boards, toggle the AIOP interrupt enable bit
  393. (this was taken from the Windows driver).
  394. Call: sPCIControllerEOI(CtlP)
  395. CONTROLLER_T *CtlP; Ptr to controller structure
  396. */
  397. #define sPCIControllerEOI(CTLP) \
  398. do { \
  399. if ((CTLP)->isUPCI) { \
  400. Word_t w = sInW((CTLP)->PCIIO); \
  401. sOutW((CTLP)->PCIIO, (w ^ PCI_INT_CTRL_AIOP)); \
  402. sOutW((CTLP)->PCIIO, w); \
  403. } \
  404. else { \
  405. sOutW((CTLP)->PCIIO, PCI_STROB); \
  406. } \
  407. } while (0)
  408. /***************************************************************************
  409. Function: sDisAiop
  410. Purpose: Disable I/O access to an AIOP
  411. Call: sDisAiop(CltP)
  412. CONTROLLER_T *CtlP; Ptr to controller structure
  413. int AiopNum; Number of AIOP on controller
  414. */
  415. #define sDisAiop(CTLP,AIOPNUM) \
  416. do { \
  417. (CTLP)->MReg3 &= sBitMapClrTbl[AIOPNUM]; \
  418. sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
  419. } while (0)
  420. /***************************************************************************
  421. Function: sDisCTSFlowCtl
  422. Purpose: Disable output flow control using CTS
  423. Call: sDisCTSFlowCtl(ChP)
  424. CHANNEL_T *ChP; Ptr to channel structure
  425. */
  426. #define sDisCTSFlowCtl(ChP) \
  427. do { \
  428. (ChP)->TxControl[2] &= ~CTSFC_EN; \
  429. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  430. } while (0)
  431. /***************************************************************************
  432. Function: sDisIXANY
  433. Purpose: Disable IXANY Software Flow Control
  434. Call: sDisIXANY(ChP)
  435. CHANNEL_T *ChP; Ptr to channel structure
  436. */
  437. #define sDisIXANY(ChP) \
  438. do { \
  439. (ChP)->R[0x0e] = 0x86; \
  440. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x0c]); \
  441. } while (0)
  442. /***************************************************************************
  443. Function: DisParity
  444. Purpose: Disable parity
  445. Call: sDisParity(ChP)
  446. CHANNEL_T *ChP; Ptr to channel structure
  447. Comments: Function sSetParity() can be used in place of functions sEnParity(),
  448. sDisParity(), sSetOddParity(), and sSetEvenParity().
  449. */
  450. #define sDisParity(ChP) \
  451. do { \
  452. (ChP)->TxControl[2] &= ~PARITY_EN; \
  453. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  454. } while (0)
  455. /***************************************************************************
  456. Function: sDisRTSToggle
  457. Purpose: Disable RTS toggle
  458. Call: sDisRTSToggle(ChP)
  459. CHANNEL_T *ChP; Ptr to channel structure
  460. */
  461. #define sDisRTSToggle(ChP) \
  462. do { \
  463. (ChP)->TxControl[2] &= ~RTSTOG_EN; \
  464. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  465. (ChP)->rtsToggle = 0; \
  466. } while (0)
  467. /***************************************************************************
  468. Function: sDisRxFIFO
  469. Purpose: Disable Rx FIFO
  470. Call: sDisRxFIFO(ChP)
  471. CHANNEL_T *ChP; Ptr to channel structure
  472. */
  473. #define sDisRxFIFO(ChP) \
  474. do { \
  475. (ChP)->R[0x32] = 0x0a; \
  476. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
  477. } while (0)
  478. /***************************************************************************
  479. Function: sDisRxStatusMode
  480. Purpose: Disable the Rx status mode
  481. Call: sDisRxStatusMode(ChP)
  482. CHANNEL_T *ChP; Ptr to channel structure
  483. Comments: This takes the channel out of the receive status mode. All
  484. subsequent reads of receive data using sReadRxWord() will return
  485. two data bytes.
  486. */
  487. #define sDisRxStatusMode(ChP) sOutW((ChP)->ChanStat,0)
  488. /***************************************************************************
  489. Function: sDisTransmit
  490. Purpose: Disable transmit
  491. Call: sDisTransmit(ChP)
  492. CHANNEL_T *ChP; Ptr to channel structure
  493. This disables movement of Tx data from the Tx FIFO into the 1 byte
  494. Tx buffer. Therefore there could be up to a 2 byte latency
  495. between the time sDisTransmit() is called and the transmit buffer
  496. and transmit shift register going completely empty.
  497. */
  498. #define sDisTransmit(ChP) \
  499. do { \
  500. (ChP)->TxControl[3] &= ~TX_ENABLE; \
  501. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  502. } while (0)
  503. /***************************************************************************
  504. Function: sDisTxSoftFlowCtl
  505. Purpose: Disable Tx Software Flow Control
  506. Call: sDisTxSoftFlowCtl(ChP)
  507. CHANNEL_T *ChP; Ptr to channel structure
  508. */
  509. #define sDisTxSoftFlowCtl(ChP) \
  510. do { \
  511. (ChP)->R[0x06] = 0x8a; \
  512. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \
  513. } while (0)
  514. /***************************************************************************
  515. Function: sEnAiop
  516. Purpose: Enable I/O access to an AIOP
  517. Call: sEnAiop(CltP)
  518. CONTROLLER_T *CtlP; Ptr to controller structure
  519. int AiopNum; Number of AIOP on controller
  520. */
  521. #define sEnAiop(CTLP,AIOPNUM) \
  522. do { \
  523. (CTLP)->MReg3 |= sBitMapSetTbl[AIOPNUM]; \
  524. sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
  525. } while (0)
  526. /***************************************************************************
  527. Function: sEnCTSFlowCtl
  528. Purpose: Enable output flow control using CTS
  529. Call: sEnCTSFlowCtl(ChP)
  530. CHANNEL_T *ChP; Ptr to channel structure
  531. */
  532. #define sEnCTSFlowCtl(ChP) \
  533. do { \
  534. (ChP)->TxControl[2] |= CTSFC_EN; \
  535. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  536. } while (0)
  537. /***************************************************************************
  538. Function: sEnIXANY
  539. Purpose: Enable IXANY Software Flow Control
  540. Call: sEnIXANY(ChP)
  541. CHANNEL_T *ChP; Ptr to channel structure
  542. */
  543. #define sEnIXANY(ChP) \
  544. do { \
  545. (ChP)->R[0x0e] = 0x21; \
  546. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x0c]); \
  547. } while (0)
  548. /***************************************************************************
  549. Function: EnParity
  550. Purpose: Enable parity
  551. Call: sEnParity(ChP)
  552. CHANNEL_T *ChP; Ptr to channel structure
  553. Comments: Function sSetParity() can be used in place of functions sEnParity(),
  554. sDisParity(), sSetOddParity(), and sSetEvenParity().
  555. Warnings: Before enabling parity odd or even parity should be chosen using
  556. functions sSetOddParity() or sSetEvenParity().
  557. */
  558. #define sEnParity(ChP) \
  559. do { \
  560. (ChP)->TxControl[2] |= PARITY_EN; \
  561. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  562. } while (0)
  563. /***************************************************************************
  564. Function: sEnRTSToggle
  565. Purpose: Enable RTS toggle
  566. Call: sEnRTSToggle(ChP)
  567. CHANNEL_T *ChP; Ptr to channel structure
  568. Comments: This function will disable RTS flow control and clear the RTS
  569. line to allow operation of RTS toggle.
  570. */
  571. #define sEnRTSToggle(ChP) \
  572. do { \
  573. (ChP)->RxControl[2] &= ~RTSFC_EN; \
  574. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
  575. (ChP)->TxControl[2] |= RTSTOG_EN; \
  576. (ChP)->TxControl[3] &= ~SET_RTS; \
  577. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  578. (ChP)->rtsToggle = 1; \
  579. } while (0)
  580. /***************************************************************************
  581. Function: sEnRxFIFO
  582. Purpose: Enable Rx FIFO
  583. Call: sEnRxFIFO(ChP)
  584. CHANNEL_T *ChP; Ptr to channel structure
  585. */
  586. #define sEnRxFIFO(ChP) \
  587. do { \
  588. (ChP)->R[0x32] = 0x08; \
  589. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
  590. } while (0)
  591. /***************************************************************************
  592. Function: sEnRxProcessor
  593. Purpose: Enable the receive processor
  594. Call: sEnRxProcessor(ChP)
  595. CHANNEL_T *ChP; Ptr to channel structure
  596. Comments: This function is used to start the receive processor. When
  597. the channel is in the reset state the receive processor is not
  598. running. This is done to prevent the receive processor from
  599. executing invalid microcode instructions prior to the
  600. downloading of the microcode.
  601. Warnings: This function must be called after valid microcode has been
  602. downloaded to the AIOP, and it must not be called before the
  603. microcode has been downloaded.
  604. */
  605. #define sEnRxProcessor(ChP) \
  606. do { \
  607. (ChP)->RxControl[2] |= RXPROC_EN; \
  608. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
  609. } while (0)
  610. /***************************************************************************
  611. Function: sEnRxStatusMode
  612. Purpose: Enable the Rx status mode
  613. Call: sEnRxStatusMode(ChP)
  614. CHANNEL_T *ChP; Ptr to channel structure
  615. Comments: This places the channel in the receive status mode. All subsequent
  616. reads of receive data using sReadRxWord() will return a data byte
  617. in the low word and a status byte in the high word.
  618. */
  619. #define sEnRxStatusMode(ChP) sOutW((ChP)->ChanStat,STATMODE)
  620. /***************************************************************************
  621. Function: sEnTransmit
  622. Purpose: Enable transmit
  623. Call: sEnTransmit(ChP)
  624. CHANNEL_T *ChP; Ptr to channel structure
  625. */
  626. #define sEnTransmit(ChP) \
  627. do { \
  628. (ChP)->TxControl[3] |= TX_ENABLE; \
  629. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  630. } while (0)
  631. /***************************************************************************
  632. Function: sEnTxSoftFlowCtl
  633. Purpose: Enable Tx Software Flow Control
  634. Call: sEnTxSoftFlowCtl(ChP)
  635. CHANNEL_T *ChP; Ptr to channel structure
  636. */
  637. #define sEnTxSoftFlowCtl(ChP) \
  638. do { \
  639. (ChP)->R[0x06] = 0xc5; \
  640. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \
  641. } while (0)
  642. /***************************************************************************
  643. Function: sGetAiopIntStatus
  644. Purpose: Get the AIOP interrupt status
  645. Call: sGetAiopIntStatus(CtlP,AiopNum)
  646. CONTROLLER_T *CtlP; Ptr to controller structure
  647. int AiopNum; AIOP number
  648. Return: Byte_t: The AIOP interrupt status. Bits 0 through 7
  649. represent channels 0 through 7 respectively. If a
  650. bit is set that channel is interrupting.
  651. */
  652. #define sGetAiopIntStatus(CTLP,AIOPNUM) sInB((CTLP)->AiopIntChanIO[AIOPNUM])
  653. /***************************************************************************
  654. Function: sGetAiopNumChan
  655. Purpose: Get the number of channels supported by an AIOP
  656. Call: sGetAiopNumChan(CtlP,AiopNum)
  657. CONTROLLER_T *CtlP; Ptr to controller structure
  658. int AiopNum; AIOP number
  659. Return: int: The number of channels supported by the AIOP
  660. */
  661. #define sGetAiopNumChan(CTLP,AIOPNUM) (CTLP)->AiopNumChan[AIOPNUM]
  662. /***************************************************************************
  663. Function: sGetChanIntID
  664. Purpose: Get a channel's interrupt identification byte
  665. Call: sGetChanIntID(ChP)
  666. CHANNEL_T *ChP; Ptr to channel structure
  667. Return: Byte_t: The channel interrupt ID. Can be any
  668. combination of the following flags:
  669. RXF_TRIG: Rx FIFO trigger level interrupt
  670. TXFIFO_MT: Tx FIFO empty interrupt
  671. SRC_INT: Special receive condition interrupt
  672. DELTA_CD: CD change interrupt
  673. DELTA_CTS: CTS change interrupt
  674. DELTA_DSR: DSR change interrupt
  675. */
  676. #define sGetChanIntID(ChP) (sInB((ChP)->IntID) & (RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR))
  677. /***************************************************************************
  678. Function: sGetChanNum
  679. Purpose: Get the number of a channel within an AIOP
  680. Call: sGetChanNum(ChP)
  681. CHANNEL_T *ChP; Ptr to channel structure
  682. Return: int: Channel number within AIOP, or NULLCHAN if channel does
  683. not exist.
  684. */
  685. #define sGetChanNum(ChP) (ChP)->ChanNum
  686. /***************************************************************************
  687. Function: sGetChanStatus
  688. Purpose: Get the channel status
  689. Call: sGetChanStatus(ChP)
  690. CHANNEL_T *ChP; Ptr to channel structure
  691. Return: Word_t: The channel status. Can be any combination of
  692. the following flags:
  693. LOW BYTE FLAGS
  694. CTS_ACT: CTS input asserted
  695. DSR_ACT: DSR input asserted
  696. CD_ACT: CD input asserted
  697. TXFIFOMT: Tx FIFO is empty
  698. TXSHRMT: Tx shift register is empty
  699. RDA: Rx data available
  700. HIGH BYTE FLAGS
  701. STATMODE: status mode enable bit
  702. RXFOVERFL: receive FIFO overflow
  703. RX2MATCH: receive compare byte 2 match
  704. RX1MATCH: receive compare byte 1 match
  705. RXBREAK: received BREAK
  706. RXFRAME: received framing error
  707. RXPARITY: received parity error
  708. Warnings: This function will clear the high byte flags in the Channel
  709. Status Register.
  710. */
  711. #define sGetChanStatus(ChP) sInW((ChP)->ChanStat)
  712. /***************************************************************************
  713. Function: sGetChanStatusLo
  714. Purpose: Get the low byte only of the channel status
  715. Call: sGetChanStatusLo(ChP)
  716. CHANNEL_T *ChP; Ptr to channel structure
  717. Return: Byte_t: The channel status low byte. Can be any combination
  718. of the following flags:
  719. CTS_ACT: CTS input asserted
  720. DSR_ACT: DSR input asserted
  721. CD_ACT: CD input asserted
  722. TXFIFOMT: Tx FIFO is empty
  723. TXSHRMT: Tx shift register is empty
  724. RDA: Rx data available
  725. */
  726. #define sGetChanStatusLo(ChP) sInB((ByteIO_t)(ChP)->ChanStat)
  727. /**********************************************************************
  728. * Get RI status of channel
  729. * Defined as a function in rocket.c -aes
  730. */
  731. #if 0
  732. #define sGetChanRI(ChP) ((ChP)->CtlP->AltChanRingIndicator ? \
  733. (sInB((ByteIO_t)((ChP)->ChanStat+8)) & DSR_ACT) : \
  734. (((ChP)->CtlP->boardType == ROCKET_TYPE_PC104) ? \
  735. (!(sInB((ChP)->CtlP->AiopIO[3]) & sBitMapSetTbl[(ChP)->ChanNum])) : \
  736. 0))
  737. #endif
  738. /***************************************************************************
  739. Function: sGetControllerIntStatus
  740. Purpose: Get the controller interrupt status
  741. Call: sGetControllerIntStatus(CtlP)
  742. CONTROLLER_T *CtlP; Ptr to controller structure
  743. Return: Byte_t: The controller interrupt status in the lower 4
  744. bits. Bits 0 through 3 represent AIOP's 0
  745. through 3 respectively. If a bit is set that
  746. AIOP is interrupting. Bits 4 through 7 will
  747. always be cleared.
  748. */
  749. #define sGetControllerIntStatus(CTLP) (sInB((CTLP)->MReg1IO) & 0x0f)
  750. /***************************************************************************
  751. Function: sPCIGetControllerIntStatus
  752. Purpose: Get the controller interrupt status
  753. Call: sPCIGetControllerIntStatus(CtlP)
  754. CONTROLLER_T *CtlP; Ptr to controller structure
  755. Return: unsigned char: The controller interrupt status in the lower 4
  756. bits and bit 4. Bits 0 through 3 represent AIOP's 0
  757. through 3 respectively. Bit 4 is set if the int
  758. was generated from periodic. If a bit is set the
  759. AIOP is interrupting.
  760. */
  761. #define sPCIGetControllerIntStatus(CTLP) \
  762. ((CTLP)->isUPCI ? \
  763. (sInW((CTLP)->PCIIO2) & UPCI_AIOP_INTR_BITS) : \
  764. ((sInW((CTLP)->PCIIO) >> 8) & AIOP_INTR_BITS))
  765. /***************************************************************************
  766. Function: sGetRxCnt
  767. Purpose: Get the number of data bytes in the Rx FIFO
  768. Call: sGetRxCnt(ChP)
  769. CHANNEL_T *ChP; Ptr to channel structure
  770. Return: int: The number of data bytes in the Rx FIFO.
  771. Comments: Byte read of count register is required to obtain Rx count.
  772. */
  773. #define sGetRxCnt(ChP) sInW((ChP)->TxRxCount)
  774. /***************************************************************************
  775. Function: sGetTxCnt
  776. Purpose: Get the number of data bytes in the Tx FIFO
  777. Call: sGetTxCnt(ChP)
  778. CHANNEL_T *ChP; Ptr to channel structure
  779. Return: Byte_t: The number of data bytes in the Tx FIFO.
  780. Comments: Byte read of count register is required to obtain Tx count.
  781. */
  782. #define sGetTxCnt(ChP) sInB((ByteIO_t)(ChP)->TxRxCount)
  783. /*****************************************************************************
  784. Function: sGetTxRxDataIO
  785. Purpose: Get the I/O address of a channel's TxRx Data register
  786. Call: sGetTxRxDataIO(ChP)
  787. CHANNEL_T *ChP; Ptr to channel structure
  788. Return: WordIO_t: I/O address of a channel's TxRx Data register
  789. */
  790. #define sGetTxRxDataIO(ChP) (ChP)->TxRxData
  791. /***************************************************************************
  792. Function: sInitChanDefaults
  793. Purpose: Initialize a channel structure to it's default state.
  794. Call: sInitChanDefaults(ChP)
  795. CHANNEL_T *ChP; Ptr to the channel structure
  796. Comments: This function must be called once for every channel structure
  797. that exists before any other SSCI calls can be made.
  798. */
  799. #define sInitChanDefaults(ChP) \
  800. do { \
  801. (ChP)->CtlP = NULLCTLPTR; \
  802. (ChP)->AiopNum = NULLAIOP; \
  803. (ChP)->ChanID = AIOPID_NULL; \
  804. (ChP)->ChanNum = NULLCHAN; \
  805. } while (0)
  806. /***************************************************************************
  807. Function: sResetAiopByNum
  808. Purpose: Reset the AIOP by number
  809. Call: sResetAiopByNum(CTLP,AIOPNUM)
  810. CONTROLLER_T CTLP; Ptr to controller structure
  811. AIOPNUM; AIOP index
  812. */
  813. #define sResetAiopByNum(CTLP,AIOPNUM) \
  814. do { \
  815. sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,RESET_ALL); \
  816. sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,0x0); \
  817. } while (0)
  818. /***************************************************************************
  819. Function: sSendBreak
  820. Purpose: Send a transmit BREAK signal
  821. Call: sSendBreak(ChP)
  822. CHANNEL_T *ChP; Ptr to channel structure
  823. */
  824. #define sSendBreak(ChP) \
  825. do { \
  826. (ChP)->TxControl[3] |= SETBREAK; \
  827. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  828. } while (0)
  829. /***************************************************************************
  830. Function: sSetBaud
  831. Purpose: Set baud rate
  832. Call: sSetBaud(ChP,Divisor)
  833. CHANNEL_T *ChP; Ptr to channel structure
  834. Word_t Divisor; 16 bit baud rate divisor for channel
  835. */
  836. #define sSetBaud(ChP,DIVISOR) \
  837. do { \
  838. (ChP)->BaudDiv[2] = (Byte_t)(DIVISOR); \
  839. (ChP)->BaudDiv[3] = (Byte_t)((DIVISOR) >> 8); \
  840. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->BaudDiv[0]); \
  841. } while (0)
  842. /***************************************************************************
  843. Function: sSetData7
  844. Purpose: Set data bits to 7
  845. Call: sSetData7(ChP)
  846. CHANNEL_T *ChP; Ptr to channel structure
  847. */
  848. #define sSetData7(ChP) \
  849. do { \
  850. (ChP)->TxControl[2] &= ~DATA8BIT; \
  851. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  852. } while (0)
  853. /***************************************************************************
  854. Function: sSetData8
  855. Purpose: Set data bits to 8
  856. Call: sSetData8(ChP)
  857. CHANNEL_T *ChP; Ptr to channel structure
  858. */
  859. #define sSetData8(ChP) \
  860. do { \
  861. (ChP)->TxControl[2] |= DATA8BIT; \
  862. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  863. } while (0)
  864. /***************************************************************************
  865. Function: sSetDTR
  866. Purpose: Set the DTR output
  867. Call: sSetDTR(ChP)
  868. CHANNEL_T *ChP; Ptr to channel structure
  869. */
  870. #define sSetDTR(ChP) \
  871. do { \
  872. (ChP)->TxControl[3] |= SET_DTR; \
  873. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  874. } while (0)
  875. /***************************************************************************
  876. Function: sSetEvenParity
  877. Purpose: Set even parity
  878. Call: sSetEvenParity(ChP)
  879. CHANNEL_T *ChP; Ptr to channel structure
  880. Comments: Function sSetParity() can be used in place of functions sEnParity(),
  881. sDisParity(), sSetOddParity(), and sSetEvenParity().
  882. Warnings: This function has no effect unless parity is enabled with function
  883. sEnParity().
  884. */
  885. #define sSetEvenParity(ChP) \
  886. do { \
  887. (ChP)->TxControl[2] |= EVEN_PAR; \
  888. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  889. } while (0)
  890. /***************************************************************************
  891. Function: sSetOddParity
  892. Purpose: Set odd parity
  893. Call: sSetOddParity(ChP)
  894. CHANNEL_T *ChP; Ptr to channel structure
  895. Comments: Function sSetParity() can be used in place of functions sEnParity(),
  896. sDisParity(), sSetOddParity(), and sSetEvenParity().
  897. Warnings: This function has no effect unless parity is enabled with function
  898. sEnParity().
  899. */
  900. #define sSetOddParity(ChP) \
  901. do { \
  902. (ChP)->TxControl[2] &= ~EVEN_PAR; \
  903. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  904. } while (0)
  905. /***************************************************************************
  906. Function: sSetRTS
  907. Purpose: Set the RTS output
  908. Call: sSetRTS(ChP)
  909. CHANNEL_T *ChP; Ptr to channel structure
  910. */
  911. #define sSetRTS(ChP) \
  912. do { \
  913. if ((ChP)->rtsToggle) break; \
  914. (ChP)->TxControl[3] |= SET_RTS; \
  915. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  916. } while (0)
  917. /***************************************************************************
  918. Function: sSetRxTrigger
  919. Purpose: Set the Rx FIFO trigger level
  920. Call: sSetRxProcessor(ChP,Level)
  921. CHANNEL_T *ChP; Ptr to channel structure
  922. Byte_t Level; Number of characters in Rx FIFO at which the
  923. interrupt will be generated. Can be any of the following flags:
  924. TRIG_NO: no trigger
  925. TRIG_1: 1 character in FIFO
  926. TRIG_1_2: FIFO 1/2 full
  927. TRIG_7_8: FIFO 7/8 full
  928. Comments: An interrupt will be generated when the trigger level is reached
  929. only if function sEnInterrupt() has been called with flag
  930. RXINT_EN set. The RXF_TRIG flag in the Interrupt Idenfification
  931. register will be set whenever the trigger level is reached
  932. regardless of the setting of RXINT_EN.
  933. */
  934. #define sSetRxTrigger(ChP,LEVEL) \
  935. do { \
  936. (ChP)->RxControl[2] &= ~TRIG_MASK; \
  937. (ChP)->RxControl[2] |= LEVEL; \
  938. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
  939. } while (0)
  940. /***************************************************************************
  941. Function: sSetStop1
  942. Purpose: Set stop bits to 1
  943. Call: sSetStop1(ChP)
  944. CHANNEL_T *ChP; Ptr to channel structure
  945. */
  946. #define sSetStop1(ChP) \
  947. do { \
  948. (ChP)->TxControl[2] &= ~STOP2; \
  949. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  950. } while (0)
  951. /***************************************************************************
  952. Function: sSetStop2
  953. Purpose: Set stop bits to 2
  954. Call: sSetStop2(ChP)
  955. CHANNEL_T *ChP; Ptr to channel structure
  956. */
  957. #define sSetStop2(ChP) \
  958. do { \
  959. (ChP)->TxControl[2] |= STOP2; \
  960. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
  961. } while (0)
  962. /***************************************************************************
  963. Function: sSetTxXOFFChar
  964. Purpose: Set the Tx XOFF flow control character
  965. Call: sSetTxXOFFChar(ChP,Ch)
  966. CHANNEL_T *ChP; Ptr to channel structure
  967. Byte_t Ch; The value to set the Tx XOFF character to
  968. */
  969. #define sSetTxXOFFChar(ChP,CH) \
  970. do { \
  971. (ChP)->R[0x07] = (CH); \
  972. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \
  973. } while (0)
  974. /***************************************************************************
  975. Function: sSetTxXONChar
  976. Purpose: Set the Tx XON flow control character
  977. Call: sSetTxXONChar(ChP,Ch)
  978. CHANNEL_T *ChP; Ptr to channel structure
  979. Byte_t Ch; The value to set the Tx XON character to
  980. */
  981. #define sSetTxXONChar(ChP,CH) \
  982. do { \
  983. (ChP)->R[0x0b] = (CH); \
  984. sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x08]); \
  985. } while (0)
  986. /***************************************************************************
  987. Function: sStartRxProcessor
  988. Purpose: Start a channel's receive processor
  989. Call: sStartRxProcessor(ChP)
  990. CHANNEL_T *ChP; Ptr to channel structure
  991. Comments: This function is used to start a Rx processor after it was
  992. stopped with sStopRxProcessor() or sStopSWInFlowCtl(). It
  993. will restart both the Rx processor and software input flow control.
  994. */
  995. #define sStartRxProcessor(ChP) sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0])
  996. /***************************************************************************
  997. Function: sWriteTxByte
  998. Purpose: Write a transmit data byte to a channel.
  999. ByteIO_t io: Channel transmit register I/O address. This can
  1000. be obtained with sGetTxRxDataIO().
  1001. Byte_t Data; The transmit data byte.
  1002. Warnings: This function writes the data byte without checking to see if
  1003. sMaxTxSize is exceeded in the Tx FIFO.
  1004. */
  1005. #define sWriteTxByte(IO,DATA) sOutB(IO,DATA)
  1006. /*
  1007. * Begin Linux specific definitions for the Rocketport driver
  1008. *
  1009. * This code is Copyright Theodore Ts'o, 1995-1997
  1010. */
  1011. struct r_port {
  1012. int magic;
  1013. int line;
  1014. int flags;
  1015. int count;
  1016. int blocked_open;
  1017. struct tty_struct *tty;
  1018. unsigned int board:3;
  1019. unsigned int aiop:2;
  1020. unsigned int chan:3;
  1021. CONTROLLER_t *ctlp;
  1022. CHANNEL_t channel;
  1023. int closing_wait;
  1024. int close_delay;
  1025. int intmask;
  1026. int xmit_fifo_room; /* room in xmit fifo */
  1027. unsigned char *xmit_buf;
  1028. int xmit_head;
  1029. int xmit_tail;
  1030. int xmit_cnt;
  1031. int cd_status;
  1032. int ignore_status_mask;
  1033. int read_status_mask;
  1034. int cps;
  1035. #ifdef DECLARE_WAITQUEUE
  1036. wait_queue_head_t open_wait;
  1037. wait_queue_head_t close_wait;
  1038. #else
  1039. struct wait_queue *open_wait;
  1040. struct wait_queue *close_wait;
  1041. #endif
  1042. spinlock_t slock;
  1043. struct mutex write_mtx;
  1044. };
  1045. #define RPORT_MAGIC 0x525001
  1046. #define NUM_BOARDS 8
  1047. #define MAX_RP_PORTS (32*NUM_BOARDS)
  1048. /*
  1049. * The size of the xmit buffer is 1 page, or 4096 bytes
  1050. */
  1051. #define XMIT_BUF_SIZE 4096
  1052. /* number of characters left in xmit buffer before we ask for more */
  1053. #define WAKEUP_CHARS 256
  1054. /* Internal flags used only by the rocketport driver */
  1055. #define ROCKET_INITIALIZED 0x80000000 /* Port is active */
  1056. #define ROCKET_CLOSING 0x40000000 /* Serial port is closing */
  1057. #define ROCKET_NORMAL_ACTIVE 0x20000000 /* Normal port is active */
  1058. /* tty subtypes */
  1059. #define SERIAL_TYPE_NORMAL 1
  1060. /*
  1061. * Assigned major numbers for the Comtrol Rocketport
  1062. */
  1063. #define TTY_ROCKET_MAJOR 46
  1064. #define CUA_ROCKET_MAJOR 47
  1065. #ifdef PCI_VENDOR_ID_RP
  1066. #undef PCI_VENDOR_ID_RP
  1067. #undef PCI_DEVICE_ID_RP8OCTA
  1068. #undef PCI_DEVICE_ID_RP8INTF
  1069. #undef PCI_DEVICE_ID_RP16INTF
  1070. #undef PCI_DEVICE_ID_RP32INTF
  1071. #undef PCI_DEVICE_ID_URP8OCTA
  1072. #undef PCI_DEVICE_ID_URP8INTF
  1073. #undef PCI_DEVICE_ID_URP16INTF
  1074. #undef PCI_DEVICE_ID_CRP16INTF
  1075. #undef PCI_DEVICE_ID_URP32INTF
  1076. #endif
  1077. /* Comtrol PCI Vendor ID */
  1078. #define PCI_VENDOR_ID_RP 0x11fe
  1079. /* Comtrol Device ID's */
  1080. #define PCI_DEVICE_ID_RP32INTF 0x0001 /* Rocketport 32 port w/external I/F */
  1081. #define PCI_DEVICE_ID_RP8INTF 0x0002 /* Rocketport 8 port w/external I/F */
  1082. #define PCI_DEVICE_ID_RP16INTF 0x0003 /* Rocketport 16 port w/external I/F */
  1083. #define PCI_DEVICE_ID_RP4QUAD 0x0004 /* Rocketport 4 port w/quad cable */
  1084. #define PCI_DEVICE_ID_RP8OCTA 0x0005 /* Rocketport 8 port w/octa cable */
  1085. #define PCI_DEVICE_ID_RP8J 0x0006 /* Rocketport 8 port w/RJ11 connectors */
  1086. #define PCI_DEVICE_ID_RP4J 0x0007 /* Rocketport 4 port w/RJ11 connectors */
  1087. #define PCI_DEVICE_ID_RP8SNI 0x0008 /* Rocketport 8 port w/ DB78 SNI (Siemens) connector */
  1088. #define PCI_DEVICE_ID_RP16SNI 0x0009 /* Rocketport 16 port w/ DB78 SNI (Siemens) connector */
  1089. #define PCI_DEVICE_ID_RPP4 0x000A /* Rocketport Plus 4 port */
  1090. #define PCI_DEVICE_ID_RPP8 0x000B /* Rocketport Plus 8 port */
  1091. #define PCI_DEVICE_ID_RP6M 0x000C /* RocketModem 6 port */
  1092. #define PCI_DEVICE_ID_RP4M 0x000D /* RocketModem 4 port */
  1093. #define PCI_DEVICE_ID_RP2_232 0x000E /* Rocketport Plus 2 port RS232 */
  1094. #define PCI_DEVICE_ID_RP2_422 0x000F /* Rocketport Plus 2 port RS422 */
  1095. /* Universal PCI boards */
  1096. #define PCI_DEVICE_ID_URP32INTF 0x0801 /* Rocketport UPCI 32 port w/external I/F */
  1097. #define PCI_DEVICE_ID_URP8INTF 0x0802 /* Rocketport UPCI 8 port w/external I/F */
  1098. #define PCI_DEVICE_ID_URP16INTF 0x0803 /* Rocketport UPCI 16 port w/external I/F */
  1099. #define PCI_DEVICE_ID_URP8OCTA 0x0805 /* Rocketport UPCI 8 port w/octa cable */
  1100. #define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C /* Rocketmodem III 8 port */
  1101. #define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D /* Rocketmodem III 4 port */
  1102. /* Compact PCI device */
  1103. #define PCI_DEVICE_ID_CRP16INTF 0x0903 /* Rocketport Compact PCI 16 port w/external I/F */
  1104. #define TTY_GET_LINE(t) t->index
  1105. #define TTY_DRIVER_MINOR_START(t) t->driver->minor_start
  1106. #define TTY_DRIVER_SUBTYPE(t) t->driver->subtype
  1107. #define TTY_DRIVER_NAME(t) t->driver->name
  1108. #define TTY_DRIVER_NAME_BASE(t) t->driver->name_base
  1109. #define TTY_DRIVER_FLUSH_BUFFER_EXISTS(t) t->driver->flush_buffer
  1110. #define TTY_DRIVER_FLUSH_BUFFER(t) t->driver->flush_buffer(t)