XenevaOS
Loading...
Searching...
No Matches
serial_core.h
Go to the documentation of this file.
1/*
2 * DCL <linux/linux/serial_core.h> -- assembled from mainline v7.2.
3 *
4 * include/linux/serial_core.h
5 * include/uapi/linux/serial_core.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/* SPDX-License-Identifier: GPL-2.0-or-later */
28/*
29 * linux/drivers/char/serial_core.h
30 *
31 * Copyright (C) 2000 Deep Blue Solutions Ltd.
32 */
33#ifndef LINUX_SERIAL_CORE_H
34#define LINUX_SERIAL_CORE_H
35
36#include <linux/bitops.h>
37#include <linux/compiler.h>
38#include <linux/console.h>
39#include <linux/interrupt.h>
40#include <linux/lockdep.h>
41#include <linux/printk.h>
42#include <linux/spinlock.h>
43#include <linux/sched.h>
44#include <linux/tty.h>
45#include <linux/mutex.h>
46#include <linux/sysrq.h>
47/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
48/*
49 * Copyright (C) 2000 Deep Blue Solutions Ltd.
50 */
51#ifndef _UAPILINUX_SERIAL_CORE_H
52#define _UAPILINUX_SERIAL_CORE_H
53
54#include <linux/serial.h>
55
56/*
57 * The type definitions. These are from Ted Ts'o's serial.h
58 * By historical reasons the values from 0 to 13 are defined
59 * in the include/uapi/linux/serial.h, do not define them here.
60 * Values 0 to 19 are used by setserial from busybox and must never
61 * be modified.
62 */
63#define PORT_NS16550A 14
64#define PORT_XSCALE 15
65#define PORT_RM9000 16 /* PMC-Sierra RM9xxx internal UART */
66#define PORT_OCTEON 17 /* Cavium OCTEON internal UART */
67#define PORT_AR7 18 /* Texas Instruments AR7 internal UART */
68#define PORT_U6_16550A 19 /* ST-Ericsson U6xxx internal UART */
69#define PORT_TEGRA 20 /* NVIDIA Tegra internal UART */
70#define PORT_XR17D15X 21 /* Exar XR17D15x UART */
71#define PORT_LPC3220 22 /* NXP LPC32xx SoC "Standard" UART */
72#define PORT_8250_CIR 23 /* CIR infrared port, has its own driver */
73#define PORT_XR17V35X 24 /* Exar XR17V35x UARTs */
74#define PORT_BRCM_TRUMANAGE 25
75#define PORT_ALTR_16550_F32 26 /* Altera 16550 UART with 32 FIFOs */
76#define PORT_ALTR_16550_F64 27 /* Altera 16550 UART with 64 FIFOs */
77#define PORT_ALTR_16550_F128 28 /* Altera 16550 UART with 128 FIFOs */
78#define PORT_RT2880 29 /* Ralink RT2880 internal UART */
79#define PORT_16550A_FSL64 30 /* Freescale 16550 UART with 64 FIFOs */
80
81/*
82 * ARM specific type numbers. These are not currently guaranteed
83 * to be implemented, and will change in the future. These are
84 * separate so any additions to the old serial.c that occur before
85 * we are merged can be easily merged here.
86 */
87#define PORT_PXA 31
88#define PORT_AMBA 32
89#define PORT_CLPS711X 33
90#define PORT_SA1100 34
91#define PORT_UART00 35
92#define PORT_OWL 36
93#define PORT_21285 37
94
95/* Sparc type numbers. */
96#define PORT_SUNZILOG 38
97#define PORT_SUNSAB 39
98
99/* Nuvoton UART */
100#define PORT_NPCM 40
101
102/* NVIDIA Tegra Combined UART */
103#define PORT_TEGRA_TCU 41
104
105/* ASPEED AST2x00 virtual UART */
106#define PORT_ASPEED_VUART 42
107
108/* Intel EG20 */
109#define PORT_PCH_8LINE 44
110#define PORT_PCH_2LINE 45
111
112/* DEC */
113#define PORT_DZ 46
114#define PORT_ZS 47
115
116/* Parisc type numbers. */
117#define PORT_MUX 48
118
119/* Atmel AT91 SoC */
120#define PORT_ATMEL 49
121
122/* Macintosh Zilog type numbers */
123#define PORT_MAC_ZILOG 50 /* m68k : not yet implemented */
124#define PORT_PMAC_ZILOG 51
125
126/* SH-SCI */
127#define PORT_SCI 52
128#define PORT_SCIF 53
129#define PORT_IRDA 54
130
131/* SGI IP22 aka Indy / Challenge S / Indigo 2 */
132#define PORT_IP22ZILOG 56
133
134/* PPC CPM type number */
135#define PORT_CPM 58
136
137/* MPC52xx (and MPC512x) type numbers */
138#define PORT_MPC52xx 59
139
140/* IBM icom */
141#define PORT_ICOM 60
142
143/* Motorola i.MX SoC */
144#define PORT_IMX 62
145
146/* TXX9 type number */
147#define PORT_TXX9 64
148
149/*Digi jsm */
150#define PORT_JSM 69
151
152/* SUN4V Hypervisor Console */
153#define PORT_SUNHV 72
154
155/* Xilinx uartlite */
156#define PORT_UARTLITE 74
157
158/* Broadcom BCM7271 UART */
159#define PORT_BCM7271 76
160
161/* Broadcom SB1250, etc. SOC */
162#define PORT_SB1250_DUART 77
163
164/* Freescale ColdFire */
165#define PORT_MCF 78
166
167#define PORT_SC26XX 82
168
169/* SH-SCI */
170#define PORT_SCIFA 83
171
172#define PORT_S3C6400 84
173
174/* MAX3100 */
175#define PORT_MAX3100 86
176
177/* Timberdale UART */
178#define PORT_TIMBUART 87
179
180/* Qualcomm MSM SoCs */
181#define PORT_MSM 88
182
183/* BCM63xx family SoCs */
184#define PORT_BCM63XX 89
185
186/* Aeroflex Gaisler GRLIB APBUART */
187#define PORT_APBUART 90
188
189/* Altera UARTs */
190#define PORT_ALTERA_JTAGUART 91
191#define PORT_ALTERA_UART 92
192
193/* SH-SCI */
194#define PORT_SCIFB 93
195
196/* MAX310X */
197#define PORT_MAX310X 94
198
199/* TI DA8xx/66AK2x */
200#define PORT_DA830 95
201
202/* TI OMAP-UART */
203#define PORT_OMAP 96
204
205/* VIA VT8500 SoC */
206#define PORT_VT8500 97
207
208/* Cadence (Xilinx Zynq) UART */
209#define PORT_XUARTPS 98
210
211/* Atheros AR933X SoC */
212#define PORT_AR933X 99
213
214/* MCHP 16550A UART with 256 byte FIFOs */
215#define PORT_MCHP16550A 100
216
217/* ARC (Synopsys) on-chip UART */
218#define PORT_ARC 101
219
220/* Rocketport EXPRESS/INFINITY */
221#define PORT_RP2 102
222
223/* Freescale lpuart */
224#define PORT_LPUART 103
225
226/* SH-SCI */
227#define PORT_HSCIF 104
228
229/* ST ASC type numbers */
230#define PORT_ASC 105
231
232/* MEN 16z135 UART */
233#define PORT_MEN_Z135 107
234
235/* SC16IS7xx */
236#define PORT_SC16IS7XX 108
237
238/* MESON */
239#define PORT_MESON 109
240
241/* Conexant Digicolor */
242#define PORT_DIGICOLOR 110
243
244/* SPRD SERIAL */
245#define PORT_SPRD 111
246
247/* STM32 USART */
248#define PORT_STM32 113
249
250/* MVEBU UART */
251#define PORT_MVEBU 114
252
253/* Microchip PIC32 UART */
254#define PORT_PIC32 115
255
256/* MPS2 UART */
257#define PORT_MPS2UART 116
258
259/* MediaTek BTIF */
260#define PORT_MTK_BTIF 117
261
262/* RDA UART */
263#define PORT_RDA 118
264
265/* Socionext Milbeaut UART */
266#define PORT_MLB_USIO 119
267
268/* SiFive UART */
269#define PORT_SIFIVE_V0 120
270
271/* Sunix UART */
272#define PORT_SUNIX 121
273
274/* Freescale LINFlexD UART */
275#define PORT_LINFLEXUART 122
276
277/* Sunplus UART */
278#define PORT_SUNPLUS 123
279
280/* Generic type identifier for ports which type is not important to userspace. */
281#define PORT_GENERIC (-1)
282
283#endif /* _UAPILINUX_SERIAL_CORE_H */
284
285
286#ifdef CONFIG_SERIAL_CORE_CONSOLE
287#define uart_console(port) \
288 ((port)->cons && (port)->cons->index == (port)->line)
289#else
290#define uart_console(port) ({ (void)port; 0; })
291#endif
292
293struct uart_port;
294struct serial_struct;
295struct serial_port_device;
296struct device;
297struct gpio_desc;
298
638struct uart_ops {
639 unsigned int (*tx_empty)(struct uart_port *);
640 void (*set_mctrl)(struct uart_port *, unsigned int mctrl);
641 unsigned int (*get_mctrl)(struct uart_port *);
642 void (*stop_tx)(struct uart_port *);
643 void (*start_tx)(struct uart_port *);
644 void (*throttle)(struct uart_port *);
645 void (*unthrottle)(struct uart_port *);
646 void (*send_xchar)(struct uart_port *, char ch);
647 void (*stop_rx)(struct uart_port *);
648 void (*start_rx)(struct uart_port *);
649 void (*enable_ms)(struct uart_port *);
650 void (*break_ctl)(struct uart_port *, int ctl);
651 int (*startup)(struct uart_port *);
652 void (*shutdown)(struct uart_port *);
653 void (*flush_buffer)(struct uart_port *);
654 void (*set_termios)(struct uart_port *, struct ktermios *new,
655 const struct ktermios *old);
656 void (*set_ldisc)(struct uart_port *, struct ktermios *);
657 void (*pm)(struct uart_port *, unsigned int state,
658 unsigned int oldstate);
659 const char *(*type)(struct uart_port *);
660 void (*release_port)(struct uart_port *);
661 int (*request_port)(struct uart_port *);
662 void (*config_port)(struct uart_port *, int);
663 int (*verify_port)(struct uart_port *, struct serial_struct *);
664 int (*ioctl)(struct uart_port *, unsigned int, unsigned long);
665#ifdef CONFIG_CONSOLE_POLL
666 int (*poll_init)(struct uart_port *);
667 void (*poll_put_char)(struct uart_port *, unsigned char);
668 int (*poll_get_char)(struct uart_port *);
669#endif
670};
671
672#define NO_POLL_CHAR 0x00ff0000
673#define UART_CONFIG_TYPE (1 << 0)
674#define UART_CONFIG_IRQ (1 << 1)
675
689
691typedef unsigned int __bitwise upstat_t;
692
695 UPIO_PORT = SERIAL_IO_PORT, /* 8b I/O port access */
696 UPIO_HUB6 = SERIAL_IO_HUB6, /* Hub6 ISA card */
697 UPIO_MEM = SERIAL_IO_MEM, /* driver-specific */
698 UPIO_MEM32 = SERIAL_IO_MEM32, /* 32b little endian */
699 UPIO_AU = SERIAL_IO_AU, /* Au1x00 and RT288x type IO */
700 UPIO_TSI = SERIAL_IO_TSI, /* Tsi108/109 type IO */
701 UPIO_MEM32BE = SERIAL_IO_MEM32BE, /* 32b big endian */
702 UPIO_MEM16 = SERIAL_IO_MEM16, /* 16b little endian */
703};
704
705struct uart_port {
706 spinlock_t lock; /* port lock */
707 unsigned long iobase; /* in/out[bwl] */
708 unsigned char __iomem *membase; /* read/write[bwl] */
709 u32 (*serial_in)(struct uart_port *, unsigned int offset);
710 void (*serial_out)(struct uart_port *, unsigned int offset, u32 val);
711 void (*set_termios)(struct uart_port *,
712 struct ktermios *new,
713 const struct ktermios *old);
714 void (*set_ldisc)(struct uart_port *,
715 struct ktermios *);
716 unsigned int (*get_mctrl)(struct uart_port *);
717 void (*set_mctrl)(struct uart_port *, unsigned int);
718 unsigned int (*get_divisor)(struct uart_port *,
719 unsigned int baud,
720 unsigned int *frac);
721 void (*set_divisor)(struct uart_port *,
722 unsigned int baud,
723 unsigned int quot,
724 unsigned int quot_frac);
725 int (*startup)(struct uart_port *port);
726 void (*shutdown)(struct uart_port *port);
727 void (*throttle)(struct uart_port *port);
728 void (*unthrottle)(struct uart_port *port);
729 int (*handle_irq)(struct uart_port *);
730 void (*pm)(struct uart_port *, unsigned int state,
731 unsigned int old);
732 void (*handle_break)(struct uart_port *);
733 int (*rs485_config)(struct uart_port *,
734 struct ktermios *termios,
735 struct serial_rs485 *rs485);
736 int (*iso7816_config)(struct uart_port *,
737 struct serial_iso7816 *iso7816);
738 unsigned int ctrl_id; /* optional serial core controller id */
739 unsigned int port_id; /* optional serial core port id */
740 unsigned int irq; /* irq number */
741 unsigned long irqflags; /* irq flags */
742 unsigned int uartclk; /* base uart clock */
743 unsigned int fifosize; /* tx fifo size */
744 unsigned char x_char; /* xon/xoff char */
745 unsigned char regshift; /* reg offset shift */
746
747 unsigned char quirks; /* internal quirks */
748
749 /* internal quirks must be updated while holding port mutex */
750#define UPQ_NO_TXEN_TEST BIT(0)
751
752 enum uart_iotype iotype; /* io access style */
753
754 unsigned int read_status_mask; /* driver specific */
755 unsigned int ignore_status_mask; /* driver specific */
756 struct uart_state *state; /* pointer to parent state */
757 struct uart_icount icount; /* statistics */
758
759 struct console *cons; /* struct console, if any */
760 /* flags must be updated while holding port mutex */
762
763 /*
764 * These flags must be equivalent to the flags defined in
765 * include/uapi/linux/tty_flags.h which are the userspace definitions
766 * assigned from the serial_struct flags in uart_set_info()
767 * [for bit definitions in the UPF_CHANGE_MASK]
768 *
769 * Bits [0..ASYNCB_LAST_USER] are userspace defined/visible/changeable
770 * The remaining bits are serial-core specific and not modifiable by
771 * userspace.
772 */
773#ifdef CONFIG_HAS_IOPORT
774#define UPF_FOURPORT ((__force upf_t) ASYNC_FOURPORT /* 1 */ )
775#else
776#define UPF_FOURPORT 0
777#endif
778#define UPF_SAK ((__force upf_t) ASYNC_SAK /* 2 */ )
779#define UPF_SPD_HI ((__force upf_t) ASYNC_SPD_HI /* 4 */ )
780#define UPF_SPD_VHI ((__force upf_t) ASYNC_SPD_VHI /* 5 */ )
781#define UPF_SPD_CUST ((__force upf_t) ASYNC_SPD_CUST /* 0x0030 */ )
782#define UPF_SPD_WARP ((__force upf_t) ASYNC_SPD_WARP /* 0x1010 */ )
783#define UPF_SPD_MASK ((__force upf_t) ASYNC_SPD_MASK /* 0x1030 */ )
784#define UPF_SKIP_TEST ((__force upf_t) ASYNC_SKIP_TEST /* 6 */ )
785#define UPF_AUTO_IRQ ((__force upf_t) ASYNC_AUTO_IRQ /* 7 */ )
786#define UPF_HARDPPS_CD ((__force upf_t) ASYNC_HARDPPS_CD /* 11 */ )
787#define UPF_SPD_SHI ((__force upf_t) ASYNC_SPD_SHI /* 12 */ )
788#define UPF_LOW_LATENCY ((__force upf_t) ASYNC_LOW_LATENCY /* 13 */ )
789#define UPF_BUGGY_UART ((__force upf_t) ASYNC_BUGGY_UART /* 14 */ )
790#define UPF_MAGIC_MULTIPLIER ((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ )
791
792#define UPF_NO_THRE_TEST ((__force upf_t) BIT_ULL(19))
793/* Port has hardware-assisted h/w flow control */
794#define UPF_AUTO_CTS ((__force upf_t) BIT_ULL(20))
795#define UPF_AUTO_RTS ((__force upf_t) BIT_ULL(21))
796#define UPF_HARD_FLOW ((__force upf_t) (UPF_AUTO_CTS | UPF_AUTO_RTS))
797/* Port has hardware-assisted s/w flow control */
798#define UPF_SOFT_FLOW ((__force upf_t) BIT_ULL(22))
799/* Deprecated: use uart_set_cons_flow_enabled()/uart_cons_flow_enabled() instead. */
800#define UPF_CONS_FLOW ((__force upf_t) BIT_ULL(23))
801#define UPF_SHARE_IRQ ((__force upf_t) BIT_ULL(24))
802#define UPF_EXAR_EFR ((__force upf_t) BIT_ULL(25))
803#define UPF_BUG_THRE ((__force upf_t) BIT_ULL(26))
804/* The exact UART type is known and should not be probed. */
805#define UPF_FIXED_TYPE ((__force upf_t) BIT_ULL(27))
806#define UPF_BOOT_AUTOCONF ((__force upf_t) BIT_ULL(28))
807#define UPF_FIXED_PORT ((__force upf_t) BIT_ULL(29))
808#define UPF_DEAD ((__force upf_t) BIT_ULL(30))
809#define UPF_IOREMAP ((__force upf_t) BIT_ULL(31))
810#define UPF_FULL_PROBE ((__force upf_t) BIT_ULL(32))
811
812#define __UPF_CHANGE_MASK 0x17fff
813#define UPF_CHANGE_MASK ((__force upf_t) __UPF_CHANGE_MASK)
814#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))
815
816#if __UPF_CHANGE_MASK > ASYNC_FLAGS
817#error Change mask not equivalent to userspace-visible bit defines
818#endif
819
820 /*
821 * Must hold termios_rwsem, port mutex and port lock to change;
822 * can hold any one lock to read.
823 */
825
826#define UPSTAT_CTS_ENABLE ((__force upstat_t) (1 << 0))
827#define UPSTAT_DCD_ENABLE ((__force upstat_t) (1 << 1))
828#define UPSTAT_AUTORTS ((__force upstat_t) (1 << 2))
829#define UPSTAT_AUTOCTS ((__force upstat_t) (1 << 3))
830#define UPSTAT_AUTOXOFF ((__force upstat_t) (1 << 4))
831#define UPSTAT_SYNC_FIFO ((__force upstat_t) (1 << 5))
832
833 bool hw_stopped; /* sw-assisted CTS flow state */
834 bool cons_flow; /* user specified console flow control */
835 unsigned int mctrl; /* current modem ctrl settings */
836 unsigned int frame_time; /* frame timing in ns */
837 unsigned int type; /* port type */
838 const struct uart_ops *ops;
839 unsigned int custom_divisor;
840 unsigned int line; /* port index */
841 unsigned int minor;
842 resource_size_t mapbase; /* for ioremap */
844 struct device *dev; /* serial port physical parent device */
845 struct serial_port_device *port_dev; /* serial core port device */
846
847 unsigned long sysrq; /* sysrq timeout */
848 u8 sysrq_ch; /* char for sysrq */
849 unsigned char has_sysrq;
850 unsigned char sysrq_seq; /* index in sysrq_toggle_seq */
851
852 unsigned char hub6; /* this should be in the 8250 driver */
853 unsigned char suspended;
854 unsigned char console_reinit;
855 const char *name; /* port name */
856 struct attribute_group *attr_group; /* port specific attributes */
857 const struct attribute_group **tty_groups; /* all attributes (serial core use only) */
859 struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */
860 struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */
861 struct gpio_desc *rs485_rx_during_tx_gpio; /* Output GPIO that sets the state of RS485 RX during TX */
863 void *private_data; /* generic platform data pointer */
864};
865
866/*
867 * Only for console->device_lock()/_unlock() callbacks and internal
868 * port lock wrapper synchronization.
869 */
870static inline void __uart_port_lock_irqsave(struct uart_port *up, unsigned long *flags)
871{
872 spin_lock_irqsave(&up->lock, *flags);
873}
874
875/*
876 * Only for console->device_lock()/_unlock() callbacks and internal
877 * port lock wrapper synchronization.
878 */
879static inline void __uart_port_unlock_irqrestore(struct uart_port *up, unsigned long flags)
880{
882}
883
893static inline void uart_port_set_cons(struct uart_port *up, struct console *con)
894{
895 unsigned long flags;
896
897 __uart_port_lock_irqsave(up, &flags);
898 up->cons = con;
899 __uart_port_unlock_irqrestore(up, flags);
900}
901
902/*
903 * nbcon (the atomic console) is reduced to its non-nbcon answer.
904 *
905 * mainline decides, on every port lock, whether the console attached to the
906 * port is an atomic one -- CON_NBCON with a ->write_atomic, on the console
907 * list -- and if so takes the console's own atomic context around the lock.
908 * DCL has none of that: no CON_NBCON, no ->write_atomic, no nbcon_device_*
909 * anywhere in BaseHdr, and a struct console whose only output path is ->write,
910 * which must not be reentered. The port lock is precisely what serialises it.
911 *
912 * What matters for the vendored sources is that the WRAPPERS stay callable
913 * with mainline's signatures -- uart_port_lock(), uart_port_lock_irq(),
914 * uart_port_lock_irqsave() and the guard definitions below all route through
915 * these three, and 8250_port.c / serial_core.c are compiled byte-identical to
916 * upstream. So the shapes are kept and only the answer changes, and `false`
917 * is not a stub standing in for unimplemented behaviour: it is mainline's own
918 * first branch for any console that is not CON_NBCON, which is every console
919 * DCL can register. The nbcon arms are unreachable rather than approximated.
920 *
921 * If DCL ever grows an atomic console this is the function to restore -- the
922 * call sites never changed, so only the bodies have to come back.
923 */
924static inline bool __uart_port_using_nbcon(struct uart_port *up)
925{
926 (void)up;
927 return false;
928}
929
930static inline bool __uart_port_nbcon_try_acquire(struct uart_port *up)
931{
932 (void)up;
933 return true;
934}
935
936static inline void __uart_port_nbcon_acquire(struct uart_port *up)
937{
938 (void)up;
939}
940
941static inline void __uart_port_nbcon_release(struct uart_port *up)
942{
943 (void)up;
944}
945
950static inline void uart_port_lock(struct uart_port *up)
951{
952 spin_lock(&up->lock);
953 __uart_port_nbcon_acquire(up);
954}
955
960static inline void uart_port_lock_irq(struct uart_port *up)
961{
962 spin_lock_irq(&up->lock);
963 __uart_port_nbcon_acquire(up);
964}
965
971static inline void uart_port_lock_irqsave(struct uart_port *up, unsigned long *flags)
972{
973 spin_lock_irqsave(&up->lock, *flags);
974 __uart_port_nbcon_acquire(up);
975}
976
983static inline bool uart_port_trylock(struct uart_port *up)
984{
985 if (!spin_trylock(&up->lock))
986 return false;
987
988 if (!__uart_port_nbcon_try_acquire(up)) {
989 spin_unlock(&up->lock);
990 return false;
991 }
992
993 return true;
994}
995
1003static inline bool uart_port_trylock_irqsave(struct uart_port *up, unsigned long *flags)
1004{
1005 if (!spin_trylock_irqsave(&up->lock, *flags))
1006 return false;
1007
1008 if (!__uart_port_nbcon_try_acquire(up)) {
1010 return false;
1011 }
1012
1013 return true;
1014}
1015
1020static inline void uart_port_unlock(struct uart_port *up)
1021{
1022 __uart_port_nbcon_release(up);
1023 spin_unlock(&up->lock);
1024}
1025
1030static inline void uart_port_unlock_irq(struct uart_port *up)
1031{
1032 __uart_port_nbcon_release(up);
1033 spin_unlock_irq(&up->lock);
1034}
1035
1041static inline void uart_port_unlock_irqrestore(struct uart_port *up, unsigned long flags)
1042{
1043 __uart_port_nbcon_release(up);
1045}
1046
1047/*
1048 * Two of mainline's six guard definitions are missing here: DEFINE_GUARD_COND
1049 * and DEFINE_LOCK_GUARD_1_COND, which produced `uart_port_lock_try` and
1050 * `uart_port_lock_irqsave_try`.
1051 *
1052 * Dropped rather than ported, for the reason <linux/cleanup.h> gives in its
1053 * own header: "Add them when something does, rather than carrying a
1054 * speculative surface." Grep guard( across 8250_port.c, serial_core.c and
1055 * 8250.h -- uart_port_lock_irq, uart_port_lock_irqsave,
1056 * uart_port_lock_check_sysrq_irqsave, serial8250_rpm, mutex, rwsem_write,
1057 * spinlock_irq -- and no _try class is ever taken. A conditional acquire
1058 * with no caller is machinery with no test and no way to get it wrong yet.
1059 *
1060 * The other four definitions remain mainline's verbatim: only the two that
1061 * produce types nothing uses were removed.
1062 */
1063DEFINE_GUARD(uart_port_lock, struct uart_port *, uart_port_lock(_T), uart_port_unlock(_T));
1064DEFINE_GUARD(uart_port_lock_irq, struct uart_port *, uart_port_lock_irq(_T),
1065 uart_port_unlock_irq(_T));
1066
1067DEFINE_LOCK_GUARD_1(uart_port_lock_irqsave, struct uart_port,
1068 uart_port_lock_irqsave(_T->lock, &_T->flags),
1069 uart_port_unlock_irqrestore(_T->lock, _T->flags),
1070 unsigned long flags);
1071static inline int serial_port_in(struct uart_port *up, int offset)
1072{
1073 return up->serial_in(up, offset);
1074}
1075
1076static inline void serial_port_out(struct uart_port *up, int offset, int value)
1077{
1078 up->serial_out(up, offset, value);
1079}
1080
1092
1093/*
1094 * This is the state information which is persistent across opens.
1095 */
1105
1106#define UART_XMIT_SIZE PAGE_SIZE
1107
1108
1109/* number of characters left in xmit buffer before we ask for more */
1110#define WAKEUP_CHARS 256
1111
1121static inline void uart_xmit_advance(struct uart_port *up, unsigned int chars)
1122{
1123 struct tty_port *tport = &up->state->port;
1124
1125 kfifo_skip_count(&tport->xmit_fifo, chars);
1126 up->icount.tx += chars;
1127}
1128
1129static inline unsigned int uart_fifo_out(struct uart_port *up,
1130 unsigned char *buf, unsigned int chars)
1131{
1132 struct tty_port *tport = &up->state->port;
1133
1134 chars = kfifo_out(&tport->xmit_fifo, buf, chars);
1135 up->icount.tx += chars;
1136
1137 return chars;
1138}
1139
1140static inline unsigned int uart_fifo_get(struct uart_port *up,
1141 unsigned char *ch)
1142{
1143 struct tty_port *tport = &up->state->port;
1144 unsigned int chars;
1145
1146 chars = kfifo_get(&tport->xmit_fifo, ch);
1147 up->icount.tx += chars;
1148
1149 return chars;
1150}
1151
1152struct module;
1153struct tty_driver;
1154
1156 struct module *owner;
1157 const char *driver_name;
1158 const char *dev_name;
1161 int nr;
1162 struct console *cons;
1163
1164 /*
1165 * these are private; the low level driver should not
1166 * touch these; they should be initialised to NULL
1167 */
1170};
1171
1172void uart_write_wakeup(struct uart_port *port);
1173
1182
1183#define __uart_port_tx(uport, ch, flags, tx_ready, put_char, tx_done, \
1184 for_test, for_post) \
1185({ \
1186 struct uart_port *__port = (uport); \
1187 struct tty_port *__tport = &__port->state->port; \
1188 unsigned int pending; \
1189 \
1190 for (; (for_test) && (tx_ready); (for_post), __port->icount.tx++) { \
1191 if (__port->x_char) { \
1192 (ch) = __port->x_char; \
1193 (put_char); \
1194 __port->x_char = 0; \
1195 continue; \
1196 } \
1197 \
1198 if (uart_tx_stopped(__port)) \
1199 break; \
1200 \
1201 if (!kfifo_get(&__tport->xmit_fifo, &(ch))) \
1202 break; \
1203 \
1204 (put_char); \
1205 } \
1206 \
1207 (tx_done); \
1208 \
1209 pending = kfifo_len(&__tport->xmit_fifo); \
1210 if (pending < WAKEUP_CHARS) { \
1211 uart_write_wakeup(__port); \
1212 \
1213 if (!((flags) & UART_TX_NOSTOP) && pending == 0) \
1214 __port->ops->stop_tx(__port); \
1215 } \
1216 \
1217 pending; \
1218})
1219
1246#define uart_port_tx_limited(port, ch, count, tx_ready, put_char, tx_done) ({ \
1247 unsigned int __count = (count); \
1248 __uart_port_tx(port, ch, 0, tx_ready, put_char, tx_done, __count, \
1249 __count--); \
1250})
1251
1264#define uart_port_tx_limited_flags(port, ch, flags, count, tx_ready, put_char, tx_done) ({ \
1265 unsigned int __count = (count); \
1266 __uart_port_tx(port, ch, flags, tx_ready, put_char, tx_done, __count, \
1267 __count--); \
1268})
1269
1279#define uart_port_tx(port, ch, tx_ready, put_char) \
1280 __uart_port_tx(port, ch, 0, tx_ready, put_char, ({}), true, ({}))
1281
1282
1293#define uart_port_tx_flags(port, ch, flags, tx_ready, put_char) \
1294 __uart_port_tx(port, ch, flags, tx_ready, put_char, ({}), true, ({}))
1295/*
1296 * Baud rate helpers.
1297 */
1298void uart_update_timeout(struct uart_port *port, unsigned int cflag,
1299 unsigned int baud);
1300unsigned int uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
1301 const struct ktermios *old, unsigned int min,
1302 unsigned int max);
1303unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud);
1304
1305/*
1306 * Calculates FIFO drain time.
1307 */
1308static inline unsigned long uart_fifo_timeout(struct uart_port *port)
1309{
1310 u64 fifo_timeout = (u64)READ_ONCE(port->frame_time) * port->fifosize;
1311
1312 /* Add .02 seconds of slop */
1313 fifo_timeout += 20 * NSEC_PER_MSEC;
1314
1315 return max(nsecs_to_jiffies(fifo_timeout), 1UL);
1316}
1317
1318/* Base timer interval for polling */
1319static inline unsigned long uart_poll_timeout(struct uart_port *port)
1320{
1321 unsigned long timeout = uart_fifo_timeout(port);
1322
1323 return timeout > 6 ? (timeout / 2 - 2) : 1;
1324}
1325
1326/*
1327 * Console helpers.
1328 */
1330 struct console *con;
1332 char options[32]; /* e.g., 115200n8 */
1333 unsigned int baud;
1334};
1335
1337 char name[15];
1338 char name_term; /* In case compiler didn't '\0' term name */
1339 char compatible[128];
1340 int (*setup)(struct earlycon_device *, const char *options);
1341};
1342
1343extern const struct earlycon_id __earlycon_table[];
1344extern const struct earlycon_id __earlycon_table_end[];
1345
1346#if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
1347#define EARLYCON_USED_OR_UNUSED __used
1348#else
1349#define EARLYCON_USED_OR_UNUSED __maybe_unused
1350#endif
1351
1352#define OF_EARLYCON_DECLARE(_name, compat, fn) \
1353 static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
1354 EARLYCON_USED_OR_UNUSED __section("__earlycon_table") \
1355 __aligned(__alignof__(struct earlycon_id)) \
1356 = { .name = __stringify(_name), \
1357 .compatible = compat, \
1358 .setup = fn }
1359
1360#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)
1361
1362int of_setup_earlycon(const struct earlycon_id *match, unsigned long node,
1363 const char *options);
1364
1365#ifdef CONFIG_SERIAL_EARLYCON
1366extern bool earlycon_acpi_spcr_enable __initdata;
1367int setup_earlycon(char *buf);
1368#else
1369static const bool earlycon_acpi_spcr_enable EARLYCON_USED_OR_UNUSED;
1370static inline int setup_earlycon(char *buf) { return 0; }
1371#endif
1372
1373/* Variant of uart_console_registered() when the console_list_lock is held. */
1374static inline bool uart_console_registered_locked(struct uart_port *port)
1375{
1376 return uart_console(port) && console_is_registered_locked(port->cons);
1377}
1378
1379static inline bool uart_console_registered(struct uart_port *port)
1380{
1381 return uart_console(port) && console_is_registered(port->cons);
1382}
1383
1384int uart_parse_earlycon(char *p, enum uart_iotype *iotype,
1385 resource_size_t *addr, char **options);
1386void uart_parse_options(const char *options, int *baud, int *parity, int *bits,
1387 int *flow);
1388int uart_set_options(struct uart_port *port, struct console *co, int baud,
1389 int parity, int bits, int flow);
1391void uart_console_write(struct uart_port *port, const char *s,
1392 unsigned int count,
1393 void (*putchar)(struct uart_port *, unsigned char));
1394
1395/*
1396 * Port/driver registration/removal
1397 */
1400int uart_add_one_port(struct uart_driver *reg, struct uart_port *port);
1401void uart_remove_one_port(struct uart_driver *reg, struct uart_port *port);
1404bool uart_match_port(const struct uart_port *port1,
1405 const struct uart_port *port2);
1406
1407/*
1408 * Power Management
1409 */
1410int uart_suspend_port(struct uart_driver *reg, struct uart_port *port);
1411int uart_resume_port(struct uart_driver *reg, struct uart_port *port);
1412
1413static inline int uart_tx_stopped(struct uart_port *port)
1414{
1415 struct tty_struct *tty = port->state->port.tty;
1416 if ((tty && tty->flow.stopped) || port->hw_stopped)
1417 return 1;
1418 return 0;
1419}
1420
1421static inline bool uart_cts_enabled(struct uart_port *uport)
1422{
1423 return !!(uport->status & UPSTAT_CTS_ENABLE);
1424}
1425
1426static inline bool uart_softcts_mode(struct uart_port *uport)
1427{
1429
1430 return ((uport->status & mask) == UPSTAT_CTS_ENABLE);
1431}
1432
1433static inline void uart_set_cons_flow_enabled(struct uart_port *uport, bool enabled)
1434{
1435 uport->cons_flow = enabled;
1436}
1437
1438static inline bool uart_cons_flow_enabled(const struct uart_port *uport)
1439{
1440 return uport->cons_flow;
1441}
1442
1443static inline bool uart_console_hwflow_active(struct uart_port *uport)
1444{
1445 return uart_console(uport) &&
1446 !(uport->rs485.flags & SER_RS485_ENABLED) &&
1447 uart_cons_flow_enabled(uport) &&
1448 uart_cts_enabled(uport);
1449}
1450
1451/*
1452 * The following are helper functions for the low level drivers.
1453 */
1454
1455void uart_handle_dcd_change(struct uart_port *uport, bool active);
1456void uart_handle_cts_change(struct uart_port *uport, bool active);
1457
1458void uart_insert_char(struct uart_port *port, unsigned int status,
1459 unsigned int overrun, u8 ch, u8 flag);
1460
1461void uart_xchar_out(struct uart_port *uport, int offset);
1462
1463#ifdef CONFIG_MAGIC_SYSRQ_SERIAL
1464#define SYSRQ_TIMEOUT (HZ * 5)
1465
1466bool uart_try_toggle_sysrq(struct uart_port *port, u8 ch);
1467
1468static inline int uart_handle_sysrq_char(struct uart_port *port, u8 ch)
1469{
1470 if (!port->sysrq)
1471 return 0;
1472
1473 if (ch && time_before(jiffies, port->sysrq)) {
1474 if (sysrq_mask()) {
1475 handle_sysrq(ch);
1476 port->sysrq = 0;
1477 return 1;
1478 }
1479 if (uart_try_toggle_sysrq(port, ch))
1480 return 1;
1481 }
1482 port->sysrq = 0;
1483
1484 return 0;
1485}
1486
1487static inline int uart_prepare_sysrq_char(struct uart_port *port, u8 ch)
1488{
1489 if (!port->sysrq)
1490 return 0;
1491
1492 if (ch && time_before(jiffies, port->sysrq)) {
1493 if (sysrq_mask()) {
1494 port->sysrq_ch = ch;
1495 port->sysrq = 0;
1496 return 1;
1497 }
1498 if (uart_try_toggle_sysrq(port, ch))
1499 return 1;
1500 }
1501 port->sysrq = 0;
1502
1503 return 0;
1504}
1505
1506static inline void uart_unlock_and_check_sysrq(struct uart_port *port)
1507{
1508 u8 sysrq_ch;
1509
1510 if (!port->has_sysrq) {
1511 uart_port_unlock(port);
1512 return;
1513 }
1514
1515 sysrq_ch = port->sysrq_ch;
1516 port->sysrq_ch = 0;
1517
1518 uart_port_unlock(port);
1519
1520 if (sysrq_ch)
1521 handle_sysrq(sysrq_ch);
1522}
1523
1524static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port,
1525 unsigned long flags)
1526{
1527 u8 sysrq_ch;
1528
1529 if (!port->has_sysrq) {
1530 uart_port_unlock_irqrestore(port, flags);
1531 return;
1532 }
1533
1534 sysrq_ch = port->sysrq_ch;
1535 port->sysrq_ch = 0;
1536
1537 uart_port_unlock_irqrestore(port, flags);
1538
1539 if (sysrq_ch)
1540 handle_sysrq(sysrq_ch);
1541}
1542#else /* CONFIG_MAGIC_SYSRQ_SERIAL */
1543static inline int uart_handle_sysrq_char(struct uart_port *port, u8 ch)
1544{
1545 return 0;
1546}
1547static inline int uart_prepare_sysrq_char(struct uart_port *port, u8 ch)
1548{
1549 return 0;
1550}
1551static inline void uart_unlock_and_check_sysrq(struct uart_port *port)
1552{
1553 uart_port_unlock(port);
1554}
1555static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port,
1556 unsigned long flags)
1557{
1558 uart_port_unlock_irqrestore(port, flags);
1559}
1560#endif /* CONFIG_MAGIC_SYSRQ_SERIAL */
1561
1562/*
1563 * Variant of guard(uart_port_lock_irqsave) for IRQ handlers that may capture
1564 * a SysRq character via uart_prepare_sysrq_char(). The destructor uses the
1565 * sysrq-aware unlock helper so that a captured port->sysrq_ch is dispatched
1566 * to handle_sysrq() on scope exit. The plain guard variant silently drops
1567 * sysrq_ch and must not be used by callers that process RX.
1568 */
1569DEFINE_LOCK_GUARD_1(uart_port_lock_check_sysrq_irqsave, struct uart_port,
1570 uart_port_lock_irqsave(_T->lock, &_T->flags),
1571 uart_unlock_and_check_sysrq_irqrestore(_T->lock, _T->flags),
1572 unsigned long flags);
1573
1574/*
1575 * We do the SysRQ and SAK checking like this...
1576 */
1577static inline int uart_handle_break(struct uart_port *port)
1578{
1579 struct uart_state *state = port->state;
1580
1581 if (port->handle_break)
1582 port->handle_break(port);
1583
1584#ifdef CONFIG_MAGIC_SYSRQ_SERIAL
1585 if (port->has_sysrq && uart_console(port)) {
1586 if (!port->sysrq) {
1587 port->sysrq = jiffies + SYSRQ_TIMEOUT;
1588 return 1;
1589 }
1590 port->sysrq = 0;
1591 }
1592#endif
1593 if (port->flags & UPF_SAK)
1594 do_SAK(state->port.tty);
1595 return 0;
1596}
1597
1598/*
1599 * UART_ENABLE_MS - determine if port should enable modem status irqs
1600 */
1601#define UART_ENABLE_MS(port,cflag) ((port)->flags & UPF_HARDPPS_CD || \
1602 (cflag) & CRTSCTS || \
1603 !((cflag) & CLOCAL))
1604
1606#endif /* LINUX_SERIAL_CORE_H */
int putchar(int)
Definition stdio.cpp:240
char * chars
Definition clib.cpp:105
uint8_t flags
Definition virtio.h:0
#define index(str, chr)
Definition string.h:66
#define __iomem
Definition aclinux.h:312
#define BIT(nr)
Definition bitops.h:112
flag
Definition bytecode.h:29
#define DEFINE_LOCK_GUARD_1(_name, _type, _lock, _unlock,...)
Definition cleanup.h:255
#define DEFINE_GUARD(_name, _type, _lock, _unlock)
Definition cleanup.h:223
#define __bitwise
Definition compiler.h:57
bool enabled
Definition compose3d.cpp:135
int console_is_registered(struct console *con)
uint32_t __u32
Definition drm.h:42
size_t size_t offset
Definition drm_bridge.h:1299
void int node
Definition kthread.h:31
uint64_t u64
Definition kernel.h:17
uintptr_t resource_size_t
Definition kernel.h:41
uint8_t u8
Definition kernel.h:14
#define READ_ONCE(x)
Definition kernel.h:605
#define spin_unlock_irqrestore(l, f)
Definition kernel.h:227
#define spin_lock_irqsave(l, f)
Definition kernel.h:226
#define NSEC_PER_MSEC
Definition kernel.h:407
int spinlock_t
Definition kernel.h:44
uint32_t u32
Definition kernel.h:16
#define SERIAL_IO_TSI
Definition serial.h:108
#define SERIAL_IO_MEM
Definition serial.h:105
#define SERIAL_IO_AU
Definition serial.h:107
#define SERIAL_IO_HUB6
Definition serial.h:104
#define SER_RS485_ENABLED
Definition serial.h:181
#define SERIAL_IO_MEM32
Definition serial.h:106
#define SERIAL_IO_MEM16
Definition serial.h:110
#define SERIAL_IO_MEM32BE
Definition serial.h:109
#define SERIAL_IO_PORT
Definition serial.h:103
#define spin_trylock(l)
Definition spinlock.h:43
#define spin_lock(l)
Definition spinlock.h:36
#define spin_unlock(l)
Definition spinlock.h:37
#define spin_trylock_irqsave(l, f)
Definition spinlock.h:165
#define spin_lock_irq(l)
Definition spinlock.h:38
#define spin_unlock_irq(l)
Definition spinlock.h:39
#define time_before(a, b)
Definition timer.h:98
#define jiffies
Definition timer.h:55
#define nsecs_to_jiffies(n)
Definition timer.h:83
void do_SAK(struct tty_struct *tty)
@ options
Definition m_menu.c:234
#define min(a, b)
Definition minmax.h:24
#define max(a, b)
Definition minmax.h:28
@ up
Definition p_spec.h:261
#define UPSTAT_CTS_ENABLE
Definition serial_core.h:826
void uart_update_timeout(struct uart_port *port, unsigned int cflag, unsigned int baud)
int uart_get_rs485_mode(struct uart_port *port)
#define UPSTAT_AUTOCTS
Definition serial_core.h:829
const struct earlycon_id __earlycon_table_end[]
unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud)
int uart_set_options(struct uart_port *port, struct console *co, int baud, int parity, int bits, int flow)
void uart_xchar_out(struct uart_port *uport, int offset)
uart_pm_state
Definition serial_core.h:1087
@ UART_PM_STATE_OFF
Definition serial_core.h:1089
@ UART_PM_STATE_UNDEFINED
Definition serial_core.h:1090
@ UART_PM_STATE_ON
Definition serial_core.h:1088
u64 __bitwise upf_t
Definition serial_core.h:690
unsigned int __bitwise upstat_t
Definition serial_core.h:691
#define EARLYCON_USED_OR_UNUSED
Definition serial_core.h:1349
bool uart_match_port(const struct uart_port *port1, const struct uart_port *port2)
const struct earlycon_id __earlycon_table[]
void uart_console_write(struct uart_port *port, const char *s, unsigned int count, void(*putchar)(struct uart_port *, unsigned char))
UART_TX_FLAGS
Definition serial_core.h:1179
@ UART_TX_NOSTOP
Definition serial_core.h:1180
void uart_parse_options(const char *options, int *baud, int *parity, int *bits, int *flow)
int uart_parse_earlycon(char *p, enum uart_iotype *iotype, resource_size_t *addr, char **options)
unsigned int uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, const struct ktermios *old, unsigned int min, unsigned int max)
int uart_register_driver(struct uart_driver *uart)
int uart_read_port_properties(struct uart_port *port)
void uart_write_wakeup(struct uart_port *port)
void uart_remove_one_port(struct uart_driver *reg, struct uart_port *port)
int uart_resume_port(struct uart_driver *reg, struct uart_port *port)
int uart_add_one_port(struct uart_driver *reg, struct uart_port *port)
int of_setup_earlycon(const struct earlycon_id *match, unsigned long node, const char *options)
void uart_handle_cts_change(struct uart_port *uport, bool active)
uart_iotype
Definition serial_core.h:693
@ UPIO_TSI
Definition serial_core.h:700
@ UPIO_AU
Definition serial_core.h:699
@ UPIO_MEM32
Definition serial_core.h:698
@ UPIO_MEM
Definition serial_core.h:697
@ UPIO_HUB6
Definition serial_core.h:696
@ UPIO_PORT
Definition serial_core.h:695
@ UPIO_MEM32BE
Definition serial_core.h:701
@ UPIO_UNKNOWN
Definition serial_core.h:694
@ UPIO_MEM16
Definition serial_core.h:702
void uart_insert_char(struct uart_port *port, unsigned int status, unsigned int overrun, u8 ch, u8 flag)
void uart_unregister_driver(struct uart_driver *uart)
#define UPF_SAK
Definition serial_core.h:778
void uart_handle_dcd_change(struct uart_port *uport, bool active)
int uart_read_and_validate_port_properties(struct uart_port *port)
struct tty_driver * uart_console_device(struct console *co, int *index)
#define uart_console(port)
Definition serial_core.h:290
int uart_suspend_port(struct uart_driver *reg, struct uart_port *port)
Definition atomic.h:31
Definition sysfs.h:33
Definition console.h:39
Definition fs.h:255
Definition serial_core.h:1329
struct uart_port port
Definition serial_core.h:1331
struct console * con
Definition serial_core.h:1330
unsigned int baud
Definition serial_core.h:1333
char options[32]
Definition serial_core.h:1332
Definition serial_core.h:1336
int(* setup)(struct earlycon_device *, const char *options)
Definition serial_core.h:1340
char compatible[128]
Definition serial_core.h:1339
char name[15]
Definition serial_core.h:1337
char name_term
Definition serial_core.h:1338
Definition termios.h:250
Definition serial.h:213
Definition serial.h:179
__u32 flags
Definition serial.h:180
Definition serial.h:56
Definition termios.h:230
Definition tty_driver.h:122
Definition tty_port.h:79
unsigned long flags
Definition tty_port.h:90
struct tty_struct * tty
Definition tty_port.h:81
struct tty_bufhead buf
Definition tty_port.h:80
Definition tty.h:203
bool stopped
Definition tty.h:228
struct tty_struct::@94 flow
struct tty_port * port
Definition tty.h:208
Definition serial_core.h:1155
struct tty_driver * tty_driver
Definition serial_core.h:1169
const char * dev_name
Definition serial_core.h:1158
int nr
Definition serial_core.h:1161
struct console * cons
Definition serial_core.h:1162
struct uart_state * state
Definition serial_core.h:1168
const char * driver_name
Definition serial_core.h:1157
int major
Definition serial_core.h:1159
int minor
Definition serial_core.h:1160
struct module * owner
Definition serial_core.h:1156
Definition serial_core.h:676
__u32 parity
Definition serial_core.h:685
__u32 cts
Definition serial_core.h:677
__u32 overrun
Definition serial_core.h:684
__u32 frame
Definition serial_core.h:683
__u32 buf_overrun
Definition serial_core.h:687
__u32 rng
Definition serial_core.h:679
__u32 tx
Definition serial_core.h:682
__u32 dsr
Definition serial_core.h:678
__u32 dcd
Definition serial_core.h:680
__u32 brk
Definition serial_core.h:686
__u32 rx
Definition serial_core.h:681
Definition serial_core.h:638
int(* request_port)(struct uart_port *)
Definition serial_core.h:661
unsigned int(* get_mctrl)(struct uart_port *)
Definition serial_core.h:641
void(* start_rx)(struct uart_port *)
Definition serial_core.h:648
void(* throttle)(struct uart_port *)
Definition serial_core.h:644
void(* shutdown)(struct uart_port *)
Definition serial_core.h:652
void(* set_ldisc)(struct uart_port *, struct ktermios *)
Definition serial_core.h:656
void(* stop_tx)(struct uart_port *)
Definition serial_core.h:642
void(* config_port)(struct uart_port *, int)
Definition serial_core.h:662
void(* pm)(struct uart_port *, unsigned int state, unsigned int oldstate)
Definition serial_core.h:657
int(* verify_port)(struct uart_port *, struct serial_struct *)
Definition serial_core.h:663
void(* send_xchar)(struct uart_port *, char ch)
Definition serial_core.h:646
void(* stop_rx)(struct uart_port *)
Definition serial_core.h:647
void(* flush_buffer)(struct uart_port *)
Definition serial_core.h:653
void(* set_termios)(struct uart_port *, struct ktermios *new, const struct ktermios *old)
Definition serial_core.h:654
int(* ioctl)(struct uart_port *, unsigned int, unsigned long)
Definition serial_core.h:664
void(* release_port)(struct uart_port *)
Definition serial_core.h:660
int(* startup)(struct uart_port *)
Definition serial_core.h:651
void(* start_tx)(struct uart_port *)
Definition serial_core.h:643
unsigned int(* tx_empty)(struct uart_port *)
Definition serial_core.h:639
void(* set_mctrl)(struct uart_port *, unsigned int mctrl)
Definition serial_core.h:640
void(* enable_ms)(struct uart_port *)
Definition serial_core.h:649
void(* break_ctl)(struct uart_port *, int ctl)
Definition serial_core.h:650
void(* unthrottle)(struct uart_port *)
Definition serial_core.h:645
Definition serial_core.h:705
void(* serial_out)(struct uart_port *, unsigned int offset, u32 val)
Definition serial_core.h:710
void(* pm)(struct uart_port *, unsigned int state, unsigned int old)
Definition serial_core.h:730
void * private_data
Definition serial_core.h:863
bool cons_flow
Definition serial_core.h:834
unsigned char has_sysrq
Definition serial_core.h:849
struct device * dev
Definition serial_core.h:844
struct uart_state * state
Definition serial_core.h:756
struct gpio_desc * rs485_rx_during_tx_gpio
Definition serial_core.h:861
unsigned int read_status_mask
Definition serial_core.h:754
unsigned char __iomem * membase
Definition serial_core.h:708
struct console * cons
Definition serial_core.h:759
unsigned int irq
Definition serial_core.h:740
void(* set_ldisc)(struct uart_port *, struct ktermios *)
Definition serial_core.h:714
unsigned char hub6
Definition serial_core.h:852
struct attribute_group * attr_group
Definition serial_core.h:856
struct serial_port_device * port_dev
Definition serial_core.h:845
struct serial_iso7816 iso7816
Definition serial_core.h:862
const struct uart_ops * ops
Definition serial_core.h:838
resource_size_t mapbase
Definition serial_core.h:842
unsigned int type
Definition serial_core.h:837
void(* shutdown)(struct uart_port *port)
Definition serial_core.h:726
upstat_t status
Definition serial_core.h:824
unsigned long iobase
Definition serial_core.h:707
struct gpio_desc * rs485_term_gpio
Definition serial_core.h:860
void(* handle_break)(struct uart_port *)
Definition serial_core.h:732
unsigned int(* get_mctrl)(struct uart_port *)
Definition serial_core.h:716
int(* rs485_config)(struct uart_port *, struct ktermios *termios, struct serial_rs485 *rs485)
Definition serial_core.h:733
upf_t flags
Definition serial_core.h:761
unsigned long irqflags
Definition serial_core.h:741
unsigned int minor
Definition serial_core.h:841
unsigned long sysrq
Definition serial_core.h:847
int(* handle_irq)(struct uart_port *)
Definition serial_core.h:729
unsigned char x_char
Definition serial_core.h:744
struct uart_icount icount
Definition serial_core.h:757
unsigned char regshift
Definition serial_core.h:745
struct serial_rs485 rs485_supported
Definition serial_core.h:859
unsigned int ctrl_id
Definition serial_core.h:738
u32(* serial_in)(struct uart_port *, unsigned int offset)
Definition serial_core.h:709
enum uart_iotype iotype
Definition serial_core.h:752
const char * name
Definition serial_core.h:855
const struct attribute_group ** tty_groups
Definition serial_core.h:857
unsigned char console_reinit
Definition serial_core.h:854
void(* set_termios)(struct uart_port *, struct ktermios *new, const struct ktermios *old)
Definition serial_core.h:711
unsigned int frame_time
Definition serial_core.h:836
unsigned int port_id
Definition serial_core.h:739
unsigned char suspended
Definition serial_core.h:853
unsigned int fifosize
Definition serial_core.h:743
unsigned int mctrl
Definition serial_core.h:835
unsigned int ignore_status_mask
Definition serial_core.h:755
unsigned int line
Definition serial_core.h:840
void(* unthrottle)(struct uart_port *port)
Definition serial_core.h:728
unsigned int(* get_divisor)(struct uart_port *, unsigned int baud, unsigned int *frac)
Definition serial_core.h:718
unsigned int uartclk
Definition serial_core.h:742
u8 sysrq_ch
Definition serial_core.h:848
unsigned int custom_divisor
Definition serial_core.h:839
int(* startup)(struct uart_port *port)
Definition serial_core.h:725
spinlock_t lock
Definition serial_core.h:706
void(* set_divisor)(struct uart_port *, unsigned int baud, unsigned int quot, unsigned int quot_frac)
Definition serial_core.h:721
void(* set_mctrl)(struct uart_port *, unsigned int)
Definition serial_core.h:717
int(* iso7816_config)(struct uart_port *, struct serial_iso7816 *iso7816)
Definition serial_core.h:736
unsigned char sysrq_seq
Definition serial_core.h:850
void(* throttle)(struct uart_port *port)
Definition serial_core.h:727
bool hw_stopped
Definition serial_core.h:833
unsigned char quirks
Definition serial_core.h:747
struct serial_rs485 rs485
Definition serial_core.h:858
resource_size_t mapsize
Definition serial_core.h:843
Definition serial_core.h:1096
atomic_t refcount
Definition serial_core.h:1101
struct tty_port port
Definition serial_core.h:1097
struct uart_port * uart_port
Definition serial_core.h:1103
wait_queue_head_t remove_wait
Definition serial_core.h:1102
enum uart_pm_state pm_state
Definition serial_core.h:1099
Definition wait.h:75
#define state(x)