Re: [PATCH/RFC] 8250: Auto RS485 direction control

Russell King
2008-07-24T12:11:15Z

On Thu, Jul 24, 2008 at 01:47:29PM +0200, Laurent Pinchart wrote:
> This patch adds support for the automatic RS485 direction control feature
> present in 16850 UARTs.
>
> A new termios c_cflag, CARTS, is introduced to configure automatic direction
> control from userspace.
>
> This is a first proposal. I'm open to suggestions regarding the CARTS name.

I think CARTS is a bad name - if you look at other 8250 ports, they have
auto-flow control for normal communications which not only includes
stopping the transmitter when CTS deasserts, but also allows the device
to deassert RTS when the receive FIFO reaches a certain level.

That means that the name "auto RTS" is confusing.

Maybe a better name would be CRS485 to enable RS485 direction control?
Then we can use CRTSCTS to mean "on the RTS signal". If/when a
CDTRDSR for DTR/DSR flow control is introduced, we could then use
that to switch to DTR RS485 direction control instead.

> I assume the CARTS flag will have to be added to all asm/termbits.h
> headers.

Yes...

> Why are the termios bits definitions platform specific ?

... though if you can find a free bit in the cflag on all platforms,
creating an asm-generic/termbits.h might be a good idea?

Alan should probably comment on that first though.

> diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h
> index 3c8a6aa..3db78cc 100644
> --- a/include/linux/serial_reg.h
> +++ b/include/linux/serial_reg.h
> @@ -188,6 +188,7 @@
> #define UART_FCTR_RTS_8DELAY 0x03
> #define UART_FCTR_IRDA 0x04 /* IrDa data encode select */
> #define UART_FCTR_TX_INT 0x08 /* Tx interrupt type select */
> +#define UART_FCTR_RS485 0x08 /* Auto RS485 direction control */

Please include in the comment which device this refers to (as the entries
below do.)

> #define UART_FCTR_TRGA 0x00 /* Tx/Rx 550 trigger table select */
> #define UART_FCTR_TRGB 0x10 /* Tx/Rx 650 trigger table select */
> #define UART_FCTR_TRGC 0x20 /* Tx/Rx 654 trigger table select */

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/