blob: d42f7766c65292cf83f4eb44eb1bbf6ae1ab5ed3 [file] [log] [blame]
Jiri Slaby037ad482006-12-08 02:38:11 -08001#ifndef _MXSER_H
2#define _MXSER_H
3
4/*
5 * Semi-public control interfaces
6 */
7
8/*
9 * MOXA ioctls
10 */
11
12#define MOXA 0x400
13#define MOXA_GETDATACOUNT (MOXA + 23)
14#define MOXA_GET_CONF (MOXA + 35)
15#define MOXA_DIAGNOSE (MOXA + 50)
16#define MOXA_CHKPORTENABLE (MOXA + 60)
17#define MOXA_HighSpeedOn (MOXA + 61)
18#define MOXA_GET_MAJOR (MOXA + 63)
19#define MOXA_GET_CUMAJOR (MOXA + 64)
20#define MOXA_GETMSTATUS (MOXA + 65)
21#define MOXA_SET_OP_MODE (MOXA + 66)
22#define MOXA_GET_OP_MODE (MOXA + 67)
23
24#define RS232_MODE 0
25#define RS485_2WIRE_MODE 1
26#define RS422_MODE 2
27#define RS485_4WIRE_MODE 3
28#define OP_MODE_MASK 3
Jiri Slaby037ad482006-12-08 02:38:11 -080029
Jiri Slabyed79ba12007-02-10 01:45:18 -080030#define MOXA_SDS_RSTICOUNTER (MOXA + 69)
Jiri Slaby037ad482006-12-08 02:38:11 -080031#define MOXA_ASPP_OQUEUE (MOXA + 70)
32#define MOXA_ASPP_SETBAUD (MOXA + 71)
33#define MOXA_ASPP_GETBAUD (MOXA + 72)
34#define MOXA_ASPP_MON (MOXA + 73)
35#define MOXA_ASPP_LSTATUS (MOXA + 74)
36#define MOXA_ASPP_MON_EXT (MOXA + 75)
37#define MOXA_SET_BAUD_METHOD (MOXA + 76)
Jiri Slabyf64c84a2007-02-10 01:45:21 -080038#define MOXA_SET_SPECIAL_BAUD_RATE (MOXA + 77)
39#define MOXA_GET_SPECIAL_BAUD_RATE (MOXA + 78)
Jiri Slaby037ad482006-12-08 02:38:11 -080040
Jiri Slaby037ad482006-12-08 02:38:11 -080041/* --------------------------------------------------- */
42
43#define NPPI_NOTIFY_PARITY 0x01
44#define NPPI_NOTIFY_FRAMING 0x02
45#define NPPI_NOTIFY_HW_OVERRUN 0x04
46#define NPPI_NOTIFY_SW_OVERRUN 0x08
47#define NPPI_NOTIFY_BREAK 0x10
48
Jiri Slabyed79ba12007-02-10 01:45:18 -080049#define NPPI_NOTIFY_CTSHOLD 0x01 /* Tx hold by CTS low */
50#define NPPI_NOTIFY_DSRHOLD 0x02 /* Tx hold by DSR low */
51#define NPPI_NOTIFY_XOFFHOLD 0x08 /* Tx hold by Xoff received */
52#define NPPI_NOTIFY_XOFFXENT 0x10 /* Xoff Sent */
Jiri Slaby037ad482006-12-08 02:38:11 -080053
Jiri Slabyed79ba12007-02-10 01:45:18 -080054/* follow just for Moxa Must chip define. */
55/* */
56/* when LCR register (offset 0x03) write following value, */
57/* the Must chip will enter enchance mode. And write value */
58/* on EFR (offset 0x02) bit 6,7 to change bank. */
Jiri Slaby037ad482006-12-08 02:38:11 -080059#define MOXA_MUST_ENTER_ENCHANCE 0xBF
60
Jiri Slabyed79ba12007-02-10 01:45:18 -080061/* when enhance mode enable, access on general bank register */
Jiri Slaby037ad482006-12-08 02:38:11 -080062#define MOXA_MUST_GDL_REGISTER 0x07
63#define MOXA_MUST_GDL_MASK 0x7F
64#define MOXA_MUST_GDL_HAS_BAD_DATA 0x80
65
Jiri Slabyed79ba12007-02-10 01:45:18 -080066#define MOXA_MUST_LSR_RERR 0x80 /* error in receive FIFO */
67/* enchance register bank select and enchance mode setting register */
68/* when LCR register equal to 0xBF */
Jiri Slaby037ad482006-12-08 02:38:11 -080069#define MOXA_MUST_EFR_REGISTER 0x02
Jiri Slabyed79ba12007-02-10 01:45:18 -080070/* enchance mode enable */
Jiri Slaby037ad482006-12-08 02:38:11 -080071#define MOXA_MUST_EFR_EFRB_ENABLE 0x10
Jiri Slabyed79ba12007-02-10 01:45:18 -080072/* enchance reister bank set 0, 1, 2 */
Jiri Slaby037ad482006-12-08 02:38:11 -080073#define MOXA_MUST_EFR_BANK0 0x00
74#define MOXA_MUST_EFR_BANK1 0x40
75#define MOXA_MUST_EFR_BANK2 0x80
76#define MOXA_MUST_EFR_BANK3 0xC0
77#define MOXA_MUST_EFR_BANK_MASK 0xC0
78
Jiri Slabyed79ba12007-02-10 01:45:18 -080079/* set XON1 value register, when LCR=0xBF and change to bank0 */
Jiri Slaby037ad482006-12-08 02:38:11 -080080#define MOXA_MUST_XON1_REGISTER 0x04
81
Jiri Slabyed79ba12007-02-10 01:45:18 -080082/* set XON2 value register, when LCR=0xBF and change to bank0 */
Jiri Slaby037ad482006-12-08 02:38:11 -080083#define MOXA_MUST_XON2_REGISTER 0x05
84
Jiri Slabyed79ba12007-02-10 01:45:18 -080085/* set XOFF1 value register, when LCR=0xBF and change to bank0 */
Jiri Slaby037ad482006-12-08 02:38:11 -080086#define MOXA_MUST_XOFF1_REGISTER 0x06
87
Jiri Slabyed79ba12007-02-10 01:45:18 -080088/* set XOFF2 value register, when LCR=0xBF and change to bank0 */
Jiri Slaby037ad482006-12-08 02:38:11 -080089#define MOXA_MUST_XOFF2_REGISTER 0x07
90
91#define MOXA_MUST_RBRTL_REGISTER 0x04
92#define MOXA_MUST_RBRTH_REGISTER 0x05
93#define MOXA_MUST_RBRTI_REGISTER 0x06
94#define MOXA_MUST_THRTL_REGISTER 0x07
95#define MOXA_MUST_ENUM_REGISTER 0x04
96#define MOXA_MUST_HWID_REGISTER 0x05
97#define MOXA_MUST_ECR_REGISTER 0x06
98#define MOXA_MUST_CSR_REGISTER 0x07
99
Jiri Slabyed79ba12007-02-10 01:45:18 -0800100/* good data mode enable */
Jiri Slaby037ad482006-12-08 02:38:11 -0800101#define MOXA_MUST_FCR_GDA_MODE_ENABLE 0x20
Jiri Slabyed79ba12007-02-10 01:45:18 -0800102/* only good data put into RxFIFO */
Jiri Slaby037ad482006-12-08 02:38:11 -0800103#define MOXA_MUST_FCR_GDA_ONLY_ENABLE 0x10
104
Jiri Slabyed79ba12007-02-10 01:45:18 -0800105/* enable CTS interrupt */
Jiri Slaby037ad482006-12-08 02:38:11 -0800106#define MOXA_MUST_IER_ECTSI 0x80
Jiri Slabyed79ba12007-02-10 01:45:18 -0800107/* enable RTS interrupt */
Jiri Slaby037ad482006-12-08 02:38:11 -0800108#define MOXA_MUST_IER_ERTSI 0x40
Jiri Slabyed79ba12007-02-10 01:45:18 -0800109/* enable Xon/Xoff interrupt */
Jiri Slaby037ad482006-12-08 02:38:11 -0800110#define MOXA_MUST_IER_XINT 0x20
Jiri Slabyed79ba12007-02-10 01:45:18 -0800111/* enable GDA interrupt */
Jiri Slaby037ad482006-12-08 02:38:11 -0800112#define MOXA_MUST_IER_EGDAI 0x10
113
114#define MOXA_MUST_RECV_ISR (UART_IER_RDI | MOXA_MUST_IER_EGDAI)
115
Jiri Slabyed79ba12007-02-10 01:45:18 -0800116/* GDA interrupt pending */
Jiri Slaby037ad482006-12-08 02:38:11 -0800117#define MOXA_MUST_IIR_GDA 0x1C
118#define MOXA_MUST_IIR_RDA 0x04
119#define MOXA_MUST_IIR_RTO 0x0C
120#define MOXA_MUST_IIR_LSR 0x06
121
Jiri Slabyed79ba12007-02-10 01:45:18 -0800122/* recieved Xon/Xoff or specical interrupt pending */
Jiri Slaby037ad482006-12-08 02:38:11 -0800123#define MOXA_MUST_IIR_XSC 0x10
124
Jiri Slabyed79ba12007-02-10 01:45:18 -0800125/* RTS/CTS change state interrupt pending */
Jiri Slaby037ad482006-12-08 02:38:11 -0800126#define MOXA_MUST_IIR_RTSCTS 0x20
127#define MOXA_MUST_IIR_MASK 0x3E
128
129#define MOXA_MUST_MCR_XON_FLAG 0x40
130#define MOXA_MUST_MCR_XON_ANY 0x80
131#define MOXA_MUST_MCR_TX_XON 0x08
132
Jiri Slabyed79ba12007-02-10 01:45:18 -0800133/* software flow control on chip mask value */
Jiri Slaby037ad482006-12-08 02:38:11 -0800134#define MOXA_MUST_EFR_SF_MASK 0x0F
Jiri Slabyed79ba12007-02-10 01:45:18 -0800135/* send Xon1/Xoff1 */
Jiri Slaby037ad482006-12-08 02:38:11 -0800136#define MOXA_MUST_EFR_SF_TX1 0x08
Jiri Slabyed79ba12007-02-10 01:45:18 -0800137/* send Xon2/Xoff2 */
Jiri Slaby037ad482006-12-08 02:38:11 -0800138#define MOXA_MUST_EFR_SF_TX2 0x04
Jiri Slabyed79ba12007-02-10 01:45:18 -0800139/* send Xon1,Xon2/Xoff1,Xoff2 */
Jiri Slaby037ad482006-12-08 02:38:11 -0800140#define MOXA_MUST_EFR_SF_TX12 0x0C
Jiri Slabyed79ba12007-02-10 01:45:18 -0800141/* don't send Xon/Xoff */
Jiri Slaby037ad482006-12-08 02:38:11 -0800142#define MOXA_MUST_EFR_SF_TX_NO 0x00
Jiri Slabyed79ba12007-02-10 01:45:18 -0800143/* Tx software flow control mask */
Jiri Slaby037ad482006-12-08 02:38:11 -0800144#define MOXA_MUST_EFR_SF_TX_MASK 0x0C
Jiri Slabyed79ba12007-02-10 01:45:18 -0800145/* don't receive Xon/Xoff */
Jiri Slaby037ad482006-12-08 02:38:11 -0800146#define MOXA_MUST_EFR_SF_RX_NO 0x00
Jiri Slabyed79ba12007-02-10 01:45:18 -0800147/* receive Xon1/Xoff1 */
Jiri Slaby037ad482006-12-08 02:38:11 -0800148#define MOXA_MUST_EFR_SF_RX1 0x02
Jiri Slabyed79ba12007-02-10 01:45:18 -0800149/* receive Xon2/Xoff2 */
Jiri Slaby037ad482006-12-08 02:38:11 -0800150#define MOXA_MUST_EFR_SF_RX2 0x01
Jiri Slabyed79ba12007-02-10 01:45:18 -0800151/* receive Xon1,Xon2/Xoff1,Xoff2 */
Jiri Slaby037ad482006-12-08 02:38:11 -0800152#define MOXA_MUST_EFR_SF_RX12 0x03
Jiri Slabyed79ba12007-02-10 01:45:18 -0800153/* Rx software flow control mask */
Jiri Slaby037ad482006-12-08 02:38:11 -0800154#define MOXA_MUST_EFR_SF_RX_MASK 0x03
155
Jiri Slabyed79ba12007-02-10 01:45:18 -0800156#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do { \
157 u8 __oldlcr, __efr; \
158 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800159 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800160 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
161 __efr |= MOXA_MUST_EFR_EFRB_ENABLE; \
162 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
163 outb(__oldlcr, (baseio)+UART_LCR); \
164} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800165
Jiri Slabyed79ba12007-02-10 01:45:18 -0800166#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do { \
167 u8 __oldlcr, __efr; \
168 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800169 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800170 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
171 __efr &= ~MOXA_MUST_EFR_EFRB_ENABLE; \
172 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
173 outb(__oldlcr, (baseio)+UART_LCR); \
174} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800175
Jiri Slabyed79ba12007-02-10 01:45:18 -0800176#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) do { \
177 u8 __oldlcr, __efr; \
178 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800179 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800180 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
181 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
182 __efr |= MOXA_MUST_EFR_BANK0; \
183 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800184 outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800185 outb(__oldlcr, (baseio)+UART_LCR); \
186} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800187
Jiri Slabyed79ba12007-02-10 01:45:18 -0800188#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) do { \
189 u8 __oldlcr, __efr; \
190 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800191 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800192 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
193 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
194 __efr |= MOXA_MUST_EFR_BANK0; \
195 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800196 outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800197 outb(__oldlcr, (baseio)+UART_LCR); \
198} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800199
Jiri Slabyed79ba12007-02-10 01:45:18 -0800200#define SET_MOXA_MUST_FIFO_VALUE(info) do { \
201 u8 __oldlcr, __efr; \
202 __oldlcr = inb((info)->ioaddr+UART_LCR); \
203 outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR);\
Jiri Slaby55b307d2006-12-08 02:38:14 -0800204 __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800205 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
206 __efr |= MOXA_MUST_EFR_BANK1; \
Jiri Slaby55b307d2006-12-08 02:38:14 -0800207 outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800208 outb((u8)((info)->rx_high_water), (info)->ioaddr+ \
209 MOXA_MUST_RBRTH_REGISTER); \
210 outb((u8)((info)->rx_trigger), (info)->ioaddr+ \
211 MOXA_MUST_RBRTI_REGISTER); \
212 outb((u8)((info)->rx_low_water), (info)->ioaddr+ \
213 MOXA_MUST_RBRTL_REGISTER); \
214 outb(__oldlcr, (info)->ioaddr+UART_LCR); \
215} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800216
Jiri Slabyf64c84a2007-02-10 01:45:21 -0800217#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) do { \
218 u8 __oldlcr, __efr; \
219 __oldlcr = inb((baseio)+UART_LCR); \
220 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
221 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
222 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
223 __efr |= MOXA_MUST_EFR_BANK2; \
224 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
225 outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER); \
226 outb(__oldlcr, (baseio)+UART_LCR); \
227} while (0)
228
Jiri Slabyed79ba12007-02-10 01:45:18 -0800229#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) do { \
230 u8 __oldlcr, __efr; \
231 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800232 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800233 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
234 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
235 __efr |= MOXA_MUST_EFR_BANK2; \
236 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
237 *pId = inb((baseio)+MOXA_MUST_HWID_REGISTER); \
238 outb(__oldlcr, (baseio)+UART_LCR); \
239} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800240
Jiri Slabyed79ba12007-02-10 01:45:18 -0800241#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) do { \
242 u8 __oldlcr, __efr; \
243 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800244 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800245 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
246 __efr &= ~MOXA_MUST_EFR_SF_MASK; \
247 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
248 outb(__oldlcr, (baseio)+UART_LCR); \
249} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800250
Jiri Slabyed79ba12007-02-10 01:45:18 -0800251#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do { \
252 u8 __oldlcr, __efr; \
253 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800254 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800255 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
256 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \
257 __efr |= MOXA_MUST_EFR_SF_TX1; \
258 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
259 outb(__oldlcr, (baseio)+UART_LCR); \
260} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800261
Jiri Slabyed79ba12007-02-10 01:45:18 -0800262#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do { \
263 u8 __oldlcr, __efr; \
264 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800265 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800266 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
267 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \
268 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
269 outb(__oldlcr, (baseio)+UART_LCR); \
270} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800271
Jiri Slabyed79ba12007-02-10 01:45:18 -0800272#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do { \
273 u8 __oldlcr, __efr; \
274 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800275 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800276 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
277 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \
278 __efr |= MOXA_MUST_EFR_SF_RX1; \
279 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
280 outb(__oldlcr, (baseio)+UART_LCR); \
281} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800282
Jiri Slabyed79ba12007-02-10 01:45:18 -0800283#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do { \
284 u8 __oldlcr, __efr; \
285 __oldlcr = inb((baseio)+UART_LCR); \
Jiri Slaby037ad482006-12-08 02:38:11 -0800286 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
Jiri Slabyed79ba12007-02-10 01:45:18 -0800287 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
288 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \
289 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
290 outb(__oldlcr, (baseio)+UART_LCR); \
291} while (0)
Jiri Slaby037ad482006-12-08 02:38:11 -0800292
Jiri Slaby037ad482006-12-08 02:38:11 -0800293#endif