From patchwork Sat Jan 16 05:01:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 59899 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp931999lbb; Fri, 15 Jan 2016 21:07:52 -0800 (PST) X-Received: by 10.140.101.201 with SMTP id u67mr17991628qge.33.1452920872163; Fri, 15 Jan 2016 21:07:52 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id c191si17566961qka.29.2016.01.15.21.07.51 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 15 Jan 2016 21:07:52 -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 1aKJ3u-0007DE-Dr; Sat, 16 Jan 2016 05:06:06 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aKJ3s-0007Cx-LE for xen-devel@lists.xen.org; Sat, 16 Jan 2016 05:06:04 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id DA/D1-24450-BBFC9965; Sat, 16 Jan 2016 05:06:03 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1452920760!17190326!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 39886 invoked from network); 16 Jan 2016 05:06:02 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-9.tower-27.messagelabs.com with SMTP; 16 Jan 2016 05:06:02 -0000 Received: from 172.24.1.49 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.49]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CZY66089; Sat, 16 Jan 2016 13:02:29 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Sat, 16 Jan 2016 13:02:21 +0800 From: Shannon Zhao To: Date: Sat, 16 Jan 2016 13:01:17 +0800 Message-ID: <1452920477-13916-11-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1452920477-13916-1-git-send-email-zhaoshenglong@huawei.com> References: <1452920477-13916-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.0A020202.5699CEE5.0144, 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: f00d7ccbaf0bf7366d09d2c5962ab504 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 v4 10/10] 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 /*