qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Baptiste Reynal <b.reynal@virtualopensystems.com>
To: iommu@lists.linux-foundation.org, qemu-devel@nongnu.org
Cc: Baptiste Reynal <b.reynal@virtualopensystems.com>,
	tech@virtualopensystems.com, will.deacon@arm.com,
	Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [RFC 5/6] hw/arm/sysbus-fdt: enable vsmmu dynamic instantiation
Date: Fri, 12 Jun 2015 16:20:09 +0200	[thread overview]
Message-ID: <1434118810-28219-6-git-send-email-b.reynal@virtualopensystems.com> (raw)
In-Reply-To: <1434118810-28219-1-git-send-email-b.reynal@virtualopensystems.com>

This patch adds the device tree node creation for the vSMMU.

Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>
---
 hw/arm/sysbus-fdt.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c
index 3038b94..67f4425 100644
--- a/hw/arm/sysbus-fdt.c
+++ b/hw/arm/sysbus-fdt.c
@@ -26,6 +26,10 @@
 #include "sysemu/device_tree.h"
 #include "hw/platform-bus.h"
 #include "sysemu/sysemu.h"
+#include "hw/vfio/vfio-platform.h"
+#include "hw/vfio/vfio-smmu.h"
+
+#include <libfdt.h>
 
 /*
  * internal struct that contains the information to create dynamic
@@ -53,8 +57,47 @@ typedef struct NodeCreationPair {
     int (*add_fdt_node_fn)(SysBusDevice *sbdev, void *opaque);
 } NodeCreationPair;
 
+VFIOSmmuDevice *vsmmu = NULL;
+
+static int add_arm_smmu_fdt_node(SysBusDevice *sbdev, void *opaque)
+{
+    PlatformBusFDTData *data = opaque;
+    vsmmu = VFIO_SMMU_DEVICE(sbdev);
+    void *fdt = data->fdt;
+    const char *nodename;
+    uint32_t reg_attr[4], irq_attr[3];
+    uint32_t gint = 0;
+
+    nodename = g_strdup_printf("/smmu@%" PRIx64, vsmmu->base);
+
+    qemu_fdt_add_subnode(fdt, nodename);
+    qemu_fdt_setprop(fdt, nodename, "compatible", "arm,smmu-v2", 12);
+
+    reg_attr[0] = 0;
+    reg_attr[1] = cpu_to_be32(vsmmu->base);
+    reg_attr[2] = 0;
+    reg_attr[3] = cpu_to_be32(vsmmu->size);
+
+    qemu_fdt_setprop(fdt, nodename, "reg",
+            reg_attr, 4*sizeof(uint32_t));
+
+    /* Add dummy interrupt */
+    irq_attr[0] = 0;
+    irq_attr[1] = 0;
+    irq_attr[2] = 0;
+
+    qemu_fdt_setprop(fdt, nodename, "interrupts",
+            irq_attr, 3*sizeof(uint32_t));
+
+    qemu_fdt_setprop(fdt, nodename, "#global-interrupts", &gint,
+            sizeof(uint32_t));
+
+    return 0;
+}
+
 /* list of supported dynamic sysbus devices */
 static const NodeCreationPair add_fdt_node_functions[] = {
+    {TYPE_VFIO_SMMU, add_arm_smmu_fdt_node},
     {"", NULL}, /* last element */
 };
 
-- 
2.4.3

  parent reply	other threads:[~2015-06-12 14:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 14:20 [Qemu-devel] [RFC 0/6] vSMMU initialization Baptiste Reynal
2015-06-12 14:20 ` [Qemu-devel] [RFC 1/6] headers sync Baptiste Reynal
2015-06-12 14:20 ` [Qemu-devel] [RFC 2/6] hw/core/platform-bus: initialization notifier Baptiste Reynal
2015-06-12 14:20 ` [Qemu-devel] [RFC 3/6] hw/core/platform-bus: add base_address field Baptiste Reynal
2015-06-12 14:20 ` [Qemu-devel] [RFC 4/6] hw/vfio: vsmmu device Baptiste Reynal
2015-06-12 14:20 ` Baptiste Reynal [this message]
2015-06-12 14:20 ` [Qemu-devel] [RFC 6/6] hw/arm/sysbus-fdt: add smmu masters in device tree Baptiste Reynal
2015-06-12 14:23 ` [Qemu-devel] [RFC 0/6] vSMMU initialization Will Deacon
2015-07-14  2:21   ` Varun Sethi
2015-07-14 11:04     ` Will Deacon
2015-07-15 13:38       ` Baptiste Reynal
2015-07-15 13:42         ` Will Deacon
2015-07-15 16:41         ` Varun Sethi
2015-07-15 17:28       ` Varun Sethi
2015-07-15 17:37         ` Will Deacon

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=1434118810-28219-6-git-send-email-b.reynal@virtualopensystems.com \
    --to=b.reynal@virtualopensystems.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=tech@virtualopensystems.com \
    --cc=will.deacon@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).