From patchwork Mon Aug 7 08:53:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109535 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482080obb; Mon, 7 Aug 2017 01:55:59 -0700 (PDT) X-Received: by 10.107.4.142 with SMTP id 136mr10728692ioe.251.1502096159891; Mon, 07 Aug 2017 01:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096159; cv=none; d=google.com; s=arc-20160816; b=aSZZTHV/neTGBQtDEHVPU5vcCilKkerUXnsFuvP5rdXKfWZHmF9om7IlWL9rkb6b6M FUk9jXE33KcD4nrSKkpQAdyB+y57/YmDlSLMEsRR9KejeHr9JEmJuEHVmkbzDgz0vLoW XHq6nGNzx93IkpBdK162xdUzfFv4PIlIbHoDNA3/eR1pDJmJ5ErBnB10ZGP4HYn0TJFH NrRTfV9SwK4hAILXYopEGKB37W5r/WHgDKfug90f9AYE27UlkmrvFogGoKUK0e+xZlhH WxkLDuA6woTQ1AozsTrvcUWFuG/G6FBxl33SSiTI+idf2KFcyvjf04Se2NjBpOEuubgq FK4Q== 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=9tqeqthSHgi7Mj0AvcKB8TrGTzttOz/kx3TurC+OQV0=; b=Gzzsv4hgTUA3O8UXOR8k8JCNEt+3gOSQ/LX22j39BlOuTQUb1bgF6eklw1C5COSWZX BqmEDZW46cFzy2kqk38XGFjOKBpaT2LlY3DSznTjJQIvUpuLHg6UTssTtXLr8rTzOJUz OPKBfvxIOVBxI1OYULiirfqkmdB8plY1SY0GSxeRP201VI+Yk4cI77Oi644lkAH2coNf hMTxaM2Xb0klXwQR5ElpucjDuTqtDKxn/bBkpfIv1N0dIRrCmO3OcT2S0QPP1FJGkCRq wIsnW8Z98JKmb65I1TPpNBS01SLOTUDo+brwKieWSuA7UIgtLgoOdiNG3UdKOY8BUtqe 2bLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=K1x/V4hB; 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 h66si8105603iod.181.2017.08.07.01.55.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:59 -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.b=K1x/V4hB; 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 1dedoD-0005Y3-9X; Mon, 07 Aug 2017 08:54:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedoB-0005V1-Kx for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:43 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 94/EA-09901-3DA28895; Mon, 07 Aug 2017 08:54:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRuspXtJqyP S4MItCYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP434fsBb8VK562rmBsYOyQ6mLk4hASmMko 8aj5HyuIwyIwj1nix4G5bCCOhEA/q8Tsj2uZuxg5gZw0iU+zZ7BC2JUSp+d0s4PYQgJaEkdPz WaFGNXGJPFt5i2mLkYODjYBE4lZHRIgNSICShL3Vk1mAqlhFpjPKNE0qZcNJCEsECPxu+sPmM 0ioCox7d4lNpBeXgEfialLoHbJSdw81wl2AydQ+PylNywQe70lbh/rY5zAKLCAkWEVo0ZxalF ZapGukZFeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgaDEAwQ7GNfMDDzFKcjAp ifLGr2iLFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBm6DZESkkWJSanlqRlpkDDHKYtAQHj5II7 wt1oDRvcUFibnFmOkTqFKMxx6QD278wcbya8P8bkxBLXn5eqpQ4bw7IJAGQ0ozSPLhBsOi7xC grJczLCHSaEE9BalFuZgmq/CtGcQ5GJWHeSSBTeDLzSuD2vQI6hQnolDeJrSCnlCQipKQaGOe t3/H6j82WSR+1V9yYlOkVwHCzQE/8yeypktI7FFUZH2kGv3klki61blmYE1vuIemX4vabtMtD FitsPrYmZouZ+J1KPdXPvCtXWpU9a72eqHGk08J0wZyA504f9dMUQ65m3901/cXZNMGaKJW01 T1tPj+4rHVdJrV5mTk1deTJtsTq/De5rcRSnJFoqMVcVJwIAPFBup+5AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1502096081!53698507!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43996 invoked from network); 7 Aug 2017 08:54:42 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-6.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:42 -0000 Received: by mail-pg0-f42.google.com with SMTP id u185so31684069pgb.1 for ; Mon, 07 Aug 2017 01:54:42 -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=0kBNhxW6fBT1xKvZKCjrmuLQDg2QR/CDj1OEhFL/+AE=; b=K1x/V4hBdqYK/RMykFeJkv1K9Do8fFN2mfzqq2GkI01s0XuEbb0gexyh9K5pYkpClp Js4ATjx8D4EXwX/ty8Dr5unDY4WlMRHtThHF9TNt+s3KSUvFZku4seG6EB9yU8U5Neax fx7A9JajU2F9tQsIQdRIr6nzSlW66YPuDM0ro= 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=0kBNhxW6fBT1xKvZKCjrmuLQDg2QR/CDj1OEhFL/+AE=; b=FztIwBXQqzlJyCETy3V0yfey0ltuySOZ6/l7BmXUjOZVXdtTyjft6puPNCvkJJ8BG8 ouP9tSHmSNE/B6FTWFj1FZl0w3a1Pso1l6hfJV5c/Ly+wx/EFtymnP/xJ+ItqjWkxnlT OzxrImhb/IOjewwrzdm5HhdYzalfFNdL4W8sFHy+599eLVk1YZ5Tb3IuSanMaSCy2tJq pULirECTlWe6nY7akFvY4BVzlxRZpfKvAESPzVv2akRo2V0tzYw1jeNOojCK5QkyV2P2 7gS3hohQcsSN6cTE0MuQyDxlcHvKSHVLndd3upOZWiwnvs3aF5Z16cJpfK5zxz4RyGz3 XCnw== X-Gm-Message-State: AIVw111/L3CBmrCOM64LBh6izIyGFRXJmRNRW0n4Mdyzy+kK/tfCOebI 0qadni0VVw7jpfjRRn+fvw== X-Received: by 10.99.62.75 with SMTP id l72mr10685220pga.316.1502096080670; Mon, 07 Aug 2017 01:54:40 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:40 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:16 +0530 Message-Id: <1502095997-31219-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/25 v7] 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. A check is added to ensure that user specified irq does not conflict with the SPI assgined to vpl011. If there is a conflict then it flags an error. 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 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 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index a33d3c9..6629852 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -43,11 +43,29 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { uint32_t nr_spis = 0; unsigned int i; + uint32_t vuart_irq = 0; + + /* + * 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; + } for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + /* + * The user specified irq should not conflict with the vpl011 irq. + */ + if (irq == vuart_irq) { + LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -590,6 +608,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 +939,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) );