From patchwork Wed Sep 6 13:52:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yixun Lan X-Patchwork-Id: 9940797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 430AE60350 for ; Wed, 6 Sep 2017 13:53:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26E5C28BE2 for ; Wed, 6 Sep 2017 13:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B5D328BE4; Wed, 6 Sep 2017 13:53:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83DC228BE2 for ; Wed, 6 Sep 2017 13:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=shOTnpa869HDM0BJr4ji/lRRgDDSdaYACbAQbMkeSyg=; b=VLD gAOz12ekD8AR8S9ZqoaCsBCUL6zAZ7kGuZjDyihkFiM4tm6JLJpc/dxpiHEtHTlVXafSvv0i1pyn+ htF0RMtfkZw5sBTFtPulurT2JPTyLfv3kJh5ERnm2Xd+3ZszQb1p0H6WFrD8bCvVViyuoQgaKQQS7 vDxMep1rqWse8FoGu923Su7G1Asn8VDGoVO3qPR9MLFgDy3J/30GRFz0UUktU8rZ4yVQWz1FRKzaa ciSscgKLQf44gBKNXh8Q0v/001Xv7B2rOBl+tsf7p5Yt80O5ymqbw1unEHBUIU061fO6x5Tal2ZJu l9uY+UDt4Ys/7AqgvDD5HDtx4Ss+FwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dpam1-0005eR-SR; Wed, 06 Sep 2017 13:53:45 +0000 Received: from smtp.gentoo.org ([140.211.166.183]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dpalu-0005Vg-Lf; Wed, 06 Sep 2017 13:53:43 +0000 Received: from localhost.localdomain (unknown [58.32.228.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dlan) by smtp.gentoo.org (Postfix) with ESMTPSA id 56E8033BEAE; Wed, 6 Sep 2017 13:53:14 +0000 (UTC) From: Yixun Lan To: Kevin Hilman , Greg Kroah-Hartman Subject: [PATCH v2] serial: meson: add Magic SysRq support Date: Wed, 6 Sep 2017 21:52:39 +0800 Message-Id: <20170906135239.29531-1-dlan@gentoo.org> X-Mailer: git-send-email 2.14.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170906_065338_811902_88CA0CDB X-CRM114-Status: UNSURE ( 9.17 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yixun Lan , linux-kernel@vger.kernel.org, Ben Dooks , linux-serial@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Yixun Lan Reviewed-by: Neil Armstrong --- Changes since v1 at [0]: - add changelog & a few more comments [0] https://patchwork.kernel.org/patch/9728475/ --- drivers/tty/serial/meson_uart.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 42e4a4c7597f..3fea24bafd80 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -14,6 +14,10 @@ * */ +#if defined(CONFIG_SERIAL_MESON_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + #include #include #include @@ -183,12 +187,12 @@ static void meson_receive_chars(struct uart_port *port) { struct tty_port *tport = &port->state->port; char flag; - u32 status, ch, mode; + u32 ostatus, status, ch, mode; do { flag = TTY_NORMAL; 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_TX_FIFO_WERR) @@ -216,6 +220,16 @@ static void meson_receive_chars(struct uart_port *port) ch = readl(port->membase + AML_UART_RFIFO); 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) tty_insert_flip_char(tport, ch, flag);