1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * include/linux/serial.h 4607ca46eSDavid Howells * 5607ca46eSDavid Howells * Copyright (C) 1992 by Theodore Ts'o. 6607ca46eSDavid Howells * 7607ca46eSDavid Howells * Redistribution of this file is permitted under the terms of the GNU 8607ca46eSDavid Howells * Public License (GPL) 9607ca46eSDavid Howells */ 10607ca46eSDavid Howells 11607ca46eSDavid Howells #ifndef _UAPI_LINUX_SERIAL_H 12607ca46eSDavid Howells #define _UAPI_LINUX_SERIAL_H 13607ca46eSDavid Howells 1476ac8e29SCrescent CY Hsieh #include <linux/const.h> 15607ca46eSDavid Howells #include <linux/types.h> 16607ca46eSDavid Howells 17607ca46eSDavid Howells #include <linux/tty_flags.h> 18607ca46eSDavid Howells 19607ca46eSDavid Howells 20607ca46eSDavid Howells struct serial_struct { 21607ca46eSDavid Howells int type; 22607ca46eSDavid Howells int line; 23607ca46eSDavid Howells unsigned int port; 24607ca46eSDavid Howells int irq; 25607ca46eSDavid Howells int flags; 26607ca46eSDavid Howells int xmit_fifo_size; 27607ca46eSDavid Howells int custom_divisor; 28607ca46eSDavid Howells int baud_base; 29607ca46eSDavid Howells unsigned short close_delay; 30607ca46eSDavid Howells char io_type; 31607ca46eSDavid Howells char reserved_char[1]; 32607ca46eSDavid Howells int hub6; 33607ca46eSDavid Howells unsigned short closing_wait; /* time to wait before closing */ 34607ca46eSDavid Howells unsigned short closing_wait2; /* no longer used... */ 35607ca46eSDavid Howells unsigned char *iomem_base; 36607ca46eSDavid Howells unsigned short iomem_reg_shift; 37607ca46eSDavid Howells unsigned int port_high; 38607ca46eSDavid Howells unsigned long iomap_base; /* cookie passed into ioremap */ 39607ca46eSDavid Howells }; 40607ca46eSDavid Howells 41607ca46eSDavid Howells /* 42607ca46eSDavid Howells * For the close wait times, 0 means wait forever for serial port to 43607ca46eSDavid Howells * flush its output. 65535 means don't wait at all. 44607ca46eSDavid Howells */ 45607ca46eSDavid Howells #define ASYNC_CLOSING_WAIT_INF 0 46607ca46eSDavid Howells #define ASYNC_CLOSING_WAIT_NONE 65535 47607ca46eSDavid Howells 48607ca46eSDavid Howells /* 49607ca46eSDavid Howells * These are the supported serial types. 50607ca46eSDavid Howells */ 51607ca46eSDavid Howells #define PORT_UNKNOWN 0 52607ca46eSDavid Howells #define PORT_8250 1 53607ca46eSDavid Howells #define PORT_16450 2 54607ca46eSDavid Howells #define PORT_16550 3 55607ca46eSDavid Howells #define PORT_16550A 4 56f76edd8fSJiri Slaby #define PORT_CIRRUS 5 57607ca46eSDavid Howells #define PORT_16650 6 58607ca46eSDavid Howells #define PORT_16650V2 7 59607ca46eSDavid Howells #define PORT_16750 8 60f76edd8fSJiri Slaby #define PORT_STARTECH 9 61607ca46eSDavid Howells #define PORT_16C950 10 /* Oxford Semiconductor */ 62607ca46eSDavid Howells #define PORT_16654 11 63607ca46eSDavid Howells #define PORT_16850 12 64607ca46eSDavid Howells #define PORT_RSA 13 /* RSA-DV II/S card */ 65607ca46eSDavid Howells #define PORT_MAX 13 66607ca46eSDavid Howells 67607ca46eSDavid Howells #define SERIAL_IO_PORT 0 68607ca46eSDavid Howells #define SERIAL_IO_HUB6 1 69607ca46eSDavid Howells #define SERIAL_IO_MEM 2 70647f162bSPeter Hurley #define SERIAL_IO_MEM32 3 71647f162bSPeter Hurley #define SERIAL_IO_AU 4 72647f162bSPeter Hurley #define SERIAL_IO_TSI 5 73647f162bSPeter Hurley #define SERIAL_IO_MEM32BE 6 74bd94c407SMasahiro Yamada #define SERIAL_IO_MEM16 7 75607ca46eSDavid Howells 76607ca46eSDavid Howells #define UART_CLEAR_FIFO 0x01 77607ca46eSDavid Howells #define UART_USE_FIFO 0x02 78607ca46eSDavid Howells #define UART_STARTECH 0x04 79607ca46eSDavid Howells #define UART_NATSEMI 0x08 80607ca46eSDavid Howells 81607ca46eSDavid Howells 82607ca46eSDavid Howells /* 83607ca46eSDavid Howells * Multiport serial configuration structure --- external structure 84607ca46eSDavid Howells */ 85607ca46eSDavid Howells struct serial_multiport_struct { 86607ca46eSDavid Howells int irq; 87607ca46eSDavid Howells int port1; 88607ca46eSDavid Howells unsigned char mask1, match1; 89607ca46eSDavid Howells int port2; 90607ca46eSDavid Howells unsigned char mask2, match2; 91607ca46eSDavid Howells int port3; 92607ca46eSDavid Howells unsigned char mask3, match3; 93607ca46eSDavid Howells int port4; 94607ca46eSDavid Howells unsigned char mask4, match4; 95607ca46eSDavid Howells int port_monitor; 96607ca46eSDavid Howells int reserved[32]; 97607ca46eSDavid Howells }; 98607ca46eSDavid Howells 99607ca46eSDavid Howells /* 100607ca46eSDavid Howells * Serial input interrupt line counters -- external structure 101607ca46eSDavid Howells * Four lines can interrupt: CTS, DSR, RI, DCD 102607ca46eSDavid Howells */ 103607ca46eSDavid Howells struct serial_icounter_struct { 104607ca46eSDavid Howells int cts, dsr, rng, dcd; 105607ca46eSDavid Howells int rx, tx; 106607ca46eSDavid Howells int frame, overrun, parity, brk; 107607ca46eSDavid Howells int buf_overrun; 108607ca46eSDavid Howells int reserved[9]; 109607ca46eSDavid Howells }; 110607ca46eSDavid Howells 1116dd07781SIlpo Järvinen /** 1126dd07781SIlpo Järvinen * struct serial_rs485 - serial interface for controlling RS485 settings. 1136dd07781SIlpo Järvinen * @flags: RS485 feature flags. 1146dd07781SIlpo Järvinen * @delay_rts_before_send: Delay before send (milliseconds). 1156dd07781SIlpo Järvinen * @delay_rts_after_send: Delay after send (milliseconds). 1166dd07781SIlpo Järvinen * @addr_recv: Receive filter for RS485 addressing mode 1176dd07781SIlpo Järvinen * (used only when %SER_RS485_ADDR_RECV is set). 1186dd07781SIlpo Järvinen * @addr_dest: Destination address for RS485 addressing mode 1196dd07781SIlpo Järvinen * (used only when %SER_RS485_ADDR_DEST is set). 1206dd07781SIlpo Järvinen * @padding0: Padding (set to zero). 1216dd07781SIlpo Järvinen * @padding1: Padding (set to zero). 1226dd07781SIlpo Järvinen * @padding: Deprecated, use @padding0 and @padding1 instead. 1236dd07781SIlpo Järvinen * Do not use with @addr_recv and @addr_dest (due to 1246dd07781SIlpo Järvinen * overlap). 1256dd07781SIlpo Järvinen * 126607ca46eSDavid Howells * Serial interface for controlling RS485 settings on chips with suitable 127607ca46eSDavid Howells * support. Set with TIOCSRS485 and get with TIOCGRS485 if supported by your 128607ca46eSDavid Howells * platform. The set function returns the new state, with any unsupported bits 129607ca46eSDavid Howells * reverted appropriately. 1306dd07781SIlpo Järvinen * 1316dd07781SIlpo Järvinen * The flag bits are: 1326dd07781SIlpo Järvinen * 1336dd07781SIlpo Järvinen * * %SER_RS485_ENABLED - RS485 enabled. 1346dd07781SIlpo Järvinen * * %SER_RS485_RTS_ON_SEND - Logical level for RTS pin when sending. 1356dd07781SIlpo Järvinen * * %SER_RS485_RTS_AFTER_SEND - Logical level for RTS pin after sent. 1366dd07781SIlpo Järvinen * * %SER_RS485_RX_DURING_TX - Full-duplex RS485 line. 1376dd07781SIlpo Järvinen * * %SER_RS485_TERMINATE_BUS - Enable bus termination (if supported). 1386dd07781SIlpo Järvinen * * %SER_RS485_ADDRB - Enable RS485 addressing mode. 1396dd07781SIlpo Järvinen * * %SER_RS485_ADDR_RECV - Receive address filter (enables @addr_recv). Requires %SER_RS485_ADDRB. 1406dd07781SIlpo Järvinen * * %SER_RS485_ADDR_DEST - Destination address (enables @addr_dest). Requires %SER_RS485_ADDRB. 1416056f20fSCrescent CY Hsieh * * %SER_RS485_MODE_RS422 - Enable RS422. Requires %SER_RS485_ENABLED. 142607ca46eSDavid Howells */ 143607ca46eSDavid Howells struct serial_rs485 { 1446dd07781SIlpo Järvinen __u32 flags; 14576ac8e29SCrescent CY Hsieh #define SER_RS485_ENABLED _BITUL(0) 14676ac8e29SCrescent CY Hsieh #define SER_RS485_RTS_ON_SEND _BITUL(1) 14776ac8e29SCrescent CY Hsieh #define SER_RS485_RTS_AFTER_SEND _BITUL(2) 148*e15c99beSChristoph Niedermaier /* Placeholder for bit 3: SER_RS485_RTS_BEFORE_SEND, which isn't used anymore */ 149*e15c99beSChristoph Niedermaier #define SER_RS485_RX_DURING_TX _BITUL(4) 150*e15c99beSChristoph Niedermaier #define SER_RS485_TERMINATE_BUS _BITUL(5) 151*e15c99beSChristoph Niedermaier #define SER_RS485_ADDRB _BITUL(6) 152*e15c99beSChristoph Niedermaier #define SER_RS485_ADDR_RECV _BITUL(7) 153*e15c99beSChristoph Niedermaier #define SER_RS485_ADDR_DEST _BITUL(8) 154*e15c99beSChristoph Niedermaier #define SER_RS485_MODE_RS422 _BITUL(9) 1554f768e94SIlpo Järvinen 1566dd07781SIlpo Järvinen __u32 delay_rts_before_send; 1576dd07781SIlpo Järvinen __u32 delay_rts_after_send; 1584f768e94SIlpo Järvinen 1594f768e94SIlpo Järvinen /* The fields below are defined by flags */ 1604f768e94SIlpo Järvinen union { 1614f768e94SIlpo Järvinen __u32 padding[5]; /* Memory is cheap, new structs are a pain */ 1624f768e94SIlpo Järvinen 1634f768e94SIlpo Järvinen struct { 1644f768e94SIlpo Järvinen __u8 addr_recv; 1654f768e94SIlpo Järvinen __u8 addr_dest; 1664f768e94SIlpo Järvinen __u8 padding0[2]; 1674f768e94SIlpo Järvinen __u32 padding1[4]; 1684f768e94SIlpo Järvinen }; 1694f768e94SIlpo Järvinen }; 170607ca46eSDavid Howells }; 171607ca46eSDavid Howells 172ad8c0eaaSNicolas Ferre /* 173ad8c0eaaSNicolas Ferre * Serial interface for controlling ISO7816 settings on chips with suitable 174ad8c0eaaSNicolas Ferre * support. Set with TIOCSISO7816 and get with TIOCGISO7816 if supported by 175ad8c0eaaSNicolas Ferre * your platform. 176ad8c0eaaSNicolas Ferre */ 177ad8c0eaaSNicolas Ferre struct serial_iso7816 { 178ad8c0eaaSNicolas Ferre __u32 flags; /* ISO7816 feature flags */ 179ad8c0eaaSNicolas Ferre #define SER_ISO7816_ENABLED (1 << 0) 180ad8c0eaaSNicolas Ferre #define SER_ISO7816_T_PARAM (0x0f << 4) 181ad8c0eaaSNicolas Ferre #define SER_ISO7816_T(t) (((t) & 0x0f) << 4) 182ad8c0eaaSNicolas Ferre __u32 tg; 183ad8c0eaaSNicolas Ferre __u32 sc_fi; 184ad8c0eaaSNicolas Ferre __u32 sc_di; 185ad8c0eaaSNicolas Ferre __u32 clk; 186ad8c0eaaSNicolas Ferre __u32 reserved[5]; 187ad8c0eaaSNicolas Ferre }; 188ad8c0eaaSNicolas Ferre 189607ca46eSDavid Howells #endif /* _UAPI_LINUX_SERIAL_H */ 190