zs.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * zs.h: Definitions for the DECstation Z85C30 serial driver.
  3. *
  4. * Adapted from drivers/sbus/char/sunserial.h by Paul Mackerras.
  5. * Adapted from drivers/macintosh/macserial.h by Harald Koerfgen.
  6. *
  7. * Copyright (C) 1996 Paul Mackerras (Paul.Mackerras@cs.anu.edu.au)
  8. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  9. * Copyright (C) 2004, 2005, 2007 Maciej W. Rozycki
  10. */
  11. #ifndef _SERIAL_ZS_H
  12. #define _SERIAL_ZS_H
  13. #ifdef __KERNEL__
  14. #define ZS_NUM_REGS 16
  15. /*
  16. * This is our internal structure for each serial port's state.
  17. */
  18. struct zs_port {
  19. struct zs_scc *scc; /* Containing SCC. */
  20. struct uart_port port; /* Underlying UART. */
  21. int clk_mode; /* May be 1, 16, 32, or 64. */
  22. unsigned int tty_break; /* Set on BREAK condition. */
  23. int tx_stopped; /* Output is suspended. */
  24. unsigned int mctrl; /* State of modem lines. */
  25. u8 brk; /* BREAK state from RR0. */
  26. u8 regs[ZS_NUM_REGS]; /* Channel write registers. */
  27. };
  28. /*
  29. * Per-SCC state for locking and the interrupt handler.
  30. */
  31. struct zs_scc {
  32. struct zs_port zport[2];
  33. spinlock_t zlock;
  34. atomic_t irq_guard;
  35. int initialised;
  36. };
  37. #endif /* __KERNEL__ */
  38. /*
  39. * Conversion routines to/from brg time constants from/to bits per second.
  40. */
  41. #define ZS_BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
  42. #define ZS_BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
  43. /*
  44. * The Zilog register set.
  45. */
  46. /* Write Register 0 (Command) */
  47. #define R0 0 /* Register selects */
  48. #define R1 1
  49. #define R2 2
  50. #define R3 3
  51. #define R4 4
  52. #define R5 5
  53. #define R6 6
  54. #define R7 7
  55. #define R8 8
  56. #define R9 9
  57. #define R10 10
  58. #define R11 11
  59. #define R12 12
  60. #define R13 13
  61. #define R14 14
  62. #define R15 15
  63. #define NULLCODE 0 /* Null Code */
  64. #define POINT_HIGH 0x8 /* Select upper half of registers */
  65. #define RES_EXT_INT 0x10 /* Reset Ext. Status Interrupts */
  66. #define SEND_ABORT 0x18 /* HDLC Abort */
  67. #define RES_RxINT_FC 0x20 /* Reset RxINT on First Character */
  68. #define RES_Tx_P 0x28 /* Reset TxINT Pending */
  69. #define ERR_RES 0x30 /* Error Reset */
  70. #define RES_H_IUS 0x38 /* Reset highest IUS */
  71. #define RES_Rx_CRC 0x40 /* Reset Rx CRC Checker */
  72. #define RES_Tx_CRC 0x80 /* Reset Tx CRC Checker */
  73. #define RES_EOM_L 0xC0 /* Reset EOM latch */
  74. /* Write Register 1 (Tx/Rx/Ext Int Enable and WAIT/DMA Commands) */
  75. #define EXT_INT_ENAB 0x1 /* Ext Int Enable */
  76. #define TxINT_ENAB 0x2 /* Tx Int Enable */
  77. #define PAR_SPEC 0x4 /* Parity is special condition */
  78. #define RxINT_DISAB 0 /* Rx Int Disable */
  79. #define RxINT_FCERR 0x8 /* Rx Int on First Character Only or Error */
  80. #define RxINT_ALL 0x10 /* Int on all Rx Characters or error */
  81. #define RxINT_ERR 0x18 /* Int on error only */
  82. #define RxINT_MASK 0x18
  83. #define WT_RDY_RT 0x20 /* Wait/Ready on R/T */
  84. #define WT_FN_RDYFN 0x40 /* Wait/FN/Ready FN */
  85. #define WT_RDY_ENAB 0x80 /* Wait/Ready Enable */
  86. /* Write Register 2 (Interrupt Vector) */
  87. /* Write Register 3 (Receive Parameters and Control) */
  88. #define RxENABLE 0x1 /* Rx Enable */
  89. #define SYNC_L_INH 0x2 /* Sync Character Load Inhibit */
  90. #define ADD_SM 0x4 /* Address Search Mode (SDLC) */
  91. #define RxCRC_ENAB 0x8 /* Rx CRC Enable */
  92. #define ENT_HM 0x10 /* Enter Hunt Mode */
  93. #define AUTO_ENAB 0x20 /* Auto Enables */
  94. #define Rx5 0x0 /* Rx 5 Bits/Character */
  95. #define Rx7 0x40 /* Rx 7 Bits/Character */
  96. #define Rx6 0x80 /* Rx 6 Bits/Character */
  97. #define Rx8 0xc0 /* Rx 8 Bits/Character */
  98. #define RxNBITS_MASK 0xc0
  99. /* Write Register 4 (Transmit/Receive Miscellaneous Parameters and Modes) */
  100. #define PAR_ENA 0x1 /* Parity Enable */
  101. #define PAR_EVEN 0x2 /* Parity Even/Odd* */
  102. #define SYNC_ENAB 0 /* Sync Modes Enable */
  103. #define SB1 0x4 /* 1 stop bit/char */
  104. #define SB15 0x8 /* 1.5 stop bits/char */
  105. #define SB2 0xc /* 2 stop bits/char */
  106. #define SB_MASK 0xc
  107. #define MONSYNC 0 /* 8 Bit Sync character */
  108. #define BISYNC 0x10 /* 16 bit sync character */
  109. #define SDLC 0x20 /* SDLC Mode (01111110 Sync Flag) */
  110. #define EXTSYNC 0x30 /* External Sync Mode */
  111. #define X1CLK 0x0 /* x1 clock mode */
  112. #define X16CLK 0x40 /* x16 clock mode */
  113. #define X32CLK 0x80 /* x32 clock mode */
  114. #define X64CLK 0xc0 /* x64 clock mode */
  115. #define XCLK_MASK 0xc0
  116. /* Write Register 5 (Transmit Parameters and Controls) */
  117. #define TxCRC_ENAB 0x1 /* Tx CRC Enable */
  118. #define RTS 0x2 /* RTS */
  119. #define SDLC_CRC 0x4 /* SDLC/CRC-16 */
  120. #define TxENAB 0x8 /* Tx Enable */
  121. #define SND_BRK 0x10 /* Send Break */
  122. #define Tx5 0x0 /* Tx 5 bits (or less)/character */
  123. #define Tx7 0x20 /* Tx 7 bits/character */
  124. #define Tx6 0x40 /* Tx 6 bits/character */
  125. #define Tx8 0x60 /* Tx 8 bits/character */
  126. #define TxNBITS_MASK 0x60
  127. #define DTR 0x80 /* DTR */
  128. /* Write Register 6 (Sync bits 0-7/SDLC Address Field) */
  129. /* Write Register 7 (Sync bits 8-15/SDLC 01111110) */
  130. /* Write Register 8 (Transmit Buffer) */
  131. /* Write Register 9 (Master Interrupt Control) */
  132. #define VIS 1 /* Vector Includes Status */
  133. #define NV 2 /* No Vector */
  134. #define DLC 4 /* Disable Lower Chain */
  135. #define MIE 8 /* Master Interrupt Enable */
  136. #define STATHI 0x10 /* Status high */
  137. #define SOFTACK 0x20 /* Software Interrupt Acknowledge */
  138. #define NORESET 0 /* No reset on write to R9 */
  139. #define CHRB 0x40 /* Reset channel B */
  140. #define CHRA 0x80 /* Reset channel A */
  141. #define FHWRES 0xc0 /* Force hardware reset */
  142. /* Write Register 10 (Miscellaneous Transmitter/Receiver Control Bits) */
  143. #define BIT6 1 /* 6 bit/8bit sync */
  144. #define LOOPMODE 2 /* SDLC Loop mode */
  145. #define ABUNDER 4 /* Abort/flag on SDLC xmit underrun */
  146. #define MARKIDLE 8 /* Mark/flag on idle */
  147. #define GAOP 0x10 /* Go active on poll */
  148. #define NRZ 0 /* NRZ mode */
  149. #define NRZI 0x20 /* NRZI mode */
  150. #define FM1 0x40 /* FM1 (transition = 1) */
  151. #define FM0 0x60 /* FM0 (transition = 0) */
  152. #define CRCPS 0x80 /* CRC Preset I/O */
  153. /* Write Register 11 (Clock Mode Control) */
  154. #define TRxCXT 0 /* TRxC = Xtal output */
  155. #define TRxCTC 1 /* TRxC = Transmit clock */
  156. #define TRxCBR 2 /* TRxC = BR Generator Output */
  157. #define TRxCDP 3 /* TRxC = DPLL output */
  158. #define TRxCOI 4 /* TRxC O/I */
  159. #define TCRTxCP 0 /* Transmit clock = RTxC pin */
  160. #define TCTRxCP 8 /* Transmit clock = TRxC pin */
  161. #define TCBR 0x10 /* Transmit clock = BR Generator output */
  162. #define TCDPLL 0x18 /* Transmit clock = DPLL output */
  163. #define RCRTxCP 0 /* Receive clock = RTxC pin */
  164. #define RCTRxCP 0x20 /* Receive clock = TRxC pin */
  165. #define RCBR 0x40 /* Receive clock = BR Generator output */
  166. #define RCDPLL 0x60 /* Receive clock = DPLL output */
  167. #define RTxCX 0x80 /* RTxC Xtal/No Xtal */
  168. /* Write Register 12 (Lower Byte of Baud Rate Generator Time Constant) */
  169. /* Write Register 13 (Upper Byte of Baud Rate Generator Time Constant) */
  170. /* Write Register 14 (Miscellaneous Control Bits) */
  171. #define BRENABL 1 /* Baud rate generator enable */
  172. #define BRSRC 2 /* Baud rate generator source */
  173. #define DTRREQ 4 /* DTR/Request function */
  174. #define AUTOECHO 8 /* Auto Echo */
  175. #define LOOPBAK 0x10 /* Local loopback */
  176. #define SEARCH 0x20 /* Enter search mode */
  177. #define RMC 0x40 /* Reset missing clock */
  178. #define DISDPLL 0x60 /* Disable DPLL */
  179. #define SSBR 0x80 /* Set DPLL source = BR generator */
  180. #define SSRTxC 0xa0 /* Set DPLL source = RTxC */
  181. #define SFMM 0xc0 /* Set FM mode */
  182. #define SNRZI 0xe0 /* Set NRZI mode */
  183. /* Write Register 15 (External/Status Interrupt Control) */
  184. #define WR7P_EN 1 /* WR7 Prime SDLC Feature Enable */
  185. #define ZCIE 2 /* Zero count IE */
  186. #define DCDIE 8 /* DCD IE */
  187. #define SYNCIE 0x10 /* Sync/hunt IE */
  188. #define CTSIE 0x20 /* CTS IE */
  189. #define TxUIE 0x40 /* Tx Underrun/EOM IE */
  190. #define BRKIE 0x80 /* Break/Abort IE */
  191. /* Read Register 0 (Transmit/Receive Buffer Status and External Status) */
  192. #define Rx_CH_AV 0x1 /* Rx Character Available */
  193. #define ZCOUNT 0x2 /* Zero count */
  194. #define Tx_BUF_EMP 0x4 /* Tx Buffer empty */
  195. #define DCD 0x8 /* DCD */
  196. #define SYNC_HUNT 0x10 /* Sync/hunt */
  197. #define CTS 0x20 /* CTS */
  198. #define TxEOM 0x40 /* Tx underrun */
  199. #define BRK_ABRT 0x80 /* Break/Abort */
  200. /* Read Register 1 (Special Receive Condition Status) */
  201. #define ALL_SNT 0x1 /* All sent */
  202. /* Residue Data for 8 Rx bits/char programmed */
  203. #define RES3 0x8 /* 0/3 */
  204. #define RES4 0x4 /* 0/4 */
  205. #define RES5 0xc /* 0/5 */
  206. #define RES6 0x2 /* 0/6 */
  207. #define RES7 0xa /* 0/7 */
  208. #define RES8 0x6 /* 0/8 */
  209. #define RES18 0xe /* 1/8 */
  210. #define RES28 0x0 /* 2/8 */
  211. /* Special Rx Condition Interrupts */
  212. #define PAR_ERR 0x10 /* Parity Error */
  213. #define Rx_OVR 0x20 /* Rx Overrun Error */
  214. #define FRM_ERR 0x40 /* CRC/Framing Error */
  215. #define END_FR 0x80 /* End of Frame (SDLC) */
  216. /* Read Register 2 (Interrupt Vector (WR2) -- channel A). */
  217. /* Read Register 2 (Modified Interrupt Vector -- channel B). */
  218. /* Read Register 3 (Interrupt Pending Bits -- channel A only). */
  219. #define CHBEXT 0x1 /* Channel B Ext/Stat IP */
  220. #define CHBTxIP 0x2 /* Channel B Tx IP */
  221. #define CHBRxIP 0x4 /* Channel B Rx IP */
  222. #define CHAEXT 0x8 /* Channel A Ext/Stat IP */
  223. #define CHATxIP 0x10 /* Channel A Tx IP */
  224. #define CHARxIP 0x20 /* Channel A Rx IP */
  225. /* Read Register 6 (SDLC FIFO Status and Byte Count LSB) */
  226. /* Read Register 7 (SDLC FIFO Status and Byte Count MSB) */
  227. /* Read Register 8 (Receive Data) */
  228. /* Read Register 10 (Miscellaneous Status Bits) */
  229. #define ONLOOP 2 /* On loop */
  230. #define LOOPSEND 0x10 /* Loop sending */
  231. #define CLK2MIS 0x40 /* Two clocks missing */
  232. #define CLK1MIS 0x80 /* One clock missing */
  233. /* Read Register 12 (Lower Byte of Baud Rate Generator Constant (WR12)) */
  234. /* Read Register 13 (Upper Byte of Baud Rate Generator Constant (WR13) */
  235. /* Read Register 15 (External/Status Interrupt Control (WR15)) */
  236. #endif /* _SERIAL_ZS_H */