From patchwork Thu May 8 22:23:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 4139261 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 B728F9F387 for ; Thu, 8 May 2014 22:34:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D111E202DD for ; Thu, 8 May 2014 22:34:10 +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 04563201E7 for ; Thu, 8 May 2014 22:34:10 +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 1WiWrI-0002lB-9D; Thu, 08 May 2014 22:32:08 +0000 Received: from mail-ob0-x22c.google.com ([2607:f8b0:4003:c01::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiWrE-0002h1-Uz for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2014 22:32:05 +0000 Received: by mail-ob0-f172.google.com with SMTP id wp18so3877937obc.3 for ; Thu, 08 May 2014 15:31:44 -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=Uin2f6F1PDRdP3kba+nZQLKRUcGKRlopHjFbe5UJOHw=; b=DeVNrHiEQDOaW9p+bqrTMrFwhgVA6Hb5EWIsTbwBaN/fcY6gK073K241b6m1m5/K9c C0FbvB5Umv7cpPodbFsRGyPO0V9WgLH16p2E9uaWpZlkVUoI7zeqNrxaspwA3ff4laUQ NXja1TsyKOsCMupKLBWfLXQkxZQpMB5GnwUpZNYg7JZnpprquRYiIokj/NYQcieVaH6u 9i3ta/quEJNNyfsGdhQuRGV2q2DfJJ09E94ruLLvRq66cUl4KI1FK+OPh22A6K+vPrDf 0MqvcFwB4danURvupJlKLqH9/tIQzKCIEgdAslK05kkAZTEtLpUUraKPbCrDAzBNkc6U j8ZA== X-Received: by 10.182.70.39 with SMTP id j7mr8738939obu.55.1399587839871; Thu, 08 May 2014 15:23:59 -0700 (PDT) Received: from localhost.localdomain (72-48-77-163.dyn.grandenetworks.net. [72.48.77.163]) by mx.google.com with ESMTPSA id fj9sm9311932oeb.6.2014.05.08.15.23.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 May 2014 15:23:59 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/6] serial: earlycon: add DT support Date: Thu, 8 May 2014 17:23:40 -0500 Message-Id: <1399587823-17701-4-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399587823-17701-1-git-send-email-robherring2@gmail.com> References: <1399587823-17701-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140508_153205_051182_7CFD2539 X-CRM114-Status: GOOD ( 17.37 ) X-Spam-Score: 0.1 (/) Cc: Rob Herring , Arnd Bergmann , benh@kernel.crashing.org, Greg Kroah-Hartman , Grant Likely , 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=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This adds the infrastructure to generic earlycon for earlycon setup using DT. The actual setup is not enabled until a following commit to add the FDT parsing. Signed-off-by: Rob Herring Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Arnd Bergmann --- drivers/tty/serial/earlycon.c | 27 +++++++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 4 +++- include/linux/serial_core.h | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index c92e830..021fe5f 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef CONFIG_FIX_EARLYCON_MEM #include @@ -32,6 +33,9 @@ static struct earlycon_device early_console_dev = { .con = &early_con, }; +static const struct of_device_id __earlycon_of_table_sentinel + __used __section(__earlycon_of_table_end); + static void __iomem * __init earlycon_map(unsigned long paddr, size_t size) { void __iomem *base; @@ -142,3 +146,26 @@ int __init setup_earlycon(char *buf, const char *match, register_console(early_console_dev.con); return 0; } + +int __init of_setup_earlycon(unsigned long addr, + int (*setup)(struct earlycon_device *, const char *)) +{ + int err; + struct uart_port *port = &early_console_dev.port; + + port->iotype = UPIO_MEM; + port->mapbase = addr; + port->uartclk = BASE_BAUD * 16; + port->membase = earlycon_map(addr, SZ_4K); + + early_console_dev.con->data = &early_console_dev; + err = setup(&early_console_dev, NULL); + if (err < 0) + return err; + if (!early_console_dev.con->write) + return -ENODEV; + + + register_console(early_console_dev.con); + return 0; +} diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 120ccb9..f5249c4 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -129,6 +129,7 @@ #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) +#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) #define KERNEL_DTB() \ STRUCT_ALIGN(); \ @@ -458,7 +459,8 @@ CLKSRC_OF_TABLES() \ CPU_METHOD_OF_TABLES() \ KERNEL_DTB() \ - IRQCHIP_OF_MATCH_TABLE() + IRQCHIP_OF_MATCH_TABLE() \ + EARLYCON_OF_TABLES() #define INIT_TEXT \ *(.init.text) \ diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 7a15b5b..5bbb809 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -294,6 +294,9 @@ struct earlycon_device { int setup_earlycon(char *buf, const char *match, int (*setup)(struct earlycon_device *, const char *)); +extern int of_setup_earlycon(unsigned long addr, + int (*setup)(struct earlycon_device *, const char *)); + #define EARLYCON_DECLARE(name, func) \ static int __init name ## _setup_earlycon(char *buf) \ { \ @@ -301,6 +304,9 @@ static int __init name ## _setup_earlycon(char *buf) \ } \ early_param("earlycon", name ## _setup_earlycon); +#define OF_EARLYCON_DECLARE(name, compat, fn) \ + _OF_DECLARE(earlycon, name, compat, fn, void *) + struct uart_port *uart_get_console(struct uart_port *ports, int nr, struct console *c); void uart_parse_options(char *options, int *baud, int *parity, int *bits,