zs.h 9.5 KB

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