mxser_new.h 9.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#ifndef _MXSER_H
#define _MXSER_H

/*
 *	Semi-public control interfaces
 */

/*
 *	MOXA ioctls
 */

#define MOXA			0x400
#define MOXA_GETDATACOUNT	(MOXA + 23)
#define MOXA_DIAGNOSE		(MOXA + 50)
#define MOXA_CHKPORTENABLE	(MOXA + 60)
#define MOXA_HighSpeedOn	(MOXA + 61)
#define MOXA_GET_MAJOR		(MOXA + 63)
#define MOXA_GETMSTATUS		(MOXA + 65)
#define MOXA_SET_OP_MODE	(MOXA + 66)
#define MOXA_GET_OP_MODE	(MOXA + 67)

#define RS232_MODE		0
#define RS485_2WIRE_MODE	1
#define RS422_MODE		2
#define RS485_4WIRE_MODE	3
#define OP_MODE_MASK		3

28
#define MOXA_SDS_RSTICOUNTER	(MOXA + 69)
29 30 31 32 33 34 35 36 37 38 39 40 41 42
#define MOXA_ASPP_OQUEUE  	(MOXA + 70)
#define MOXA_ASPP_MON     	(MOXA + 73)
#define MOXA_ASPP_LSTATUS 	(MOXA + 74)
#define MOXA_ASPP_MON_EXT 	(MOXA + 75)
#define MOXA_SET_BAUD_METHOD	(MOXA + 76)

/* --------------------------------------------------- */

#define NPPI_NOTIFY_PARITY	0x01
#define NPPI_NOTIFY_FRAMING	0x02
#define NPPI_NOTIFY_HW_OVERRUN	0x04
#define NPPI_NOTIFY_SW_OVERRUN	0x08
#define NPPI_NOTIFY_BREAK	0x10

43 44 45 46 47 48 49 50 51 52
#define NPPI_NOTIFY_CTSHOLD         0x01	/* Tx hold by CTS low */
#define NPPI_NOTIFY_DSRHOLD         0x02	/* Tx hold by DSR low */
#define NPPI_NOTIFY_XOFFHOLD        0x08	/* Tx hold by Xoff received */
#define NPPI_NOTIFY_XOFFXENT        0x10	/* Xoff Sent */

/* follow just for Moxa Must chip define. */
/* */
/* when LCR register (offset 0x03) write following value, */
/* the Must chip will enter enchance mode. And write value */
/* on EFR (offset 0x02) bit 6,7 to change bank. */
53 54
#define MOXA_MUST_ENTER_ENCHANCE	0xBF

55
/* when enhance mode enable, access on general bank register */
56 57 58 59
#define MOXA_MUST_GDL_REGISTER		0x07
#define MOXA_MUST_GDL_MASK		0x7F
#define MOXA_MUST_GDL_HAS_BAD_DATA	0x80

60 61 62
#define MOXA_MUST_LSR_RERR		0x80	/* error in receive FIFO */
/* enchance register bank select and enchance mode setting register */
/* when LCR register equal to 0xBF */
63
#define MOXA_MUST_EFR_REGISTER		0x02
64
/* enchance mode enable */
65
#define MOXA_MUST_EFR_EFRB_ENABLE	0x10
66
/* enchance reister bank set 0, 1, 2 */
67 68 69 70 71 72
#define MOXA_MUST_EFR_BANK0		0x00
#define MOXA_MUST_EFR_BANK1		0x40
#define MOXA_MUST_EFR_BANK2		0x80
#define MOXA_MUST_EFR_BANK3		0xC0
#define MOXA_MUST_EFR_BANK_MASK		0xC0

73
/* set XON1 value register, when LCR=0xBF and change to bank0 */
74 75
#define MOXA_MUST_XON1_REGISTER		0x04

76
/* set XON2 value register, when LCR=0xBF and change to bank0 */
77 78
#define MOXA_MUST_XON2_REGISTER		0x05

79
/* set XOFF1 value register, when LCR=0xBF and change to bank0 */
80 81
#define MOXA_MUST_XOFF1_REGISTER	0x06

82
/* set XOFF2 value register, when LCR=0xBF and change to bank0 */
83 84 85 86 87 88 89 90 91 92 93
#define MOXA_MUST_XOFF2_REGISTER	0x07

#define MOXA_MUST_RBRTL_REGISTER	0x04
#define MOXA_MUST_RBRTH_REGISTER	0x05
#define MOXA_MUST_RBRTI_REGISTER	0x06
#define MOXA_MUST_THRTL_REGISTER	0x07
#define MOXA_MUST_ENUM_REGISTER		0x04
#define MOXA_MUST_HWID_REGISTER		0x05
#define MOXA_MUST_ECR_REGISTER		0x06
#define MOXA_MUST_CSR_REGISTER		0x07

94
/* good data mode enable */
95
#define MOXA_MUST_FCR_GDA_MODE_ENABLE	0x20
96
/* only good data put into RxFIFO */
97 98
#define MOXA_MUST_FCR_GDA_ONLY_ENABLE	0x10

99
/* enable CTS interrupt */
100
#define MOXA_MUST_IER_ECTSI		0x80
101
/* enable RTS interrupt */
102
#define MOXA_MUST_IER_ERTSI		0x40
103
/* enable Xon/Xoff interrupt */
104
#define MOXA_MUST_IER_XINT		0x20
105
/* enable GDA interrupt */
106 107 108 109
#define MOXA_MUST_IER_EGDAI		0x10

