From: claudio@evidence.eu.com
To: linux-serial@vger.kernel.org
Cc: nicolas.ferre@atmel.com, clagix@gmail.com,
Claudio Scordino <claudio@evidence.eu.com>
Subject: [PATCH 2/3] atmel_serial: use msleep for delays
Date: Mon, 11 Feb 2013 16:54:25 +0100 [thread overview]
Message-ID: <1360598067-3577-3-git-send-email-claudio@evidence.eu.com> (raw)
In-Reply-To: <CAJa4H3fQ_khDVNcSu+39C+oZyc268YUgq9ahzt2ugk1_6eqYfw@mail.gmail.com>
From: Claudio Scordino <claudio@evidence.eu.com>
The Transmitter TimeGuard Register (TTGR) should not be used for delays in
RS485 mode, because it is not a feature related only to RS485 (it should be
also available in RS232 mode) and bacause delays should be expressed in
milliseconds rrather than in bit times.
This patch sets RS485 delays using msleep (as in the cris driver) rather than
using TTGR.
Signed-off-by: Claudio Scordino <claudio@evidence.eu.com>
Signed-off-by: Guido Classen <clagix@gmail.com>
---
drivers/tty/serial/atmel_serial.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 922e85a..52648ec 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -30,6 +30,7 @@
#include <linux/serial.h>
#include <linux/clk.h>
#include <linux/console.h>
+#include <linux/delay.h>
#include <linux/sysrq.h>
#include <linux/tty_flip.h>
#include <linux/platform_device.h>
@@ -228,8 +229,6 @@ void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
if (rs485conf->flags & SER_RS485_ENABLED) {
dev_dbg(port->dev, "Setting UART to RS485\n");
atmel_port->tx_done_mask = ATMEL_US_TXEMPTY;
- if ((rs485conf->delay_rts_after_send) > 0)
- UART_PUT_TTGR(port, rs485conf->delay_rts_after_send);
mode |= ATMEL_US_USMODE_RS485;
} else {
dev_dbg(port->dev, "Setting UART to RS232\n");
@@ -304,9 +303,6 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
dev_dbg(port->dev, "Setting UART to RS485\n");
- if ((atmel_port->rs485.delay_rts_after_send) > 0)
- UART_PUT_TTGR(port,
- atmel_port->rs485.delay_rts_after_send);
mode |= ATMEL_US_USMODE_RS485;
} else {
dev_dbg(port->dev, "Setting UART to RS232\n");
@@ -549,7 +545,12 @@ static void atmel_tx_chars(struct uart_port *port)
return;
while (UART_GET_CSR(port) & atmel_port->tx_done_mask) {
+ if ((atmel_port->rs485.delay_rts_before_send) > 0)
+ msleep(atmel_port->rs485.delay_rts_before_send);
UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
+ if ((atmel_port->rs485.delay_rts_after_send) > 0)
+ msleep(atmel_port->rs485.delay_rts_after_send);
+
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
port->icount.tx++;
if (uart_circ_empty(xmit))
@@ -1232,9 +1233,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
dev_dbg(port->dev, "Setting UART to RS485\n");
- if ((atmel_port->rs485.delay_rts_after_send) > 0)
- UART_PUT_TTGR(port,
- atmel_port->rs485.delay_rts_after_send);
mode |= ATMEL_US_USMODE_RS485;
} else {
dev_dbg(port->dev, "Setting UART to RS232\n");
--
1.7.9.5
next prev parent reply other threads:[~2013-02-11 16:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAJa4H3cYT6QOaacWEy2yZjb0hM3m4p+0L2_fXBYv8tWajYkmGw@mail.gmail.com>
2013-01-30 10:30 ` RS485 implementation questions (primarly in atmel_serial.c) Claudio Scordino
[not found] ` <510A3740.6060809@evidence.eu.com>
[not found] ` <CAJa4H3dG4V6viRbVQBgHQKtJr4Sz26mkhj8-kT7RFaLGRFXW1g@mail.gmail.com>
[not found] ` <51125488.7090408@evidence.eu.com>
[not found] ` <CAJa4H3eNAS7B+aGnN0D3WJMPVtE=sxp5HhRMutq-TrBOmXb7dw@mail.gmail.com>
[not found] ` <5114B500.7050007@evidence.eu.com>
2013-02-08 12:12 ` Guido Classen
2013-02-11 15:54 ` [PATCH] atmel_serial: general fixes for RS485 and TTGR claudio
2013-02-11 17:05 ` Guido Classen
2013-02-11 15:54 ` [PATCH 1/3] RS485: add unit of measure for delays claudio
2013-02-11 15:54 ` claudio [this message]
2013-02-11 15:54 ` [PATCH 3/3] atmel_serial: add generic TTGR support claudio
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=1360598067-3577-3-git-send-email-claudio@evidence.eu.com \
--to=claudio@evidence.eu.com \
--cc=clagix@gmail.com \
--cc=linux-serial@vger.kernel.org \
--cc=nicolas.ferre@atmel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).