From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: keir@xen.org, Ian Campbell <ian.campbell@citrix.com>,
stefano.stabellini@eu.citrix.com, julien.grall@linaro.org,
tim@xen.org, jbeulich@suse.com, Josh Zhao <joshsystem@gmail.com>
Subject: [PATCH 4/8] ns16550: support DesignWare 8250
Date: Fri, 13 Sep 2013 17:04:03 +0100 [thread overview]
Message-ID: <1379088247-29325-4-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1379088118.19256.95.camel@kazak.uk.xensource.com>
This hardware has an additional feature which signals an error if you try to
write LCR while the UART is busy. We need to clear this error during setup,
otherwise LCR.DLAB doesn't get set and we cannot read/write the divisor.
This has been tested on the cubieboard2
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Cc: jbeulich@suse.com
---
v2: Remove pointless cast.
---
xen/drivers/char/ns16550.c | 14 ++++++++++++++
xen/include/xen/8250-uart.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 45da924..5892eb7 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -61,6 +61,7 @@ static struct ns16550 {
struct timer resume_timer;
unsigned int timeout_ms;
bool_t intr_works;
+ bool_t dw_usr_bsy;
#ifdef HAS_PCI
/* PCI card parameters. */
unsigned int pb_bdf[3]; /* pci bridge BDF */
@@ -237,6 +238,16 @@ static void ns16550_setup_preirq(struct ns16550 *uart)
/* No interrupts. */
ns_write_reg(uart, UART_IER, 0);
+ if ( uart->dw_usr_bsy &&
+ (ns_read_reg(uart, UART_IIR) & UART_IIR_BSY) == UART_IIR_BSY )
+ {
+ /* DesignWare 8250 detects if LCR is written while the UART is
+ * busy and raises a "busy detect" interrupt. Read the UART
+ * Status Register to clear this state.
+ */
+ ns_read_reg(uart, UART_USR);
+ }
+
/* Line control and baud-rate generator. */
ns_write_reg(uart, UART_LCR, lcr | UART_LCR_DLAB);
if ( uart->baud != BAUD_AUTO )
@@ -787,6 +798,8 @@ static int __init ns16550_uart_dt_init(struct dt_device_node *dev,
/* The common bit of the driver mostly deals with irq not dt_irq. */
uart->irq = uart->dt_irq.irq;
+ uart->dw_usr_bsy = dt_device_is_compatible(dev, "snps,dw-apb-uart");
+
uart->vuart.base_addr = uart->io_base;
uart->vuart.size = uart->io_size;
uart->vuart.data_off = UART_THR <<uart->reg_shift;
@@ -804,6 +817,7 @@ static int __init ns16550_uart_dt_init(struct dt_device_node *dev,
static const char const *ns16550_dt_compat[] __initconst =
{
"ns16550",
+ "snps,dw-apb-uart",
NULL
};
diff --git a/xen/include/xen/8250-uart.h b/xen/include/xen/8250-uart.h
index 8693d15..a682bae 100644
--- a/xen/include/xen/8250-uart.h
+++ b/xen/include/xen/8250-uart.h
@@ -32,6 +32,7 @@
#define UART_MCR 0x04 /* Modem control */
#define UART_LSR 0x05 /* line status */
#define UART_MSR 0x06 /* Modem status */
+#define UART_USR 0x1f /* Status register (DW) */
#define UART_DLL 0x00 /* divisor latch (ls) (DLAB=1) */
#define UART_DLM 0x01 /* divisor latch (ms) (DLAB=1) */
@@ -48,6 +49,7 @@
#define UART_IIR_RDA 0x04 /* - rx data recv'd */
#define UART_IIR_THR 0x02 /* - tx reg. empty */
#define UART_IIR_MSI 0x00 /* - MODEM status */
+#define UART_IIR_BSY 0x07 /* - busy detect (DW) */
/* FIFO Control Register */
#define UART_FCR_ENABLE 0x01 /* enable FIFO */
--
1.7.10.4
next prev parent reply other threads:[~2013-09-13 16:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-13 16:01 [PATCH RFC 0/8] xen/arm: initial cubieboard2 support Ian Campbell
2013-09-13 16:04 ` [PATCH 1/8] xen/arm: Implement ioremap Ian Campbell
2013-09-13 16:04 ` [PATCH 3/8] ns16550: make usable on ARM Ian Campbell
2013-09-13 16:16 ` Jan Beulich
2013-09-13 16:04 ` Ian Campbell [this message]
2013-09-13 16:04 ` [PATCH 5/8] xen/arm: Support Cortex-A7 GIC Ian Campbell
2013-09-13 16:04 ` [PATCH 6/8] xen/arm: Basic support for sunxi/sun7i platform Ian Campbell
2013-09-13 16:04 ` [PATCH 7/8] xen/arm: Blacklist some sun7i UARTs Ian Campbell
2013-09-13 16:04 ` [PATCH 8/8] xen/arm: Some early trap logging Ian Campbell
2013-09-13 16:43 ` [PATCH RFC 0/8] xen/arm: initial cubieboard2 support Julien Grall
[not found] ` <1379088247-29325-2-git-send-email-ian.campbell@citrix.com>
[not found] ` <52333E52.5060308@linaro.org>
2013-09-20 15:51 ` [PATCH 2/8] xen/arm: replace io{read, write}{l, b} with {read, write}{l, b} Ian Campbell
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=1379088247-29325-4-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=joshsystem@gmail.com \
--cc=julien.grall@linaro.org \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.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).