blob: e6cb15626567a7312e9cbcf88cb6597d14bd28bb [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _MXSER_H
3#define _MXSER_H
4
5/*
6 * Semi-public control interfaces
7 */
Jiri Slaby1c456072008-02-07 00:16:46 -08008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009/*
10 * MOXA ioctls
11 */
12
13#define MOXA 0x400
14#define MOXA_GETDATACOUNT (MOXA + 23)
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#define MOXA_DIAGNOSE (MOXA + 50)
16#define MOXA_CHKPORTENABLE (MOXA + 60)
17#define MOXA_HighSpeedOn (MOXA + 61)
18#define MOXA_GET_MAJOR (MOXA + 63)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#define MOXA_GETMSTATUS (MOXA + 65)
20#define MOXA_SET_OP_MODE (MOXA + 66)
21#define MOXA_GET_OP_MODE (MOXA + 67)
22
23#define RS232_MODE 0
24#define RS485_2WIRE_MODE 1
25#define RS422_MODE 2
26#define RS485_4WIRE_MODE 3
27#define OP_MODE_MASK 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Jiri Slaby1c456072008-02-07 00:16:46 -080029#define MOXA_SDS_RSTICOUNTER (MOXA + 69)
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#define MOXA_ASPP_OQUEUE (MOXA + 70)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#define MOXA_ASPP_MON (MOXA + 73)
32#define MOXA_ASPP_LSTATUS (MOXA + 74)
33#define MOXA_ASPP_MON_EXT (MOXA + 75)
34#define MOXA_SET_BAUD_METHOD (MOXA + 76)
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/* --------------------------------------------------- */
37
38#define NPPI_NOTIFY_PARITY 0x01
39#define NPPI_NOTIFY_FRAMING 0x02
40#define NPPI_NOTIFY_HW_OVERRUN 0x04
41#define NPPI_NOTIFY_SW_OVERRUN 0x08
42#define NPPI_NOTIFY_BREAK 0x10
43
Jiri Slaby1c456072008-02-07 00:16:46 -080044#define NPPI_NOTIFY_CTSHOLD 0x01 /* Tx hold by CTS low */
45#define NPPI_NOTIFY_DSRHOLD 0x02 /* Tx hold by DSR low */
46#define NPPI_NOTIFY_XOFFHOLD 0x08 /* Tx hold by Xoff received */
47#define NPPI_NOTIFY_XOFFXENT 0x10 /* Xoff Sent */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Jiri Slaby1c456072008-02-07 00:16:46 -080049/* follow just for Moxa Must chip define. */
50/* */
51/* when LCR register (offset 0x03) write following value, */
52/* the Must chip will enter enchance mode. And write value */
53/* on EFR (offset 0x02) bit 6,7 to change bank. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#define MOXA_MUST_ENTER_ENCHANCE 0xBF
55
Jiri Slaby1c456072008-02-07 00:16:46 -080056/* when enhance mode enable, access on general bank register */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define MOXA_MUST_GDL_REGISTER 0x07
58#define MOXA_MUST_GDL_MASK 0x7F
59#define MOXA_MUST_GDL_HAS_BAD_DATA 0x80
60
Jiri Slaby1c456072008-02-07 00:16:46 -080061#define MOXA_MUST_LSR_RERR 0x80 /* error in receive FIFO */
62/* enchance register bank select and enchance mode setting register */
63/* when LCR register equal to 0xBF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define MOXA_MUST_EFR_REGISTER 0x02
Jiri Slaby1c456072008-02-07 00:16:46 -080065/* enchance mode enable */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#define MOXA_MUST_EFR_EFRB_ENABLE 0x10
Jiri Slaby1c456072008-02-07 00:16:46 -080067/* enchance reister bank set 0, 1, 2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#define MOXA_MUST_EFR_BANK0 0x00
69#define MOXA_MUST_EFR_BANK1 0x40
70#define MOXA_MUST_EFR_BANK2 0x80
71#define MOXA_MUST_EFR_BANK3 0xC0
72#define MOXA_MUST_EFR_BANK_MASK 0xC0
73
Jiri Slaby1c456072008-02-07 00:16:46 -080074/* set XON1 value register, when LCR=0xBF and change to bank0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#define MOXA_MUST_XON1_REGISTER 0x04
76
Jiri Slaby1c456072008-02-07 00:16:46 -080077/* set XON2 value register, when LCR=0xBF and change to bank0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#define MOXA_MUST_XON2_REGISTER 0x05
79
Jiri Slaby1c456072008-02-07 00:16:46 -080080/* set XOFF1 value register, when LCR=0xBF and change to bank0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#define MOXA_MUST_XOFF1_REGISTER 0x06
82
Jiri Slaby1c456072008-02-07 00:16:46 -080083/* set XOFF2 value register, when LCR=0xBF and change to bank0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#define MOXA_MUST_XOFF2_REGISTER 0x07
85
86#define MOXA_MUST_RBRTL_REGISTER 0x04
87#define MOXA_MUST_RBRTH_REGISTER 0x05
88#define MOXA_MUST_RBRTI_REGISTER 0x06
89#define MOXA_MUST_THRTL_REGISTER 0x07
90#define MOXA_MUST_ENUM_REGISTER 0x04
91#define MOXA_MUST_HWID_REGISTER 0x05
92#define MOXA_MUST_ECR_REGISTER 0x06
93#define MOXA_MUST_CSR_REGISTER 0x07
94
Jiri Slaby1c456072008-02-07 00:16:46 -080095/* good data mode enable */
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#define MOXA_MUST_FCR_GDA_MODE_ENABLE 0x20
Jiri Slaby1c456072008-02-07 00:16:46 -080097/* only good data put into RxFIFO */
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#define MOXA_MUST_FCR_GDA_ONLY_ENABLE 0x10
99
Jiri Slaby1c456072008-02-07 00:16:46 -0800100/* enable CTS interrupt */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#define MOXA_MUST_IER_ECTSI 0x80
Jiri Slaby1c456072008-02-07 00:16:46 -0800102/* enable RTS interrupt */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#define MOXA_MUST_IER_ERTSI 0x40
Jiri Slaby1c456072008-02-07 00:16:46 -0800104/* enable Xon/Xoff interrupt */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#define MOXA_MUST_IER_XINT 0x20
Jiri Slaby1c456072008-02-07 00:16:46 -0800106/* enable GDA interrupt */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107#define MOXA_MUST_IER_EGDAI 0x10
108
109#define MOXA_MUST_RECV_ISR (UART_IER_RDI | MOXA_MUST_IER_EGDAI)
110
Jiri Slaby1c456072008-02-07 00:16:46 -0800111/* GDA interrupt pending */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#define MOXA_MUST_IIR_GDA 0x1C
113#define MOXA_MUST_IIR_RDA 0x04
114#define MOXA_MUST_IIR_RTO 0x0C
115#define MOXA_MUST_IIR_LSR 0x06
116
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300117/* received Xon/Xoff or specical interrupt pending */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#define MOXA_MUST_IIR_XSC 0x10
119
Jiri Slaby1c456072008-02-07 00:16:46 -0800120/* RTS/CTS change state interrupt pending */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#define MOXA_MUST_IIR_RTSCTS 0x20
122#define MOXA_MUST_IIR_MASK 0x3E
123
124#define MOXA_MUST_MCR_XON_FLAG 0x40
125#define MOXA_MUST_MCR_XON_ANY 0x80
126#define MOXA_MUST_MCR_TX_XON 0x08
127
Jiri Slaby1c456072008-02-07 00:16:46 -0800128/* software flow control on chip mask value */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#define MOXA_MUST_EFR_SF_MASK 0x0F
Jiri Slaby1c456072008-02-07 00:16:46 -0800130/* send Xon1/Xoff1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#define MOXA_MUST_EFR_SF_TX1 0x08
Jiri Slaby1c456072008-02-07 00:16:46 -0800132/* send Xon2/Xoff2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133#define MOXA_MUST_EFR_SF_TX2 0x04
Jiri Slaby1c456072008-02-07 00:16:46 -0800134/* send Xon1,Xon2/Xoff1,Xoff2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#define MOXA_MUST_EFR_SF_TX12 0x0C
Jiri Slaby1c456072008-02-07 00:16:46 -0800136/* don't send Xon/Xoff */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137#define MOXA_MUST_EFR_SF_TX_NO 0x00
Jiri Slaby1c456072008-02-07 00:16:46 -0800138/* Tx software flow control mask */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#define MOXA_MUST_EFR_SF_TX_MASK 0x0C
Jiri Slaby1c456072008-02-07 00:16:46 -0800140/* don't receive Xon/Xoff */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#define MOXA_MUST_EFR_SF_RX_NO 0x00
Jiri Slaby1c456072008-02-07 00:16:46 -0800142/* receive Xon1/Xoff1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143#define MOXA_MUST_EFR_SF_RX1 0x02
Jiri Slaby1c456072008-02-07 00:16:46 -0800144/* receive Xon2/Xoff2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#define MOXA_MUST_EFR_SF_RX2 0x01
Jiri Slaby1c456072008-02-07 00:16:46 -0800146/* receive Xon1,Xon2/Xoff1,Xoff2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147#define MOXA_MUST_EFR_SF_RX12 0x03
Jiri Slaby1c456072008-02-07 00:16:46 -0800148/* Rx software flow control mask */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#define MOXA_MUST_EFR_SF_RX_MASK 0x03
150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif