XenevaOS
Loading...
Searching...
No Matches
serial.h
Go to the documentation of this file.
1/*
2 * DCL <linux/linux/serial.h> -- assembled from mainline v7.2.
3 *
4 * include/linux/serial.h
5 * include/uapi/linux/serial.h
6 *
7 * Provenance, verbatim upstream:
8 * (unresolved)
9 *
10 * How this file was produced (python3 /tmp/mkbasehdr.py):
11 * - upstream text is copied as-is; these are layout-critical declarations
12 * and a hand-typed `struct uart_port` that disagrees with the vendor
13 * sources by one field would compile cleanly and then read the wrong
14 * offset at runtime, which is exactly the class of bug this whole
15 * exercise exists to avoid
16 * - <uapi/linux/X> content is inlined in place of its include: DCL has no
17 * uapi tree, BaseHdr is flat, and no vendored .c names a uapi path
18 * - the driver-local headers (8250.h, serial_base.h,
19 * serial_mctrl_gpio.h) are NOT here -- they are private to their driver
20 * and live in Vendored/ beside the .c that includes them, resolved by
21 * quoted-include rules
22 *
23 * Everything below this comment is mainline's. DCL-specific deviations are
24 * made where the errors demand them, not speculatively.
25 */
26
27/*
28 * include/linux/serial.h
29 *
30 * Copyright (C) 1992 by Theodore Ts'o.
31 *
32 * Redistribution of this file is permitted under the terms of the GNU
33 * Public License (GPL)
34 */
35#ifndef _LINUX_SERIAL_H
36#define _LINUX_SERIAL_H
37/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
38/*
39 * include/linux/serial.h
40 *
41 * Copyright (C) 1992 by Theodore Ts'o.
42 *
43 * Redistribution of this file is permitted under the terms of the GNU
44 * Public License (GPL)
45 */
46
47#ifndef _UAPI_LINUX_SERIAL_H
48#define _UAPI_LINUX_SERIAL_H
49
50#include <linux/const.h>
51#include <linux/types.h>
52
53#include <linux/tty_flags.h>
54
55
57 int type;
58 int line;
59 unsigned int port;
60 int irq;
61 int flags;
65 unsigned short close_delay;
66 char io_type;
68 int hub6;
69 unsigned short closing_wait; /* time to wait before closing */
70 unsigned short closing_wait2; /* no longer used... */
71 unsigned char *iomem_base;
72 unsigned short iomem_reg_shift;
73 unsigned int port_high;
74 unsigned long iomap_base; /* cookie passed into ioremap */
75};
76
77/*
78 * For the close wait times, 0 means wait forever for serial port to
79 * flush its output. 65535 means don't wait at all.
80 */
81#define ASYNC_CLOSING_WAIT_INF 0
82#define ASYNC_CLOSING_WAIT_NONE 65535
83
84/*
85 * These are the supported serial types.
86 */
87#define PORT_UNKNOWN 0
88#define PORT_8250 1
89#define PORT_16450 2
90#define PORT_16550 3
91#define PORT_16550A 4
92#define PORT_CIRRUS 5
93#define PORT_16650 6
94#define PORT_16650V2 7
95#define PORT_16750 8
96#define PORT_STARTECH 9
97#define PORT_16C950 10 /* Oxford Semiconductor */
98#define PORT_16654 11
99#define PORT_16850 12
100#define PORT_RSA 13 /* RSA-DV II/S card */
101#define PORT_MAX 13
102
103#define SERIAL_IO_PORT 0
104#define SERIAL_IO_HUB6 1
105#define SERIAL_IO_MEM 2
106#define SERIAL_IO_MEM32 3
107#define SERIAL_IO_AU 4
108#define SERIAL_IO_TSI 5
109#define SERIAL_IO_MEM32BE 6
110#define SERIAL_IO_MEM16 7
111
112#define UART_CLEAR_FIFO 0x01
113#define UART_USE_FIFO 0x02
114#define UART_STARTECH 0x04
115#define UART_NATSEMI 0x08
116
117
118/*
119 * Multiport serial configuration structure --- external structure
120 */
122 int irq;
123 int port1;
124 unsigned char mask1, match1;
125 int port2;
126 unsigned char mask2, match2;
127 int port3;
128 unsigned char mask3, match3;
129 int port4;
130 unsigned char mask4, match4;
132 int reserved[32];
133};
134
135/*
136 * Serial input interrupt line counters -- external structure
137 * Four lines can interrupt: CTS, DSR, RI, DCD
138 */
146
181#define SER_RS485_ENABLED _BITUL(0)
182#define SER_RS485_RTS_ON_SEND _BITUL(1)
183#define SER_RS485_RTS_AFTER_SEND _BITUL(2)
184/* Placeholder for bit 3: SER_RS485_RTS_BEFORE_SEND, which isn't used anymore */
185#define SER_RS485_RX_DURING_TX _BITUL(4)
186#define SER_RS485_TERMINATE_BUS _BITUL(5)
187#define SER_RS485_ADDRB _BITUL(6)
188#define SER_RS485_ADDR_RECV _BITUL(7)
189#define SER_RS485_ADDR_DEST _BITUL(8)
190#define SER_RS485_MODE_RS422 _BITUL(9)
191
194
195 /* The fields below are defined by flags */
196 union {
197 __u32 padding[5]; /* Memory is cheap, new structs are a pain */
198
199 struct {
204 };
205 };
206};
207
208/*
209 * Serial interface for controlling ISO7816 settings on chips with suitable
210 * support. Set with TIOCSISO7816 and get with TIOCGISO7816 if supported by
211 * your platform.
212 */
214 __u32 flags; /* ISO7816 feature flags */
215#define SER_ISO7816_ENABLED (1 << 0)
216#define SER_ISO7816_T_PARAM (0x0f << 4)
217#define SER_ISO7816_T(t) (((t) & 0x0f) << 4)
223};
224
225#endif /* _UAPI_LINUX_SERIAL_H */
226
227#include <linux/ioctl.h>
228#include <linux/serial_reg.h>
229
230#define UART_IER_ALL_INTR (UART_IER_MSI | \
231 UART_IER_RLSI | \
232 UART_IER_THRI | \
233 UART_IER_RDI)
234
235/* Helper for dealing with UART_LCR_WLEN* defines */
236#define UART_LCR_WLEN(x) ((x) - 5)
237
238/* FIFO and shifting register empty */
239#define UART_LSR_BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
240
241static inline bool uart_lsr_tx_empty(u16 lsr)
242{
244}
245
246#define UART_MSR_STATUS_BITS (UART_MSR_DCD | \
247 UART_MSR_RI | \
248 UART_MSR_DSR | \
249 UART_MSR_CTS)
250
251/*
252 * Counters of the input lines (CTS, DSR, RI, CD) interrupts
253 */
254
260
261#include <linux/compiler.h>
262
263
264/*
265 * Serial ioctl request numbers.
266 *
267 * mainline keeps these in include/uapi/asm-generic/ioctls.h, mixed in with
268 * every other request number on the architecture; DCL's tree has no
269 * asm-generic layer and no other home for them, so they sit here next to the
270 * rest of the serial vocabulary they operate on (struct serial_struct,
271 * struct serial_iso7816 -- both defined above, which is what makes the two
272 * _IOWR/_IOR entries below computable at all).
273 *
274 * Every value is an ABI constant: userspace passes these straight through
275 * tty_io.c to uart_ioctl(), and 8250_port.c's ioctl() dispatch switches on
276 * them. Copied verbatim from asm-generic/ioctls.h (mainline v7.2) -- the
277 * numbers are the interesting part, not the spelling.
278 *
279 * Note the encoding split these reveal: all but two are bare integers, while
280 * TIOCGISO7816/TIOCSISO7816 are built with _IOR/_IOWR from <linux/ioctl.h>.
281 * See that header for why two encodings coexist in the tree right now.
282 */
283#define TIOCGSERIAL 0x541E
284#define TIOCSSERIAL 0x541F
285#define TIOCGRS485 0x542E
286#define TIOCSRS485 0x542F
287#define TIOCSERCONFIG 0x5453
288#define TIOCSERGETLSR 0x5459 /* Get line status register */
289#define TIOCSERGETMULTI 0x545A /* Get multiport config */
290#define TIOCSERSETMULTI 0x545B /* Set multiport config */
291#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
292#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
293#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
294#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
295#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
296
297#endif /* _LINUX_SERIAL_H */
uint32_t __u32
Definition drm.h:42
uint8_t __u8
Definition drm.h:38
uint16_t u16
Definition kernel.h:15
#define UART_LSR_BOTH_EMPTY
Definition serial.h:239
Definition serial.h:255
__u32 dsr
Definition serial.h:256
__u32 cts
Definition serial.h:256
__u32 tx
Definition serial.h:256
__u32 overrun
Definition serial.h:257
__u32 dcd
Definition serial.h:256
__u32 rng
Definition serial.h:256
__u32 brk
Definition serial.h:257
__u32 frame
Definition serial.h:257
__u32 parity
Definition serial.h:257
__u32 rx
Definition serial.h:256
__u32 buf_overrun
Definition serial.h:258
Definition serial.h:139
int reserved[9]
Definition serial.h:144
int frame
Definition serial.h:142
int tx
Definition serial.h:141
int rx
Definition serial.h:141
int parity
Definition serial.h:142
int rng
Definition serial.h:140
int cts
Definition serial.h:140
int brk
Definition serial.h:142
int dcd
Definition serial.h:140
int overrun
Definition serial.h:142
int dsr
Definition serial.h:140
int buf_overrun
Definition serial.h:143
Definition serial.h:213
__u32 sc_di
Definition serial.h:220
__u32 reserved[5]
Definition serial.h:222
__u32 clk
Definition serial.h:221
__u32 sc_fi
Definition serial.h:219
__u32 flags
Definition serial.h:214
__u32 tg
Definition serial.h:218
Definition serial.h:121
unsigned char match2
Definition serial.h:126
unsigned char mask1
Definition serial.h:124
unsigned char match1
Definition serial.h:124
int port4
Definition serial.h:129
int port1
Definition serial.h:123
int port_monitor
Definition serial.h:131
unsigned char mask4
Definition serial.h:130
unsigned char match4
Definition serial.h:130
int port3
Definition serial.h:127
unsigned char mask2
Definition serial.h:126
unsigned char mask3
Definition serial.h:128
unsigned char match3
Definition serial.h:128
int reserved[32]
Definition serial.h:132
int port2
Definition serial.h:125
int irq
Definition serial.h:122
Definition serial.h:179
__u32 flags
Definition serial.h:180
__u8 padding0[2]
Definition serial.h:202
__u32 delay_rts_after_send
Definition serial.h:193
__u32 delay_rts_before_send
Definition serial.h:192
__u32 padding1[4]
Definition serial.h:203
__u32 padding[5]
Definition serial.h:197
__u8 addr_dest
Definition serial.h:201
__u8 addr_recv
Definition serial.h:200
Definition serial.h:56
unsigned short close_delay
Definition serial.h:65
int baud_base
Definition serial.h:64
unsigned short closing_wait2
Definition serial.h:70
int line
Definition serial.h:58
char reserved_char[1]
Definition serial.h:67
unsigned int port_high
Definition serial.h:73
int hub6
Definition serial.h:68
int custom_divisor
Definition serial.h:63
char io_type
Definition serial.h:66
unsigned char * iomem_base
Definition serial.h:71
int flags
Definition serial.h:61
unsigned int port
Definition serial.h:59
unsigned short iomem_reg_shift
Definition serial.h:72
int irq
Definition serial.h:60
unsigned short closing_wait
Definition serial.h:69
int xmit_fifo_size
Definition serial.h:62
int type
Definition serial.h:57
unsigned long iomap_base
Definition serial.h:74