From patchwork Sat Jan 23 08:00:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 60233 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp326361lbb; Sat, 23 Jan 2016 00:03:03 -0800 (PST) X-Received: by 10.28.11.73 with SMTP id 70mr7461190wml.40.1453536183171; Sat, 23 Jan 2016 00:03:03 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id 186si9552318wms.43.2016.01.23.00.03.02 (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 23 Jan 2016 00:03:03 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aMt8M-00021Q-SU; Sat, 23 Jan 2016 08:01:22 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aMt8M-000216-1f for xen-devel@lists.xen.org; Sat, 23 Jan 2016 08:01:22 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id FB/8B-28791-15333A65; Sat, 23 Jan 2016 08:01:21 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1453536073!16887896!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1806 invoked from network); 23 Jan 2016 08:01:18 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-2.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jan 2016 08:01:18 -0000 Received: from 172.24.1.48 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.48]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DAK77852; Sat, 23 Jan 2016 16:00:54 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Sat, 23 Jan 2016 16:00:42 +0800 From: Shannon Zhao To: Date: Sat, 23 Jan 2016 16:00:20 +0800 Message-ID: <1453536020-16196-9-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1453536020-16196-1-git-send-email-zhaoshenglong@huawei.com> References: <1453536020-16196-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.56A33337.0075, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 290d8249cbec739ccbe012febf531ac2 Cc: julien.grall@citrix.com, peter.huangpeng@huawei.com, stefano.stabellini@citrix.com, ian.campbell@citrix.com, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v5 8/8] pl011: Refactor pl011 driver to dt and common initialization parts X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Shannon Zhao 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 Signed-off-by: Shannon Zhao Acked-by: Stefano Stabellini --- xen/drivers/char/pl011.c | 64 ++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 26 deletions(-) -- 2.0.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c index 67e6df5..7e16294 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -226,12 +226,42 @@ static struct uart_driver __read_mostly pl011_driver = { .vuart_info = pl011_vuart, }; +static int __init pl011_uart_init(int irq, u64 addr, u64 size) +{ + struct pl011 *uart; + + uart = &pl011_com; + uart->irq = irq; + 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; + + /* Register with generic serial driver. */ + serial_register_uart(SERHND_DTUART, &pl011_driver, uart); + + return 0; +} + /* TODO: Parse UART config from the command line */ -static int __init pl011_uart_init(struct dt_device_node *dev, - const void *data) +static int __init pl011_dt_uart_init(struct dt_device_node *dev, + const void *data) { const char *config = data; - struct pl011 *uart; int res; u64 addr, size; @@ -240,14 +270,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev, printk("WARNING: UART configuration is not supported\n"); } - 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 ) { @@ -262,24 +284,14 @@ static int __init pl011_uart_init(struct dt_device_node *dev, printk("pl011: Unable to retrieve the IRQ\n"); return -EINVAL; } - uart->irq = res; - uart->regs = ioremap_nocache(addr, size); - if ( !uart->regs ) + res = pl011_uart_init(res, 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); - dt_device_set_used_by(dev, DOMID_XEN); return 0; @@ -293,7 +305,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 = pl011_dt_uart_init, DT_DEVICE_END /*