linux/drivers/tty/serial
Lukas Wunner 2dd8a74fdd serial: core: Initialize rs485 RTS polarity already on probe
RTS polarity of rs485-enabled ports is currently initialized on uart
open via:

tty_port_open()
  tty_port_block_til_ready()
    tty_port_raise_dtr_rts()  # if (C_BAUD(tty))
      uart_dtr_rts()
        uart_port_dtr_rts()

There's at least three problems here:

First, if no baud rate is set, RTS polarity is not initialized.
That's the right thing to do for rs232, but not for rs485, which
requires that RTS is deasserted unconditionally.

Second, if the DeviceTree property "linux,rs485-enabled-at-boot-time" is
present, RTS should be deasserted as early as possible, i.e. on probe.
Otherwise it may remain asserted until first open.

Third, even though RTS is deasserted on open and close, it may
subsequently be asserted by uart_throttle(), uart_unthrottle() or
uart_set_termios() because those functions aren't rs485-aware.
(Only uart_tiocmset() is.)

To address these issues, move RTS initialization from uart_port_dtr_rts()
to uart_configure_port().  Prevent subsequent modification of RTS
polarity by moving the existing rs485 check from uart_tiocmget() to
uart_update_mctrl().

That way, RTS is initialized on probe and then remains unmodified unless
the uart transmits data.  If rs485 is enabled at runtime (instead of at
boot) through a TIOCSRS485 ioctl(), RTS is initialized by the uart
driver's ->rs485_config() callback and then likewise remains unmodified.

