• Lukas Wunner's avatar
    serial: 8250_bcm2835aux: Support rs485 software emulation · f93bf758
    Lukas Wunner authored
    Amend 8250_bcm2835aux.c to support rs485 as introduced for 8250_omap.c
    by commit e490c914 ("tty: Add software emulated RS485 support for
    8250").
    
    The bcm2835aux differs from omap chips by inverting the meaning of RTS
    in the MCR register:  If the bit is clear, RTS is high.  With omap, it's
    apparently the other way round.
    
    Moreover, omap achieves half-duplex mode by disabling the UART_IER_RDI
    interrupt and clearing the RX FIFO when TX stops.  This approach doesn't
    work on bcm2835aux because the UART_LSR_DR bit is set even when
    UART_IER_RDI is disabled.  Consequently, serial8250_handle_irq() invokes
    serial8250_rx_chars() to empty the FIFO and characters are received even
    though the user requested half-duplex.  Solve by disabling the receiver
    using the non-standard CNTL register.
    
    Cache that register in the driver's private data for performance.  Set
    the private data pointer before calling serial8250_register_8250_port()
    to prevent a null pointer deref in case one of the rs485 callbacks is
    invoked immediately after port registration.
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Cc: Matwey V. Kornilov <matwey@sai.msu.ru>
    Link: https://lore.kernel.org/r/dd86460e20a8f979b7272a0bde73640312b902b1.1582895077.git.lukas@wunner.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    f93bf758
8250_bcm2835aux.c 5.94 KB