From patchwork Fri Sep 22 08:23: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: 113989 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3011300qgf; Fri, 22 Sep 2017 01:26:15 -0700 (PDT) X-Received: by 10.36.146.196 with SMTP id l187mr5985575itd.85.1506068775058; Fri, 22 Sep 2017 01:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506068775; cv=none; d=google.com; s=arc-20160816; b=s80hBmr1bHhJdw6MZFm8EjnK9oEgqSmrosI/zNmVBIpEY8V1o7J2ZGkh06rOmC8mMF UWLbkt4IQb682+3xqbHkqbZU30jOTDUfCE9x+9hbnovcQ7+dbPiYiLPxuUymBXpNWG8z CYTJODoESmq3I4MXMsqciUZk+WY+J+0iggBboZzOIi7YUKiQmE2s41QXfgMmegGNQAGf EEDRxzbqg5tI/rc5Gk5N9tvf1tkNZSInqx+xYMS4DlX6blmTj1jUEo8i+hWYpGBRQcQb IqL3HSj3AtbMU9K00Vuuzo3vakvrsu4aLxV4bHNbRa7t6Dt8v90fLkp5j4JCdnngxOPe rjIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=ia2w5dL59G4X6+C2K0E6OoFSmdQkQ2qrAt+g+fzQ0uY=; b=fmPkgxJqR5WzzlfsnvrvyM4J++kQYkIshGESmxRzEAkTMgDpkE2gza95UN4hqB0qsD sXoY6P6REgUi13ul5JNC42zM6U47VmuHIYfuaxa4qUyw1K94KS2qna6rI+vbwdMUjhYd 1klnWxc679UUBvr0BLK82sT/46Se1NNe0BkgohLlSqXqZFdOVExg+gE/gzfTIEyIb0ZP 5sO5kurwbIhbvtEC5AxcJicSp0buj9hCgMPFHaL+XpfM9RnBA27wBZbHGCtiQ4VG54/L qeruH2nz26Bon8S4lIYAG1rQpY9q3qAIyGKN826gAHp/fRZHS1FlnvecCkJGpGKv8snZ y7/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Z6tTejsE; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m184si2999491ioa.80.2017.09.22.01.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 01:26:15 -0700 (PDT) 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 header.s=google header.b=Z6tTejsE; 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 1dvJGT-0004mF-68; Fri, 22 Sep 2017 08:24:49 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvJGS-0004jY-4d for xen-devel@lists.xenproject.org; Fri, 22 Sep 2017 08:24:48 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 26/95-25121-FC8C4C95; Fri, 22 Sep 2017 08:24:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsVyMfTAet1zJ45 EGuybqW7xfctkJgdGj8MfrrAEMEaxZuYl5VcksGZsfLiSvWCGWsWe/0tZGhj7ZLsYOTmEBKYz SuxcIdLFyMXBIjCPWeLx5BfMIAkJgX5WiZ4Tjl2MHEB2nsSpDawQ4TSJNScWsEPYpRKNTY+YI OZoSRw9NZsVZI6QwA4mic7185hBetkETCRmdUiA1IgIKEncWzWZCaSGWWA+o0TTpF42kISwQK zE8YMtjCA2i4CqxIWGrWA38Ar4SFzdvRRqmZzEzXOdYHFOoPja/xtYIBZ7S2y9cZVlAqPgAka GVYzqxalFZalFuiZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBwcYABDsYG784 HWKU5GBSEuV9fORIpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3p3HgXKCRanpqRVpmTnAsIdJS 3DwKInw8gJDX4i3uCAxtzgzHSJ1itGS48KdS3+YOA7suQUkO27e/cMkxJKXn5cqJc4rCtIgAN KQUZoHNw4Wm5cYZaWEeRmBDhTiKUgtys0sQZV/xSjOwagkzHsd5CqezLwSuK2vgA5iAjqofDX YQSWJCCmpBsbaHR3sar0izhV7LR+V7eaOTJBdIj3lofPDlqorTpdV12uvubrqB2O5bG7VtOKj l+wVZ6qosfGpntSbpMDdprFWecJcF62SmVW5/vrnHpssLPxz3C4ojJMr/0Px54e+bD8f9aW+t +CWn+Rx+P8Gu18BcculGZN+XVLgsRTkmH5aMpZ39sGNaUosxRmJhlrMRcWJAOKIYnbIAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-31.messagelabs.com!1506068685!57935893!1 X-Originating-IP: [209.85.192.175] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17218 invoked from network); 22 Sep 2017 08:24:46 -0000 Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by server-4.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Sep 2017 08:24:46 -0000 Received: by mail-pf0-f175.google.com with SMTP id y29so244561pff.0 for ; Fri, 22 Sep 2017 01:24:46 -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=8o2al3bzod4mOOONVe20amJaaulnmm2NgPZDeRZkrVE=; b=Z6tTejsEq/6f3eVFfCvuKpb0VanNa9UzwxOnUvpmBDh0MUbpVzSNCywig7iAE13EUf Y/NM7lI7F97KgV9N5xW2pIUDWlp8KaD2Qcyyaple29IMX/KnZNTiRPmI9JcxKNe+17nJ tdPqwyo7DXLhZOUhGLvQZq+7T6T8zl+8CrLmI= 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=8o2al3bzod4mOOONVe20amJaaulnmm2NgPZDeRZkrVE=; b=dVtLx/YaDvDXa2BHcXhIZklHFwzj62uyauQ33TLIPanVdaGnps55nsPUReuhLxfp/w I5LAgHRQt0iv9vUo6gt0fFO+FVFq6zVysJvjbxGRilj6CZwwO9knLtGXpK4v36z3pEEN vKD2ozhlnSU4LAspY+Hg8m5tTqQ5y3U+O7/wkxdxljszqXoqHijachFhdxPYf58z+J0t 3UUhuOnHprjxci26gaNxBz2lwxDk+2cRKSZsCO3FvR7yiKOYUOHtceazOk7pETAalTIp xpxaQ2hU9JT7CKEodmoa8uYurCkJ3K+twj4CR1ZxOl2c613seQtKJ0yAFLyL2DXvdAax FOSw== X-Gm-Message-State: AHPjjUjt8zrTU5XuUVVdTKimwrDRzN/pD3X/VQBcvieHZb/zoZ8bder5 ozNbL6E2tGouaNZ5QqYhGuByulmpNvU= X-Google-Smtp-Source: AOwi7QD0l1bh90s6vuSs3nCtWV2Mm/TjsxWnQnibiVaW2pESZv5NYXID2Zskkv1qSzxi568VLLK6Sw== X-Received: by 10.98.89.6 with SMTP id n6mr8325338pfb.27.1506068684761; Fri, 22 Sep 2017 01:24:44 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id f74sm5569284pfa.36.2017.09.22.01.24.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 01:24:44 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 22 Sep 2017 13:53:23 +0530 Message-Id: <1506068606-17066-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506068606-17066-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506068606-17066-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/27 v10] 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" 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 Currently the baud rate of 115200 has been selected as a default value, which is one of the valid baud rate settings. Higher baud rate was selected since an emulated pl011 can support any valid baud rate without any limitation of the hardware. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v7: - Added a TODO to avoid conflict between vpl011 irq and user specified irqs. - Used a new bool vuart_enabled to explicitly set whether pl011 UART is enabled/disabled. Changes since v6: - Added a comment explaining why user specified IRQ should not conflict with vpl011 SPI. - Checking the vuart type explicitly against vpl011 enum type. - Removed uart-compat string and using "arm,sbsa-uart" string directly. - I have retained the reviewed-by/acked-by tags as these are minor changes. tools/libxl/libxl_arm.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 2e9f780..bfb7d08 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -43,11 +43,38 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { uint32_t nr_spis = 0; unsigned int i; + uint32_t vuart_irq; + bool vuart_enabled = false; + + /* + * If pl011 vuart is enabled then increment the nr_spis to allow allocation + * of SPI VIRQ for pl011. + */ + if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) { + nr_spis += (GUEST_VPL011_SPI - 32) + 1; + vuart_irq = GUEST_VPL011_SPI; + vuart_enabled = true; + } for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + /* + * This check ensures the if user has requested pass-through of a certain irq + * which conflicts with vpl011 irq then it flags an error to indicate to the + * user that the specific HW irq cannot be used as it is dedicated for vpl011. + * + * TODO: + * The vpl011 irq should be assigned such that it never conflicts with user + * specified irqs thereby preventing its pass-through. This TODO is for + * implementing that logic in future. + */ + if (vuart_enabled && irq == vuart_irq) { + LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -590,6 +617,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, "arm,sbsa-uart"); + 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 +948,9 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) );