From patchwork Fri Mar 21 21:08:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 3876491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 47DC09F334 for ; Fri, 21 Mar 2014 21:14:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5EC75201FD for ; Fri, 21 Mar 2014 21:14:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 59411200DF for ; Fri, 21 Mar 2014 21:14:00 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WR6jF-00052l-Mv; Fri, 21 Mar 2014 21:11:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WR6id-00028I-RJ; Fri, 21 Mar 2014 21:11:11 +0000 Received: from mail-oa0-x232.google.com ([2607:f8b0:4003:c02::232]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WR6he-00020A-I6 for linux-arm-kernel@lists.infradead.org; Fri, 21 Mar 2014 21:10:13 +0000 Received: by mail-oa0-f50.google.com with SMTP id i7so3181281oag.23 for ; Fri, 21 Mar 2014 14:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XliRGlZcuPggne99HQ82uY3It1sbyPtg4mb4/56edbc=; b=u4VB17AymyaeejClrj02rYYJdNHsn6TPORmjPTKHS51XTHsTrJV2UF0LvGS0V0UHjU CMDLYoYGmXg96qvdQ3UfuhOkOw5J1tJVRltgZk6bFMzcYPgrdyECbAdKGz2OJNV3RSD7 AB8FOZTwwRS6QeWq6nehZsZNr1QUL+TMentLYlaIIz3NoJPNmRzNiuPCYANNxX25NUs4 7YbvJV+3Q/ntnmYk3ntF+41wPlKw9bopV0gGw0aEj8f3tsl4EKdtvGKH48qGlL/Y4v/J 70eRjs/IJbPsrzPEsqZkhCrZBMXysvt7edRbGSx/q4aHhk6q4VJq61XUa0tncVi6k2oi so/Q== X-Received: by 10.60.119.73 with SMTP id ks9mr3608585oeb.75.1395436189121; Fri, 21 Mar 2014 14:09:49 -0700 (PDT) Received: from localhost.localdomain (72-48-77-163.dyn.grandenetworks.net. [72.48.77.163]) by mx.google.com with ESMTPSA id tz6sm9859086obc.10.2014.03.21.14.09.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 14:09:47 -0700 (PDT) From: Rob Herring To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 6/8] tty/serial: pl011: add generic earlycon support Date: Fri, 21 Mar 2014 16:08:46 -0500 Message-Id: <1395436128-11244-7-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395436128-11244-1-git-send-email-robherring2@gmail.com> References: <1395436128-11244-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140321_171010_721107_34D7C0D0 X-CRM114-Status: GOOD ( 14.86 ) X-Spam-Score: -1.8 (-) Cc: Rob Herring , Russell King , Arnd Bergmann , Greg Kroah-Hartman , x86@kernel.org, Will Deacon , Catalin Marinas , Jiri Slaby X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Herring Add earlycon support for the pl011 serial port. This allows enabling the pl011 for console when early_params are processed. This is based on the arm64 earlyprintk support and is intended to replace it. Signed-off-by: Rob Herring Cc: Russell King Cc: Greg Kroah-Hartman Cc: Jiri Slaby --- Documentation/kernel-parameters.txt | 5 +++-- drivers/tty/serial/amba-pl011.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 5ce8b7a..81bdd52 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -887,8 +887,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. uart[8250],io,[,options] uart[8250],mmio,[,options] uart[8250],mmio32,[,options] - Start an early, polled-mode console on the 8250/16550 - UART at the specified I/O port or MMIO address. + pl011, + Start an early, polled-mode console on a serial port + at the specified I/O port or MMIO address. 8250 MMIO inter-register address stride is either 8-bit (mmio) or 32-bit (mmio32). The options are the same as for ttyS, above. diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index d4eda24..4227c0a 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -303,7 +303,7 @@ static void pl011_dma_probe_initcall(struct device *dev, struct uart_amba_port * /* Optionally make use of an RX channel as well */ chan = dma_request_slave_channel(dev, "rx"); - + if (!chan && plat->dma_rx_param) { chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); @@ -2045,6 +2045,34 @@ static struct console amba_console = { }; #define AMBA_CONSOLE (&amba_console) + +static void pl011_putc(struct uart_port *port, int c) +{ + while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF) + ; + writeb(c, port->membase + UART01x_DR); + while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY) + ; +} + +static void pl011_early_write(struct console *con, const char *s, unsigned n) +{ + struct earlycon_device *dev = con->data; + + uart_console_write(&dev->port, s, n, pl011_putc); +} + +static int __init pl011_early_console_setup(struct earlycon_device *device, + const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = pl011_early_write; + return 0; +} +EARLYCON_DECLARE(pl011, pl011_early_console_setup); + #else #define AMBA_CONSOLE NULL #endif