From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] msm_serial: Fix NUL byte output on UARTDM
Date: Wed, 24 Jul 2013 11:37:28 -0700 [thread overview]
Message-ID: <1374691051-28544-2-git-send-email-sboyd@codeaurora.org> (raw)
In-Reply-To: <1374691051-28544-1-git-send-email-sboyd@codeaurora.org>
UARTDM serial devices require us to wait for the entire TX fifo
to drain before we can change the contents of the NCF_TX
register. Furthermore, if we write any characters to the TX fifo
within the same clock cycle of changing the NCF_TX register the
NCF_TX register won't latch properly.
To fix these issues we should read back the NCF_TX register to
delay any TX fifo accesses by a clock cycle and we should wait
for the TX fifo to drain (instead of just waiting for the fifo to
be ready to receive more characters). Failure to do so leads to
random NUL bytes interspersed in the output.
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
drivers/tty/serial/msm_serial.c | 14 +++++++++-----
drivers/tty/serial/msm_serial.h | 1 +
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 2c6cfb3..fa3fc67 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -50,11 +50,14 @@ struct msm_port {
unsigned int old_snap_state;
};
-static inline void wait_for_xmitr(struct uart_port *port, int bits)
+static inline void wait_for_xmitr(struct uart_port *port)
{
- if (!(msm_read(port, UART_SR) & UART_SR_TX_EMPTY))
- while ((msm_read(port, UART_ISR) & bits) != bits)
- cpu_relax();
+ while (!(msm_read(port, UART_SR) & UART_SR_TX_EMPTY)) {
+ if (msm_read(port, UART_ISR) & UART_ISR_TX_READY)
+ break;
+ udelay(1);
+ }
+ msm_write(port, UART_CR_CMD_RESET_TX_READY, UART_CR);
}
static void msm_stop_tx(struct uart_port *port)
@@ -194,8 +197,9 @@ static void handle_rx(struct uart_port *port)
static void reset_dm_count(struct uart_port *port)
{
- wait_for_xmitr(port, UART_ISR_TX_READY);
+ wait_for_xmitr(port);
msm_write(port, 1, UARTDM_NCF_TX);
+ msm_read(port, UARTDM_NCF_TX);
}
static void handle_tx(struct uart_port *port)
diff --git a/drivers/tty/serial/msm_serial.h b/drivers/tty/serial/msm_serial.h
index e4acef5..15c186e 100644
--- a/drivers/tty/serial/msm_serial.h
+++ b/drivers/tty/serial/msm_serial.h
@@ -71,6 +71,7 @@
#define UART_CR_CMD_RESET_RFR (14 << 4)
#define UART_CR_CMD_PROTECTION_EN (16 << 4)
#define UART_CR_CMD_STALE_EVENT_ENABLE (80 << 4)
+#define UART_CR_CMD_RESET_TX_READY (3 << 8)
#define UART_CR_TX_DISABLE (1 << 3)
#define UART_CR_TX_ENABLE (1 << 2)
#define UART_CR_RX_DISABLE (1 << 1)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2013-07-24 18:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 18:37 [PATCH 0/4] msm_serial fixes and improvements Stephen Boyd
2013-07-24 18:37 ` Stephen Boyd [this message]
2013-07-24 20:29 ` [PATCH 1/4] msm_serial: Fix NUL byte output on UARTDM David Brown
2013-07-24 18:37 ` [PATCH 2/4] msm_serial: Fix sparse warnings Stephen Boyd
2013-07-24 20:30 ` David Brown
2013-07-24 18:37 ` [PATCH 3/4] msm_serial: Make baud_code detection more dynamic Stephen Boyd
2013-07-24 20:30 ` David Brown
2013-07-26 4:30 ` Bjorn Andersson
2013-07-26 17:05 ` Stephen Boyd
2013-07-24 18:37 ` [PATCH 4/4] msm_serial: Send more than 1 character at a time on UARTDM Stephen Boyd
2013-07-24 20:31 ` David Brown
2013-07-24 20:31 ` [PATCH 0/4] msm_serial fixes and improvements David Brown
2013-07-29 9:31 ` Ivan T. Ivanov
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=1374691051-28544-2-git-send-email-sboyd@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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).