From patchwork Tue Jul 22 22:29:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 4606531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A537AC0514 for ; Tue, 22 Jul 2014 22:31:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B54A72018B for ; Tue, 22 Jul 2014 22:31:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C151820179 for ; Tue, 22 Jul 2014 22:31:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9iZE-0001am-61; Tue, 22 Jul 2014 22:29:52 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9iZ4-0001Rs-94 for linux-arm-kernel@lists.infradead.org; Tue, 22 Jul 2014 22:29:42 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 75EB513FFF7; Tue, 22 Jul 2014 22:29:21 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 68209140152; Tue, 22 Jul 2014 22:29:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from sboyd-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 84E1C13FFF7; Tue, 22 Jul 2014 22:29:20 +0000 (UTC) From: Stephen Boyd To: Greg Kroah-Hartman Subject: [PATCH] tty: serial: msm: Add DT based earlycon support Date: Tue, 22 Jul 2014 15:29:18 -0700 Message-Id: <1406068158-16491-1-git-send-email-sboyd@codeaurora.org> X-Mailer: git-send-email 1.9.0.1.gd5ccf8c X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140722_152942_358084_2F365B47 X-CRM114-Status: GOOD ( 18.60 ) X-Spam-Score: -0.0 (/) Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rob Herring X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for DT based early console on platforms with the msm serial hardware. Cc: Rob Herring Signed-off-by: Stephen Boyd --- I've tested this on top of Rob's arm-fixmap[1] branch and a cherry-pick of commit 68252424a7c7 (tty: serial: msm: Support big-endian CPUs, 2014-06-30) and the merge of commit 45e0f0f56843 (tty/serial: pl011: add DT based earlycon support, 2014-03-27) [1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git arm-fixmap drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/msm_serial.c | 72 ++++++++++++++++++++++++++++++++++------- 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 26cec64dadd7..903a3277fa60 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1051,6 +1051,7 @@ config SERIAL_MSM_CONSOLE bool "MSM serial console support" depends on SERIAL_MSM=y select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON config SERIAL_MSM_HS tristate "MSM UART High Speed: Serial Driver" diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index c549110509bb..d68faa2e7a6c 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -856,22 +856,15 @@ static inline struct uart_port *get_port_from_line(unsigned int line) } #ifdef CONFIG_SERIAL_MSM_CONSOLE -static void msm_console_write(struct console *co, const char *s, - unsigned int count) +static void __msm_console_write(struct uart_port *port, const char *s, + unsigned int count, bool is_uartdm) { int i; - struct uart_port *port; - struct msm_port *msm_port; int num_newlines = 0; bool replaced = false; void __iomem *tf; - BUG_ON(co->index < 0 || co->index >= UART_NR); - - port = get_port_from_line(co->index); - msm_port = UART_TO_MSM(port); - - if (msm_port->is_uartdm) + if (is_uartdm) tf = port->membase + UARTDM_TF; else tf = port->membase + UART_TF; @@ -883,7 +876,7 @@ static void msm_console_write(struct console *co, const char *s, count += num_newlines; spin_lock(&port->lock); - if (msm_port->is_uartdm) + if (is_uartdm) reset_dm_count(port, count); i = 0; @@ -892,7 +885,7 @@ static void msm_console_write(struct console *co, const char *s, unsigned int num_chars; char buf[4] = { 0 }; - if (msm_port->is_uartdm) + if (is_uartdm) num_chars = min(count - i, (unsigned int)sizeof(buf)); else num_chars = 1; @@ -921,6 +914,20 @@ static void msm_console_write(struct console *co, const char *s, spin_unlock(&port->lock); } +static void msm_console_write(struct console *co, const char *s, + unsigned int count) +{ + struct uart_port *port; + struct msm_port *msm_port; + + BUG_ON(co->index < 0 || co->index >= UART_NR); + + port = get_port_from_line(co->index); + msm_port = UART_TO_MSM(port); + + __msm_console_write(port, s, count, msm_port->is_uartdm); +} + static int __init msm_console_setup(struct console *co, char *options) { struct uart_port *port; @@ -963,6 +970,47 @@ static int __init msm_console_setup(struct console *co, char *options) return uart_set_options(port, co, baud, parity, bits, flow); } +static void +msm_serial_early_write(struct console *con, const char *s, unsigned n) +{ + struct earlycon_device *dev = con->data; + + __msm_console_write(&dev->port, s, n, false); +} + +static int __init +msm_serial_early_console_setup(struct earlycon_device *device, const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = msm_serial_early_write; + return 0; +} +OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart", + msm_serial_early_console_setup); + +static void +msm_serial_early_write_dm(struct console *con, const char *s, unsigned n) +{ + struct earlycon_device *dev = con->data; + + __msm_console_write(&dev->port, s, n, true); +} + +static int __init +msm_serial_early_console_setup_dm(struct earlycon_device *device, + const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = msm_serial_early_write_dm; + return 0; +} +OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm", + msm_serial_early_console_setup_dm); + static struct uart_driver msm_uart_driver; static struct console msm_console = {