summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Turley <patrick.turley@freescale.com>2010-01-06 19:22:46 -0600
committerPatrick Turley <patrick.turley@freescale.com>2010-01-06 21:05:11 -0600
commit1d336b06e827f12862cba32d4d817443d5ccfb4f (patch)
treea4ac1ca2a0e5aee82d8b22b3bcf297e2677c52d6
parent36808bfcd0766355b2a9b4a5359716602025f6e9 (diff)
ENGR00119847 [MX23_BSP] Support polled read/write for debug UART
Added the polled read and write functions for the debug UART port. Signed-off-by: Patrick Turley <patrick.turley@freescale.com>
-rw-r--r--drivers/serial/stmp-dbg.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/drivers/serial/stmp-dbg.c b/drivers/serial/stmp-dbg.c
index c8c21b57281e..40040f3df5c9 100644
--- a/drivers/serial/stmp-dbg.c
+++ b/drivers/serial/stmp-dbg.c
@@ -7,7 +7,7 @@
* Copyright (C) 2000 Deep Blue Solutions Ltd.
* Modifications for STMP36XX Debug Serial (c) 2005 Sigmatel Inc
*
- * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
*/
@@ -551,6 +551,46 @@ static int stmpdbg_verify_port(struct uart_port *port,
return ret;
}
+#ifdef CONFIG_CONSOLE_POLL
+/*
+ * Console polling routines for writing and reading from the UART while
+ * in an interrupt or debug context.
+ */
+
+static int stmpdbg_get_poll_char(struct uart_port *port)
+{
+ struct uart_stmpdbg_port *uap = (struct uart_stmpdbg_port *)port;
+ unsigned int status;
+
+ /* Wait until a character arrives. */
+
+ do {
+ status = __raw_readl(uap->port.membase + UART01x_FR);
+ } while (status & UART01x_FR_RXFE);
+
+ /* Read the character and return it. */
+
+ return __raw_readl(uap->port.membase + UART01x_DR) & 0xff;
+
+}
+
+static void stmpdbg_put_poll_char(struct uart_port *port, unsigned char c)
+{
+ struct uart_stmpdbg_port *uap = (struct uart_stmpdbg_port *)port;
+
+ /* Wait until the transmit FIFO is empty. */
+
+ while (!(__raw_readl(uap->port.membase + UART01x_FR) & UART011_FR_TXFE))
+ barrier();
+
+ /* Transmit the character. */
+
+ __raw_writel(c, uap->port.membase + UART01x_DR);
+
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
static struct uart_ops stmpdbg_pops = {
.tx_empty = stmpdbg_tx_empty,
.set_mctrl = stmpdbg_set_mctrl,
@@ -568,6 +608,10 @@ static struct uart_ops stmpdbg_pops = {
.request_port = stmpdbg_request_port,
.config_port = stmpdbg_config_port,
.verify_port = stmpdbg_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+ .poll_get_char = stmpdbg_get_poll_char,
+ .poll_put_char = stmpdbg_put_poll_char,
+#endif
};
static struct uart_stmpdbg_port stmpdbg_ports[UART_NR] = {