From: Eric Auger <eric.auger@linaro.org>
To: eric.auger@st.com, christoffer.dall@linaro.org,
qemu-devel@nongnu.org, a.rigo@virtualopensystems.com,
kim.phillips@freescale.com, marc.zyngier@arm.com,
manish.jaggi@caviumnetworks.com, joel.schopp@amd.com,
agraf@suse.de, peter.maydell@linaro.org, pbonzini@redhat.com,
afaerber@suse.de
Cc: patches@linaro.org, eric.auger@linaro.org, will.deacon@arm.com,
stuart.yoder@freescale.com, Bharat.Bhushan@freescale.com,
alex.williamson@redhat.com, a.motakis@virtualopensystems.com,
kvmarm@lists.cs.columbia.edu
Subject: [Qemu-devel] [PATCH v3 2/6] hw/arm/dyn_sysbus_devtree: helpers for sysbus device dynamic dt node generation
Date: Tue, 9 Sep 2014 08:54:29 +0100 [thread overview]
Message-ID: <1410249273-6063-3-git-send-email-eric.auger@linaro.org> (raw)
In-Reply-To: <1410249273-6063-1-git-send-email-eric.auger@linaro.org>
This module will be used by ARM machine files to generate
device tree nodes of dynamically instantiated sysbus devices (ie.
those instantiated with -device option).
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
v2 -> v3:
- add arm_ prefix
- arm_sysbus_device_create_devtree becomes static
v1 -> v2:
- Code moved in an arch specific file to accomodate architecture
dependent specificities.
- remove platform_bus_base from PlatformDevtreeData
v1: code originally written by Alex Graf in e500.c and reused for ARM
[Eric Auger]
code originally moved in hw/misc/platform_devices and device itself
---
hw/arm/Makefile.objs | 1 +
hw/arm/dyn_sysbus_devtree.c | 66 +++++++++++++++++++++++++++++++++++++
include/hw/arm/dyn_sysbus_devtree.h | 16 +++++++++
3 files changed, 83 insertions(+)
create mode 100644 hw/arm/dyn_sysbus_devtree.c
create mode 100644 include/hw/arm/dyn_sysbus_devtree.h
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
index 6088e53..bc5e014 100644
--- a/hw/arm/Makefile.objs
+++ b/hw/arm/Makefile.objs
@@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o
obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
+obj-y += dyn_sysbus_devtree.o
obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
obj-$(CONFIG_DIGIC) += digic.o
diff --git a/hw/arm/dyn_sysbus_devtree.c b/hw/arm/dyn_sysbus_devtree.c
new file mode 100644
index 0000000..6375024
--- /dev/null
+++ b/hw/arm/dyn_sysbus_devtree.c
@@ -0,0 +1,66 @@
+#include "hw/arm/dyn_sysbus_devtree.h"
+#include "qemu/error-report.h"
+#include "sysemu/device_tree.h"
+
+static int arm_sysbus_device_create_devtree(Object *obj, void *opaque)
+{
+ PlatformDevtreeData *data = opaque;
+ Object *dev;
+ SysBusDevice *sbdev;
+ bool matched = false;
+
+ dev = object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE);
+ sbdev = (SysBusDevice *)dev;
+
+ if (!sbdev) {
+ /* Container, traverse it for children */
+ return object_child_foreach(obj,
+ arm_sysbus_device_create_devtree, data);
+ }
+
+ if (!matched) {
+ error_report("Device %s is not supported by this machine yet.",
+ qdev_fw_name(DEVICE(dev)));
+ exit(1);
+ }
+
+ return 0;
+}
+
+void arm_platform_bus_create_devtree(DynSysbusParams *params,
+ void *fdt, const char *intc)
+{
+ gchar *node = g_strdup_printf("/platform@%"PRIx64,
+ params->platform_bus_base);
+ const char platcomp[] = "qemu,platform\0simple-bus";
+ PlatformDevtreeData data;
+ Object *container;
+ uint64_t addr = params->platform_bus_base;
+ uint64_t size = params->platform_bus_size;
+ int irq_start = params->platform_bus_first_irq;
+
+ /* Create a /platform node that we can put all devices into */
+ qemu_fdt_add_subnode(fdt, node);
+ qemu_fdt_setprop(fdt, node, "compatible", platcomp, sizeof(platcomp));
+
+ /* Our platform bus region is less than 32bit big, so 1 cell is enough for
+ address and size */
+ qemu_fdt_setprop_cells(fdt, node, "#size-cells", 1);
+ qemu_fdt_setprop_cells(fdt, node, "#address-cells", 1);
+ qemu_fdt_setprop_cells(fdt, node, "ranges", 0, addr >> 32, addr, size);
+
+ qemu_fdt_setprop_phandle(fdt, node, "interrupt-parent", intc);
+
+ /* Loop through all devices and create nodes for known ones */
+ data.fdt = fdt;
+ data.intc = intc;
+ data.irq_start = irq_start;
+ data.node = node;
+
+ container = container_get(qdev_get_machine(), "/peripheral");
+ arm_sysbus_device_create_devtree(container, &data);
+ container = container_get(qdev_get_machine(), "/peripheral-anon");
+ arm_sysbus_device_create_devtree(container, &data);
+
+ g_free(node);
+}
diff --git a/include/hw/arm/dyn_sysbus_devtree.h b/include/hw/arm/dyn_sysbus_devtree.h
new file mode 100644
index 0000000..b072365
--- /dev/null
+++ b/include/hw/arm/dyn_sysbus_devtree.h
@@ -0,0 +1,16 @@
+#ifndef HW_ARM_DYN_SYSBUS_DEVTREE_H
+#define HW_ARM_DYN_SYSBUS_DEVTREE_H
+
+#include "hw/misc/dyn_sysbus_binding.h"
+
+typedef struct PlatformDevtreeData {
+ void *fdt;
+ const char *intc;
+ int irq_start;
+ const char *node;
+} PlatformDevtreeData;
+
+void arm_platform_bus_create_devtree(DynSysbusParams *params,
+ void *fdt, const char *intc);
+
+#endif
--
1.8.3.2
next prev parent reply other threads:[~2014-09-09 7:55 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 7:54 [Qemu-devel] [PATCH v3 0/6] machvirt dynamic sysbus device instantiation Eric Auger
2014-09-09 7:54 ` [Qemu-devel] [PATCH v3 1/6] hw/misc/dyn_sysbus_binding: helpers for sysbus device dynamic binding Eric Auger
2014-09-09 10:56 ` Paolo Bonzini
2014-09-09 15:25 ` Eric Auger
2014-09-09 15:59 ` Paolo Bonzini
2014-09-09 16:11 ` Eric Auger
2014-09-10 9:31 ` Alexander Graf
2014-09-10 9:43 ` Paolo Bonzini
2014-09-10 9:56 ` Alexander Graf
2014-09-10 10:05 ` Paolo Bonzini
2014-09-10 10:09 ` Alexander Graf
2014-09-10 10:21 ` Paolo Bonzini
2014-09-10 10:26 ` Alexander Graf
2014-09-10 10:34 ` Paolo Bonzini
2014-09-10 13:51 ` Eric Auger
2014-09-10 14:18 ` Paolo Bonzini
2014-09-10 14:38 ` Alexander Graf
2014-09-10 14:39 ` Paolo Bonzini
2014-09-10 15:21 ` Alexander Graf
2014-09-10 10:06 ` Paolo Bonzini
2014-09-09 7:54 ` Eric Auger [this message]
2014-09-09 11:04 ` [Qemu-devel] [PATCH v3 2/6] hw/arm/dyn_sysbus_devtree: helpers for sysbus device dynamic dt node generation Paolo Bonzini
2014-09-09 14:39 ` Peter Crosthwaite
2014-09-09 15:56 ` Eric Auger
2014-09-09 16:00 ` Peter Maydell
2014-09-09 16:08 ` Eric Auger
2014-09-09 16:03 ` Paolo Bonzini
2014-09-09 16:11 ` Eric Auger
2014-09-09 7:54 ` [Qemu-devel] [PATCH v3 3/6] PPC: e500: use dyn_sysbus_binding helper routines Eric Auger
2014-09-09 7:54 ` [Qemu-devel] [PATCH v3 4/6] hw/arm/boot: load_dtb becomes non static arm_load_dtb Eric Auger
2014-09-09 7:54 ` [Qemu-devel] [PATCH v3 5/6] hw/arm/virt: new add_fdt_*_node functions Eric Auger
2014-09-09 11:06 ` Paolo Bonzini
2014-09-09 7:54 ` [Qemu-devel] [PATCH v3 6/6] hw/arm/virt: Support dynamically spawned sysbus devices Eric Auger
2014-09-09 11:11 ` Paolo Bonzini
2014-09-09 11:17 ` Peter Maydell
2014-10-20 14:41 ` Eric Auger
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=1410249273-6063-3-git-send-email-eric.auger@linaro.org \
--to=eric.auger@linaro.org \
--cc=Bharat.Bhushan@freescale.com \
--cc=a.motakis@virtualopensystems.com \
--cc=a.rigo@virtualopensystems.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@st.com \
--cc=joel.schopp@amd.com \
--cc=kim.phillips@freescale.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=manish.jaggi@caviumnetworks.com \
--cc=marc.zyngier@arm.com \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stuart.yoder@freescale.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).