Commit b86ac225 authored by Yixun Lan's avatar Yixun Lan Committed by Greg Kroah-Hartman

serial: meson: add Magic SysRq support

This dirver try to implement the Magic SysRq support[1] for
Amlogic Inc's meson platfo
>From the hardware perspective, the UART IP can't detect the 'BREAK' command
clearly via the status register. Instead, we rely on the combination of
'FRAME_ERR bit && ch == 0', and it works fine.

[1] Documentation/admin-guide/sysrq.rst
Signed-off-by: default avatarYixun Lan <dlan@gentoo.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2bd6bf03
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
* *
*/ */
#if defined(CONFIG_SERIAL_MESON_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
#define SUPPORT_SYSRQ
#endif
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -183,12 +187,12 @@ static void meson_receive_chars(struct uart_port *port) ...@@ -183,12 +187,12 @@ static void meson_receive_chars(struct uart_port *port)
{ {
struct tty_port *tport = &port->state->port; struct tty_port *tport = &port->state->port;
char flag; char flag;
u32 status, ch, mode; u32 ostatus, status, ch, mode;
do { do {
flag = TTY_NORMAL; flag = TTY_NORMAL;
port->icount.rx++; port->icount.rx++;
status = readl(port->membase + AML_UART_STATUS); ostatus = status = readl(port->membase + AML_UART_STATUS);
if (status & AML_UART_ERR) { if (status & AML_UART_ERR) {
if (status & AML_UART_TX_FIFO_WERR) if (status & AML_UART_TX_FIFO_WERR)
...@@ -216,6 +220,16 @@ static void meson_receive_chars(struct uart_port *port) ...@@ -216,6 +220,16 @@ static void meson_receive_chars(struct uart_port *port)
ch = readl(port->membase + AML_UART_RFIFO); ch = readl(port->membase + AML_UART_RFIFO);
ch &= 0xff; ch &= 0xff;
if ((ostatus & AML_UART_FRAME_ERR) && (ch == 0)) {
port->icount.brk++;
flag = TTY_BREAK;
if (uart_handle_break(port))
continue;
}
if (uart_handle_sysrq_char(port, ch))
continue;
if ((status & port->ignore_status_mask) == 0) if ((status & port->ignore_status_mask) == 0)
tty_insert_flip_char(tport, ch, flag); tty_insert_flip_char(tport, ch, flag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment