diff options
author | Patrick Turley <patrick.turley@freescale.com> | 2010-01-06 19:22:46 -0600 |
---|---|---|
committer | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2010-05-24 11:50:02 +0200 |
commit | b121942ae725fcba32c37111d381dc3c212ae880 (patch) | |
tree | 30abbcbe3af10b13194c35c59fe1baa80783b76b /drivers/serial | |
parent | e11c28524c6b043bd3506b79ef614ab9c28c5944 (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>
Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/stmp-dbg.c | 46 |
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] = { |