From: Christian Pinto <c.pinto@virtualopensystems.com>
To: qemu-devel@nongnu.org
Cc: b.reynal@virtualopensystems.com, tech@virtualopensystems.com,
Claudio.Fontana@huawei.com, Jani.Kokkonen@huawei.com,
Christian Pinto <c.pinto@virtualopensystems.com>
Subject: [Qemu-devel] [RFC v3 3/6] hw/arm: sysbus-fdt
Date: Fri, 17 Jun 2016 17:55:00 +0200 [thread overview]
Message-ID: <1466178903-2184-4-git-send-email-c.pinto@virtualopensystems.com> (raw)
In-Reply-To: <1466178903-2184-1-git-send-email-c.pinto@virtualopensystems.com>
From: Baptiste Reynal <b.reynal@virtualopensystems.com>
Added node creation for dynamically instantiated sysbus SDM device.
Support added for all ARM machines modeling dynamic sysbus devices
instantiation.
Signed-off-by: Christian Pinto <c.pinto@virtualopensystems.com>
Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>
---
hw/arm/sysbus-fdt.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c
index 9d28797..9ad7912 100644
--- a/hw/arm/sysbus-fdt.c
+++ b/hw/arm/sysbus-fdt.c
@@ -28,6 +28,7 @@
#include "sysemu/sysemu.h"
#include "hw/vfio/vfio-platform.h"
#include "hw/vfio/vfio-calxeda-xgmac.h"
+#include "hw/misc/sdm-platform.h"
#include "hw/arm/fdt.h"
/*
@@ -123,9 +124,70 @@ fail_reg:
return ret;
}
+/**
+ * add_sdm_fdt_node
+ *
+ * Generates a node with following properties:
+ * compatible string, regs, interrupts
+ *
+ */
+static int add_sdm_fdt_node(SysBusDevice *sbdev, void *opaque)
+{
+ PlatformBusFDTData *data = opaque;
+ PlatformBusDevice *pbus = data->pbus;
+ const char sdm_compat[] = "sdm-ipi";
+ void *fdt = data->fdt;
+ const char *parent_node = data->pbus_node_name;
+ char *nodename;
+ int ret = -1;
+ uint32_t *irq_attr, *reg_attr;
+ uint64_t mmio_base, irq_number;
+
+ mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
+ nodename = g_strdup_printf("%s/%s@%" PRIx64, parent_node,
+ TYPE_SDM_PLATFORM, mmio_base);
+ qemu_fdt_add_subnode(fdt, nodename);
+
+ qemu_fdt_setprop(fdt, nodename, "compatible", sdm_compat,
+ sizeof(sdm_compat));
+
+ /**
+ * There is only one MMIO region defined for the SDM device
+ */
+ reg_attr = g_new(uint32_t, 2);
+ mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
+ reg_attr[0] = cpu_to_be32(mmio_base);
+ reg_attr[1] = cpu_to_be32(SDM_PLATFORM_SIZE);
+ ret = qemu_fdt_setprop(fdt, nodename, "reg", reg_attr,
+ 2 * sizeof(uint32_t));
+ if (ret) {
+ error_report("could not set reg property of node %s", nodename);
+ goto fail;
+ }
+
+ irq_attr = g_new(uint32_t, 3);
+ irq_number = platform_bus_get_irqn(pbus, sbdev , 0)
+ + data->irq_start;
+ irq_attr[0] = cpu_to_be32(GIC_FDT_IRQ_TYPE_SPI);
+ irq_attr[1] = cpu_to_be32(irq_number);
+ irq_attr[2] = cpu_to_be32(GIC_FDT_IRQ_FLAGS_EDGE_LO_HI);
+ ret = qemu_fdt_setprop(fdt, nodename, "interrupts",
+ irq_attr, 3 * sizeof(uint32_t));
+ if (ret) {
+ error_report("could not set interrupts property of node %s",
+ nodename);
+ }
+ g_free(irq_attr);
+fail:
+ g_free(reg_attr);
+ g_free(nodename);
+ return ret;
+}
+
/* list of supported dynamic sysbus devices */
static const NodeCreationPair add_fdt_node_functions[] = {
{TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node},
+ {TYPE_SDM_PLATFORM, add_sdm_fdt_node},
{"", NULL}, /* last element */
};
--
1.9.1
next prev parent reply other threads:[~2016-06-17 15:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 15:54 [Qemu-devel] [RFC v3 0/6] SDM Interface Christian Pinto
2016-06-17 15:54 ` [Qemu-devel] [RFC v3 1/6] hw/misc: sdm interface Christian Pinto
2016-06-17 15:54 ` [Qemu-devel] [RFC v3 2/6] hw/misc: sdm platform device Christian Pinto
2016-06-17 15:55 ` Christian Pinto [this message]
2016-06-17 15:55 ` [Qemu-devel] [RFC v3 4/6] hw/misc: sdm virtio device Christian Pinto
2016-06-17 15:55 ` [Qemu-devel] [RFC v3 5/6] hw/misc: sdm communication local Christian Pinto
2016-06-17 15:55 ` [Qemu-devel] [RFC v3 6/6] hw/misc: sdm communication socket Christian Pinto
2016-06-30 8:26 ` [Qemu-devel] [RFC v3 0/6] SDM Interface Christian Pinto
2016-06-30 8:47 ` [Qemu-devel] [virtio-dev] " Stefan Hajnoczi
2016-06-30 11:44 ` Christian Pinto
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=1466178903-2184-4-git-send-email-c.pinto@virtualopensystems.com \
--to=c.pinto@virtualopensystems.com \
--cc=Claudio.Fontana@huawei.com \
--cc=Jani.Kokkonen@huawei.com \
--cc=b.reynal@virtualopensystems.com \
--cc=qemu-devel@nongnu.org \
--cc=tech@virtualopensystems.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).