All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhupinder Thakur <bhupinder.thakur@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>, Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 11/12 v3] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree
Date: Wed, 10 May 2017 20:05:17 +0530	[thread overview]
Message-ID: <1494426918-32737-6-git-send-email-bhupinder.thakur@linaro.org> (raw)
In-Reply-To: <1494426918-32737-1-git-send-email-bhupinder.thakur@linaro.org>

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

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---

Changes since v2:
- Currently device discovery using ACPI is not supported.
- Dropped the reviewed-by tag by Stefano as there were some IRQ related changes
  done later.

 tools/libxl/libxl_arm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index d842d88..f88ef0d 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -44,10 +44,23 @@ 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.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.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 +143,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 +604,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 +935,9 @@ next_resize:
         FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) );
         FDT( make_hypervisor_node(gc, fdt, vers) );
 
+        if (info->vuart)
+            FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) );
+
         if (pfdt)
             FDT( copy_partial_fdt(gc, fdt, pfdt) );
 
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-05-10 14:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-10 14:35 [PATCH 06/12 v3] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
2017-05-10 14:35 ` [PATCH 07/12 v3] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
2017-05-11 11:10   ` Wei Liu
2017-05-16 22:59   ` Stefano Stabellini
2017-05-10 14:35 ` [PATCH 08/12 v3] xen/arm: vpl011: Modify xenconsole to support multiple consoles Bhupinder Thakur
2017-05-11 11:15   ` Wei Liu
2017-05-16 23:41   ` Stefano Stabellini
2017-05-25 10:57     ` Bhupinder Thakur
2017-05-25 18:24       ` Stefano Stabellini
2017-05-10 14:35 ` [PATCH 09/12 v3] xen/arm: vpl011: Add support for vuart in xenconsole Bhupinder Thakur
2017-05-11 11:17   ` Wei Liu
2017-05-16 23:44   ` Stefano Stabellini
2017-05-22 14:37     ` Julien Grall
2017-05-10 14:35 ` [PATCH 10/12 v3] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
2017-05-11 11:17   ` Wei Liu
2017-05-16 23:02   ` Stefano Stabellini
2017-05-10 14:35 ` Bhupinder Thakur [this message]
2017-05-11 11:18   ` [PATCH 11/12 v3] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Wei Liu
2017-05-16 23:05   ` Stefano Stabellini
2017-05-22 14:42   ` Julien Grall
2017-05-10 14:35 ` [PATCH 12/12 v3] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
2017-05-11 11:19   ` Wei Liu
2017-05-16 23:10   ` Stefano Stabellini
2017-05-11 11:10 ` [PATCH 06/12 v3] xen/arm: vpl011: Add a new vuart node in the xenstore Wei Liu
2017-05-12  9:32   ` Bhupinder Thakur
2017-05-16 15:18     ` Wei Liu
2017-05-22 11:03       ` Bhupinder Thakur
2017-05-30 11:58         ` Wei Liu
2017-06-01  8:43           ` Bhupinder Thakur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494426918-32737-6-git-send-email-bhupinder.thakur@linaro.org \
    --to=bhupinder.thakur@linaro.org \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.