* [PATCH v3 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-12 20:55 ` Cristian Ciocaltea
0 siblings, 0 replies; 2+ messages in thread
From: Cristian Ciocaltea @ 2021-01-12 20:55 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Andreas Färber,
Manivannan Sadhasivam
Cc: linux-serial, linux-arm-kernel, linux-actions, linux-kernel
Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
'owl_uart_ops' that enables OWL UART to be used for kernel debugging
over serial line.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
Changes in v3:
- Used 'readl_poll_timeout_atomic()' in 'owl_uart_poll_put_char()'
to get rid of 'cpu_relax()' and provide a max bound to the loop,
as indicated by Greg and Jiri
Changes in v2:
- Reverted unnecessary changes per Andreas feedback
- Optimized implementation for 'owl_uart_poll_get_char()'
and 'owl_uart_poll_put_char()' callbacks
drivers/tty/serial/owl-uart.c | 38 +++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
index c149f8c30007..abc6042f0378 100644
--- a/drivers/tty/serial/owl-uart.c
+++ b/drivers/tty/serial/owl-uart.c
@@ -12,6 +12,7 @@
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
@@ -62,6 +63,9 @@
#define OWL_UART_STAT_TRFL_MASK GENMASK(16, 11)
#define OWL_UART_STAT_UTBB BIT(17)
+#define OWL_UART_POLL_USEC 5
+#define OWL_UART_TIMEOUT_USEC 10000
+
static struct uart_driver owl_uart_driver;
struct owl_uart_info {
@@ -461,6 +465,36 @@ static void owl_uart_config_port(struct uart_port *port, int flags)
}
}
+#ifdef CONFIG_CONSOLE_POLL
+
+static int owl_uart_poll_get_char(struct uart_port *port)
+{
+ if (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)
+ return NO_POLL_CHAR;
+
+ return owl_uart_read(port, OWL_UART_RXDAT);
+}
+
+static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+ u32 reg;
+ int ret;
+
+ /* Wait while FIFO is full or timeout */
+ ret = readl_poll_timeout_atomic(port->membase + OWL_UART_STAT, reg,
+ !(reg & OWL_UART_STAT_TFFU),
+ OWL_UART_POLL_USEC,
+ OWL_UART_TIMEOUT_USEC);
+ if (ret == -ETIMEDOUT) {
+ dev_err(port->dev, "Timeout waiting while UART TX FULL\n");
+ return;
+ }
+
+ owl_uart_write(port, ch, OWL_UART_TXDAT);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
static const struct uart_ops owl_uart_ops = {
.set_mctrl = owl_uart_set_mctrl,
.get_mctrl = owl_uart_get_mctrl,
@@ -476,6 +510,10 @@ static const struct uart_ops owl_uart_ops = {
.request_port = owl_uart_request_port,
.release_port = owl_uart_release_port,
.verify_port = owl_uart_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+ .poll_get_char = owl_uart_poll_get_char,
+ .poll_put_char = owl_uart_poll_put_char,
+#endif
};
#ifdef CONFIG_SERIAL_OWL_CONSOLE
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v3 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-12 20:55 ` Cristian Ciocaltea
0 siblings, 0 replies; 2+ messages in thread
From: Cristian Ciocaltea @ 2021-01-12 20:55 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Andreas Färber,
Manivannan Sadhasivam
Cc: linux-actions, linux-arm-kernel, linux-serial, linux-kernel
Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
'owl_uart_ops' that enables OWL UART to be used for kernel debugging
over serial line.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
Changes in v3:
- Used 'readl_poll_timeout_atomic()' in 'owl_uart_poll_put_char()'
to get rid of 'cpu_relax()' and provide a max bound to the loop,
as indicated by Greg and Jiri
Changes in v2:
- Reverted unnecessary changes per Andreas feedback
- Optimized implementation for 'owl_uart_poll_get_char()'
and 'owl_uart_poll_put_char()' callbacks
drivers/tty/serial/owl-uart.c | 38 +++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
index c149f8c30007..abc6042f0378 100644
--- a/drivers/tty/serial/owl-uart.c
+++ b/drivers/tty/serial/owl-uart.c
@@ -12,6 +12,7 @@
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
@@ -62,6 +63,9 @@
#define OWL_UART_STAT_TRFL_MASK GENMASK(16, 11)
#define OWL_UART_STAT_UTBB BIT(17)
+#define OWL_UART_POLL_USEC 5
+#define OWL_UART_TIMEOUT_USEC 10000
+
static struct uart_driver owl_uart_driver;
struct owl_uart_info {
@@ -461,6 +465,36 @@ static void owl_uart_config_port(struct uart_port *port, int flags)
}
}
+#ifdef CONFIG_CONSOLE_POLL
+
+static int owl_uart_poll_get_char(struct uart_port *port)
+{
+ if (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)
+ return NO_POLL_CHAR;
+
+ return owl_uart_read(port, OWL_UART_RXDAT);
+}
+
+static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+ u32 reg;
+ int ret;
+
+ /* Wait while FIFO is full or timeout */
+ ret = readl_poll_timeout_atomic(port->membase + OWL_UART_STAT, reg,
+ !(reg & OWL_UART_STAT_TFFU),
+ OWL_UART_POLL_USEC,
+ OWL_UART_TIMEOUT_USEC);
+ if (ret == -ETIMEDOUT) {
+ dev_err(port->dev, "Timeout waiting while UART TX FULL\n");
+ return;
+ }
+
+ owl_uart_write(port, ch, OWL_UART_TXDAT);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
static const struct uart_ops owl_uart_ops = {
.set_mctrl = owl_uart_set_mctrl,
.get_mctrl = owl_uart_get_mctrl,
@@ -476,6 +510,10 @@ static const struct uart_ops owl_uart_ops = {
.request_port = owl_uart_request_port,
.release_port = owl_uart_release_port,
.verify_port = owl_uart_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+ .poll_get_char = owl_uart_poll_get_char,
+ .poll_put_char = owl_uart_poll_put_char,
+#endif
};
#ifdef CONFIG_SERIAL_OWL_CONSOLE
--
2.30.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-12 21:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 20:55 [PATCH v3 1/1] tty: serial: owl: Add support for kernel debugger Cristian Ciocaltea
2021-01-12 20:55 ` Cristian Ciocaltea
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.