LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Martin Kepplinger <martin.kepplinger@ginzinger.com>
To: <gregkh@linuxfoundation.org>, <robh+dt@kernel.org>,
<mark.rutland@arm.com>, <jslaby@suse.com>, <corbet@lwn.net>,
<richard.genoud@gmail.com>, <nicolas.ferre@microchip.com>,
<alexandre.belloni@bootlin.com>,
<ludovic.desroches@microchip.com>, <mcoquelin.stm32@gmail.com>,
<alexandre.torgue@st.com>, <linux-serial@vger.kernel.org>,
<devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-stm32@st-md-mailman.stormreply.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 5/9] serial: omap-serial: add support for rs485 RTS delays in microseconds
Date: Wed, 20 Feb 2019 16:27:27 +0100 [thread overview]
Message-ID: <20190220152731.4051-5-martin.kepplinger@ginzinger.com> (raw)
In-Reply-To: <20190220152731.4051-1-martin.kepplinger@ginzinger.com>
[-- Attachment #1: Type: text/plain, Size: 2402 bytes --]
Read struct serial_rs485's flag SER_RS485_DELAY_IN_USEC and apply the delay
accordingly.
Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.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
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3616 bytes --]
prev parent reply other threads:[~2019-02-20 15:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 15:27 [PATCH 1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485 Martin Kepplinger
2019-02-20 15:27 ` [PATCH 2/9] Documentation: serial-rs485: document SER_RS485_DELAY_IN_USEC flag Martin Kepplinger
2019-02-20 15:27 ` [PATCH 3/9] serial: core: add rs485-rts-delay-us devicetree property for RS485 Martin Kepplinger
2019-02-20 15:27 ` [PATCH 4/9] serial: 8250: add support for rs485 RTS delays in microseconds Martin Kepplinger
2019-02-20 15:27 ` Martin Kepplinger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190220152731.4051-5-martin.kepplinger@ginzinger.com \
--to=martin.kepplinger@ginzinger.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@st.com \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=ludovic.desroches@microchip.com \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=nicolas.ferre@microchip.com \
--cc=richard.genoud@gmail.com \
--cc=robh+dt@kernel.org \
--subject='Re: [PATCH 5/9] serial: omap-serial: add support for rs485 RTS delays in microseconds' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).