From c1104dfed8e2d3facf7774488748738d1faf44d9 Mon Sep 17 00:00:00 2001 From: Patrick Turley Date: Wed, 6 Jan 2010 19:22:46 -0600 Subject: [PATCH] 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 --- drivers/serial/stmp-dbg.c | 46 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/serial/stmp-dbg.c b/drivers/serial/stmp-dbg.c index c8c21b57281..40040f3df5c 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] = {