diff mbox

[1/4] apbuart: add polling callbacks to apbuart driver

Message ID 1317390450-5982-2-git-send-email-konrad@gaisler.com
State Superseded
Delegated to: David Miller
Headers show

Commit Message

Konrad Eisele Sept. 30, 2011, 1:47 p.m. UTC
Add the 2 callbacks poll_get_char and poll_put_char so
that the driver can be used as an interface with KGDB.

Signed-off-by: Konrad Eisele <konrad@gaisler.com>
---
 drivers/tty/serial/apbuart.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index 19a9436..153e065 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -39,6 +39,10 @@ 
 #define UART_DUMMY_RSR_RX	0x8000	/* for ignore all read */
 
 static void apbuart_tx_chars(struct uart_port *port);
+#ifdef CONFIG_CONSOLE_POLL
+static int apbuart_poll_get_char(struct uart_port *port);
+static void apbuart_poll_put_char(struct uart_port *port, unsigned char ch);
+#endif
 
 static void apbuart_stop_tx(struct uart_port *port)
 {
@@ -345,6 +349,10 @@  static struct uart_ops grlib_apbuart_ops = {
 	.request_port = apbuart_request_port,
 	.config_port = apbuart_config_port,
 	.verify_port = apbuart_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+	.poll_get_char	= apbuart_poll_get_char,
+	.poll_put_char	= apbuart_poll_put_char,
+#endif
 };
 
 static struct uart_port grlib_apbuart_ports[UART_NR];
@@ -420,7 +428,7 @@  static void apbuart_flush_fifo(struct uart_port *port)
 /* Console driver, if enabled                                               */
 /* ======================================================================== */
 
-#ifdef CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE
+#if defined(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE) || defined(CONFIG_CONSOLE_POLL)
 
 static void apbuart_console_putchar(struct uart_port *port, int ch)
 {
@@ -431,6 +439,29 @@  static void apbuart_console_putchar(struct uart_port *port, int ch)
 	UART_PUT_CHAR(port, ch);
 }
 
+#endif
+
+#ifdef CONFIG_CONSOLE_POLL
+
+static int apbuart_poll_get_char(struct uart_port *port)
+{
+	int c = NO_POLL_CHAR;
+	unsigned int status = UART_GET_STATUS(port);
+	if (status & UART_STATUS_DR) {
+		c = UART_GET_CHAR(port);
+	}
+	return c;
+}
+
+static void apbuart_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+	apbuart_console_putchar(port, ch);
+}
+
+#endif
+
+#ifdef CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE
+
 static void
 apbuart_console_write(struct console *co, const char *s, unsigned int count)
 {