From patchwork Wed Sep 27 06:13:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 114334 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4665381qgf; Tue, 26 Sep 2017 23:17:01 -0700 (PDT) X-Received: by 10.107.189.129 with SMTP id n123mr496456iof.48.1506493021389; Tue, 26 Sep 2017 23:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506493021; cv=none; d=google.com; s=arc-20160816; b=MgQxx87dUv+JIk+FbEWaXbBXw0VQDf+N+Wbp2AQ8ZOSQJVgSqoZgT0YAjOM1GX0V/2 51Pi/TZE6G2uibiIhDrdIYoHZNjEjRRrzIgdUHjFpVYUfWkqvgSWTLzOlCdgL99YBItx yojJXzU7PNB1tRVaS59BkovRg9E2ksnEXsnvE5sC0Tz2wAJP5l9GoBhwm2kTAj/pSzKi A8gCi3xzmhDa+K2/5VIoIMXSRlNE1P42iDdarAtp6bjvtBFSOijYUCoUpOQC1LhJe6Oa pM49Tlm13GxpOkXO3sG2TIn7I4a3lQ5Whx3KaFpii8dd6gdCs5DmyyySy7JioEhI+FuK 334Q== 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=KHk3LYjrMHguLqYxynzoSi9RNXoQde0R1UGlpgHHBAds9u7OI3WZFYjXdeZLw5TgO8 scsI1L4lQFfOXZY7sPuqpzXDY4KEKcMG5/5eMh8lzsnKCbnMuxDJc37Z+fKzLbTnAZmR NdpyJqOwrtmZDKsnr4c6T+JotntxbjqT9S7ab4Rj0mXHb26bSF9oOjLJUDt+PMSKs2lG CTDxKT2MrwYbQrHB7jdCnp7kAt66YEi1BYLyouoVBCfLmAZXuJhGr4JV+T8p6krxwCkv rxpWaic7RBH4T5n2/g6+/c4MN8UnXzD6R3f4zVWTviENWn1brzCjDdlmYonA/z4lU1NU 9Jnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BWgQVDZ3; 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 l75si8819038ioe.135.2017.09.26.23.17.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2017 23:17:01 -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=BWgQVDZ3; 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 1dx5c5-0003OV-0E; Wed, 27 Sep 2017 06:14:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5c3-0003Lm-Ps for xen-devel@lists.xenproject.org; Wed, 27 Sep 2017 06:14:27 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id FE/FF-03414-3C14BC95; Wed, 27 Sep 2017 06:14:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsXiVRtsqHvQ8XS kQcMzSYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPjw5XsBTPUKvb8X8rSwNgn28XIxSEkMINR ovlNFyOIwyIwj1nixPEZrCCOhEA/q8Tvzm8sXYycQE6exNk/D9kg7DSJyVv/MEHYFRJtPQ+YQ WwhAS2Jo6dms0KMXcEk8eb4OqBmDg42AROJWR0SIDUiAkoS91ZNZgKpYRaYzyjRNKkXbKiwQK zEmzOb2UFsFgFVieWNK1hBbF4BH4m1u/5BLZaTuHmuE2wZJ1D8dP9tNojF3hKXVvazTmAUXMD IsIpRozi1qCy1SNfQRC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzDoGIBgB+P1 jQGHGCU5mJREeWv+n4oU4kvKT6nMSCzOiC8qzUktPsQow8GhJMF7w+F0pJBgUWp6akVaZg4w/ GHSEhw8SiK810DSvMUFibnFmekQqVOMlhxfem/8YeLYt+cWkOy4efcPkxBLXn5eqpQ470WQBg GQhozSPLhxsBi9xCgrJczLCHSgEE9BalFuZgmq/CtGcQ5GJWHehSBTeDLzSuC2vgI6iAnooN6 pJ0AOKklESEk1MPoE2B26+Fm838mEaXvdDt8XwqLeMzb8jLk/Ky6XJ1sjsXryWdd49nPrzZQ+ Jr+/m2dzXO3cnNhDTPz7/H3cfm9Z6Sale2RZvPtODnuNqC6l415i716wzwm6UZqw8dl8/dmn5 q5IbG78G/V15bLb7ccK9618Kl//08nBqXTfsxO3Hplt3unjsluJpTgj0VCLuag4EQD+oZB9zA IAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1506492864!84828988!1 X-Originating-IP: [74.125.83.49] 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 17740 invoked from network); 27 Sep 2017 06:14:25 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Sep 2017 06:14:25 -0000 Received: by mail-pg0-f49.google.com with SMTP id k193so7220888pgc.8 for ; Tue, 26 Sep 2017 23:14:25 -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=BWgQVDZ3DiaBOxA038MJDkkmSlQ4Z9eMrNd/w/CJ1wlTUTFz7CqHAJAhA7VQjbDO31 RbMgu+b0XZFVAfTnfs73KVS/wfOA9MDYT1V+6o5HZuy8HKwLY8CjT2H4auK73Sm2RyTi nWuTgs2+lgT53nIBzcPPtJiod/Tvzyeb1V+HE= 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=cKdu324IPHUmTHnmmEKKyI4/IzoKjU98t3H9n+VfWW7EroLJIFW6jQD8SqXSZlFqkk 1XWhIjNSJMQD/ztvzToFnyHOaNIz2ZQCIlmEHAsqcV2QXWUMCIpr3ZrQcxbWYipdO/5Y A8pSWsYszFL4eyR9fFY7TXM7ya5UPrFzFpD+dfbi05UkpPPbX/9CkBCMosESzRFX81rl BrW8aD/cx02EErpAAlCSYqjTMlTxzCWtsDFSHnWdaOOEiPwauK+3J8X0gdblkRGGHPBh g1PMzzM0MwbBR3UtZw5cJVLZGhUAKLxXwrM4p9MsnyfHlk9wjWuvfZAnsPgUsm45kXBt Cepw== X-Gm-Message-State: AHPjjUhOOxWO/RZ1p+VBfWOzfeWFzDXpNRr6JEcPTjqgfTdMPgOUiGLH Y4uazVeG0+7CcOcH2Jh7tjyQRUWw9VE= X-Google-Smtp-Source: AOwi7QBvDqJf/f2M4fFytEP1GGR9foQTO7jGEWgO0YHPAw0KmJjGmnnbavNTB2+4kkHPu+t7X7B56Q== X-Received: by 10.98.157.139 with SMTP id a11mr360549pfk.70.1506492863469; Tue, 26 Sep 2017 23:14:23 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id s187sm18013485pgb.82.2017.09.26.23.14.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 23:14:22 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 27 Sep 2017 11:43:33 +0530 Message-Id: <1506492816-25954-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/27 v11] 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) );