Re: [PATCH v8 3/3] tty: 8250_omap: Use software emulated RS485 direction control

From: ÐÐÑÑÑ ÐÐÑÐÐÐÐ
Date: Fri Feb 12 2016 - 04:39:49 EST


2016-02-12 10:57 GMT+03:00 Matwey V. Kornilov <matwey@xxxxxxxxxx>:
> up->em485 is always pointer, however you are right, that
> serial8250_em485_init stores pointer to up when the timers are inited.
> More complex issue here that serial8250_em485_init need to set RTS to
> proper state and probably can't do that before
> serial8250_register_8250_port. So omap8250_probe should directly or
> indirectly use serial8250_get_port(priv->line) after
> serial8250_register_8250_port. As for me, possible solution could be
> to add a wrapper:
>
> int serial8250_em485_init_by_line(int line) {
> struct uart_8250_port *uart = &serial8250_ports[line];
> int ret;
> unsigned long flags;
>
> spin_lock_irqsave(&uart->port.lock, flags);
> ret = serial8250_em485_init(uart).
> spin_unlock_irqrestore(&uart->port.lock, flags);
>
> return ret;
> }

Also, I noticed that in 8250_core.c the em485 tx handlers change the
MCR register itself. But in the case when RTS signal is itself
emulated, say by flipping a GPIO, a more generic approach would be
necessary, such as get_mctrl/set_mctrl, so that the use of helpers in
serial_mctrl_gpio.c is straightforward.

For example, in our design the RS232<->RS485 direction switch is
driven by a pin which cannot be pinmuxed as UART RTS but can be a
GPIO. Since it is already in production, making incompatible changes
to the design (and getting away with it) is not inherently feasible.


Regards,
Ilyas G.