From patchwork Tue Feb 21 11:26:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94260 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396495qgi; Tue, 21 Feb 2017 03:28:21 -0800 (PST) X-Received: by 10.107.3.195 with SMTP id e64mr1979729ioi.18.1487676501847; Tue, 21 Feb 2017 03:28:21 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e77si1640237ioi.180.2017.02.21.03.28.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:21 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aZ-0002or-Nn; Tue, 21 Feb 2017 11:26:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aY-0002ng-1j for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:34 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id C1/0D-27165-9E32CA85; Tue, 21 Feb 2017 11:26:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRusr/tCeU2 EwbYmG4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNaP/22m2goXSFWuuTGFtYJwm0sXIxSEkMJNR YtGfBkYQh0VgHrNEe8NadhBHQqCfVWLq4ftMXYycQE6MxL03DawQdqXE5ZmbwWwhAS2Jo6dms 0KMamWS6DizCKibg4NNwERiVocESI2IgJLEvVWTweYwC4RK/HvWxg5iCwskSWxfdZQNxGYRUJ XYsOI/I4jNK+At8fLbBzaIXXISN891MoPYnAI+En/3vWSH2OstMe3OCrYJjAILGBlWMaoXpxa VpRbpmuglFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgQGFgMQ7GDsvux/iFGSg0lJ lDdbak2EEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneOUpAOcGi1PTUirTMHGCIw6QlOHiURHiPK AKleYsLEnOLM9MhUqcYdTl27br8kkmIJS8/L1VKnLcMZIYASFFGaR7cCFi8XWKUlRLmZQQ6So inILUoN7MEVf4VozgHo5Iw736QKTyZeSVwm14BHcEEdMRNj5UgR5QkIqSkGhiPzS5gUp4wr+y i34wYNqmpqnaJ5pqPNaK/G6VPfrG+2eVmTLVRvqnKpS8/LxuY+wXdKH4THPn4sUreq23TPP9e WWp84azLAykDQa/1wRMWBYpGbL2X57oj4Na/f2fMys7MPrWu8vh2IbtY7ljRuqsR796zVtfIv /ytzRp5LS9/lsNFO6Hf5+KVWIozEg21mIuKEwHo9/0RsgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1487676391!35707396!1 X-Originating-IP: [74.125.83.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18535 invoked from network); 21 Feb 2017 11:26:32 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-6.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:32 -0000 Received: by mail-pg0-f47.google.com with SMTP id b129so34938632pgc.2 for ; Tue, 21 Feb 2017 03:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HDHl5lSx7RvXzJkLcvzgBWrfdXi3HHyQWTPd6x1LmTU=; b=TmNhK8U+xptTZs72VxYFmU+S/tIdhZiV3l0zc7iOZqD+c04IcJlcx21qxe2bkyGqg/ D4UIkLoRwyiIolTS/2Ib5767UHG02M2PeeG0hUNCLg3oxu2tEbTXq4aluDpEwAebB/SM MM6xxKJi6EMhGrZuHtAe+/QI+DhqHvfH+1edM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HDHl5lSx7RvXzJkLcvzgBWrfdXi3HHyQWTPd6x1LmTU=; b=K/8uOKiG2JaarljLGXAQLh2XsMwQwX5Qj77hiQvznXxKLm54pFFeGpvae1iN6Q3zg/ THNYOmvYwAHAO5E/KPRMIEtAWOmz4QeUK3F4gT1/cxM3H6eRk6aOqKR/hYjg1DGwSkf4 hDVl/zksQdZXaKTlJo+iBmM6txnz4bksbuc2ExGCCT9wTCBfMWbyIjcvyOt+DnvS1Srq i6NM0L1aFtl9u+GPppWuXsUP2fZq3LHKTluLERBdYzHU0iWpFV7rjxqoA2K/nqGyjxx/ vkYY4xQWw/STsKltM/PF/3DsG910RJdDDwfTnKn9Pll15qxOfuQmLKd6U9i2xq3GODxi nfDg== X-Gm-Message-State: AMke39nyAcQMxTe/+0nGCp6PYns9owfriCBEaAUqPy3C8PtXJBnoCIBJUHQr1dA1Rf+MTgf7 X-Received: by 10.99.143.13 with SMTP id n13mr33526398pgd.10.1487676391527; Tue, 21 Feb 2017 03:26:31 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:31 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:03 +0530 Message-Id: <1487676368-22356-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 06/11] xen/arm: vpl011: Add a new pl011 uart node in the guest DT in the toolstack X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new pl011 uart node - Get the pl011 spi virq from Xen using a hvm call - Add a new device tree node in the guest DT for SBSA pl011 uart containing the IRQ (read above) and the MMIO address range to be used by the guest The format for the node is specified in Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt. Signed-off-by: Bhupinder Thakur --- tools/libxl/libxl_arm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..34c7e39 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -130,9 +130,10 @@ static struct arch_info { const char *guest_type; const char *timer_compat; const char *cpu_compat; + const char *uart_compat; } arch_info[] = { - {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15" }, - {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8" }, + {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15", "arm,sbsa-uart" }, + {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8", "arm,sbsa-uart" }, }; /* @@ -590,6 +591,38 @@ static int make_hypervisor_node(libxl__gc *gc, void *fdt, return 0; } +static int make_vpl011_uart_node(libxl__gc *gc, void *fdt, + const struct arch_info *ainfo, + struct xc_dom_image *dom, uint64_t irq) +{ + int res; + gic_interrupt intr; + + res = fdt_begin_node(fdt, "sbsa-pl011"); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, ainfo->uart_compat); + if (res) return res; + + res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS, + 1, + GUEST_PL011_BASE, GUEST_PL011_SIZE); + if (res) + return res; + + set_interrupt(intr, irq, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + + res = fdt_property_interrupts(gc, fdt, &intr, 1); + if (res) return res; + + fdt_property_u32(fdt, "current-speed", 115200); + + res = fdt_end_node(fdt); + if (res) return res; + + return 0; +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *dom) { @@ -790,6 +823,7 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info, int rc, res; size_t fdt_size = 0; int pfdt_size = 0; + uint64_t vpl011_irq=0; const libxl_version_info *vers; const struct arch_info *ainfo; @@ -889,6 +923,13 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + /* + * get the vpl011 VIRQ and use it for creating a vpl011 node entry + */ + if ( !xc_hvm_param_get(dom->xch, dom->guest_domid, HVM_PARAM_VPL011_VIRQ, + &vpl011_irq) ) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom, vpl011_irq) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) ); @@ -933,9 +974,11 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc, val |= GUEST_EVTCHN_PPI; rc = xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CALLBACK_IRQ, val); + if (rc) return rc; + rc = libxl__prepare_dtb(gc, info, state, dom); if (rc) goto out;