ip22zilog.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _IP22_ZILOG_H
  3. #define _IP22_ZILOG_H
  4. #include <asm/byteorder.h>
  5. struct zilog_channel {
  6. #ifdef __BIG_ENDIAN
  7. volatile unsigned char unused0[3];
  8. volatile unsigned char control;
  9. volatile unsigned char unused1[3];
  10. volatile unsigned char data;
  11. #else /* __LITTLE_ENDIAN */
  12. volatile unsigned char control;
  13. volatile unsigned char unused0[3];
  14. volatile unsigned char data;
  15. volatile unsigned char unused1[3];
  16. #endif
  17. };
  18. struct zilog_layout {
  19. struct zilog_channel channelB;
  20. struct zilog_channel channelA;
  21. };
  22. #define NUM_ZSREGS 16
  23. /* Conversion routines to/from brg time constants from/to bits
  24. * per second.
  25. */
  26. #define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
  27. #define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
  28. /* The Zilog register set */
  29. #define FLAG 0x7e
  30. /* Write Register 0 */
  31. #define R0 0 /* Register selects */
  32. #define R1 1
  33. #define R2 2
  34. #define R3 3
  35. #define R4 4
  36. #define R5 5
  37. #define R6 6
  38. #define R7 7
  39. #define R8 8
  40. #define R9 9
  41. #define R10 10
  42. #define R11 11
  43. #define R12 12
  44. #define R13 13
  45. #define R14 14
  46. #define R15 15
  47. #define NULLCODE 0 /* Null Code */
  48. #define POINT_HIGH 0x8 /* Select upper half of registers */
  49. #define RES_EXT_INT 0x10 /* Reset Ext. Status Interrupts */
  50. #define SEND_ABORT 0x18 /* HDLC Abort */
  51. #define RES_RxINT_FC 0x20 /* Reset RxINT on First Character */
  52. #define RES_Tx_P 0x28 /* Reset TxINT Pending */
  53. #define ERR_RES 0x30 /* Error Reset */
  54. #define RES_H_IUS 0x38 /* Reset highest IUS */
  55. #define RES_Rx_CRC 0x40 /* Reset Rx CRC Checker */
  56. #define RES_Tx_CRC 0x80 /* Reset Tx CRC Checker */
  57. #define RES_EOM_L 0xC0 /* Reset EOM latch */
  58. /* Write Register 1 */
  59. #define EXT_INT_ENAB 0x1 /* Ext Int Enable */
  60. #define TxINT_ENAB 0x2 /* Tx Int Enable */
  61. #define PAR_SPEC 0x4 /* Parity is special condition */
  62. #define RxINT_DISAB 0 /* Rx Int Disable */
  63. #define RxINT_FCERR 0x8 /* Rx Int on First Character Only or Error */
  64. #define INT_ALL_Rx 0x10 /* Int on all Rx Characters or error */
  65. #define INT_ERR_Rx 0x18 /* Int on error only */
  66. #define RxINT_MASK 0x18
  67. #define WT_RDY_RT 0x20 /* Wait/Ready on R/T */
  68. #define WT_FN_RDYFN 0x40 /* Wait/FN/Ready FN */
  69. #define WT_RDY_ENAB 0x80 /* Wait/Ready Enable */
  70. /* Write Register #2 (Interrupt Vector) */
  71. /* Write Register 3 */
  72. #define RxENAB 0x1 /* Rx Enable */
  73. #define SYNC_L_INH 0x2 /* Sync Character Load Inhibit */
  74. #define ADD_SM 0x4 /* Address Search Mode (SDLC) */
  75. #define RxCRC_ENAB 0x8 /* Rx CRC Enable */
  76. #define ENT_HM 0x10 /* Enter Hunt Mode */
  77. #define AUTO_ENAB 0x20 /* Auto Enables */
  78. #define Rx5 0x0 /* Rx 5 Bits/Character */
  79. #define Rx7 0x40 /* Rx 7 Bits/Character */
  80. #define Rx6 0x80 /* Rx 6 Bits/Character */
  81. #define Rx8 0xc0 /* Rx 8 Bits/Character */
  82. #define RxN_MASK 0xc0
  83. /* Write Register 4 */
  84. #define PAR_ENAB 0x1 /* Parity Enable */
  85. #define PAR_EVEN 0x2 /* Parity Even/Odd* */
  86. #define SYNC_ENAB 0 /* Sync Modes Enable */
  87. #define SB1 0x4 /* 1 stop bit/char */
  88. #define SB15 0x8 /* 1.5 stop bits/char */
  89. #define SB2 0xc /* 2 stop bits/char */
  90. #define MONSYNC 0 /* 8 Bit Sync character */
  91. #define BISYNC 0x10 /* 16 bit sync character */
  92. #define SDLC 0x20 /* SDLC Mode (01111110 Sync Flag) */
  93. #define EXTSYNC 0x30 /* External Sync Mode */
  94. #define X1CLK 0x0 /* x1 clock mode */
  95. #define X16CLK 0x40 /* x16 clock mode */
  96. #define X32CLK 0x80 /* x32 clock mode */
  97. #define X64CLK 0xC0 /* x64 clock mode */
  98. #define XCLK_MASK 0xC0
  99. /* Write Register 5 */
  100. #define TxCRC_ENAB 0x1 /* Tx CRC Enable */
  101. #define RTS 0x2 /* RTS */
  102. #define SDLC_CRC 0x4 /* SDLC/CRC-16 */
  103. #define TxENAB 0x8 /* Tx Enable */
  104. #define SND_BRK 0x10 /* Send Break */
  105. #define Tx5 0x0 /* Tx 5 bits (or less)/character */
  106. #define Tx7 0x20 /* Tx 7 bits/character */
  107. #define Tx6 0x40 /* Tx 6 bits/character */
  108. #define Tx8 0x60 /* Tx 8 bits/character */
  109. #define TxN_MASK 0x60
  110. #define DTR 0x80 /* DTR */
  111. /* Write Register 6 (Sync bits 0-7/SDLC Address Field) */
  112. /* Write Register 7 (Sync bits 8-15/SDLC 01111110) */
  113. /* Write Register 8 (transmit buffer) */
  114. /* Write Register 9 (Master interrupt control) */
  115. #define VIS 1 /* Vector Includes Status */
  116. #define NV 2 /* No Vector */
  117. #define DLC 4 /* Disable Lower Chain */
  118. #define MIE 8 /* Master Interrupt Enable */
  119. #define STATHI 0x10 /* Status high */
  120. #define NORESET 0 /* No reset on write to R9 */
  121. #define CHRB 0x40 /* Reset channel B */
  122. #define CHRA 0x80 /* Reset channel A */
  123. #define FHWRES 0xc0 /* Force hardware reset */
  124. /* Write Register 10 (misc control bits) */
  125. #define BIT6 1 /* 6 bit/8bit sync */
  126. #define LOOPMODE 2 /* SDLC Loop mode */
  127. #define ABUNDER 4 /* Abort/flag on SDLC xmit underrun */
  128. #define MARKIDLE 8 /* Mark/flag on idle */
  129. #define GAOP 0x10 /* Go active on poll */
  130. #define NRZ 0 /* NRZ mode */
  131. #define NRZI 0x20 /* NRZI mode */
  132. #define FM1 0x40 /* FM1 (transition = 1) */
  133. #define FM0 0x60 /* FM0 (transition = 0) */
  134. #define CRCPS 0x80 /* CRC Preset I/O */
  135. /* Write Register 11 (Clock Mode control) */
  136. #define TRxCXT 0 /* TRxC = Xtal output */
  137. #define TRxCTC 1 /* TRxC = Transmit clock */
  138. #define TRxCBR 2 /* TRxC = BR Generator Output */
  139. #define TRxCDP 3 /* TRxC = DPLL output */
  140. #define TRxCOI 4 /* TRxC O/I */
  141. #define TCRTxCP 0 /* Transmit clock = RTxC pin */
  142. #define TCTRxCP 8 /* Transmit clock = TRxC pin */
  143. #define TCBR 0x10 /* Transmit clock = BR Generator output */
  144. #define TCDPLL 0x18 /* Transmit clock = DPLL output */
  145. #define RCRTxCP 0 /* Receive clock = RTxC pin */
  146. #define RCTRxCP 0x20 /* Receive clock = TRxC pin */
  147. #define RCBR 0x40 /* Receive clock = BR Generator output */
  148. #define RCDPLL 0x60 /* Receive clock = DPLL output */
  149. #define RTxCX 0x80 /* RTxC Xtal/No Xtal */
  150. /* Write Register 12 (lower byte of baud rate generator time constant) */
  151. /* Write Register 13 (upper byte of baud rate generator time constant) */
  152. /* Write Register 14 (Misc control bits) */
  153. #define BRENAB 1 /* Baud rate generator enable */
  154. #define BRSRC 2 /* Baud rate generator source */
  155. #define DTRREQ 4 /* DTR/Request function */
  156. #define AUTOECHO 8 /* Auto Echo */
  157. #define LOOPBAK 0x10 /* Local loopback */
  158. #define SEARCH 0x20 /* Enter search mode */
  159. #define RMC 0x40 /* Reset missing clock */
  160. #define DISDPLL 0x60 /* Disable DPLL */
  161. #define SSBR 0x80 /* Set DPLL source = BR generator */
  162. #define SSRTxC 0xa0 /* Set DPLL source = RTxC */
  163. #define SFMM 0xc0 /* Set FM mode */
  164. #define SNRZI 0xe0 /* Set NRZI mode */
  165. /* Write Register 15 (external/status interrupt control) */
  166. #define ZCIE 2 /* Zero count IE */
  167. #define DCDIE 8 /* DCD IE */
  168. #define SYNCIE 0x10 /* Sync/hunt IE */
  169. #define CTSIE 0x20 /* CTS IE */
  170. #define TxUIE 0x40 /* Tx Underrun/EOM IE */
  171. #define BRKIE 0x80 /* Break/Abort IE */
  172. /* Read Register 0 */
  173. #define Rx_CH_AV 0x1 /* Rx Character Available */
  174. #define ZCOUNT 0x2 /* Zero count */
  175. #define Tx_BUF_EMP 0x4 /* Tx Buffer empty */
  176. #define DCD 0x8 /* DCD */
  177. #define SYNC 0x10 /* Sync/hunt */
  178. #define CTS 0x20 /* CTS */
  179. #define TxEOM 0x40 /* Tx underrun */
  180. #define BRK_ABRT 0x80 /* Break/Abort */
  181. /* Read Register 1 */
  182. #define ALL_SNT 0x1 /* All sent */
  183. /* Residue Data for 8 Rx bits/char programmed */
  184. #define RES3 0x8 /* 0/3 */
  185. #define RES4 0x4 /* 0/4 */
  186. #define RES5 0xc /* 0/5 */
  187. #define RES6 0x2 /* 0/6 */
  188. #define RES7 0xa /* 0/7 */
  189. #define RES8 0x6 /* 0/8 */
  190. #define RES18 0xe /* 1/8 */
  191. #define RES28 0x0 /* 2/8 */
  192. /* Special Rx Condition Interrupts */
  193. #define PAR_ERR 0x10 /* Parity error */
  194. #define Rx_OVR 0x20 /* Rx Overrun Error */
  195. #define CRC_ERR 0x40 /* CRC/Framing Error */
  196. #define END_FR 0x80 /* End of Frame (SDLC) */
  197. /* Read Register 2 (channel b only) - Interrupt vector */
  198. #define CHB_Tx_EMPTY 0x00
  199. #define CHB_EXT_STAT 0x02
  200. #define CHB_Rx_AVAIL 0x04
  201. #define CHB_SPECIAL 0x06
  202. #define CHA_Tx_EMPTY 0x08
  203. #define CHA_EXT_STAT 0x0a
  204. #define CHA_Rx_AVAIL 0x0c
  205. #define CHA_SPECIAL 0x0e
  206. #define STATUS_MASK 0x0e
  207. /* Read Register 3 (interrupt pending register) ch a only */
  208. #define CHBEXT 0x1 /* Channel B Ext/Stat IP */
  209. #define CHBTxIP 0x2 /* Channel B Tx IP */
  210. #define CHBRxIP 0x4 /* Channel B Rx IP */
  211. #define CHAEXT 0x8 /* Channel A Ext/Stat IP */
  212. #define CHATxIP 0x10 /* Channel A Tx IP */
  213. #define CHARxIP 0x20 /* Channel A Rx IP */
  214. /* Read Register 8 (receive data register) */
  215. /* Read Register 10 (misc status bits) */
  216. #define ONLOOP 2 /* On loop */
  217. #define LOOPSEND 0x10 /* Loop sending */
  218. #define CLK2MIS 0x40 /* Two clocks missing */
  219. #define CLK1MIS 0x80 /* One clock missing */
  220. /* Read Register 12 (lower byte of baud rate generator constant) */
  221. /* Read Register 13 (upper byte of baud rate generator constant) */
  222. /* Read Register 15 (value of WR 15) */
  223. /* Misc macros */
  224. #define ZS_CLEARERR(channel) do { writeb(ERR_RES, &channel->control); \
  225. udelay(5); } while(0)
  226. #define ZS_CLEARSTAT(channel) do { writeb(RES_EXT_INT, &channel->control); \
  227. udelay(5); } while(0)
  228. #define ZS_CLEARFIFO(channel) do { readb(&channel->data); \
  229. udelay(2); \
  230. readb(&channel->data); \
  231. udelay(2); \
  232. readb(&channel->data); \
  233. udelay(2); } while(0)
  234. #endif /* _IP22_ZILOG_H */