From patchwork Tue Nov 17 09:40:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56736 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1826820lbb; Tue, 17 Nov 2015 01:47:27 -0800 (PST) X-Received: by 10.31.54.142 with SMTP id d136mr2738062vka.116.1447753646078; Tue, 17 Nov 2015 01:47:26 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id 19si2025839vkh.206.2015.11.17.01.47.25 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 01:47:26 -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; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycq8-0005jT-JH; Tue, 17 Nov 2015 09:46:16 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycq6-0005h5-Il for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:46:15 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id 70/42-22142-567FA465; Tue, 17 Nov 2015 09:46:13 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-7.tower-206.messagelabs.com!1447753572!4238117!1 X-Originating-IP: [74.125.82.48] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26276 invoked from network); 17 Nov 2015 09:46:12 -0000 Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by server-7.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:46:12 -0000 Received: by wmvv187 with SMTP id v187so217880826wmv.1 for ; Tue, 17 Nov 2015 01:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=49DruI2zmdK1mR0jeLEQkjNfF0/OhBl67yc26UrL0FM=; b=uAAUhXyGcR8zLgg/whE0UUVAYhLKPJJe1MUj64CF8HaVR2pNX7XVE+uBFEFh5mtFpB HsDWkFkZtfKmVxP6pYzI/Xpdbzi7Uy0R1D265dqcpdJ+r1Q+babz1+kIt2fba7sXWHEY cuibvmVhcq0jAHZEXdX8cIdV3Wu3E7l1HwbwjZ3eoI/fzFbqpnJCvBcoO7ski+tSzEPK jFiv+kzW5RRcNAhG+XBiA9ZJJLgWjRJpiEDjCCfc0NTWkhMlSuL5f5+cqaEiuYaTQbhM lviurQWEp0u44aShIi6lZlfPhPCYCVoFzMTDkVbgGm0XqtBCA1UkhaEggrBA2xImfJGt 7KLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=49DruI2zmdK1mR0jeLEQkjNfF0/OhBl67yc26UrL0FM=; b=d/93gnJTVaf+3cGdEHGu9OTvA6DmAvqLJuSxBtwXgl/XhuddvzmZPgv8gl5wQ9CZEj Bch6fm4jE3e8RAs2ze/nmTVPwKJw3iiEuoQzuYQw7G1fUbc8iaQjnpwKJQ/p55zR/ujU mmyDr6nbHsv4ccjaVyUdZUiiTnqiS0oV1MNzkcdZRTDoi8FZMk34bp1r/0UIMgeyLjxS jg9ku+7TKieBcUSWTYaKHfs3BtSD2nrB7Tz/qcQSg2L58iCmT15VTODwK1kQ75I2FiyD kok8QXgSLg/ks70TvPXRQ9KEgmW8dlKC5twT7E2zhek98g4ZhdyH4dEhT1sllm1fLP56 G4Fg== X-Gm-Message-State: ALoCoQkQiyKKPg5E0+R45FI6XL+LsN/KHh+siURVGmNwK9WGxdCObdYg2qZZND7TvQMFW6/eUX1L X-Received: by 10.28.186.67 with SMTP id k64mr1566301wmf.56.1447753572202; Tue, 17 Nov 2015 01:46:12 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id u139sm22928481wmu.22.2015.11.17.01.46.09 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:46:11 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Date: Tue, 17 Nov 2015 17:40:33 +0800 Message-Id: <1447753261-7552-35-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 34/62] 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: , MIME-Version: 1.0 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 --- xen/drivers/char/pl011.c | 64 ++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 26 deletions(-) -- 2.1.0 _______________________________________________ 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..16abaa5 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 dt_pl011_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 = dt_pl011_uart_init, DT_DEVICE_END /*