[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190221171758.10322-5-martin.kepplinger@ginzinger.com>
Date: Thu, 21 Feb 2019 18:17:54 +0100
From: Martin Kepplinger <martin.kepplinger@...zinger.com>
To: <gregkh@...uxfoundation.org>, <robh+dt@...nel.org>,
<mark.rutland@....com>, <jslaby@...e.com>, <corbet@....net>,
<richard.genoud@...il.com>, <nicolas.ferre@...rochip.com>,
<alexandre.belloni@...tlin.com>, <ludovic.desroches@...rochip.com>,
<mcoquelin.stm32@...il.com>, <alexandre.torgue@...com>,
<linux-serial@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-stm32@...md-mailman.stormreply.com>
CC: <linux-kernel@...r.kernel.org>,
Martin Kepplinger <martin.kepplinger@...zinger.com>
Subject: [PATCH v2 5/9] serial: omap-serial: add support for rs485 RTS delays in microseconds
Read struct serial_rs485's flag SER_RS485_DELAY_IN_USEC and apply the delay
accordingly.
Signed-off-by: Martin Kepplinger <martin.kepplinger@...zinger.com>
---
drivers/tty/serial/omap-serial.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6420ae581a80..adcd75ce5112 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -310,7 +310,11 @@ static void serial_omap_stop_tx(struct uart_port *port)
res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ?
1 : 0;
if (gpio_get_value(up->rts_gpio) != res) {
- if (port->rs485.delay_rts_after_send > 0)
+ if (port->rs485.delay_rts_after_send > 0 &&
+ port->rs485.flags & SER_RS485_DELAY_IN_USEC)
+ udelay(
+ port->rs485.delay_rts_after_send);
+ else if (port->rs485.delay_rts_after_send > 0)
mdelay(
port->rs485.delay_rts_after_send);
gpio_set_value(up->rts_gpio, res);
@@ -420,7 +424,11 @@ static void serial_omap_start_tx(struct uart_port *port)
res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0;
if (gpio_get_value(up->rts_gpio) != res) {
gpio_set_value(up->rts_gpio, res);
- if (port->rs485.delay_rts_before_send > 0)
+ if (port->rs485.delay_rts_before_send > 0 &&
+ port->rs485.flags & SER_RS485_DELAY_IN_USEC)
+ udelay(port->rs485.delay_rts_before_send);
+ else if (port->rs485.delay_rts_before_send > 0 &&
+ !(port->rs485.flags & SER_RS485_DELAY_IN_USEC)
mdelay(port->rs485.delay_rts_before_send);
}
}
@@ -1407,8 +1415,17 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
serial_out(up, UART_IER, 0);
/* Clamp the delays to [0, 100ms] */
- rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
- rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
+ if (port->rs485.flags & SER_RS485_DELAY_IN_USEC) {
+ rs485->delay_rts_before_send = min(rs485->delay_rts_before_send,
+ 100000U);
+ rs485->delay_rts_after_send = min(rs485->delay_rts_after_send,
+ 100000U);
+ } else {
+ rs485->delay_rts_before_send = min(rs485->delay_rts_before_send,
+ 100);
+ rs485->delay_rts_after_send = min(rs485->delay_rts_after_send,
+ 100U);
+ }
/* store new config */
port->rs485 = *rs485;
--
2.20.1
Download attachment "smime.p7s" of type "application/x-pkcs7-signature" (3616 bytes)
Powered by blists - more mailing lists