xref: /linux/include/linux/serial.h (revision 4413e16d9d21673bb5048a2e542f1aaa00015c2e)
1 /*
2  * include/linux/serial.h
3  *
4  * Copyright (C) 1992 by Theodore Ts'o.
5  *
6  * Redistribution of this file is permitted under the terms of the GNU
7  * Public License (GPL)
8  */
9 
10 #ifndef _LINUX_SERIAL_H
11 #define _LINUX_SERIAL_H
12 
13 #include <linux/types.h>
14 
15 #include <linux/tty_flags.h>
16 
17 #ifdef __KERNEL__
18 #include <asm/page.h>
19 
20 
21 /*
22  * Counters of the input lines (CTS, DSR, RI, CD) interrupts
23  */
24 
25 struct async_icount {
26 	__u32	cts, dsr, rng, dcd, tx, rx;
27 	__u32	frame, parity, overrun, brk;
28 	__u32	buf_overrun;
29 };
30 
31 /*
32  * The size of the serial xmit buffer is 1 page, or 4096 bytes
33  */
34 #define SERIAL_XMIT_SIZE PAGE_SIZE
35 
36 #endif
37 
38 struct serial_struct {
39 	int	type;
40 	int	line;
41 	unsigned int	port;
42 	int	irq;
43 	int	flags;
44 	int	xmit_fifo_size;
45 	int	custom_divisor;
46 	int	baud_base;
47 	unsigned short	close_delay;
48 	char	io_type;
49 	char	reserved_char[1];
50 	int	hub6;
51 	unsigned short	closing_wait; /* time to wait before closing */
52 	unsigned short	closing_wait2; /* no longer used... */
53 	unsigned char	*iomem_base;
54 	unsigned short	iomem_reg_shift;
55 	unsigned int	port_high;
56 	unsigned long	iomap_base;	/* cookie passed into ioremap */
57 };
58 
59 /*
60  * For the close wait times, 0 means wait forever for serial port to
61  * flush its output.  65535 means don't wait at all.
62  */
63 #define ASYNC_CLOSING_WAIT_INF	0
64 #define ASYNC_CLOSING_WAIT_NONE	65535
65 
66 /*
67  * These are the supported serial types.
68  */
69 #define PORT_UNKNOWN	0
70 #define PORT_8250	1
71 #define PORT_16450	2
72 #define PORT_16550	3
73 #define PORT_16550A	4
74 #define PORT_CIRRUS     5	/* usurped by cyclades.c */
75 #define PORT_16650	6
76 #define PORT_16650V2	7
77 #define PORT_16750	8
78 #define PORT_STARTECH	9	/* usurped by cyclades.c */
79 #define PORT_16C950	10	/* Oxford Semiconductor */
80 #define PORT_16654	11
81 #define PORT_16850	12
82 #define PORT_RSA	13	/* RSA-DV II/S card */
83 #define PORT_MAX	13
84 
85 #define SERIAL_IO_PORT	0
86 #define SERIAL_IO_HUB6	1
87 #define SERIAL_IO_MEM	2
88 
89 #define UART_CLEAR_FIFO		0x01
90 #define UART_USE_FIFO		0x02
91 #define UART_STARTECH		0x04
92 #define UART_NATSEMI		0x08
93 
94 
95 /*
96  * Multiport serial configuration structure --- external structure
97  */
98 struct serial_multiport_struct {
99 	int		irq;
100 	int		port1;
101 	unsigned char	mask1, match1;
102 	int		port2;
103 	unsigned char	mask2, match2;
104 	int		port3;
105 	unsigned char	mask3, match3;
106 	int		port4;
107 	unsigned char	mask4, match4;
108 	int		port_monitor;
109 	int	reserved[32];
110 };
111 
112 /*
113  * Serial input interrupt line counters -- external structure
114  * Four lines can interrupt: CTS, DSR, RI, DCD
115  */
116 struct serial_icounter_struct {
117 	int cts, dsr, rng, dcd;
118 	int rx, tx;
119 	int frame, overrun, parity, brk;
120 	int buf_overrun;
121 	int reserved[9];
122 };
123 
124 /*
125  * Serial interface for controlling RS485 settings on chips with suitable
126  * support. Set with TIOCSRS485 and get with TIOCGRS485 if supported by your
127  * platform. The set function returns the new state, with any unsupported bits
128  * reverted appropriately.
129  */
130 
131 struct serial_rs485 {
132 	__u32	flags;			/* RS485 feature flags */
133 #define SER_RS485_ENABLED		(1 << 0)	/* If enabled */
134 #define SER_RS485_RTS_ON_SEND		(1 << 1)	/* Logical level for
135 							   RTS pin when
136 							   sending */
137 #define SER_RS485_RTS_AFTER_SEND	(1 << 2)	/* Logical level for
138 							   RTS pin after sent*/
139 #define SER_RS485_RX_DURING_TX		(1 << 4)
140 	__u32	delay_rts_before_send;	/* Delay before send (milliseconds) */
141 	__u32	delay_rts_after_send;	/* Delay after send (milliseconds) */
142 	__u32	padding[5];		/* Memory is cheap, new structs
143 					   are a royal PITA .. */
144 };
145 
146 #ifdef __KERNEL__
147 #include <linux/compiler.h>
148 
149 #endif /* __KERNEL__ */
150 #endif /* _LINUX_SERIAL_H */
151