• Lukas Wunner's avatar
    serial: 8250: Generalize rs485 software emulation · 058bc104
    Lukas Wunner authored
    Commit e490c914 ("tty: Add software emulated RS485 support for 8250")
    introduced support to use RTS as an rs485 Transmit Enable signal.
    So far the only drivers taking advantage of it are 8250_omap.c and
    8250_of.c.
    
    We're about to make use of the feature in 8250_bcm2835aux.c as well.
    The bcm2835aux differs from omap chips by inverting the meaning of RTS
    in the MCR register.  Moreover, omap achieves half-duplex mode by
    disabling the RX interrupt and clearing the RX FIFO when TX stops.
    The bcm2835aux requires disabling the receiver instead.
    
    Support these behavioral differences by generalizing the rs485 emulation:
    Introduce ->rs485_start_tx() and ->rs485_stop_tx() callbacks in struct
    uart_8250_port, provide generic implementations containing the existing
    code and use them as callbacks in 8250_omap.c and 8250_of.c.
    
    start_tx_rs485() is idempotent in that it recognizes whether RTS is
    already asserted.  Achieve the same by introducing a tx_stopped flag in
    struct uart_8250_em485.  This may even perform a little better on arches
    where memory access is faster than mmio access.
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Cc: Matwey V. Kornilov <matwey@sai.msu.ru>
    Link: https://lore.kernel.org/r/5ac0464ae4414708e723a1e0d52b0c1b2bd41b9b.1582895077.git.lukas@wunner.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    058bc104
8250.h 8.21 KB