From: Trent Piepho <tpiepho@impinj.com>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Peter Chubb <peter.chubb@nicta.com.au>,
Trent Piepho <tpiepho@impinj.com>,
Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [Qemu-devel] [PATCH] i.MX: Support serial RS-232 break properly
Date: Mon, 19 Mar 2018 18:36:57 -0700 [thread overview]
Message-ID: <20180320013657.25038-1-tpiepho@impinj.com> (raw)
Linux does not detect a break from this IMX serial driver as a magic
sysrq. Nor does it note a break in the port error counts.
The former is because the Linux driver uses the BRCD bit in the USR2
register to trigger the RS-232 break handler in the kernel, which is
where sysrq hooks in. The emulated UART was not setting this status
bit.
The latter is because the Linux driver expects, in addition to the BRK
bit, that the ERR bit is set when a break is read in the FIFO. A break
should also count as a frame error, so add that bit too.
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
hw/char/imx_serial.c | 5 ++++-
include/hw/char/imx_serial.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
index 70405ccf8b..4ca821d74c 100644
--- a/hw/char/imx_serial.c
+++ b/hw/char/imx_serial.c
@@ -286,6 +286,9 @@ static void imx_put_data(void *opaque, uint32_t value)
s->usr2 |= USR2_RDR;
s->uts1 &= ~UTS1_RXEMPTY;
s->readbuff = value;
+ if (value & URXD_BRK) {
+ s->usr2 |= USR2_BRCD;
+ }
imx_update(s);
}
@@ -297,7 +300,7 @@ static void imx_receive(void *opaque, const uint8_t *buf, int size)
static void imx_event(void *opaque, int event)
{
if (event == CHR_EVENT_BREAK) {
- imx_put_data(opaque, URXD_BRK);
+ imx_put_data(opaque, URXD_BRK | URXD_FRMERR | URXD_ERR);
}
}
diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h
index baeec3183f..f8575ae6db 100644
--- a/include/hw/char/imx_serial.h
+++ b/include/hw/char/imx_serial.h
@@ -26,6 +26,7 @@
#define URXD_CHARRDY (1<<15) /* character read is valid */
#define URXD_ERR (1<<14) /* Character has error */
+#define URXD_FRMERR (1<<12) /* Character has frame error */
#define URXD_BRK (1<<11) /* Break received */
#define USR1_PARTYER (1<<15) /* Parity Error */
--
2.14.3
next reply other threads:[~2018-03-20 1:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 1:36 Trent Piepho [this message]
2018-03-20 1:50 ` [Qemu-devel] [PATCH] i.MX: Support serial RS-232 break properly no-reply
2018-03-23 11:07 ` Peter Maydell
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=20180320013657.25038-1-tpiepho@impinj.com \
--to=tpiepho@impinj.com \
--cc=andrew.smirnov@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.chubb@nicta.com.au \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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).