Kernel debugging with kgdb » 0001-serial-ar933x-Implement-CONSOLE_POLL.patch
target/linux/ath79/patches-5.10/941-serial-ar933x-Implement-CONSOLE_POLL.patch | ||
---|---|---|
From: Sven Eckelmann <sven@narfation.org>
|
||
Date: Mon, 15 Sep 2025 15:35:14 +0200
|
||
Subject: serial: ar933x: Implement CONSOLE_POLL
|
||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
|
||
index fcbaff8941930a7700c00adf18412294956fad5e..acf891b50524760c5a648c8e119704182ec94de8 100644
|
||
--- a/drivers/tty/serial/ar933x_uart.c
|
||
+++ b/drivers/tty/serial/ar933x_uart.c
|
||
@@ -564,6 +564,65 @@ static int ar933x_uart_verify_port(struct uart_port *port,
|
||
return 0;
|
||
}
|
||
|
||
+
|
||
+#ifdef CONFIG_CONSOLE_POLL
|
||
+static int ar933x_poll_get_char(struct uart_port *port)
|
||
+{
|
||
+ struct ar933x_uart_port *up =
|
||
+ container_of(port, struct ar933x_uart_port, port);
|
||
+ unsigned int rdata;
|
||
+ unsigned char ch;
|
||
+ u32 imr;
|
||
+
|
||
+ /* Disable all interrupts */
|
||
+ imr = ar933x_uart_read(up, AR933X_UART_INT_EN_REG);
|
||
+ ar933x_uart_write(up, AR933X_UART_INT_EN_REG, 0);
|
||
+
|
||
+ rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG);
|
||
+ if ((rdata & AR933X_UART_DATA_RX_CSR) == 0) {
|
||
+ /* Enable interrupts */
|
||
+ ar933x_uart_write(up, AR933X_UART_INT_EN_REG, imr);
|
||
+ return NO_POLL_CHAR;
|
||
+ }
|
||
+
|
||
+ /* remove the character from the FIFO */
|
||
+ ar933x_uart_write(up, AR933X_UART_DATA_REG,
|
||
+ AR933X_UART_DATA_RX_CSR);
|
||
+
|
||
+ ch = rdata & AR933X_UART_DATA_TX_RX_MASK;
|
||
+
|
||
+ /* Enable interrupts */
|
||
+ ar933x_uart_write(up, AR933X_UART_INT_EN_REG, imr);
|
||
+
|
||
+ return ch;
|
||
+}
|
||
+
|
||
+static void ar933x_poll_put_char(struct uart_port *port, unsigned char c)
|
||
+{
|
||
+ struct ar933x_uart_port *up =
|
||
+ container_of(port, struct ar933x_uart_port, port);
|
||
+ u32 imr;
|
||
+
|
||
+ /* Disable all interrupts */
|
||
+ imr = ar933x_uart_read(up, AR933X_UART_INT_EN_REG);
|
||
+ ar933x_uart_write(up, AR933X_UART_INT_EN_REG, 0);
|
||
+
|
||
+ /* Wait until FIFO is empty */
|
||
+ while (!(ar933x_uart_read(up, AR933X_UART_DATA_REG) & AR933X_UART_DATA_TX_CSR))
|
||
+ cpu_relax();
|
||
+
|
||
+ /* Write a character */
|
||
+ ar933x_uart_putc(up, c);
|
||
+
|
||
+ /* Wait until FIFO is empty */
|
||
+ while (!(ar933x_uart_read(up, AR933X_UART_DATA_REG) & AR933X_UART_DATA_TX_CSR))
|
||
+ cpu_relax();
|
||
+
|
||
+ /* Enable interrupts */
|
||
+ ar933x_uart_write(up, AR933X_UART_INT_EN_REG, imr);
|
||
+}
|
||
+#endif
|
||
+
|
||
static const struct uart_ops ar933x_uart_ops = {
|
||
.tx_empty = ar933x_uart_tx_empty,
|
||
.set_mctrl = ar933x_uart_set_mctrl,
|
||
@@ -580,6 +639,10 @@ static const struct uart_ops ar933x_uart_ops = {
|
||
.request_port = ar933x_uart_request_port,
|
||
.config_port = ar933x_uart_config_port,
|
||
.verify_port = ar933x_uart_verify_port,
|
||
+#ifdef CONFIG_CONSOLE_POLL
|
||
+ .poll_get_char = ar933x_poll_get_char,
|
||
+ .poll_put_char = ar933x_poll_put_char,
|
||
+#endif
|
||
};
|
||
|
||
static int ar933x_config_rs485(struct uart_port *port,
|