The PL011 driver initializes RTS on uart open and prevents subsequent
modification in its ->set_mctrl() callback.  That code is obsoleted by
the present commit, so drop it.

Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Su Bao Cheng <baocheng.su@siemens.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Link: https://lore.kernel.org/r/2d2acaf3a69e89b7bf687c912022b11fd29dfa1e.1642909284.git.lukas@wunner.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-26 14:53:12 +01:00
..
8250 serial: 8250: of: Fix mapped region size when using reg-offset property 2022-01-26 14:50:52 +01:00
cpm_uart serial: cpm_uart: Protect udbg definitions by CONFIG_SERIAL_CPM_CONSOLE 2021-10-30 11:01:48 +02:00
jsm tty: serial: jsm: hold port lock when reporting modem line changes 2021-07-21 12:36:48 +02:00
21285.c tty: serial: 21285: fix lockup on open 2020-10-28 13:39:14 +01:00
altera_jtaguart.c serial: altera_jtaguart: Use platform_get_irq_optional() to get the interrupt 2021-12-30 13:26:49 +01:00
altera_uart.c serial: altera: Use platform_get_irq_optional() to get the interrupt 2021-12-30 13:26:48 +01:00
amba-pl010.c serial: pl010: Drop CR register reset on set_termios 2022-01-06 15:56:17 +01:00
amba-pl011.c serial: core: Initialize rs485 RTS polarity already on probe 2022-01-26 14:53:12 +01:00
amba-pl011.h
apbuart.c serial: apbuart: drop low-latency workaround 2021-04-22 12:09:25 +02:00
apbuart.h
ar933x_uart.c serial: ar933x: Use platform_get_irq() to get the interrupt 2021-12-30 13:26:49 +01:00
arc_uart.c tty: cumulate and document tty_struct::flow* members 2021-05-13 16:57:16 +02:00
atmel_serial.c serial: atmel: Use platform_get_irq() to get the interrupt 2021-12-17 17:57:37 +01:00
atmel_serial.h
bcm63xx_uart.c serial: bcm63xx: Use platform_get_irq() to get the interrupt 2021-12-30 13:26:49 +01:00
clps711x.c
digicolor-usart.c
dz.c tty: serial: dz: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:11 +02:00
dz.h
earlycon-arm-semihost.c
earlycon-riscv-sbi.c
earlycon.c earlycon: simplify earlycon-table implementation 2020-12-04 15:49:48 +01:00
fsl_linflexuart.c tty: serial: linflexuart: Remove redundant check to simplify the code 2021-08-26 14:51:04 +02:00
fsl_lpuart.c tty: serial: fsl_lpuart: Add i.MXRT1050 support 2021-12-17 18:00:21 +01:00
icom.c tty: serial: icom: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:11 +02:00
icom.h
imx_earlycon.c
imx.c tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown() 2021-11-25 18:38:21 +01:00
ip22zilog.c tty: serial: ip22zilog: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
ip22zilog.h
Kconfig tty: serial: samsung: Enable console as module 2021-12-20 16:54:10 +01:00
kgdb_nmi.c tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00
kgdboc.c
lantiq.c serial: lantiq: store and compare return status correctly 2021-12-30 13:23:46 +01:00
liteuart.c serial: liteuart: fix MODULE_ALIAS 2022-01-06 15:54:54 +01:00
lpc32xx_hs.c tty: drivers/tty/, stop using tty_schedule_flip() 2021-11-25 18:35:23 +01:00
Makefile Revert "tty: serial: Add UART driver for Cortina-Access platform" 2021-06-24 14:46:32 +02:00
max310x.c serial: max310x: Make max310x_remove() return void 2021-10-13 14:33:59 +02:00
max3100.c tty_port: drop last traces of low_latency 2021-01-07 16:17:32 +01:00
mcf.c serial: mcf: drop low-latency workaround 2021-04-22 12:09:25 +02:00
men_z135_uart.c tty: serial, fix kernel-doc 2020-08-18 13:51:18 +02:00
meson_uart.c tty: serial: meson: Drop the legacy compatible strings and clock code 2021-12-30 13:28:23 +01:00
milbeaut_usio.c
mpc52xx_uart.c serial: mpc52xx_uart: drop low-latency workaround 2021-04-22 12:09:25 +02:00
mps2-uart.c
msm_serial.c sound updates for 5.17-rc1 2022-01-14 14:55:38 +01:00
mux.c parisc: Make struct parisc_driver::remove() return void 2021-08-30 10:18:25 +02:00
mvebu-uart.c serial: mvebu-uart: fix driver's tx_empty callback 2021-09-14 10:07:10 +02:00
mxs-auart.c tty: make use of tty_get_{char,frame}_size 2021-06-15 14:03:27 +02:00
omap-serial.c serial: omap: Disable PM runtime autoidle to remove pm_runtime_irq_safe() 2021-07-29 17:03:04 +02:00
owl-uart.c serial: owl: drop low-latency workaround 2021-04-22 12:09:25 +02:00
pch_uart.c serial: pch_uart: fix build error with !CONFIG_DEBUG_FS 2021-03-23 10:31:09 +01:00
pic32_uart.c
pic32_uart.h
pmac_zilog.c serial: pmac_zilog: Use platform_get_irq() to get the interrupt 2021-12-30 13:26:49 +01:00
pmac_zilog.h tty: serial: pmac_zilog: Remove unused disposable variable 'garbage' 2020-11-13 15:28:27 +01:00
pxa.c serial: pxa: Use platform_get_irq() to get the interrupt 2021-12-30 13:26:49 +01:00
qcom_geni_serial.c serial: qcom_geni_serial: use DT aliases according to DT bindings 2021-06-24 14:51:28 +02:00
rda-uart.c serial: rda: drop low-latency workaround 2021-04-22 12:09:26 +02:00
rp2.c serial: rp2: use 'request_firmware' instead of 'request_firmware_nowait' 2021-05-21 20:34:02 +02:00
sa1100.c serial: sa1100: drop low-latency workaround 2021-04-22 12:09:26 +02:00
samsung_tty.c tty: serial: samsung: Fix console registration from module 2021-12-20 16:54:37 +01:00
sb1250-duart.c tty: serial: sb1250-duart: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
sc16is7xx.c serial: sc16is7xx: Make sc16is7xx_remove() return void 2021-10-13 14:34:07 +02:00
sccnxp.c
serial_core.c serial: core: Initialize rs485 RTS polarity already on probe 2022-01-26 14:53:12 +01:00
serial_mctrl_gpio.c serial: mctrl_gpio: Fix passing zero to 'ERR_PTR' warning 2020-11-06 17:12:05 +01:00
serial_mctrl_gpio.h
serial_txx9.c tty: serial: txx9: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
serial-tegra.c serial: tegra: Change lower tolerance baud rate limit for tegra20 and tegra30 2021-11-25 18:26:32 +01:00
sh-sci.c serial: sh-sci: Remove BREAK/FRAME/PARITY/OVERRUN printouts 2021-12-20 16:55:56 +01:00
sh-sci.h serial: sh-sci: Add support for RZ/G2L SoC 2021-06-04 15:12:40 +02:00
sifive.c serial: sifive: set pointer to NULL rather than 0. 2021-10-05 14:54:21 +02:00
sprd_serial.c
st-asc.c tty: serial: st-asc: Demote a kernel-doc formatting abuse 2021-05-20 17:06:17 +02:00
stm32-usart.c serial: stm32: fix software flow control transfer 2022-01-26 14:52:49 +01:00
stm32-usart.h serial: stm32: rework TX DMA state condition 2022-01-06 15:58:46 +01:00
suncore.c
sunhv.c
sunsab.c tty: serial: sunsab: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
sunsab.h
sunsu.c serial: 8250: Move Alpha-specific quirk out of the core 2021-12-30 13:23:44 +01:00
sunzilog.c serial: sunzilog: Mark sunzilog_putchar() __maybe_unused 2021-10-26 19:15:04 +02:00
sunzilog.h
tegra-tcu.c serial: tegra-tcu: Reorder channel initialization 2021-06-15 14:02:06 +02:00
timbuart.c serial: timbuart: drop low-latency workaround 2021-04-22 12:09:26 +02:00
timbuart.h
uartlite.c tty: serial: uartlite: allow 64 bit address 2021-12-03 14:12:56 +01:00
ucc_uart.c firmware: replace HOTPLUG with UEVENT in FW_ACTION defines 2021-05-13 16:14:45 +02:00
vr41xx_siu.c tty: serial: vr41xx_siu: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
vt8500_serial.c serial: vt8500: Use platform_get_irq() to get the interrupt 2021-12-30 13:26:49 +01:00
xilinx_uartps.c serial: xilinx_uartps: Fix race condition causing stuck TX 2021-10-26 19:17:05 +02:00
zs.c
zs.h