From patchwork Sun May 17 20:03:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48647 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D440B21411 for ; Sun, 17 May 2015 20:06:48 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf46766800wgt.1 for ; Sun, 17 May 2015 13:06:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=hlpQGB2pWUxFdA8uSx1xtiOcsKxxeHE0LmXwbuVz61Y=; b=e775aDzIV4Sm+NMsv2EwxDTsjPTUe6MzOn6bo/gNHoR0mP914FbfK+Vympo2cBe6UP clzKhWkOzv9iT13j2w65BcKOTfLY2laN2OjpTebahh5L3kU5L0C7lh7aJbSAV2v6BBhq szlZhVkNjO7nMcicbMeUDvCpsSrZeCeoSRe/QMk/s4vcN+vSTCaBAQ2By191ExUVlD+y SbPplA5k/x52dDnoTweYw91Y+zumdNhnTxDMc71jgkQcRRpoh5Vfvrlye4dEvxd6ZLk0 Ef8MkEUjteeri79cBcMzpgjpjXzX1iNB8RMjv6N4BYBsGyRlIWhmzT4eUdJAyA/oGM/g 358A== X-Gm-Message-State: ALoCoQkkQ8kJjuKckcI3K4XrD61fkk5KW691veE7MZVJyvB9DAQa9FCrFwnuYQmYzpqSMTvKc8or X-Received: by 10.112.26.5 with SMTP id h5mr15317330lbg.4.1431893208173; Sun, 17 May 2015 13:06:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.231 with SMTP id e7ls631500lah.38.gmail; Sun, 17 May 2015 13:06:48 -0700 (PDT) X-Received: by 10.153.7.104 with SMTP id db8mr7897919lad.124.1431893208022; Sun, 17 May 2015 13:06:48 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id k6si5334650lam.65.2015.05.17.13.06.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by labbd9 with SMTP id bd9so191528307lab.2 for ; Sun, 17 May 2015 13:06:47 -0700 (PDT) X-Received: by 10.113.10.134 with SMTP id ea6mr14568905lbd.29.1431893207574; Sun, 17 May 2015 13:06:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3508033lbb; Sun, 17 May 2015 13:06:46 -0700 (PDT) X-Received: by 10.140.82.48 with SMTP id g45mr24622017qgd.41.1431893196770; Sun, 17 May 2015 13:06:36 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id w94si1183787qge.60.2015.05.17.13.06.36 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:06:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4on-0002Qp-0F; Sun, 17 May 2015 20:05:49 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4ol-0002Nt-4b for xen-devel@lists.xen.org; Sun, 17 May 2015 20:05:47 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id 1F/B3-03202-994F8555; Sun, 17 May 2015 20:05:45 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-5.tower-27.messagelabs.com!1431893143!13619759!1 X-Originating-IP: [209.85.192.180] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 6.13.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27033 invoked from network); 17 May 2015 20:05:44 -0000 Received: from mail-pd0-f180.google.com (HELO mail-pd0-f180.google.com) (209.85.192.180) by server-5.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:05:44 -0000 Received: by pdfh10 with SMTP id h10so117354670pdf.3 for ; Sun, 17 May 2015 13:05:43 -0700 (PDT) X-Received: by 10.68.68.175 with SMTP id x15mr31014858pbt.91.1431893143023; Sun, 17 May 2015 13:05:43 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.05.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:05:42 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:33:47 +0530 Message-Id: <1431893048-5214-21-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v2 20/41] arm : create generic uart initialization function X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Rename dt-uart.c to arm-uart.c and create new generic uart init function. move dt_uart_init to uart_init. Refactor pl011 driver to dt and common initialization parts. This will be useful later when acpi specific uart initialization function is introduced. Signed-off-by: Parth Dixit --- xen/arch/arm/setup.c | 2 +- xen/drivers/char/Makefile | 2 +- xen/drivers/char/dt-uart.c | 107 --------------------------------------------- xen/drivers/char/pl011.c | 47 ++++++++++++-------- xen/include/xen/serial.h | 3 +- 5 files changed, 33 insertions(+), 128 deletions(-) delete mode 100644 xen/drivers/char/dt-uart.c diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 5711077..1b2d74c 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -771,7 +771,7 @@ void __init start_xen(unsigned long boot_phys_offset, gic_preinit(); - dt_uart_init(); + uart_init(); console_init_preirq(); console_init_ring(); diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile index 47fc3f9..a8f65c1 100644 --- a/xen/drivers/char/Makefile +++ b/xen/drivers/char/Makefile @@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o obj-$(HAS_OMAP) += omap-uart.o obj-$(HAS_SCIF) += scif-uart.o obj-$(HAS_EHCI) += ehci-dbgp.o -obj-$(CONFIG_ARM) += dt-uart.o +obj-$(CONFIG_ARM) += arm-uart.o obj-y += serial.o diff --git a/xen/drivers/char/dt-uart.c b/xen/drivers/char/dt-uart.c deleted file mode 100644 index d599322..0000000 --- a/xen/drivers/char/dt-uart.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * xen/drivers/char/dt-uart.c - * - * Generic uart retrieved via the device tree - * - * Julien Grall - * Copyright (c) 2013 Linaro Limited. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include - -/* - * Configure UART port with a string: - * path:options - * - * @path: full path used in the device tree for the UART. If the path - * doesn't start with '/', we assuming that it's an alias. - * @options: UART speficic options (see in each UART driver) - */ -static char __initdata opt_dtuart[256] = ""; -string_param("dtuart", opt_dtuart); - -void __init dt_uart_init(void) -{ - struct dt_device_node *dev; - int ret; - const char *devpath = opt_dtuart; - char *options; - - if ( !console_has("dtuart") ) - return; /* Not for us */ - - if ( !strcmp(opt_dtuart, "") ) - { - const struct dt_device_node *chosen = dt_find_node_by_path("/chosen"); - - if ( chosen ) - { - const char *stdout; - - ret = dt_property_read_string(chosen, "stdout-path", &stdout); - if ( ret >= 0 ) - { - printk("Taking dtuart configuration from /chosen/stdout-path\n"); - if ( strlcpy(opt_dtuart, stdout, sizeof(opt_dtuart)) - >= sizeof(opt_dtuart) ) - printk("WARNING: /chosen/stdout-path too long, truncated\n"); - } - else if ( ret != -EINVAL /* Not present */ ) - printk("Failed to read /chosen/stdout-path (%d)\n", ret); - } - } - - if ( !strcmp(opt_dtuart, "") ) - { - printk("No dtuart path configured\n"); - return; - } - - options = strchr(opt_dtuart, ':'); - if ( options != NULL ) - *(options++) = '\0'; - else - options = ""; - - printk("Looking for dtuart at \"%s\", options \"%s\"\n", devpath, options); - if ( *devpath == '/' ) - dev = dt_find_node_by_path(devpath); - else - dev = dt_find_node_by_alias(devpath); - - if ( !dev ) - { - printk("Unable to find device \"%s\"\n", devpath); - return; - } - - ret = device_init(dev, DEVICE_SERIAL, options); - - if ( ret ) - printk("Unable to initialize dtuart: %d\n", ret); -} - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c index 67e6df5..f0c3daf 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -225,9 +225,32 @@ static struct uart_driver __read_mostly pl011_driver = { .stop_tx = pl011_tx_stop, .vuart_info = pl011_vuart, }; +static int __init pl011_uart_init(struct pl011 *uart, u64 addr, u64 size) +{ + uart->clock_hz = 0x16e3600; + uart->baud = BAUD_AUTO; + uart->data_bits = 8; + uart->parity = PARITY_NONE; + uart->stop_bits = 1; + + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + printk("pl011: Unable to map the UART memory\n"); + return -ENOMEM; + } + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off = DR; + uart->vuart.status_off = FR; + uart->vuart.status = 0; + + return 0; +} /* TODO: Parse UART config from the command line */ -static int __init pl011_uart_init(struct dt_device_node *dev, +static int __init dt_pl011_uart_init(struct dt_device_node *dev, const void *data) { const char *config = data; @@ -242,12 +265,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev, uart = &pl011_com; - uart->clock_hz = 0x16e3600; - uart->baud = BAUD_AUTO; - uart->data_bits = 8; - uart->parity = PARITY_NONE; - uart->stop_bits = 1; - res = dt_device_get_address(dev, 0, &addr, &size); if ( res ) { @@ -264,19 +281,13 @@ static int __init pl011_uart_init(struct dt_device_node *dev, } uart->irq = res; - uart->regs = ioremap_nocache(addr, size); - if ( !uart->regs ) + res = pl011_uart_init(uart, addr, size); + if ( res < 0 ) { - printk("pl011: Unable to map the UART memory\n"); - return -ENOMEM; + printk("pl011: Unable to initialize\n"); + return res; } - uart->vuart.base_addr = addr; - uart->vuart.size = size; - uart->vuart.data_off = DR; - uart->vuart.status_off = FR; - uart->vuart.status = 0; - /* Register with generic serial driver. */ serial_register_uart(SERHND_DTUART, &pl011_driver, uart); @@ -293,7 +304,7 @@ static const struct dt_device_match pl011_dt_match[] __initconst = DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) .dt_match = pl011_dt_match, - .init = pl011_uart_init, + .init = dt_pl011_uart_init, DT_DEVICE_END /* diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h index 71e6ade..484a6a8 100644 --- a/xen/include/xen/serial.h +++ b/xen/include/xen/serial.h @@ -98,6 +98,7 @@ struct uart_driver { #define SERHND_HI (1<<2) /* Mux/demux each transferred char by MSB. */ #define SERHND_LO (1<<3) /* Ditto, except that the MSB is cleared. */ #define SERHND_COOKED (1<<4) /* Newline/carriage-return translation? */ +#define SERHND_UART (0<<0) /* handler configured from ACPI */ /* Two-stage initialisation (before/after IRQ-subsystem initialisation). */ void serial_init_preirq(void); @@ -170,7 +171,7 @@ struct ns16550_defaults { void ns16550_init(int index, struct ns16550_defaults *defaults); void ehci_dbgp_init(void); -void __init dt_uart_init(void); +void __init uart_init(void); struct physdev_dbgp_op; int dbgp_op(const struct physdev_dbgp_op *);