This patchset adds RS-485 support to the DW UART driver. The patchset has two main parts. The first part adds HW support for RS-485 itself in various modes of operation and the second part focuses on enabling 9th bit addressing mode that can be used on a multipoint RS-485 communications line. To configure multipoint addressing, ADDRB flag is added to termios and two new IOCTLs are added into serial core. Lukas Wunner brought up during v1 review that if this addressing is only going to be used with RS-485, doing it within rs485_config would avoid having to add those IOCTLs. There was some counterexample w/o further details mentioned for RS-232 usage by Andy Shevchenko. I left the IOCTL approach there but if somebody has further input on this, please voice it as it is user-space facing API. I decided to rewrite the UART_CAP_NOTEMT patch from scratch myself based on Uwe Kleine-König's earlier suggestion and include it to this series. To make waiting for a single character easy and to avoid storing it per purpose in the uart drivers, I decided to add frame_time into uart_port. It turned out to beneficial also for serial core which had to reverse calculate it from uart_port->timeout). I was thinking of removing uart_port->timeout entirely and derive the value timeout from frame_time and fifosize where needed but I was not sure if that's ok to do lockingwise (not that fifosize is a variable that is expected to change so maybe I'm just being too cautious). I added some sketch on the ACPI enumeration file to satisfy Andy's request but I really don't know much about what should be put there. Please check it out and comment if I managed to make a mess out of it. I'm aware of the RS485 changes Lino Sanfilippo recently posted to linux-serial list which will make one assignment in the patchset redundant. I'll make the adjustment if those get applied into upstream. Cc: linux-api@xxxxxxxxxxxxxxx v1 -> v2: - Add uart_port->frame_time to avoid the need to store it per purpose - Included NOTEMT patch rewritten from scratch - Merge HW half & full-duplex patches - Detect RS485 HW using RE_EN register write+read - Removed SER_RS485_SW_RX_OR_TX - Relocated/renamed RE polarity DT prop - Use SER_RS485_RTS_ON_SEND rather than DT prop directly - Removed DE polarity prop, it is still configurable but with rts one instead - Make DE active-high by default in dwlib - Don't unnecessarily clear DE/RE_EN for non-RS485 mode - Prevent ADDRB and addrmode desync for RS485->RS232 transition - Added ACPI enumeration doc - Changed -EINVAL to -ENOTTY if no set/get_addr handler is present - Clear ADDRB in set_termios of a few more drivers - Added filtering for addresses to avoid them leaking into data stream - Reworded comments & commit messages as requested Ilpo Järvinen (12): serial: Store character timing information to uart_port serial: 8250: Handle UART without interrupt on TEMT serial: 8250_dwlib: RS485 HW half & full duplex support serial: 8250_dwlib: Implement SW half duplex support dt_bindings: rs485: Add receiver enable polarity ACPI / property: Document RS485 _DSD properties serial: termbits: ADDRB to indicate 9th bit addressing mode serial: General support for multipoint addresses serial: 8250: make saved LSR larger serial: 8250: create lsr_save_mask serial: 8250_lpss: Use 32-bit reads serial: 8250_dwlib: Support for 9th bit multipoint addressing .../devicetree/bindings/serial/rs485.yaml | 5 + .../driver-api/serial/serial-rs485.rst | 23 +- .../firmware-guide/acpi/enumeration.rst | 25 ++ arch/alpha/include/uapi/asm/ioctls.h | 3 + arch/alpha/include/uapi/asm/termbits.h | 1 + arch/mips/include/uapi/asm/ioctls.h | 3 + arch/mips/include/uapi/asm/termbits.h | 1 + arch/parisc/include/uapi/asm/ioctls.h | 3 + arch/parisc/include/uapi/asm/termbits.h | 1 + arch/powerpc/include/uapi/asm/ioctls.h | 3 + arch/powerpc/include/uapi/asm/termbits.h | 1 + arch/sh/include/uapi/asm/ioctls.h | 3 + arch/sparc/include/uapi/asm/ioctls.h | 3 + arch/sparc/include/uapi/asm/termbits.h | 1 + arch/xtensa/include/uapi/asm/ioctls.h | 3 + drivers/char/pcmcia/synclink_cs.c | 2 + drivers/ipack/devices/ipoctal.c | 2 + drivers/mmc/core/sdio_uart.c | 2 + drivers/net/usb/hso.c | 3 +- drivers/s390/char/tty3270.c | 3 + drivers/staging/greybus/uart.c | 2 + drivers/tty/amiserial.c | 6 +- drivers/tty/moxa.c | 1 + drivers/tty/mxser.c | 1 + drivers/tty/serial/8250/8250.h | 1 + drivers/tty/serial/8250/8250_core.c | 6 +- drivers/tty/serial/8250/8250_dwlib.c | 232 +++++++++++++++++- drivers/tty/serial/8250/8250_dwlib.h | 5 + drivers/tty/serial/8250/8250_lpss.c | 2 +- drivers/tty/serial/8250/8250_port.c | 42 ++-- drivers/tty/serial/serial_core.c | 76 +++++- drivers/tty/synclink_gt.c | 2 + drivers/tty/tty_ioctl.c | 2 + drivers/usb/class/cdc-acm.c | 2 + drivers/usb/serial/usb-serial.c | 6 +- include/linux/serial_8250.h | 7 +- include/linux/serial_core.h | 7 + include/uapi/asm-generic/ioctls.h | 3 + include/uapi/asm-generic/termbits.h | 1 + include/uapi/linux/serial.h | 8 + net/bluetooth/rfcomm/tty.c | 2 + 41 files changed, 470 insertions(+), 35 deletions(-) -- 2.30.2