diff options
author | Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> | 2022-07-29 14:47:46 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-08-30 14:26:01 +0300 |
commit | b36962896f00e164eb18093351f0b69d1b396964 (patch) | |
tree | e9296ec73f1c8aec5377dcbdacbc552c3808d759 /drivers/tty/serial/xilinx_uartps.c | |
parent | b8a6c3b3d4654fba19881cc77da61eac29f57cae (diff) | |
download | linux-b36962896f00e164eb18093351f0b69d1b396964.tar.xz |
tty: xilinx_uartps: Prevent writes when the controller is disabled
Prevent writing to the fifo if the controller is disabled.
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Link: https://lore.kernel.org/r/20220729114748.18332-6-shubhrajyoti.datta@xilinx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/xilinx_uartps.c')
-rw-r--r-- | drivers/tty/serial/xilinx_uartps.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index ae99e1164f0c..d1aa44febaea 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1132,6 +1132,21 @@ static struct uart_driver cdns_uart_uart_driver; */ static void cdns_uart_console_putchar(struct uart_port *port, unsigned char ch) { + unsigned int ctrl_reg; + unsigned long timeout; + + timeout = jiffies + msecs_to_jiffies(1000); + while (1) { + ctrl_reg = readl(port->membase + CDNS_UART_CR); + if (!(ctrl_reg & CDNS_UART_CR_TX_DIS)) + break; + if (time_after(jiffies, timeout)) { + dev_warn(port->dev, + "timeout waiting for Enable\n"); + return; + } + cpu_relax(); + } while (readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_TXFULL) cpu_relax(); writel(ch, port->membase + CDNS_UART_FIFO); |