From patchwork Mon Aug 28 08:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111125 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548258qge; Mon, 28 Aug 2017 01:59:02 -0700 (PDT) X-Received: by 10.36.175.91 with SMTP id l27mr4568346iti.86.1503910742829; Mon, 28 Aug 2017 01:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910742; cv=none; d=google.com; s=arc-20160816; b=g0BXfchpk5Ag122W3UShieqUWHKv2FZccEywqcXgWvmsIKRPdSmm1x3uxkq609QMOp lozH+riAFN+6jWj2pdEuIAPcPDeQE2lgsm89AKzRSndNPT1A2JyV3Wdf2cMnV8hk7WhQ 2+SEkGt4RUspXcOBCT8GCbT1tuwOQEnrUTQRVcKzriR7fDq77sbEurdLZUONge9u+N+K thTZpsPGfO2gjU5Y3Luk59/NPjHIfVaok7wkN02otbebH+5kWuj/6LoJooRj9wwkCH2f ho2OukhCG9jhqFn55yV1sTVDAEQPhuvFR5t6p4Ldx1JPfNrfZc+QlrtYGnK5TloHp+Us rDjg== 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=reEnHU+RFUemo9y4N2qY2JsFnDWqND/ps0F19rbkvow=; b=V9XBZ0i5VPQqUxV8GcXaxp0uVy4Jh755knb33in5ujTyqC2YFGmDJHiRsTSmDgzl2v LXB7M9/11FmoOxUSx8pSA9QA105cAJeZPv6MSkmbWDHvTUnZbpJKd6fWALZVgw3KYrwk G9ErrIc7RFmf9i66BVSJVPb9oplNvpZIJZRoEUXQ1G/RBAodQjoXSsXdNTwpT9zthWN1 N0w04BuEggnMCceRAQoi04k5LFKgeM8oEQGxC/Nt+BTNvZIHtgkxUkRYELkzqmaP9Ofj naJFxZIDLQ5wDbcNYZp+FW8gqndgk1fV/b1YYYrBeh5xHvjaIRoJjLdNaCHZBZ/WtTQn tscw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=f/SJ6wqd; 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 g198si11976800iog.12.2017.08.28.01.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:02 -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=f/SJ6wqd; 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 1dmFrZ-0005vW-5q; Mon, 28 Aug 2017 08:57:41 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrX-0005sO-IR for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:39 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id A6/30-03937-20BD3A95; Mon, 28 Aug 2017 08:57:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTANl2m24s jDXou8Fh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmvp31hL5ihVtH72rWBsU+2i5GLQ0hgJqPE 9L8PWEAcFoF5zBIfJq1kBHEkBPpZJW4uPcHUxcgJ5KRJXNtwnQXCrpSY8PYvO4gtJKAlcfTUb FaIUfuZJPZ07AFyODjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ReNpCEsECMxLnbl8EWsA ioSpye/x4szivgI7HgVgsjxDI5iZvnOplBbE6g+I61d6EWe0t0vf7AOoFRYAEjwypG9eLUorL UIl1TvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwMBiAIIdjNMv+x9ilORgUhLl 3VmxOFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+Zm0A5waLU9NSKtMwcYIjDpCU4eJREeD+Ap HmLCxJzizPTIVKnGI05rlxZ94WJY8qB7V+YhFjy8vNSpcR5H4KUCoCUZpTmwQ2Cxd4lRlkpYV 5GoNOEeApSi3IzS1DlXzGKczAqCfMeBJnCk5lXArfvFdApTECnKAouBDmlJBEhJdXAqCm+Xai 4vqdu5gY1Ie52kbPiR+tla2bpeazysRLj4N3lNSf3PvMz5b3xj/foTLz14zWnQO+TuU9aDBx9 9JX+Fxxcf+Ps1Km2KtUC/45JP49ctbdaetMC3y4et30lRq0frFaKis5vPuDT3rhy8Z/I7bsea LZOXmlSW7S0Zc/VuFsP3tgxfXrgrsRSnJFoqMVcVJwIADWm01a4AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1503910656!113454592!1 X-Originating-IP: [209.85.192.182] 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 2389 invoked from network); 28 Aug 2017 08:57:37 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:37 -0000 Received: by mail-pf0-f182.google.com with SMTP id h75so14507625pfh.1 for ; Mon, 28 Aug 2017 01:57:37 -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=dolSTdF8lhTDbVu9x2jD3Q8HkG3OVWOfLoo5sgv1UPc=; b=f/SJ6wqdmcagM2EZAm43qu2ajjJVrOsEHEjwYNFzsF67bSEAxOG45Hq/o7JIVe4bUQ CkQw9/Yfjz6VPxSWXv9/bxZavEkKqkPr8kCuxNM0WrAUvV0vyHfA+DLygFDsGY4IcvbJ Uy8xMJaO7gMylMQ8AxYgn2qdcvwh1zibocQAA= 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=dolSTdF8lhTDbVu9x2jD3Q8HkG3OVWOfLoo5sgv1UPc=; b=hq2+e0MeKTIUslDTjC5GFKd6nQeCDPZ3a0V4PHcUhlGetyZ9ayjfiaPc6rmNTAOHig P53XvKHx3h3SQhOiKFCj088K6a++eKKpz7Dj3Z0erHl+RjyqfuVquPFCC+VtogOMqa1q KAqnXJRFZM/zmZes4QzhtHQvb0Is34HKU/AliLJXy00VJTWLyQTjPvkB/gePr3N/TF0I xQEJoxSwLOkOEX6Hv8TgAFIOwAsBtcQTjVUZ6cC5kLAO/X7zDChz2hUWNp0OUzjPMwe/ dw30rojJPHL2OvReEWUMGXeaDrMR4uAQYXfGJKp52VrR1ueovch08VPTbvVmQU4JeeJk 1kGg== X-Gm-Message-State: AHYfb5geJyJGp18F/0MJLthGuthEqeUrxZJYb2ZmHEZwDqiBPhMaUBP8 oRU+WfSQWiei16ne7P96bw== X-Received: by 10.98.215.10 with SMTP id b10mr3574410pfh.119.1503910656161; Mon, 28 Aug 2017 01:57:36 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:35 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:07 +0530 Message-Id: <1503910570-24427-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/27 v8] 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 b8147f0..c0e496f 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) );