summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Chen <vincent.chen@sifive.com>2020-03-18 08:40:27 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-18 11:07:13 +0100
commit630db5cbc7b444bf47cd717906abb092a2ab5724 (patch)
treee4fc8f171343fb0e6589a001eb74e4d774c5fe3d
parent089b6d36549160b535e109cd07ed6d578b81de46 (diff)
tty: serial: Add CONSOLE_POLL support to SiFive UART
Add CONSOLE_POLL support for future KGDB porting. Signed-off-by: Vincent Chen <vincent.chen@sifive.com> Changes since v1: 1. Fix the compile error reported by kbuild test robot Link: https://lore.kernel.org/r/1584492027-23236-1-git-send-email-vincent.chen@sifive.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/sifive.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
index d34031e842d0..13eadcb8aec4 100644
--- a/drivers/tty/serial/sifive.c
+++ b/drivers/tty/serial/sifive.c
@@ -729,6 +729,29 @@ static const char *sifive_serial_type(struct uart_port *port)
return port->type == PORT_SIFIVE_V0 ? "SiFive UART v0" : NULL;
}
+#ifdef CONFIG_CONSOLE_POLL
+static int sifive_serial_poll_get_char(struct uart_port *port)
+{
+ struct sifive_serial_port *ssp = port_to_sifive_serial_port(port);
+ char is_empty, ch;
+
+ ch = __ssp_receive_char(ssp, &is_empty);
+ if (is_empty)
+ return NO_POLL_CHAR;
+
+ return ch;
+}
+
+static void sifive_serial_poll_put_char(struct uart_port *port,
+ unsigned char c)
+{
+ struct sifive_serial_port *ssp = port_to_sifive_serial_port(port);
+
+ __ssp_wait_for_xmitr(ssp);
+ __ssp_transmit_char(ssp, c);
+}
+#endif /* CONFIG_CONSOLE_POLL */
+
/*
* Early console support
*/
@@ -897,6 +920,10 @@ static const struct uart_ops sifive_serial_uops = {
.request_port = sifive_serial_request_port,
.config_port = sifive_serial_config_port,
.verify_port = sifive_serial_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+ .poll_get_char = sifive_serial_poll_get_char,
+ .poll_put_char = sifive_serial_poll_put_char,
+#endif
};
static struct uart_driver sifive_serial_uart_driver = {