#define MOXA_MUST_RECV_ISR		(UART_IER_RDI | MOXA_MUST_IER_EGDAI)

110
/* GDA interrupt pending */
111 112 113 114 115
#define MOXA_MUST_IIR_GDA		0x1C
#define MOXA_MUST_IIR_RDA		0x04
#define MOXA_MUST_IIR_RTO		0x0C
#define MOXA_MUST_IIR_LSR		0x06

116
/* recieved Xon/Xoff or specical interrupt pending */
117 118
#define MOXA_MUST_IIR_XSC		0x10

119
/* RTS/CTS change state interrupt pending */
120 121 122 123 124 125 126
#define MOXA_MUST_IIR_RTSCTS		0x20
#define MOXA_MUST_IIR_MASK		0x3E

#define MOXA_MUST_MCR_XON_FLAG		0x40
#define MOXA_MUST_MCR_XON_ANY		0x80
#define MOXA_MUST_MCR_TX_XON		0x08

127
/* software flow control on chip mask value */
128
#define MOXA_MUST_EFR_SF_MASK		0x0F
129
/* send Xon1/Xoff1 */
130
#define MOXA_MUST_EFR_SF_TX1		0x08
131
/* send Xon2/Xoff2 */
132
#define MOXA_MUST_EFR_SF_TX2		0x04
133
/* send Xon1,Xon2/Xoff1,Xoff2 */
134
#define MOXA_MUST_EFR_SF_TX12		0x0C
135
/* don't send Xon/Xoff */
136
#define MOXA_MUST_EFR_SF_TX_NO		0x00
137
/* Tx software flow control mask */
138
#define MOXA_MUST_EFR_SF_TX_MASK	0x0C
139
/* don't receive Xon/Xoff */
140
#define MOXA_MUST_EFR_SF_RX_NO		0x00
141
/* receive Xon1/Xoff1 */
142
#define MOXA_MUST_EFR_SF_RX1		0x02
143
/* receive Xon2/Xoff2 */
144
#define MOXA_MUST_EFR_SF_RX2		0x01
145
/* receive Xon1,Xon2/Xoff1,Xoff2 */
146
#define MOXA_MUST_EFR_SF_RX12		0x03
147
/* Rx software flow control mask */
148 149
#define MOXA_MUST_EFR_SF_RX_MASK	0x03

150 151 152
#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do { 		\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
153
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
154 155 156 157 158 159 160 161 162
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr |= MOXA_MUST_EFR_EFRB_ENABLE;			\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do {		\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
163
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
164 165 166 167 168 169 170 171 172
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_EFRB_ENABLE;			\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) do {		\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
173
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
174 175 176 177
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_BANK_MASK;			\
	__efr |= MOXA_MUST_EFR_BANK0;				\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
178
	outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER);	\
179 180
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)
181

182 183 184
#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) do {		\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
185
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
186 187 188 189
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_BANK_MASK;			\
	__efr |= MOXA_MUST_EFR_BANK0;				\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
190
	outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER);	\
191 192
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)
193

194 195 196 197
#define SET_MOXA_MUST_FIFO_VALUE(info) do {			\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((info)->ioaddr+UART_LCR);		\
	outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR);\
198
	__efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER);	\
199 200
	__efr &= ~MOXA_MUST_EFR_BANK_MASK;			\
	__efr |= MOXA_MUST_EFR_BANK1;				\
201
	outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER);	\
202 203 204 205 206 207 208 209 210
	outb((u8)((info)->rx_high_water), (info)->ioaddr+	\
			MOXA_MUST_RBRTH_REGISTER);		\
	outb((u8)((info)->rx_trigger), (info)->ioaddr+		\
			MOXA_MUST_RBRTI_REGISTER);		\
	outb((u8)((info)->rx_low_water), (info)->ioaddr+	\
			MOXA_MUST_RBRTL_REGISTER);		\
	outb(__oldlcr, (info)->ioaddr+UART_LCR);		\
} while (0)

211 212 213 214 215 216 217 218 219 220 221 222
#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) do {		\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_BANK_MASK;			\
	__efr |= MOXA_MUST_EFR_BANK2;				\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER);	\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

223 224 225
#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) do {		\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
226
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
227 228 229 230 231 232 233 234 235 236 237
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_BANK_MASK;			\
	__efr |= MOXA_MUST_EFR_BANK2;				\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	*pId = inb((baseio)+MOXA_MUST_HWID_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) do {	\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
238
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
239 240 241 242 243 244 245 246 247
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_SF_MASK;			\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do {	\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
248
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
249 250 251 252 253 254 255 256 257 258
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_SF_TX_MASK;			\
	__efr |= MOXA_MUST_EFR_SF_TX1;				\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do {	\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
259
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
260 261 262 263 264 265 266 267 268
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_SF_TX_MASK;			\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do {	\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
269
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
270 271 272 273 274 275 276 277 278 279
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_SF_RX_MASK;			\
	__efr |= MOXA_MUST_EFR_SF_RX1;				\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)

#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do {	\
	u8	__oldlcr, __efr;				\
	__oldlcr = inb((baseio)+UART_LCR);			\
280
	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
281 282 283 284 285
	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);		\
	__efr &= ~MOXA_MUST_EFR_SF_RX_MASK;			\
	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);		\
	outb(__oldlcr, (baseio)+UART_LCR);			\
} while (0)
286 287

#endif