From patchwork Mon Sep 18 10:32:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 112896 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3501305qgf; Mon, 18 Sep 2017 03:35:03 -0700 (PDT) X-Received: by 10.36.165.8 with SMTP id k8mr16235545itf.83.1505730903110; Mon, 18 Sep 2017 03:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505730903; cv=none; d=google.com; s=arc-20160816; b=D06MYcCwYWkNjQK3WHXn7U+xuq1L7Tn7Zi3IIbpdkJ4PudKmgN9D44qJeB1U7CSrph +zrF57PC8ZfZHnaVXU3sQ1liSlr45z4ubDUwqmxbYySkCPzzvdAioadKdLAggAnB/JYf TwGkb04QEbY6DOoGcxkJGvK0FfkKlGvzxO2GpuOhG+Cf2q5Mr/FQr43cyitaUIa0k9CT kIrm7HpIG6/CqLXQkAvXqeUqBNtTq4vgaWXbFXtaVy8kPAimqZjyPCwYfoDttvttQuQk 5DRWlj1Uib3eB4XthSjc0GxjBXiACPqmxp1qtjnjt/amnfdfJaky9Tr3nJpvW9KOgU6u 0zMg== 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=CgIOOnDoeUUy02Kgfx6rxozDor/WqL3SXm4KXSwN0COiecb9NgdCd1N5ZoU484miH7 e4jlqKaaawWeYsX/pgZefwJUvlGm/mz7GcqEH9u+eSoyOq63GVb2vACh4+yILO7pKsYT 9OoYiI+g0tE7HI3Jbj5iQUzrOoHKwkGQaQM6WntRY5DblET4jD0bfMGfQXjWs8ucO4He XZcRxRwz4YgTD3dY3OnC2BJ+IL3xGqq2PZJLxz1M18wFatsXQ+hffLa2IMG4TkCFqTM/ /SHzMRTi+/BPTi4KIamLFUm24i6hx6Z/Y4fHpAFMZPWI08vwawjacNsFoN4NLKHSpRH2 aDJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NU76oGK/; 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 k21si5461251ioe.167.2017.09.18.03.35.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Sep 2017 03:35:03 -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=NU76oGK/; 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 1dttMr-0002r6-GN; Mon, 18 Sep 2017 10:33:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dttMq-0002ou-Q2 for xen-devel@lists.xenproject.org; Mon, 18 Sep 2017 10:33:32 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 4C/18-02208-BF0AFB95; Mon, 18 Sep 2017 10:33:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsXiVRusr/t7wf5 IgzXXZSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyND1eyF8xQq9jzfylLA2OfbBcjF4eQwBRG id+fdjKCOCwC85glHr6fzg7iSAj0s0qcmPWGrYuRE8hJk9jydAk7jH1h32smCLtS4sGvS2A1Q gJaEkdPzWaFGLuDSeLw14NACQ4ONgETiVkdEiA1IgJKEvdWTWYCqWEWmM8o0TSpF6xZWCBG4v 2jXcwgNouAqsTR7X2sIDavgI/E1mdHoJbJSdw81wlWwwkUP7/+ASvEYm+Jeb+uME5gFFzAyLC KUaM4tagstUjXyFIvqSgzPaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMw6OoZGBh3MF7e 4neIUZKDSUmUVzRyf6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV5xYBALCRalpqdWpGXmAMMfJ i3BwaMkwrtuPlCat7ggMbc4Mx0idYrRmGPfnlt/mDg6bt79wyTEkpeflyolzvsOpFQApDSjNA 9uECwuLzHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5pUDuYcnM68Ebt8roFOYgE5p2bEH5JS SRISUVAOjXZ3O7PQDD4//aPq9qF7BJGdXpem0pWnLI/ZeOLdildV9g9Cb1bMdty9+Olt9wTPf 2+vr58oWLn16xHz+vJLFOl2TvhbqPjaTOqM/STy5alNxZ07rJWtPhsq3szITbrUs23zL74zhl vUaM7aIbCn5cP6Y6PGGuTGG6zjWrzy3p9F5pgTLh41fTZVYijMSDbWYi4oTAZseLsLGAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-206.messagelabs.com!1505730810!92023612!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.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21585 invoked from network); 18 Sep 2017 10:33:31 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-16.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Sep 2017 10:33:31 -0000 Received: by mail-pg0-f47.google.com with SMTP id 7so23377pgd.13 for ; Mon, 18 Sep 2017 03:33:31 -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=NU76oGK/gxNiKk8RxYqDI7PpJkgH3Yjth1u76NwpUcO5Q1fznUuOizz1mjnfjp0kn1 DIeA2pQP1i/NSs1ywY1VZFMT9dGVlm/i0+U4eJdlItDjvuleRez6DuAgJ+tQy4VQudva B+LWLwyy3fobxDVyvmNkF6QdaLyg9dLMiqtM0= 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=FgC+WE10AaOcfSulJJBnxBdqzYGu0AjjCQQPrAenOboa75L57mDisIT4fWc7XI0RkW ESDJ7W45JxWw0IW3RTzmHkSBWPLcISBMuVHyQlCEJhpn9QwnBE1UzeMKuZaNF5ROzOYa THCUyHcOMtLntULOmSJYlOD/DDZeeTrwOX8S2SyOZudMXf76ouAjE0G8+TgKNhE61sBE Pv0bMUct/+WMH5qUrL6CLrRMOL5aZMKm5VNPKDaXdvCgwI6DOWtApomyM8ZGG4D9+dFX 8vKn9sHuTst+GUp0Ua4Ahe9SuD8JOxBhad03hFq16Y3ns9imMYC9zj4vODIkfQjliRBX mUXQ== X-Gm-Message-State: AHPjjUiC2GMwSJT442NdONqpG1Y1NcnqBeaymLJ/+VdK2h725tdFSFEe Q+ZjXJHYTANpBUPm7dl/Xg== X-Google-Smtp-Source: ADKCNb4vHxur5DF6gAbyUXxWpB+GPCPnnVuLgkIm4LQm5QhxJ55KbwYtMfif9ozFQH6kJLpQKFlklA== X-Received: by 10.98.62.80 with SMTP id l77mr32126520pfa.267.1505730809589; Mon, 18 Sep 2017 03:33:29 -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 b7sm12937845pge.79.2017.09.18.03.33.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Sep 2017 03:33:29 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 18 Sep 2017 16:02:08 +0530 Message-Id: <1505730731-10947-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> References: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/27 v9] 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) );