From patchwork Mon Jan 12 13:08:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RWRkaWUgSHVhbmcgKOm7g+aZuuWCkSk=?= X-Patchwork-Id: 5610321 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB3119F358 for ; Mon, 12 Jan 2015 13:12:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8143203B0 for ; Mon, 12 Jan 2015 13:12:27 +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 E27EE20397 for ; Mon, 12 Jan 2015 13:12:26 +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 1YAekY-0000P3-2E; Mon, 12 Jan 2015 13:09:42 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YAekJ-0008Rp-Uq for linux-arm-kernel@lists.infradead.org; Mon, 12 Jan 2015 13:09:29 +0000 X-Listener-Flag: 11101 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 2145745085; Mon, 12 Jan 2015 21:08:55 +0800 Received: from mtkslt208.mediatek.inc (10.21.15.95) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Mon, 12 Jan 2015 21:08:54 +0800 From: Eddie Huang To: Rob Herring , Mark Rutland , Greg Kroah-Hartman , Matthias Brugger Subject: [PATCH v2 1/4] tty: serial: Add 8250 earlycon to support noinit option Date: Mon, 12 Jan 2015 21:08:21 +0800 Message-ID: <1421068104-30463-2-git-send-email-eddie.huang@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1421068104-30463-1-git-send-email-eddie.huang@mediatek.com> References: <1421068104-30463-1-git-send-email-eddie.huang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150112_050928_421974_2B99EB98 X-CRM114-Status: GOOD ( 12.65 ) X-Spam-Score: 1.3 (+) Cc: devicetree@vger.kernel.org, Vladimir Murzin , srv_heupstream@mediatek.com, Pawel Moll , Ian Campbell , Catalin Marinas , Jonathan Corbet , Will Deacon , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, yh.chen@mediatek.com, Howard Chen , Ashwin Chaugule , linux-serial@vger.kernel.org, Kumar Gala , "Joe.C" , Eddie Huang , Jiri Slaby , linux-arm-kernel@lists.infradead.org, Alan Cox 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: , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Add earlycon support not only baudrate option, but also add noinit option. If use noinit option, 8250 earlycon will not init serial hardware and use loader setting. Signed-off-by: Eddie Huang --- drivers/tty/serial/8250/8250_early.c | 7 ++++--- drivers/tty/serial/earlycon.c | 17 ++++++++++++----- include/linux/serial_8250.h | 2 ++ include/linux/serial_core.h | 1 + 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index 4858b8a..a13d757 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -138,19 +138,20 @@ static void __init init_port(struct earlycon_device *device) serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB); } -static int __init early_serial8250_setup(struct earlycon_device *device, +int __init early_serial8250_setup(struct earlycon_device *device, const char *options) { if (!(device->port.membase || device->port.iobase)) return 0; - if (!device->baud) { + if (!device->baud && !device->noinit) { device->baud = probe_baud(&device->port); snprintf(device->options, sizeof(device->options), "%u", device->baud); } - init_port(device); + if (!device->noinit) + init_port(device); early_device = device; device->con->write = early_serial8250_write; diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index 64fe25a..4891251 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -58,7 +58,7 @@ static int __init parse_options(struct earlycon_device *device, char *options) { struct uart_port *port = &device->port; - int mmio, mmio32, length; + int noinit, mmio, mmio32, length; unsigned long addr; if (!options) @@ -92,10 +92,17 @@ static int __init parse_options(struct earlycon_device *device, options = strchr(options, ','); if (options) { options++; - device->baud = simple_strtoul(options, NULL, 0); - length = min(strcspn(options, " ") + 1, - (size_t)(sizeof(device->options))); - strlcpy(device->options, options, length); + noinit = !strncmp(options, "noinit", 6); + if (noinit) { + device->noinit = noinit; + strlcpy(device->options, options, 6); + device->options[6] = '\0'; + } else { + device->baud = simple_strtoul(options, NULL, 0); + length = min(strcspn(options, " ") + 1, + (size_t)(sizeof(device->options))); + strlcpy(device->options, options, length); + } } if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM32) diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index e02acf0..0e26eec 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -119,6 +119,8 @@ extern int serial8250_find_port(struct uart_port *p); extern int serial8250_find_port_for_earlycon(void); extern unsigned int serial8250_early_in(struct uart_port *port, int offset); extern void serial8250_early_out(struct uart_port *port, int offset, int value); +extern int early_serial8250_setup(struct earlycon_device *device, + const char *options); extern int setup_early_serial8250_console(char *cmdline); extern void serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 057038c..72c6698 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -326,6 +326,7 @@ struct earlycon_device { struct uart_port port; char options[16]; /* e.g., 115200n8 */ unsigned int baud; + int noinit; }; int setup_earlycon(char *buf, const char *match, int (*setup)(struct earlycon_device *, const char *));