From patchwork Fri Apr 28 16:01:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9705029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94F8460225 for ; Fri, 28 Apr 2017 16:04:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85FCC28688 for ; Fri, 28 Apr 2017 16:04:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AD512868F; Fri, 28 Apr 2017 16:04:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 182E128688 for ; Fri, 28 Apr 2017 16:04:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LT-0000Nr-Fj; Fri, 28 Apr 2017 16:02:11 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LR-0000M3-Bd for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:02:09 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 84/E1-01999-08763095; Fri, 28 Apr 2017 16:02:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRuspduQzhx p8K6X2+L7lslMDowehz9cYQlgjGLNzEvKr0hgzXi5qou9YKl8xf6nl1kbGL+IdzFycQgJTGeU 2HFuPjuIwyIwj1mi5/R+NhBHQqCfVeLC812sXYwcQE6cxM4b9V2MnEBmlcSjIyfYQWwhAS2Jo 6dms0JMamaSmNJ5gwmknk3ARGJWhwRIjYiAksS9VZOZQGqYBd4ySvR/PMUKkhAWiJGY1vCAEc RmEVCVmDwdZDEnB6+Aj8TiDXvZIJbJSdw818kMYnMCxa/1L4Na7C3R3TCPZQKjwAJGhlWM6sW pRWWpRbpmeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgYHFAAQ7GKc2OB9ilORg UhLlrXRnjhTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwSuQBpQTLEpNT61Iy8wBhjhMWoKDR0mEV wIkzVtckJhbnJkOkTrFqMvxaOWP90xCLHn5ealS4rwRIEUCIEUZpXlwI2DxdolRVkqYlxHoKC GegtSi3MwSVPlXjOIcjErCvNNApvBk5pXAbXoFdAQT0BEsLgwgR5QkIqSkGhjXJ5prZzyOP94 wQ/x31rP5k3ctPxwt0FYgq9w8N/bID6NW3kfpDx7MFsjdtOV66caVDpfzRS1bBW3FNt3P5/n/ +nXFy4Jln1ryj/Cvamyv3rJ99bzSpQWxzPz1e/5+r5pasz5io2arSza74eNqedd3M5IWpG1Iu nZNecorPvmDazLO2aVxx4srsRRnJBpqMRcVJwIADWXXQbICAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-206.messagelabs.com!1493395325!95461757!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36478 invoked from network); 28 Apr 2017 16:02:08 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:02:08 -0000 Received: by mail-pg0-f42.google.com with SMTP id t7so16935849pgt.3 for ; Fri, 28 Apr 2017 09:02:06 -0700 (PDT) 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=PdIMbGJp48Y/2+8oZHjr/KQ/2T50XNCZzlwg16F3AGs=; b=eWl681pYAW8FH2tHHLeXnIP0c3Wtg976uwXloakCYCuvMGtcIMJkYKr/HyC1BWEu1M SL8o3hExmszaoOoSjY2ABn93KJSbDMQKrt+Uah2MXrZhNFoYelQUlOijOCK/Em83nD8z uDTWfGlYgr8g9qp/8ERQa9Tw2OoVsjTgOuRq4= 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=PdIMbGJp48Y/2+8oZHjr/KQ/2T50XNCZzlwg16F3AGs=; b=VGo+ZpAtZcgk6+gNSh1hLOmQZA6eVyyWkA2vYK5CwJTQpwu3DaJ8Ds2Oje8XVMXwIi ASLxx7hSvDHFCIJGTNOh/mXoCyD9AB9S7ubQ1Qgx8xU18DBOF8pdgE4B6KOvCjdoPOTj Dbyl8FjUwqDhkpO0LCL4CoBPzGhd5e/x95sm7PO6T2rc/kNcUghab94WISTQXhbSwiRS m7tNKwIh3DaRvsJr0Furirt5g4tdfcOaEha8ZHQPk4C/vT6dJzofrTpiBfZd8s5Rto8V 1Wb0+iIidfjW6SUnfhDGt+SWf+QhSkfMpGuhfQt1bVWFEpHuVRM2+1yt6X5R3GVZH/hI 6LLg== X-Gm-Message-State: AN3rC/7LQTxgPT7eQgTuCMacyX0sJFDVWPoI142u1gQPK1BcwIZ3rWSu aejUno38RCfYcnra X-Received: by 10.99.122.81 with SMTP id j17mr12968983pgn.111.1493395325495; Fri, 28 Apr 2017 09:02:05 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.02.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:02:05 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:23 +0530 Message-Id: <1493395284-18430-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 09/10 v2] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree 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" X-Virus-Scanned: ClamAV using ClamSMTP The SBSA uart node format is as specified in Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt and given below: ARM SBSA defined generic UART ------------------------------ This UART uses a subset of the PL011 registers and consequently lives in the PL011 driver. It's baudrate and other communication parameters cannot be adjusted at runtime, so it lacks a clock specifier here. Required properties: - compatible: must be "arm,sbsa-uart" - reg: exactly one register range - interrupts: exactly one interrupt specifier - current-speed: the (fixed) baud rate set by the firmware Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini --- Changes since v1: - Modified the code to increment nr_spis based on the SPI value reserved for vpl011. - Added a check to verify that physical irq assigment is not conflicting with vpl011 SPI. - Fixed minor indentation issues. tools/libxl/libxl_arm.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..45a56a8 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -43,11 +43,25 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { uint32_t nr_spis = 0; unsigned int i; + bool vpl011_enabled = !strcmp(d_config->b_info.vuart, "pl011"); + + /* + * If pl011 vuart is enabled then increment the nr_spis to allow allocation + * of SPI VIRQ for pl011. + */ + if (vpl011_enabled) + nr_spis += (GUEST_VPL011_SPI - 32)+1; for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + if (vpl011_enabled && irq == GUEST_VPL011_SPI) + { + LOG(ERROR, "Physical IRQ %d conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -130,9 +144,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 +605,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) +{ + 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, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + + res = fdt_property_interrupts(gc, fdt, &intr, 1); + if (res) return res; + + /* Use a default baud rate of 115200. */ + 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) { @@ -889,6 +936,9 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + if (!strcmp(info->vuart, "pl011")) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) );