From patchwork Mon Jul 17 13:06:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9844961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 867506037F for ; Mon, 17 Jul 2017 13:10:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69EF628524 for ; Mon, 17 Jul 2017 13:10:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D95128528; Mon, 17 Jul 2017 13:10:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E7FB42851D for ; Mon, 17 Jul 2017 13:10:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5l4-0005J9-Ta; Mon, 17 Jul 2017 13:08:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5l3-0005G8-HJ for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:17 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id D5/8F-02177-0C6BC695; Mon, 17 Jul 2017 13:08:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRuso3tgW06 kwYdZjBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8ako6uZCs4qVLTf/snewDhLsouRi0NIYAaj xK5jB1hBHBaBecwSF1f/ZAJxJAT6WSWm/Wxi7GLkBHLSJK523GCGsKslXj6cyQZiCwloSRw9N ZsVwm5lkrh5SamLkYODTcBEYlaHBEhYREBJ4t6qyWAzmQXmM0o0TeplA6kRFoiR2HvbB6SGRU BVovflLCYQm1fAR+LWlkYmiFVyEjfPdYKt5QSKn9mwmglilbfEzSMTmSYwCixgZFjFqF6cWlS WWqRrqpdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJERhW9QwMjDsYL391OsQoycGk JMp7kS07UogvKT+lMiOxOCO+qDQntfgQowwHh5IE7+atOZFCgkWp6akVaZk5wACHSUtw8CiJ8 FaDpHmLCxJzizPTIVKnGI05Jh3Y/oWJ49WE/9+YhFjy8vNSpcR5V4CUCoCUZpTmwQ2CRd4lRl kpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8y0Gm8GTmlcDtewV0ChPQKcK+YKeUJCKkpBoYN4u sVJxnt7TD/67n61a1u/f4fU4e8nh4ovTN9zJnpbnvzgUKrm55L3a0fIHnX52cm4mGx27OSL51 ms/D8kJX7HnHb8dTjCVuhhX21x+/X+Elm7OF85t7nOJJtQ9l5ziXHgpJ6L2yfpp8VsC2xNraU w/YXRtcZqz8LVObeuTghLAPidF3e2T2KrEUZyQaajEXFScCAPtvd7S3AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1500296894!98249672!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46890 invoked from network); 17 Jul 2017 13:08:15 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:15 -0000 Received: by mail-pg0-f44.google.com with SMTP id k14so79618485pgr.0 for ; Mon, 17 Jul 2017 06:08:15 -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=qeIH6mri6baDhY7Yk2iqtbCBeVmFW4zSmk2Zg4YVBBo=; b=QZTpAuCP6HOB2sRTkEia8Q1Fpj1l/bcxdXezYnbhJ5AFXtknA4SFUkogFI9cki4buu QwN0vbEH6HxKR8VcflSfHJi+B6ZPF7+8IaBqOoyCnFiDsGi2XSJrrYWf7JrWUx4Nt3Po Cg9vceEVahWXXxIuWSso8d/NdGZqDSaz+aPjQ= 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=qeIH6mri6baDhY7Yk2iqtbCBeVmFW4zSmk2Zg4YVBBo=; b=XY5UF0YXCX/O9W93fEuPtFlmeqEYIhrLxaWBUbjK6ej1lKyQimqtbX+h5kwTT6qqPk JjA8MpuUPeF3U45p6YPQnqPTL84q+udmUhC7ScNvRQsbMLpiR70FqUQ65oBL/BrW+pwL XPPeGkyCELLWWoECYQtRZChDqTObNJxWxO9kTY+dmTYyc98NO7n3YIF1gzcuU4oGCBDa TZuSzX+ZL2DbiGoSOMNZavoZp3PpXzy10NYFu8pEYOeQ9hWbLRsXIkt4oVo0qqHI/LB+ 7D7+YocO9EnRwkCIa48hwW/t3hifbpm+6EFK0rxEU5b6i58Nds8sNaALAxoPgSHbgWrV Qodw== X-Gm-Message-State: AIVw11059zBYJUpxlskfSmAtoHIHhXwR680UeZLfOU7hWqgGvqVgzXll 0GQQ3yyTRWvye4gtXdLD9w== X-Received: by 10.99.97.212 with SMTP id v203mr14884576pgb.188.1500296894198; Mon, 17 Jul 2017 06:08:14 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.08.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:08:13 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:54 +0530 Message-Id: <1500296815-10243-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/25 v6] 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 setttings. 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 tools/libxl/libxl_arm.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index e3e5791..9eee50c 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -44,10 +44,22 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, uint32_t nr_spis = 0; unsigned int i; + /* + * 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) + nr_spis += (GUEST_VPL011_SPI - 32) + 1; + for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + if (d_config->b_info.arch_arm.vuart && (irq == GUEST_VPL011_SPI)) { + LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -130,9 +142,10 @@ static struct arch_info { const char *guest_type; const char *timer_compat; const char *cpu_compat; + const char *uart_compat; } arch_info[] = { - {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15" }, - {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8" }, + {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15", "arm,sbsa-uart" }, + {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8", "arm,sbsa-uart" }, }; /* @@ -590,6 +603,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, ainfo->uart_compat); + 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 +934,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) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) );