|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v4 1/2] xen/ns16550: preserve XScale UUE bit in IER writes
From: Zhang Zheng <zhangzheng@xxxxxxxxxxx>
XScale-like UARTs are enabled by setting UART unit enable (UUE) bit
in the IER register. Clearing IER to mask interrupts therefore also
disables the UART, breaking both interrupt-driven and polled operation,
and prevents Xen from taking control of the UART from the SBI (RISC-V
IP variants).
Introduce ns_write_ier() to set UART_IER_UUE whenever the port is
flagged as an XScale device, and route all XScale-related IER writes
through it. The flag is determined by matching "intel,xscale-uart", and
that compatible is added to the DT match table so such UARTs are probed.
Signed-off-by: Zhang Zheng <zhangzheng@xxxxxxxxxxx>
Co-developed-by: Ronaldo Nunez <rnunez@xxxxxxxxxxxx>
Signed-off-by: Ronaldo Nunez <rnunez@xxxxxxxxxxxx>
---
xen/drivers/char/ns16550.c | 23 ++++++++++++++++++-----
xen/include/xen/8250-uart.h | 1 +
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index
be388c8e6582ec7f28a5926baae2c397fc984e77..01a55d2737d18b1985ba10488e98ac82ef8a9c8c
100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -64,6 +64,7 @@ static struct ns16550 {
bool intr_works;
bool force_polling;
bool dw_usr_bsy;
+ bool xscale;
#ifdef NS16550_PCI
/* PCI card parameters. */
bool pb_bdf_enable; /* if =1, pb-bdf effective, port behind bridge */
@@ -168,6 +169,15 @@ static void ns_write_reg(const struct ns16550 *uart,
unsigned int reg, u8 c)
}
}
+static void ns_write_ier(const struct ns16550 *uart, u8 ier)
+{
+ /* XScale-like UART IP depends on the UUE bit being set */
+ if ( uart->xscale )
+ ier |= UART_IER_UUE;
+
+ ns_write_reg(uart, UART_IER, ier);
+}
+
static int ns16550_ioport_invalid(struct ns16550 *uart)
{
return ns_read_reg(uart, UART_IER) == 0xff;
@@ -218,7 +228,7 @@ static void cf_check ns16550_interrupt(int irq, void
*dev_id)
/* Disable interrupt generation on the device and arm the timer. */
uart->force_polling = true;
- ns_write_reg(uart, UART_IER, 0);
+ ns_write_ier(uart, 0);
set_timer(&uart->timer, now + MILLISECS(uart->timeout_ms));
printk(XENLOG_WARNING
"uart interrupt taking more than %ums, switched to
polling\n",
@@ -350,7 +360,7 @@ static void ns16550_setup_preirq(struct ns16550 *uart)
lcr = (uart->data_bits - 5) | ((uart->stop_bits - 1) << 2) | uart->parity;
/* No interrupts. */
- ns_write_reg(uart, UART_IER, 0);
+ ns_write_ier(uart, 0);
/* Handle the DesignWare 8250 'busy-detect' quirk. */
handle_dw_usr_busy_quirk(uart);
@@ -446,7 +456,7 @@ static void ns16550_setup_postirq(struct ns16550 *uart)
UART_MCR, UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS);
/* Enable receive interrupts. */
- ns_write_reg(uart, UART_IER, UART_IER_ERDAI);
+ ns_write_ier(uart, UART_IER_ERDAI);
}
if ( uart->irq >= 0 )
@@ -654,7 +664,7 @@ static void cf_check ns16550_start_tx(struct serial_port
*port)
/* Unmask transmit holding register empty interrupt if currently masked. */
if ( !(ier & UART_IER_ETHREI) )
- ns_write_reg(uart, UART_IER, ier | UART_IER_ETHREI);
+ ns_write_ier(uart, ier | UART_IER_ETHREI);
}
static void cf_check ns16550_stop_tx(struct serial_port *port)
@@ -664,7 +674,7 @@ static void cf_check ns16550_stop_tx(struct serial_port
*port)
/* Mask off transmit holding register empty interrupt if currently
unmasked. */
if ( ier & UART_IER_ETHREI )
- ns_write_reg(uart, UART_IER, ier & ~UART_IER_ETHREI);
+ ns_write_ier(uart, ier & ~UART_IER_ETHREI);
}
#ifdef CONFIG_ARM
@@ -2034,6 +2044,8 @@ static int __init ns16550_uart_dt_init(struct
dt_device_node *dev,
uart->dw_usr_bsy = dt_device_is_compatible(dev, "snps,dw-apb-uart");
+ uart->xscale = dt_device_is_compatible(dev, "intel,xscale-uart");
+
#ifdef CONFIG_ARM
uart->vuart.base_addr = uart->io_base;
uart->vuart.size = uart->io_size;
@@ -2055,6 +2067,7 @@ static const struct dt_device_match ns16550_dt_match[]
__initconst =
DT_MATCH_COMPATIBLE("ns16550"),
DT_MATCH_COMPATIBLE("ns16550a"),
DT_MATCH_COMPATIBLE("snps,dw-apb-uart"),
+ DT_MATCH_COMPATIBLE("intel,xscale-uart"),
DT_MATCH_COMPATIBLE("brcm,bcm2835-aux-uart"),
{ /* sentinel */ },
};
diff --git a/xen/include/xen/8250-uart.h b/xen/include/xen/8250-uart.h
index
d13352940c13c50bac17d4cdf2f3bf584380776a..a9b567cb2e0cf00dc4804251824e07a00ea9e022
100644
--- a/xen/include/xen/8250-uart.h
+++ b/xen/include/xen/8250-uart.h
@@ -42,6 +42,7 @@
#define UART_IER_ETHREI 0x02 /* tx reg. empty */
#define UART_IER_ELSI 0x04 /* rx line status */
#define UART_IER_EMSI 0x08 /* MODEM status */
+#define UART_IER_UUE 0x40 /* UART unit enable (XScale) */
/* Interrupt Identification Register */
#define UART_IIR_NOINT 0x01 /* no interrupt pending */
--
2.53.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |